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.h
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#ifndef CORE_FXCRT_CSS_CFX_CSSDECLARATION_H_
8#define CORE_FXCRT_CSS_CFX_CSSDECLARATION_H_
9
10#include <memory>
11#include <optional>
12#include <vector>
13
14#include "core/fxcrt/css/cfx_cssdata.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxcrt/widestring.h"
17
20
22 public:
27
28 static std::optional<WideStringView> ParseCSSString(WideStringView value);
29 static std::optional<FX_ARGB> ParseCSSColor(WideStringView value);
30
33
35 bool* bImportant) const;
36
37 bool empty() const { return properties_.empty(); }
38 const_prop_iterator begin() const { return properties_.begin(); }
39 const_prop_iterator end() const { return properties_.end(); }
40
42 return custom_properties_.begin();
43 }
44 const_custom_iterator custom_end() const { return custom_properties_.end(); }
45
46 void AddProperty(const CFX_CSSData::Property* property, WideStringView value);
47 void AddProperty(const WideString& prop, const WideString& value);
49
51
52 private:
53 void ParseFontProperty(WideStringView value, bool bImportant);
54
55 // Never returns nullptr, instead returns a CSSValue representing zero
56 // if the input cannot be parsed.
57 RetainPtr<CFX_CSSValue> ParseBorderProperty(WideStringView value) const;
58
59 void ParseValueListProperty(const CFX_CSSData::Property* pProperty,
60 WideStringView value,
61 bool bImportant);
62 void Add4ValuesProperty(const std::vector<RetainPtr<CFX_CSSValue>>& list,
63 bool bImportant,
64 CFX_CSSProperty eLeft,
65 CFX_CSSProperty eTop,
66 CFX_CSSProperty eRight,
67 CFX_CSSProperty eBottom);
68 RetainPtr<CFX_CSSValue> ParseNumber(WideStringView value);
69 RetainPtr<CFX_CSSValue> ParseEnum(WideStringView value);
70 RetainPtr<CFX_CSSValue> ParseColor(WideStringView value);
71 RetainPtr<CFX_CSSValue> ParseString(WideStringView value);
72 void AddPropertyHolder(CFX_CSSProperty eProperty,
73 RetainPtr<CFX_CSSValue> pValue,
74 bool bImportant);
75
76 std::vector<std::unique_ptr<CFX_CSSPropertyHolder>> properties_;
77 std::vector<std::unique_ptr<CFX_CSSCustomProperty>> custom_properties_;
78};
79
80#endif // CORE_FXCRT_CSS_CFX_CSSDECLARATION_H_
CFX_CSSVALUETYPE
Definition cfx_css.h:14
@ CFX_CSSVALUETYPE_Shorthand
Definition cfx_css.h:17
@ CFX_CSSVALUETYPE_List
Definition cfx_css.h:16
@ 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
#define DCHECK
Definition check.h:33
static const Color * GetColorByName(WideStringView wsName)
static const LengthUnit * GetLengthUnitByName(WideStringView wsName)
static const PropertyValue * GetPropertyValueByName(WideStringView wsName)
const_prop_iterator end() const
void AddProperty(const CFX_CSSData::Property *property, WideStringView value)
const_prop_iterator begin() const
static std::optional< WideStringView > ParseCSSString(WideStringView value)
void AddProperty(const WideString &prop, const WideString &value)
size_t PropertyCountForTesting() const
const_custom_iterator custom_begin() const
std::optional< FX_ARGB > ParseColorForTest(WideStringView value)
const_custom_iterator custom_end() const
static std::optional< FX_ARGB > ParseCSSColor(WideStringView value)
RetainPtr< CFX_CSSValue > GetProperty(CFX_CSSProperty eProperty, bool *bImportant) const
std::optional< Result > NextValue()
uint32_t FX_ARGB
Definition fx_dib.h:36
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:188
int FXSYS_HexCharToInt(char c)
#define NOTREACHED_NORETURN()
Definition notreached.h:22
fxcrt::WideStringView WideStringView
CFX_CSSNumber::Unit type
Definition cfx_cssdata.h:31
CFX_CSSPropertyValue eName
Definition cfx_cssdata.h:25
CFX_CSSProperty eName
Definition cfx_cssdata.h:19
fxcrt::WideString WideString
Definition widestring.h:207