Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_cssdeclaration.cpp
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fxcrt/css/cfx_cssdeclaration.h"
8
9#include <math.h>
10
11#include <utility>
12
13#include "core/fxcrt/css/cfx_csscolorvalue.h"
14#include "core/fxcrt/css/cfx_csscustomproperty.h"
15#include "core/fxcrt/css/cfx_cssenumvalue.h"
16#include "core/fxcrt/css/cfx_cssnumbervalue.h"
17#include "core/fxcrt/css/cfx_csspropertyholder.h"
18#include "core/fxcrt/css/cfx_cssstringvalue.h"
19#include "core/fxcrt/css/cfx_cssvaluelist.h"
20#include "core/fxcrt/css/cfx_cssvaluelistparser.h"
21#include "core/fxcrt/fx_extension.h"
22#include "core/fxcrt/fx_system.h"
23#include "third_party/base/check.h"
24#include "third_party/base/check_op.h"
25#include "third_party/base/notreached.h"
26
27namespace {
28
29uint8_t Hex2Dec(uint8_t hexHigh, uint8_t hexLow) {
30 return (FXSYS_HexCharToInt(hexHigh) << 4) + FXSYS_HexCharToInt(hexLow);
31}
32
33bool ParseCSSNumber(const wchar_t* pszValue,
34 size_t nValueLen,
35 float* pValue,
36 CFX_CSSNumberValue::Unit* pOutUnit) {
37 DCHECK(pszValue);
38 DCHECK_NE(nValueLen, 0);
39
40 size_t nUsedLen = 0;
41 *pValue = FXSYS_wcstof(pszValue, nValueLen, &nUsedLen);
42 if (nUsedLen == 0 || !isfinite(*pValue))
43 return false;
44
45 nValueLen -= nUsedLen;
46 pszValue += nUsedLen;
47 *pOutUnit = CFX_CSSNumberValue::Unit::kNumber;
48 if (nValueLen >= 1 && *pszValue == '%') {
49 *pOutUnit = CFX_CSSNumberValue::Unit::kPercent;
50 } else if (nValueLen == 2) {
51 const CFX_CSSData::LengthUnit* pUnit =
52 CFX_CSSData::GetLengthUnitByName(WideStringView(pszValue, 2));
53 if (pUnit)
54 *pOutUnit = pUnit->type;
55 }
56 return true;
57}
58
59} // namespace
60
61// static
62bool CFX_CSSDeclaration::ParseCSSString(const wchar_t* pszValue,
63 size_t nValueLen,
64 size_t* nOffset,
65 size_t* nLength) {
66 DCHECK(pszValue);
67 DCHECK_NE(nValueLen, 0);
68
69 *nOffset = 0;
70 *nLength = nValueLen;
71 if (nValueLen >= 2) {
72 wchar_t first = pszValue[0];
73 wchar_t last = pszValue[nValueLen - 1];
74 if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
75 *nOffset = 1;
76 *nLength -= 2;
77 }
78 }
79 return nValueLen > 0;
80}
81
82// static.
83bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
84 size_t nValueLen,
85 FX_ARGB* dwColor) {
86 DCHECK_NE(nValueLen, 0);
87 DCHECK(dwColor);
88
89 if (*pszValue == '#') {
90 switch (nValueLen) {
91 case 4: {
92 uint8_t red = Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]);
93 uint8_t green = Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]);
94 uint8_t blue = Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]);
95 *dwColor = ArgbEncode(255, red, green, blue);
96 return true;
97 }
98 case 7: {
99 uint8_t red = Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]);
100 uint8_t green = Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]);
101 uint8_t blue = Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]);
102 *dwColor = ArgbEncode(255, red, green, blue);
103 return true;
104 }
105 default:
106 return false;
107 }
108 }
109
110 if (nValueLen >= 10) {
111 if (pszValue[nValueLen - 1] != ')' || FXSYS_wcsnicmp(L"rgb(", pszValue, 4))
112 return false;
113
114 uint8_t rgb[3] = {0};
115 float fValue;
117 CFX_CSSValueListParser list(pszValue + 4, nValueLen - 5, ',');
118 for (int32_t i = 0; i < 3; ++i) {
119 if (!list.NextValue(&eType, &pszValue, &nValueLen))
120 return false;
122 return false;
123 CFX_CSSNumberValue::Unit eNumType;
124 if (!ParseCSSNumber(pszValue, nValueLen, &fValue, &eNumType))
125 return false;
126
127 rgb[i] = eNumType == CFX_CSSNumberValue::Unit::kPercent
128 ? FXSYS_roundf(fValue * 2.55f)
129 : FXSYS_roundf(fValue);
130 }
131 *dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]);
132 return true;
133 }
134
135 const CFX_CSSData::Color* pColor =
136 CFX_CSSData::GetColorByName(WideStringView(pszValue, nValueLen));
137 if (!pColor)
138 return false;
139
140 *dwColor = pColor->value;
141 return true;
142}
143
145
147
149 CFX_CSSProperty eProperty,
150 bool* bImportant) const {
151 for (const auto& p : properties_) {
152 if (p->eProperty == eProperty) {
153 *bImportant = p->bImportant;
154 return p->pValue;
155 }
156 }
157 return nullptr;
158}
159
160void CFX_CSSDeclaration::AddPropertyHolder(CFX_CSSProperty eProperty,
161 RetainPtr<CFX_CSSValue> pValue,
162 bool bImportant) {
163 auto pHolder = std::make_unique<CFX_CSSPropertyHolder>();
164 pHolder->bImportant = bImportant;
165 pHolder->eProperty = eProperty;
166 pHolder->pValue = pValue;
167 properties_.push_back(std::move(pHolder));
168}
169
171 WideStringView value) {
172 DCHECK(!value.IsEmpty());
173
174 const wchar_t* pszValue = value.unterminated_c_str();
175 size_t nValueLen = value.GetLength();
176 bool bImportant = false;
177 if (nValueLen >= 10 && pszValue[nValueLen - 10] == '!' &&
178 FXSYS_wcsnicmp(L"important", pszValue + nValueLen - 9, 9) == 0) {
179 nValueLen -= 10;
180 if (nValueLen == 0)
181 return;
182
183 bImportant = true;
184 }
185 const CFX_CSSValueTypeMask dwType = property->dwTypes;
186 switch (dwType & 0x0F) {
188 static constexpr CFX_CSSVALUETYPE kValueGuessOrder[] = {
193 };
194 for (CFX_CSSVALUETYPE guess : kValueGuessOrder) {
195 const CFX_CSSValueTypeMask dwMatch = dwType & guess;
196 if (dwMatch == 0)
197 continue;
198
199 RetainPtr<CFX_CSSValue> pCSSValue;
200 switch (dwMatch) {
201 case CFX_CSSVALUETYPE_MaybeNumber:
202 pCSSValue = ParseNumber(pszValue, nValueLen);
203 break;
204 case CFX_CSSVALUETYPE_MaybeEnum:
205 pCSSValue = ParseEnum(pszValue, nValueLen);
206 break;
207 case CFX_CSSVALUETYPE_MaybeColor:
208 pCSSValue = ParseColor(pszValue, nValueLen);
209 break;
210 case CFX_CSSVALUETYPE_MaybeString:
211 pCSSValue = ParseString(pszValue, nValueLen);
212 break;
213 default:
214 break;
215 }
216 if (pCSSValue) {
217 AddPropertyHolder(property->eName, pCSSValue, bImportant);
218 return;
219 }
220
221 if ((dwType & ~guess) == CFX_CSSVALUETYPE_Primitive)
222 return;
223 }
224 break;
225 }
227 RetainPtr<CFX_CSSValue> pWidth;
228 switch (property->eName) {
229 case CFX_CSSProperty::Font:
230 ParseFontProperty(pszValue, nValueLen, bImportant);
231 return;
232 case CFX_CSSProperty::Border:
233 if (ParseBorderProperty(pszValue, nValueLen, pWidth)) {
234 AddPropertyHolder(CFX_CSSProperty::BorderLeftWidth, pWidth,
235 bImportant);
236 AddPropertyHolder(CFX_CSSProperty::BorderTopWidth, pWidth,
237 bImportant);
238 AddPropertyHolder(CFX_CSSProperty::BorderRightWidth, pWidth,
239 bImportant);
240 AddPropertyHolder(CFX_CSSProperty::BorderBottomWidth, pWidth,
241 bImportant);
242 return;
243 }
244 break;
245 case CFX_CSSProperty::BorderLeft:
246 if (ParseBorderProperty(pszValue, nValueLen, pWidth)) {
247 AddPropertyHolder(CFX_CSSProperty::BorderLeftWidth, pWidth,
248 bImportant);
249 return;
250 }
251 break;
252 case CFX_CSSProperty::BorderTop:
253 if (ParseBorderProperty(pszValue, nValueLen, pWidth)) {
254 AddPropertyHolder(CFX_CSSProperty::BorderTopWidth, pWidth,
255 bImportant);
256 return;
257 }
258 break;
259 case CFX_CSSProperty::BorderRight:
260 if (ParseBorderProperty(pszValue, nValueLen, pWidth)) {
261 AddPropertyHolder(CFX_CSSProperty::BorderRightWidth, pWidth,
262 bImportant);
263 return;
264 }
265 break;
266 case CFX_CSSProperty::BorderBottom:
267 if (ParseBorderProperty(pszValue, nValueLen, pWidth)) {
268 AddPropertyHolder(CFX_CSSProperty::BorderBottomWidth, pWidth,
269 bImportant);
270 return;
271 }
272 break;
273 default:
274 break;
275 }
276 } break;
277 case CFX_CSSVALUETYPE_List:
278 ParseValueListProperty(property, pszValue, nValueLen, bImportant);
279 return;
280 default:
281 NOTREACHED_NORETURN();
282 }
283}
284
285void CFX_CSSDeclaration::AddProperty(const WideString& prop,
286 const WideString& value) {
287 custom_properties_.push_back(
288 std::make_unique<CFX_CSSCustomProperty>(prop, value));
289}
290
291RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseNumber(const wchar_t* pszValue,
292 size_t nValueLen) {
293 float fValue;
294 CFX_CSSNumberValue::Unit eUnit;
295 if (!ParseCSSNumber(pszValue, nValueLen, &fValue, &eUnit))
296 return nullptr;
297 return pdfium::MakeRetain<CFX_CSSNumberValue>(eUnit, fValue);
298}
299
300RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseEnum(const wchar_t* pszValue,
301 size_t nValueLen) {
302 const CFX_CSSData::PropertyValue* pValue =
303 CFX_CSSData::GetPropertyValueByName(WideStringView(pszValue, nValueLen));
304 return pValue ? pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName) : nullptr;
305}
306
307RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseColor(const wchar_t* pszValue,
308 size_t nValueLen) {
309 FX_ARGB dwColor;
310 if (!ParseCSSColor(pszValue, nValueLen, &dwColor))
311 return nullptr;
312 return pdfium::MakeRetain<CFX_CSSColorValue>(dwColor);
313}
314
315RetainPtr<CFX_CSSValue> CFX_CSSDeclaration::ParseString(const wchar_t* pszValue,
316 size_t nValueLen) {
317 size_t iOffset;
318 if (!ParseCSSString(pszValue, nValueLen, &iOffset, &nValueLen))
319 return nullptr;
320
321 if (nValueLen == 0)
322 return nullptr;
323
324 return pdfium::MakeRetain<CFX_CSSStringValue>(
325 WideString(pszValue + iOffset, nValueLen));
326}
327
328void CFX_CSSDeclaration::ParseValueListProperty(
329 const CFX_CSSData::Property* pProperty,
330 const wchar_t* pszValue,
331 size_t nValueLen,
332 bool bImportant) {
333 wchar_t separator =
334 (pProperty->eName == CFX_CSSProperty::FontFamily) ? ',' : ' ';
335 CFX_CSSValueListParser parser(pszValue, nValueLen, separator);
336
337 const CFX_CSSValueTypeMask dwType = pProperty->dwTypes;
339 std::vector<RetainPtr<CFX_CSSValue>> list;
340 while (parser.NextValue(&eType, &pszValue, &nValueLen)) {
341 switch (eType) {
343 if (dwType & CFX_CSSVALUETYPE_MaybeNumber) {
344 float fValue;
345 CFX_CSSNumberValue::Unit eNumType;
346 if (ParseCSSNumber(pszValue, nValueLen, &fValue, &eNumType))
347 list.push_back(
348 pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue));
349 }
350 break;
352 if (dwType & CFX_CSSVALUETYPE_MaybeColor) {
353 FX_ARGB dwColor;
354 if (ParseCSSColor(pszValue, nValueLen, &dwColor)) {
355 list.push_back(pdfium::MakeRetain<CFX_CSSColorValue>(dwColor));
356 continue;
357 }
358 }
359 if (dwType & CFX_CSSVALUETYPE_MaybeEnum) {
360 const CFX_CSSData::PropertyValue* pValue =
362 WideStringView(pszValue, nValueLen));
363 if (pValue) {
364 list.push_back(pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName));
365 continue;
366 }
367 }
368 if (dwType & CFX_CSSVALUETYPE_MaybeString) {
369 list.push_back(pdfium::MakeRetain<CFX_CSSStringValue>(
370 WideString(pszValue, nValueLen)));
371 }
372 break;
374 if (dwType & CFX_CSSVALUETYPE_MaybeColor) {
375 FX_ARGB dwColor;
376 if (ParseCSSColor(pszValue, nValueLen, &dwColor)) {
377 list.push_back(pdfium::MakeRetain<CFX_CSSColorValue>(dwColor));
378 }
379 }
380 break;
381 default:
382 break;
383 }
384 }
385 if (list.empty())
386 return;
387
388 switch (pProperty->eName) {
389 case CFX_CSSProperty::BorderWidth:
390 Add4ValuesProperty(list, bImportant, CFX_CSSProperty::BorderLeftWidth,
391 CFX_CSSProperty::BorderTopWidth,
392 CFX_CSSProperty::BorderRightWidth,
393 CFX_CSSProperty::BorderBottomWidth);
394 return;
395 case CFX_CSSProperty::Margin:
396 Add4ValuesProperty(list, bImportant, CFX_CSSProperty::MarginLeft,
397 CFX_CSSProperty::MarginTop,
398 CFX_CSSProperty::MarginRight,
399 CFX_CSSProperty::MarginBottom);
400 return;
401 case CFX_CSSProperty::Padding:
402 Add4ValuesProperty(list, bImportant, CFX_CSSProperty::PaddingLeft,
403 CFX_CSSProperty::PaddingTop,
404 CFX_CSSProperty::PaddingRight,
405 CFX_CSSProperty::PaddingBottom);
406 return;
407 default: {
408 auto value_list = pdfium::MakeRetain<CFX_CSSValueList>(std::move(list));
409 AddPropertyHolder(pProperty->eName, value_list, bImportant);
410 return;
411 }
412 }
413}
414
415void CFX_CSSDeclaration::Add4ValuesProperty(
416 const std::vector<RetainPtr<CFX_CSSValue>>& list,
417 bool bImportant,
418 CFX_CSSProperty eLeft,
419 CFX_CSSProperty eTop,
420 CFX_CSSProperty eRight,
421 CFX_CSSProperty eBottom) {
422 switch (list.size()) {
423 case 1:
424 AddPropertyHolder(eLeft, list[0], bImportant);
425 AddPropertyHolder(eTop, list[0], bImportant);
426 AddPropertyHolder(eRight, list[0], bImportant);
427 AddPropertyHolder(eBottom, list[0], bImportant);
428 return;
429 case 2:
430 AddPropertyHolder(eLeft, list[1], bImportant);
431 AddPropertyHolder(eTop, list[0], bImportant);
432 AddPropertyHolder(eRight, list[1], bImportant);
433 AddPropertyHolder(eBottom, list[0], bImportant);
434 return;
435 case 3:
436 AddPropertyHolder(eLeft, list[1], bImportant);
437 AddPropertyHolder(eTop, list[0], bImportant);
438 AddPropertyHolder(eRight, list[1], bImportant);
439 AddPropertyHolder(eBottom, list[2], bImportant);
440 return;
441 case 4:
442 AddPropertyHolder(eLeft, list[3], bImportant);
443 AddPropertyHolder(eTop, list[0], bImportant);
444 AddPropertyHolder(eRight, list[1], bImportant);
445 AddPropertyHolder(eBottom, list[2], bImportant);
446 return;
447 default:
448 break;
449 }
450}
451
452bool CFX_CSSDeclaration::ParseBorderProperty(
453 const wchar_t* pszValue,
454 size_t nValueLen,
455 RetainPtr<CFX_CSSValue>& pWidth) const {
456 pWidth.Reset(nullptr);
457
459 CFX_CSSValueListParser parser(pszValue, nValueLen, ' ');
460 while (parser.NextValue(&eType, &pszValue, &nValueLen)) {
461 switch (eType) {
463 if (pWidth)
464 continue;
465
466 float fValue;
467 CFX_CSSNumberValue::Unit eNumType;
468 if (ParseCSSNumber(pszValue, nValueLen, &fValue, &eNumType))
469 pWidth = pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue);
470 break;
471 }
473 const CFX_CSSData::Color* pColorItem =
474 CFX_CSSData::GetColorByName(WideStringView(pszValue, nValueLen));
475 if (pColorItem)
476 continue;
477
478 const CFX_CSSData::PropertyValue* pValue =
480 WideStringView(pszValue, nValueLen));
481 if (!pValue)
482 continue;
483
484 switch (pValue->eName) {
485 case CFX_CSSPropertyValue::Thin:
486 case CFX_CSSPropertyValue::Thick:
487 case CFX_CSSPropertyValue::Medium:
488 if (!pWidth)
489 pWidth = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
490 break;
491 default:
492 break;
493 }
494 break;
495 }
496 default:
497 break;
498 }
499 }
500 if (!pWidth) {
501 pWidth = pdfium::MakeRetain<CFX_CSSNumberValue>(
502 CFX_CSSNumberValue::Unit::kNumber, 0.0f);
503 }
504 return true;
505}
506
507void CFX_CSSDeclaration::ParseFontProperty(const wchar_t* pszValue,
508 size_t nValueLen,
509 bool bImportant) {
510 CFX_CSSValueListParser parser(pszValue, nValueLen, '/');
511 RetainPtr<CFX_CSSValue> pStyle;
512 RetainPtr<CFX_CSSValue> pVariant;
513 RetainPtr<CFX_CSSValue> pWeight;
514 RetainPtr<CFX_CSSValue> pFontSize;
515 RetainPtr<CFX_CSSValue> pLineHeight;
516 std::vector<RetainPtr<CFX_CSSValue>> family_list;
518 while (parser.NextValue(&eType, &pszValue, &nValueLen)) {
519 switch (eType) {
521 const CFX_CSSData::PropertyValue* pValue =
523 WideStringView(pszValue, nValueLen));
524 if (pValue) {
525 switch (pValue->eName) {
526 case CFX_CSSPropertyValue::XxSmall:
527 case CFX_CSSPropertyValue::XSmall:
528 case CFX_CSSPropertyValue::Small:
529 case CFX_CSSPropertyValue::Medium:
530 case CFX_CSSPropertyValue::Large:
531 case CFX_CSSPropertyValue::XLarge:
532 case CFX_CSSPropertyValue::XxLarge:
533 case CFX_CSSPropertyValue::Smaller:
534 case CFX_CSSPropertyValue::Larger:
535 if (!pFontSize)
536 pFontSize = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
537 continue;
538 case CFX_CSSPropertyValue::Bold:
539 case CFX_CSSPropertyValue::Bolder:
540 case CFX_CSSPropertyValue::Lighter:
541 if (!pWeight)
542 pWeight = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
543 continue;
544 case CFX_CSSPropertyValue::Italic:
545 case CFX_CSSPropertyValue::Oblique:
546 if (!pStyle)
547 pStyle = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
548 continue;
549 case CFX_CSSPropertyValue::SmallCaps:
550 if (!pVariant)
551 pVariant = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
552 continue;
553 case CFX_CSSPropertyValue::Normal:
554 if (!pStyle)
555 pStyle = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
556 else if (!pVariant)
557 pVariant = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
558 else if (!pWeight)
559 pWeight = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
560 else if (!pFontSize)
561 pFontSize = pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
562 else if (!pLineHeight)
563 pLineHeight =
564 pdfium::MakeRetain<CFX_CSSEnumValue>(pValue->eName);
565 continue;
566 default:
567 break;
568 }
569 }
570 if (pFontSize) {
571 family_list.push_back(pdfium::MakeRetain<CFX_CSSStringValue>(
572 WideString(pszValue, nValueLen)));
573 }
575 break;
576 }
578 float fValue;
579 CFX_CSSNumberValue::Unit eNumType;
580 if (!ParseCSSNumber(pszValue, nValueLen, &fValue, &eNumType))
581 break;
583 switch (static_cast<int32_t>(fValue)) {
584 case 100:
585 case 200:
586 case 300:
587 case 400:
588 case 500:
589 case 600:
590 case 700:
591 case 800:
592 case 900:
593 if (!pWeight) {
594 pWeight = pdfium::MakeRetain<CFX_CSSNumberValue>(
595 CFX_CSSNumberValue::Unit::kNumber, fValue);
596 }
597 continue;
598 }
599 }
600 if (!pFontSize)
601 pFontSize = pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue);
602 else if (!pLineHeight)
603 pLineHeight =
604 pdfium::MakeRetain<CFX_CSSNumberValue>(eNumType, fValue);
605 break;
606 }
607 default:
608 break;
609 }
610 }
611
612 if (!pStyle) {
613 pStyle = pdfium::MakeRetain<CFX_CSSEnumValue>(CFX_CSSPropertyValue::Normal);
614 }
615 if (!pVariant) {
616 pVariant =
617 pdfium::MakeRetain<CFX_CSSEnumValue>(CFX_CSSPropertyValue::Normal);
618 }
619 if (!pWeight) {
620 pWeight =
621 pdfium::MakeRetain<CFX_CSSEnumValue>(CFX_CSSPropertyValue::Normal);
622 }
623 if (!pFontSize) {
624 pFontSize =
625 pdfium::MakeRetain<CFX_CSSEnumValue>(CFX_CSSPropertyValue::Medium);
626 }
627 if (!pLineHeight) {
628 pLineHeight =
629 pdfium::MakeRetain<CFX_CSSEnumValue>(CFX_CSSPropertyValue::Normal);
630 }
631
632 AddPropertyHolder(CFX_CSSProperty::FontStyle, pStyle, bImportant);
633 AddPropertyHolder(CFX_CSSProperty::FontVariant, pVariant, bImportant);
634 AddPropertyHolder(CFX_CSSProperty::FontWeight, pWeight, bImportant);
635 AddPropertyHolder(CFX_CSSProperty::FontSize, pFontSize, bImportant);
636 AddPropertyHolder(CFX_CSSProperty::LineHeight, pLineHeight, bImportant);
637 if (!family_list.empty()) {
638 auto value_list =
639 pdfium::MakeRetain<CFX_CSSValueList>(std::move(family_list));
640 AddPropertyHolder(CFX_CSSProperty::FontFamily, value_list, bImportant);
641 }
642}
643
645 return properties_.size();
646}
CFX_CSSVALUETYPE
Definition cfx_css.h:14
@ CFX_CSSVALUETYPE_Shorthand
Definition cfx_css.h:17
@ CFX_CSSVALUETYPE_Primitive
Definition cfx_css.h:15
@ CFX_CSSVALUETYPE_MaybeEnum
Definition cfx_css.h:20
@ CFX_CSSVALUETYPE_MaybeString
Definition cfx_css.h:21
@ CFX_CSSVALUETYPE_MaybeColor
Definition cfx_css.h:22
@ CFX_CSSVALUETYPE_MaybeNumber
Definition cfx_css.h:19
CFX_CSSPropertyValue
Definition cfx_css.h:35
CFX_CSSProperty
Definition cfx_css.h:28
static const Color * GetColorByName(WideStringView wsName)
static const LengthUnit * GetLengthUnitByName(WideStringView wsName)
static const PropertyValue * GetPropertyValueByName(WideStringView wsName)
void AddProperty(const CFX_CSSData::Property *property, WideStringView value)
void AddProperty(const WideString &prop, const WideString &value)
size_t PropertyCountForTesting() const
RetainPtr< CFX_CSSValue > GetProperty(CFX_CSSProperty eProperty, bool *bImportant) const
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:118
int FXSYS_HexCharToInt(char c)
int FXSYS_roundf(float f)
Definition fx_system.cpp:92
CFX_CSSNumberValue::Unit type
Definition cfx_cssdata.h:31
CFX_CSSPropertyValue eName
Definition cfx_cssdata.h:25
CFX_CSSProperty eName
Definition cfx_cssdata.h:19