7#include "xfa/fxfa/parser/cxfa_color.h"
9#include "core/fxcrt/fx_extension.h"
10#include "fxjs/xfa/cjx_node.h"
11#include "xfa/fxfa/parser/cxfa_document.h"
31 static constexpr FX_ARGB kDefaultValue = 0xff000000;
35 const wchar_t* str = view.unterminated_c_str();
36 size_t len = view.GetLength();
38 while (cc < len && FXSYS_iswspace(str[cc]))
48 if (str[cc] ==
',' || !FXSYS_IsDecimalDigit(str[cc]))
51 r = r * 10 + str[cc] -
'0';
54 if (cc < len && str[cc] ==
',') {
56 while (cc < len && FXSYS_iswspace(str[cc]))
60 if (str[cc] ==
',' || !FXSYS_IsDecimalDigit(str[cc]))
63 g = g * 10 + str[cc] -
'0';
66 if (cc < len && str[cc] ==
',') {
68 while (cc < len && FXSYS_iswspace(str[cc]))
72 if (str[cc] ==
',' || !FXSYS_IsDecimalDigit(str[cc]))
75 b = b * 10 + str[cc] -
'0';
86 {XFA_XDPPACKET::kTemplate, XFA_XDPPACKET::kForm},
91 cppgc::MakeGarbageCollected<CJX_Node>(
92 doc->GetHeap()->GetAllocationHandle(),
98 absl::optional<WideString> val =
99 JSObject()->TryCData(XFA_Attribute::Value,
false);
100 return val.has_value() ? StringToFXARGB(val->AsStringView()) : 0xFF000000;
104 absl::optional<WideString> val =
105 JSObject()->TryCData(XFA_Attribute::Value,
false);
106 return val.has_value() ? StringToFXARGB(val->AsStringView()) : defaultValue;
114 std::tie(a, r, g, b) = ArgbDecode(color);
FX_ARGB GetValueOrDefault(FX_ARGB defaultValue) const
static FX_ARGB StringToFXARGB(WideStringView view)
void SetValue(FX_ARGB color)
static WideString Format(const wchar_t *pFormat,...)
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)