Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfx_csscomputedstyle.cpp
Go to the documentation of this file.
1
// Copyright 2017 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_csscomputedstyle.h"
8
9
#
include
"core/fxcrt/containers/adapters.h"
10
#
include
"core/fxcrt/css/cfx_cssstringvalue.h"
11
#
include
"core/fxcrt/css/cfx_cssvaluelist.h"
12
13
CFX_CSSComputedStyle::CFX_CSSComputedStyle() =
default
;
14
15
CFX_CSSComputedStyle::~
CFX_CSSComputedStyle
() =
default
;
16
17
bool
CFX_CSSComputedStyle::
GetCustomStyle
(
const
WideString
& wsName,
18
WideString
* pValue)
const
{
19
for
(
const
auto
& prop : pdfium::Reversed(m_CustomProperties)) {
20
if
(wsName == prop.name()) {
21
*pValue = prop.value();
22
return
true
;
23
}
24
}
25
return
false
;
26
}
27
28
std
::optional<
WideString
> CFX_CSSComputedStyle::
GetLastFontFamily
()
const
{
29
if
(!m_InheritedData.m_pFontFamily ||
30
m_InheritedData.m_pFontFamily->values().empty()) {
31
return
std
::nullopt;
32
}
33
34
return
m_InheritedData.m_pFontFamily->values()
35
.back()
36
.AsRaw<CFX_CSSStringValue>()
37
->Value();
38
}
39
40
uint16_t CFX_CSSComputedStyle::
GetFontWeight
()
const
{
41
return
m_InheritedData.m_wFontWeight;
42
}
43
44
CFX_CSSFontVariant
CFX_CSSComputedStyle::
GetFontVariant
()
const
{
45
return
m_InheritedData.m_eFontVariant;
46
}
47
48
CFX_CSSFontStyle
CFX_CSSComputedStyle::
GetFontStyle
()
const
{
49
return
m_InheritedData.m_eFontStyle;
50
}
51
52
float
CFX_CSSComputedStyle::
GetFontSize
()
const
{
53
return
m_InheritedData.m_fFontSize;
54
}
55
56
FX_ARGB
CFX_CSSComputedStyle::
GetColor
()
const
{
57
return
m_InheritedData.m_dwFontColor;
58
}
59
60
void
CFX_CSSComputedStyle::
SetFontWeight
(uint16_t wFontWeight) {
61
m_InheritedData.m_wFontWeight = wFontWeight;
62
}
63
64
void
CFX_CSSComputedStyle::
SetFontVariant
(
CFX_CSSFontVariant
eFontVariant) {
65
m_InheritedData.m_eFontVariant = eFontVariant;
66
}
67
68
void
CFX_CSSComputedStyle::
SetFontStyle
(
CFX_CSSFontStyle
eFontStyle) {
69
m_InheritedData.m_eFontStyle = eFontStyle;
70
}
71
72
void
CFX_CSSComputedStyle::
SetFontSize
(
float
fFontSize) {
73
m_InheritedData.m_fFontSize = fFontSize;
74
}
75
76
void
CFX_CSSComputedStyle::
SetColor
(
FX_ARGB
dwFontColor) {
77
m_InheritedData.m_dwFontColor = dwFontColor;
78
}
79
80
const
CFX_CSSRect
* CFX_CSSComputedStyle::
GetBorderWidth
()
const
{
81
return
m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth)
82
:
nullptr
;
83
}
84
85
const
CFX_CSSRect
* CFX_CSSComputedStyle::
GetMarginWidth
()
const
{
86
return
m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth)
87
:
nullptr
;
88
}
89
90
const
CFX_CSSRect
* CFX_CSSComputedStyle::
GetPaddingWidth
()
const
{
91
return
m_NonInheritedData.m_bHasPadding ? &(m_NonInheritedData.m_PaddingWidth)
92
:
nullptr
;
93
}
94
95
void
CFX_CSSComputedStyle::
SetMarginWidth
(
const
CFX_CSSRect
& rect) {
96
m_NonInheritedData.m_MarginWidth = rect;
97
m_NonInheritedData.m_bHasMargin =
true
;
98
}
99
100
void
CFX_CSSComputedStyle::
SetPaddingWidth
(
const
CFX_CSSRect
& rect) {
101
m_NonInheritedData.m_PaddingWidth = rect;
102
m_NonInheritedData.m_bHasPadding =
true
;
103
}
104
105
CFX_CSSDisplay
CFX_CSSComputedStyle::
GetDisplay
()
const
{
106
return
m_NonInheritedData.m_eDisplay;
107
}
108
109
float
CFX_CSSComputedStyle::
GetLineHeight
()
const
{
110
return
m_InheritedData.m_fLineHeight;
111
}
112
113
const
CFX_CSSLength
& CFX_CSSComputedStyle::
GetTextIndent
()
const
{
114
return
m_InheritedData.m_TextIndent;
115
}
116
117
CFX_CSSTextAlign
CFX_CSSComputedStyle::
GetTextAlign
()
const
{
118
return
m_InheritedData.m_eTextAlign;
119
}
120
121
CFX_CSSVerticalAlign
CFX_CSSComputedStyle::
GetVerticalAlign
()
const
{
122
return
m_NonInheritedData.m_eVerticalAlignType;
123
}
124
125
float
CFX_CSSComputedStyle::
GetNumberVerticalAlign
()
const
{
126
return
m_NonInheritedData.m_fVerticalAlign;
127
}
128
129
Mask
<
CFX_CSSTEXTDECORATION
> CFX_CSSComputedStyle::
GetTextDecoration
()
const
{
130
return
m_NonInheritedData.m_dwTextDecoration;
131
}
132
133
const
CFX_CSSLength
& CFX_CSSComputedStyle::
GetLetterSpacing
()
const
{
134
return
m_InheritedData.m_LetterSpacing;
135
}
136
137
void
CFX_CSSComputedStyle::
SetLineHeight
(
float
fLineHeight) {
138
m_InheritedData.m_fLineHeight = fLineHeight;
139
}
140
141
void
CFX_CSSComputedStyle::
SetTextIndent
(
const
CFX_CSSLength
& textIndent) {
142
m_InheritedData.m_TextIndent = textIndent;
143
}
144
145
void
CFX_CSSComputedStyle::
SetTextAlign
(
CFX_CSSTextAlign
eTextAlign) {
146
m_InheritedData.m_eTextAlign = eTextAlign;
147
}
148
149
void
CFX_CSSComputedStyle::
SetNumberVerticalAlign
(
float
fAlign) {
150
m_NonInheritedData.m_eVerticalAlignType = CFX_CSSVerticalAlign::Number,
151
m_NonInheritedData.m_fVerticalAlign = fAlign;
152
}
153
154
void
CFX_CSSComputedStyle::
SetTextDecoration
(
155
Mask
<
CFX_CSSTEXTDECORATION
> dwTextDecoration) {
156
m_NonInheritedData.m_dwTextDecoration = dwTextDecoration;
157
}
158
159
void
CFX_CSSComputedStyle::
SetLetterSpacing
(
160
const
CFX_CSSLength
& letterSpacing) {
161
m_InheritedData.m_LetterSpacing = letterSpacing;
162
}
163
164
void
CFX_CSSComputedStyle::
AddCustomStyle
(
const
CFX_CSSCustomProperty
& prop) {
165
// Force the property to be copied so we aren't dependent on the lifetime
166
// of whatever currently owns it.
167
m_CustomProperties.push_back(prop);
168
}
169
170
CFX_CSSComputedStyle::
InheritedData
::
InheritedData
() =
default
;
171
172
CFX_CSSComputedStyle::
InheritedData
::~
InheritedData
() =
default
;
173
174
CFX_CSSComputedStyle::
NonInheritedData
::
NonInheritedData
() =
default
;
CFX_CSSFontVariant
CFX_CSSFontVariant
Definition
cfx_css.h:82
CFX_CSSFontStyle
CFX_CSSFontStyle
Definition
cfx_css.h:57
CFX_CSSDisplay
CFX_CSSDisplay
Definition
cfx_css.h:48
CFX_CSSVerticalAlign
CFX_CSSVerticalAlign
Definition
cfx_css.h:70
CFX_CSSTextAlign
CFX_CSSTextAlign
Definition
cfx_css.h:62
CFX_CSSTEXTDECORATION
CFX_CSSTEXTDECORATION
Definition
cfx_css.h:87
CFX_CSSComputedStyle::InheritedData
Definition
cfx_csscomputedstyle.h:24
CFX_CSSComputedStyle::InheritedData::~InheritedData
~InheritedData()
CFX_CSSComputedStyle::InheritedData::InheritedData
InheritedData()
CFX_CSSComputedStyle::NonInheritedData
Definition
cfx_csscomputedstyle.h:42
CFX_CSSComputedStyle::NonInheritedData::NonInheritedData
NonInheritedData()
CFX_CSSComputedStyle::SetTextAlign
void SetTextAlign(CFX_CSSTextAlign eTextAlign)
Definition
cfx_csscomputedstyle.cpp:145
CFX_CSSComputedStyle::SetNumberVerticalAlign
void SetNumberVerticalAlign(float fAlign)
Definition
cfx_csscomputedstyle.cpp:149
CFX_CSSComputedStyle::SetMarginWidth
void SetMarginWidth(const CFX_CSSRect &rect)
Definition
cfx_csscomputedstyle.cpp:95
CFX_CSSComputedStyle::SetTextDecoration
void SetTextDecoration(Mask< CFX_CSSTEXTDECORATION > dwTextDecoration)
Definition
cfx_csscomputedstyle.cpp:154
CFX_CSSComputedStyle::SetTextIndent
void SetTextIndent(const CFX_CSSLength &textIndent)
Definition
cfx_csscomputedstyle.cpp:141
CFX_CSSComputedStyle::GetBorderWidth
const CFX_CSSRect * GetBorderWidth() const
Definition
cfx_csscomputedstyle.cpp:80
CFX_CSSComputedStyle::SetPaddingWidth
void SetPaddingWidth(const CFX_CSSRect &rect)
Definition
cfx_csscomputedstyle.cpp:100
CFX_CSSComputedStyle::SetFontWeight
void SetFontWeight(uint16_t wFontWeight)
Definition
cfx_csscomputedstyle.cpp:60
CFX_CSSComputedStyle::SetFontVariant
void SetFontVariant(CFX_CSSFontVariant eFontVariant)
Definition
cfx_csscomputedstyle.cpp:64
CFX_CSSComputedStyle::SetFontStyle
void SetFontStyle(CFX_CSSFontStyle eFontStyle)
Definition
cfx_csscomputedstyle.cpp:68
CFX_CSSComputedStyle::SetColor
void SetColor(FX_ARGB dwFontColor)
Definition
cfx_csscomputedstyle.cpp:76
CFX_CSSComputedStyle::SetFontSize
void SetFontSize(float fFontSize)
Definition
cfx_csscomputedstyle.cpp:72
CFX_CSSComputedStyle::GetTextIndent
const CFX_CSSLength & GetTextIndent() const
Definition
cfx_csscomputedstyle.cpp:113
CFX_CSSComputedStyle::AddCustomStyle
void AddCustomStyle(const CFX_CSSCustomProperty &prop)
Definition
cfx_csscomputedstyle.cpp:164
CFX_CSSComputedStyle::GetColor
FX_ARGB GetColor() const
Definition
cfx_csscomputedstyle.cpp:56
CFX_CSSComputedStyle::GetVerticalAlign
CFX_CSSVerticalAlign GetVerticalAlign() const
Definition
cfx_csscomputedstyle.cpp:121
CFX_CSSComputedStyle::GetLastFontFamily
std::optional< WideString > GetLastFontFamily() const
Definition
cfx_csscomputedstyle.cpp:28
CFX_CSSComputedStyle::GetTextDecoration
Mask< CFX_CSSTEXTDECORATION > GetTextDecoration() const
Definition
cfx_csscomputedstyle.cpp:129
CFX_CSSComputedStyle::GetFontStyle
CFX_CSSFontStyle GetFontStyle() const
Definition
cfx_csscomputedstyle.cpp:48
CFX_CSSComputedStyle::GetFontWeight
uint16_t GetFontWeight() const
Definition
cfx_csscomputedstyle.cpp:40
CFX_CSSComputedStyle::GetFontVariant
CFX_CSSFontVariant GetFontVariant() const
Definition
cfx_csscomputedstyle.cpp:44
CFX_CSSComputedStyle::GetLineHeight
float GetLineHeight() const
Definition
cfx_csscomputedstyle.cpp:109
CFX_CSSComputedStyle::GetMarginWidth
const CFX_CSSRect * GetMarginWidth() const
Definition
cfx_csscomputedstyle.cpp:85
CFX_CSSComputedStyle::~CFX_CSSComputedStyle
~CFX_CSSComputedStyle() override
CFX_CSSComputedStyle::GetLetterSpacing
const CFX_CSSLength & GetLetterSpacing() const
Definition
cfx_csscomputedstyle.cpp:133
CFX_CSSComputedStyle::GetTextAlign
CFX_CSSTextAlign GetTextAlign() const
Definition
cfx_csscomputedstyle.cpp:117
CFX_CSSComputedStyle::GetFontSize
float GetFontSize() const
Definition
cfx_csscomputedstyle.cpp:52
CFX_CSSComputedStyle::GetCustomStyle
bool GetCustomStyle(const WideString &wsName, WideString *pValue) const
Definition
cfx_csscomputedstyle.cpp:17
CFX_CSSComputedStyle::GetDisplay
CFX_CSSDisplay GetDisplay() const
Definition
cfx_csscomputedstyle.cpp:105
CFX_CSSComputedStyle::SetLetterSpacing
void SetLetterSpacing(const CFX_CSSLength &letterSpacing)
Definition
cfx_csscomputedstyle.cpp:159
CFX_CSSComputedStyle::GetPaddingWidth
const CFX_CSSRect * GetPaddingWidth() const
Definition
cfx_csscomputedstyle.cpp:90
CFX_CSSComputedStyle::GetNumberVerticalAlign
float GetNumberVerticalAlign() const
Definition
cfx_csscomputedstyle.cpp:125
CFX_CSSComputedStyle::SetLineHeight
void SetLineHeight(float fLineHeight)
Definition
cfx_csscomputedstyle.cpp:137
CFX_CSSCustomProperty
Definition
cfx_csscustomproperty.h:12
CFX_CSSLength
Definition
cfx_css.h:96
CFX_CSSRect
Definition
cfx_css.h:124
fxcrt::Mask
Definition
mask.h:15
FX_ARGB
uint32_t FX_ARGB
Definition
fx_dib.h:36
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
css
cfx_csscomputedstyle.cpp
Generated on
for Qt by
1.18.0