OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 * rights reserved. |
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
7 * | 8 * |
8 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
12 * | 13 * |
13 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // bit fields, while large fields are stored in pointers and shared where not | 136 // bit fields, while large fields are stored in pointers and shared where not |
136 // modified from their parent value (see the DataRef class). | 137 // modified from their parent value (see the DataRef class). |
137 // | 138 // |
138 // Currently, ComputedStyle is hand-written and ComputedStyleBase is generated. | 139 // Currently, ComputedStyle is hand-written and ComputedStyleBase is generated. |
139 // Over time, methods will be moved to ComputedStyleBase and the generator will | 140 // Over time, methods will be moved to ComputedStyleBase and the generator will |
140 // be expanded to handle more and more types of properties. Eventually, all | 141 // be expanded to handle more and more types of properties. Eventually, all |
141 // methods will be on ComputedStyleBase (with custom methods defined in a class | 142 // methods will be on ComputedStyleBase (with custom methods defined in a class |
142 // such as ComputedStyleBase.cpp) and ComputedStyle will be removed. | 143 // such as ComputedStyleBase.cpp) and ComputedStyle will be removed. |
143 class CORE_EXPORT ComputedStyle : public ComputedStyleBase, | 144 class CORE_EXPORT ComputedStyle : public ComputedStyleBase, |
144 public RefCounted<ComputedStyle> { | 145 public RefCounted<ComputedStyle> { |
145 friend class | 146 // Used by Web Animations CSS. Sets the color styles. |
146 AnimatedStyleBuilder; // Used by Web Animations CSS. Sets the color style
s | 147 friend class AnimatedStyleBuilder; |
147 friend class | 148 // Used by Web Animations CSS. Gets visited and unvisited colors separately. |
148 CSSAnimatableValueFactory; // Used by Web Animations CSS. Gets visited an
d unvisited colors separately. | 149 friend class CSSAnimatableValueFactory; |
149 friend class | 150 // Used by CSS animations. We can't allow them to animate based off visited |
150 CSSPropertyEquality; // Used by CSS animations. We can't allow the
m to animate based off visited colors. | 151 // colors. |
151 friend class ApplyStyleCommand; // Editing has to only reveal unvisited info. | 152 friend class CSSPropertyEquality; |
152 friend class EditingStyle; // Editing has to only reveal unvisited info. | 153 // Editing has to only reveal unvisited info. |
153 friend class | 154 friend class ApplyStyleCommand; |
154 ComputedStyleCSSValueMapping; // Needs to be able to see visited and unvi
sited colors for devtools. | 155 // Editing has to only reveal unvisited info. |
155 friend class StyleBuilderFunctions; // Sets color styles | 156 friend class EditingStyle; |
156 friend class | 157 // Needs to be able to see visited and unvisited colors for devtools. |
157 CachedUAStyle; // Saves Border/Background information for later compariso
n. | 158 friend class ComputedStyleCSSValueMapping; |
158 friend class | 159 // Sets color styles |
159 ColorPropertyFunctions; // Accesses visited and unvisited colors. | 160 friend class StyleBuilderFunctions; |
| 161 // Saves Border/Background information for later comparison. |
| 162 friend class CachedUAStyle; |
| 163 // Accesses visited and unvisited colors. |
| 164 friend class ColorPropertyFunctions; |
160 | 165 |
161 // FIXME: When we stop resolving currentColor at style time, these can be remo
ved. | 166 // FIXME: When we stop resolving currentColor at style time, these can be |
| 167 // removed. |
162 friend class CSSToStyleMap; | 168 friend class CSSToStyleMap; |
163 friend class FilterOperationResolver; | 169 friend class FilterOperationResolver; |
164 friend class StyleBuilderConverter; | 170 friend class StyleBuilderConverter; |
165 friend class StyleResolverState; | 171 friend class StyleResolverState; |
166 friend class StyleResolver; | 172 friend class StyleResolver; |
167 | 173 |
168 protected: | 174 protected: |
169 // non-inherited attributes | 175 // non-inherited attributes |
170 DataRef<StyleBoxData> m_box; | 176 DataRef<StyleBoxData> m_box; |
171 DataRef<StyleVisualData> m_visual; | 177 DataRef<StyleVisualData> m_visual; |
172 DataRef<StyleBackgroundData> m_background; | 178 DataRef<StyleBackgroundData> m_background; |
173 DataRef<StyleSurroundData> m_surround; | 179 DataRef<StyleSurroundData> m_surround; |
174 DataRef<StyleRareNonInheritedData> m_rareNonInheritedData; | 180 DataRef<StyleRareNonInheritedData> m_rareNonInheritedData; |
175 | 181 |
176 // inherited attributes | 182 // inherited attributes |
177 DataRef<StyleRareInheritedData> m_rareInheritedData; | 183 DataRef<StyleRareInheritedData> m_rareInheritedData; |
178 DataRef<StyleInheritedData> m_styleInheritedData; | 184 DataRef<StyleInheritedData> m_styleInheritedData; |
179 | 185 |
180 // list of associated pseudo styles | 186 // list of associated pseudo styles |
181 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; | 187 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; |
182 | 188 |
183 DataRef<SVGComputedStyle> m_svgStyle; | 189 DataRef<SVGComputedStyle> m_svgStyle; |
184 | 190 |
185 // !START SYNC!: Keep this in sync with the copy constructor in ComputedStyle.
cpp and implicitlyInherited() in StyleResolver.cpp | 191 // !START SYNC!: Keep this in sync with the copy constructor in |
| 192 // ComputedStyle.cpp and implicitlyInherited() in StyleResolver.cpp |
186 | 193 |
187 // inherit | 194 // inherit |
188 struct InheritedData { | 195 struct InheritedData { |
189 bool operator==(const InheritedData& other) const { | 196 bool operator==(const InheritedData& other) const { |
190 return compareEqualIndependent(other) && | 197 return compareEqualIndependent(other) && |
191 compareEqualNonIndependent(other); | 198 compareEqualNonIndependent(other); |
192 } | 199 } |
193 | 200 |
194 bool operator!=(const InheritedData& other) const { | 201 bool operator!=(const InheritedData& other) const { |
195 return !(*this == other); | 202 return !(*this == other); |
(...skipping 29 matching lines...) Expand all Loading... |
225 unsigned m_captionSide : 2; // ECaptionSide | 232 unsigned m_captionSide : 2; // ECaptionSide |
226 unsigned m_listStyleType : 7; // EListStyleType | 233 unsigned m_listStyleType : 7; // EListStyleType |
227 unsigned m_listStylePosition : 1; // EListStylePosition | 234 unsigned m_listStylePosition : 1; // EListStylePosition |
228 unsigned m_textAlign : 4; // ETextAlign | 235 unsigned m_textAlign : 4; // ETextAlign |
229 unsigned m_textTransform : 2; // ETextTransform | 236 unsigned m_textTransform : 2; // ETextTransform |
230 unsigned m_textUnderline : 1; | 237 unsigned m_textUnderline : 1; |
231 unsigned m_cursorStyle : 6; // ECursor | 238 unsigned m_cursorStyle : 6; // ECursor |
232 unsigned m_direction : 1; // TextDirection | 239 unsigned m_direction : 1; // TextDirection |
233 unsigned m_whiteSpace : 3; // EWhiteSpace | 240 unsigned m_whiteSpace : 3; // EWhiteSpace |
234 unsigned m_borderCollapse : 1; // EBorderCollapse | 241 unsigned m_borderCollapse : 1; // EBorderCollapse |
235 unsigned | 242 unsigned m_boxDirection : 1; // EBoxDirection (CSS3 box_direction property, |
236 m_boxDirection : 1; // EBoxDirection (CSS3 box_direction property, flex
ible box layout module) | 243 // flexible box layout module) |
237 // 32 bits | 244 // 32 bits |
238 | 245 |
239 // non CSS2 inherited | 246 // non CSS2 inherited |
240 unsigned m_rtlOrdering : 1; // Order | 247 unsigned m_rtlOrdering : 1; // Order |
241 unsigned m_printColorAdjust : PrintColorAdjustBits; | 248 unsigned m_printColorAdjust : PrintColorAdjustBits; |
242 unsigned m_pointerEvents : 4; // EPointerEvents | 249 unsigned m_pointerEvents : 4; // EPointerEvents |
243 unsigned m_insideLink : 2; // EInsideLink | 250 unsigned m_insideLink : 2; // EInsideLink |
244 | 251 |
245 // CSS Text Layout Module Level 3: Vertical writing support | 252 // CSS Text Layout Module Level 3: Vertical writing support |
246 unsigned m_writingMode : 2; // WritingMode | 253 unsigned m_writingMode : 2; // WritingMode |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 unsigned m_overflowAnchor : 2; // EOverflowAnchor | 294 unsigned m_overflowAnchor : 2; // EOverflowAnchor |
288 unsigned m_overflowX : 3; // EOverflow | 295 unsigned m_overflowX : 3; // EOverflow |
289 unsigned m_overflowY : 3; // EOverflow | 296 unsigned m_overflowY : 3; // EOverflow |
290 unsigned m_verticalAlign : 4; // EVerticalAlign | 297 unsigned m_verticalAlign : 4; // EVerticalAlign |
291 unsigned m_clear : 2; // EClear | 298 unsigned m_clear : 2; // EClear |
292 unsigned m_position : 3; // EPosition | 299 unsigned m_position : 3; // EPosition |
293 unsigned m_tableLayout : 1; // ETableLayout | 300 unsigned m_tableLayout : 1; // ETableLayout |
294 unsigned m_unicodeBidi : 3; // EUnicodeBidi | 301 unsigned m_unicodeBidi : 3; // EUnicodeBidi |
295 | 302 |
296 // This is set if we used viewport units when resolving a length. | 303 // This is set if we used viewport units when resolving a length. |
297 // It is mutable so we can pass around const ComputedStyles to resolve lengt
hs. | 304 // It is mutable so we can pass around const ComputedStyles to resolve |
| 305 // lengths. |
298 mutable unsigned m_hasViewportUnits : 1; | 306 mutable unsigned m_hasViewportUnits : 1; |
299 | 307 |
300 // 32 bits | 308 // 32 bits |
301 | 309 |
302 unsigned m_breakBefore : 4; // EBreak | 310 unsigned m_breakBefore : 4; // EBreak |
303 unsigned m_breakAfter : 4; // EBreak | 311 unsigned m_breakAfter : 4; // EBreak |
304 unsigned m_breakInside : 2; // EBreak | 312 unsigned m_breakInside : 2; // EBreak |
305 | 313 |
306 unsigned m_styleType : 6; // PseudoId | 314 unsigned m_styleType : 6; // PseudoId |
307 unsigned m_pseudoBits : 8; | 315 unsigned m_pseudoBits : 8; |
308 unsigned | 316 unsigned m_explicitInheritance : 1; // Explicitly inherits a non-inherited |
309 m_explicitInheritance : 1; // Explicitly inherits a non-inherited prope
rty | 317 // property |
310 unsigned | 318 unsigned m_variableReference : 1; // A non-inherited property references a |
311 m_variableReference : 1; // A non-inherited property references a varia
ble or @apply is used. | 319 // variable or @apply is used. |
312 unsigned m_unique : 1; // Style can not be shared. | 320 unsigned m_unique : 1; // Style can not be shared. |
313 | 321 |
314 unsigned m_emptyState : 1; | 322 unsigned m_emptyState : 1; |
315 | 323 |
316 unsigned m_affectedByFocus : 1; | 324 unsigned m_affectedByFocus : 1; |
317 unsigned m_affectedByHover : 1; | 325 unsigned m_affectedByHover : 1; |
318 unsigned m_affectedByActive : 1; | 326 unsigned m_affectedByActive : 1; |
319 unsigned m_affectedByDrag : 1; | 327 unsigned m_affectedByDrag : 1; |
320 | 328 |
321 // 64 bits | 329 // 64 bits |
322 | 330 |
323 unsigned m_isLink : 1; | 331 unsigned m_isLink : 1; |
324 | 332 |
325 mutable unsigned m_hasRemUnits : 1; | 333 mutable unsigned m_hasRemUnits : 1; |
326 | 334 |
327 // For each independent inherited property, store a 1 if the stored | 335 // For each independent inherited property, store a 1 if the stored |
328 // value was inherited from its parent, or 0 if it is explicitly set on | 336 // value was inherited from its parent, or 0 if it is explicitly set on |
329 // this element. | 337 // this element. |
330 // Eventually, all properties will have a bit in here to store whether | 338 // Eventually, all properties will have a bit in here to store whether |
331 // they were inherited from their parent or not. | 339 // they were inherited from their parent or not. |
332 // Although two ComputedStyles are equal if their nonInheritedData is | 340 // Although two ComputedStyles are equal if their nonInheritedData is |
333 // equal regardless of the isInherited flags, this struct is stored next | 341 // equal regardless of the isInherited flags, this struct is stored next |
334 // to the existing flags to take advantage of packing as much as possible. | 342 // to the existing flags to take advantage of packing as much as possible. |
335 // TODO(sashab): Move these flags closer to inheritedData so that it's | 343 // TODO(sashab): Move these flags closer to inheritedData so that it's |
336 // clear which inherited properties have a flag stored and which don't. | 344 // clear which inherited properties have a flag stored and which don't. |
337 // Keep this list of fields in sync with: | 345 // Keep this list of fields in sync with: |
338 // - setBitDefaults() | 346 // - setBitDefaults() |
339 // - The ComputedStyle setter, which must take an extra boolean parameter an
d set this | 347 // - The ComputedStyle setter, which must take an extra boolean parameter |
340 // - propagateIndependentInheritedProperties() in ComputedStyle.cpp | 348 // and set this - propagateIndependentInheritedProperties() in |
| 349 // ComputedStyle.cpp |
341 // - The compareEqual() methods in the corresponding class | 350 // - The compareEqual() methods in the corresponding class |
342 // InheritedFlags | 351 // InheritedFlags |
343 unsigned m_isPointerEventsInherited : 1; | 352 unsigned m_isPointerEventsInherited : 1; |
344 unsigned m_isVisibilityInherited : 1; | 353 unsigned m_isVisibilityInherited : 1; |
345 | 354 |
346 // If you add more style bits here, you will also need to update ComputedSty
le::copyNonInheritedFromCached() | 355 // If you add more style bits here, you will also need to update |
347 // 68 bits | 356 // ComputedStyle::copyNonInheritedFromCached() 68 bits |
348 } m_nonInheritedData; | 357 } m_nonInheritedData; |
349 | 358 |
350 // !END SYNC! | 359 // !END SYNC! |
351 | 360 |
352 void setBitDefaults() { | 361 void setBitDefaults() { |
353 ComputedStyleBase::setBitDefaults(); | 362 ComputedStyleBase::setBitDefaults(); |
354 m_inheritedData.m_emptyCells = static_cast<unsigned>(initialEmptyCells()); | 363 m_inheritedData.m_emptyCells = static_cast<unsigned>(initialEmptyCells()); |
355 m_inheritedData.m_captionSide = static_cast<unsigned>(initialCaptionSide()); | 364 m_inheritedData.m_captionSide = static_cast<unsigned>(initialCaptionSide()); |
356 m_inheritedData.m_listStyleType = initialListStyleType(); | 365 m_inheritedData.m_listStyleType = initialListStyleType(); |
357 m_inheritedData.m_listStylePosition = initialListStylePosition(); | 366 m_inheritedData.m_listStylePosition = initialListStylePosition(); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // break-after (shorthand for page-break-after and -webkit-column-break-after) | 851 // break-after (shorthand for page-break-after and -webkit-column-break-after) |
843 static EBreak initialBreakAfter() { return BreakAuto; } | 852 static EBreak initialBreakAfter() { return BreakAuto; } |
844 EBreak breakAfter() const { | 853 EBreak breakAfter() const { |
845 return static_cast<EBreak>(m_nonInheritedData.m_breakAfter); | 854 return static_cast<EBreak>(m_nonInheritedData.m_breakAfter); |
846 } | 855 } |
847 void setBreakAfter(EBreak b) { | 856 void setBreakAfter(EBreak b) { |
848 DCHECK_LE(b, BreakValueLastAllowedForBreakAfterAndBefore); | 857 DCHECK_LE(b, BreakValueLastAllowedForBreakAfterAndBefore); |
849 m_nonInheritedData.m_breakAfter = b; | 858 m_nonInheritedData.m_breakAfter = b; |
850 } | 859 } |
851 | 860 |
852 // break-before (shorthand for page-break-before and -webkit-column-break-befo
re) | 861 // break-before (shorthand for page-break-before and |
| 862 // -webkit-column-break-before) |
853 static EBreak initialBreakBefore() { return BreakAuto; } | 863 static EBreak initialBreakBefore() { return BreakAuto; } |
854 EBreak breakBefore() const { | 864 EBreak breakBefore() const { |
855 return static_cast<EBreak>(m_nonInheritedData.m_breakBefore); | 865 return static_cast<EBreak>(m_nonInheritedData.m_breakBefore); |
856 } | 866 } |
857 void setBreakBefore(EBreak b) { | 867 void setBreakBefore(EBreak b) { |
858 DCHECK_LE(b, BreakValueLastAllowedForBreakAfterAndBefore); | 868 DCHECK_LE(b, BreakValueLastAllowedForBreakAfterAndBefore); |
859 m_nonInheritedData.m_breakBefore = b; | 869 m_nonInheritedData.m_breakBefore = b; |
860 } | 870 } |
861 | 871 |
862 // break-inside (shorthand for page-break-inside and -webkit-column-break-insi
de) | 872 // break-inside (shorthand for page-break-inside and |
| 873 // -webkit-column-break-inside) |
863 static EBreak initialBreakInside() { return BreakAuto; } | 874 static EBreak initialBreakInside() { return BreakAuto; } |
864 EBreak breakInside() const { | 875 EBreak breakInside() const { |
865 return static_cast<EBreak>(m_nonInheritedData.m_breakInside); | 876 return static_cast<EBreak>(m_nonInheritedData.m_breakInside); |
866 } | 877 } |
867 void setBreakInside(EBreak b) { | 878 void setBreakInside(EBreak b) { |
868 DCHECK_LE(b, BreakValueLastAllowedForBreakInside); | 879 DCHECK_LE(b, BreakValueLastAllowedForBreakInside); |
869 m_nonInheritedData.m_breakInside = b; | 880 m_nonInheritedData.m_breakInside = b; |
870 } | 881 } |
871 | 882 |
872 // clip | 883 // clip |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 static unsigned initialBoxFlexGroup() { return 1; } | 1077 static unsigned initialBoxFlexGroup() { return 1; } |
1067 unsigned boxFlexGroup() const { | 1078 unsigned boxFlexGroup() const { |
1068 return m_rareNonInheritedData->m_deprecatedFlexibleBox->flexGroup; | 1079 return m_rareNonInheritedData->m_deprecatedFlexibleBox->flexGroup; |
1069 } | 1080 } |
1070 void setBoxFlexGroup(unsigned fg) { | 1081 void setBoxFlexGroup(unsigned fg) { |
1071 SET_NESTED_VAR(m_rareNonInheritedData, m_deprecatedFlexibleBox, flexGroup, | 1082 SET_NESTED_VAR(m_rareNonInheritedData, m_deprecatedFlexibleBox, flexGroup, |
1072 fg); | 1083 fg); |
1073 } | 1084 } |
1074 | 1085 |
1075 // -webkit-box-align | 1086 // -webkit-box-align |
1076 // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox
-20090723/#alignment | 1087 // For valid values of box-align see |
| 1088 // http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment |
1077 static EBoxAlignment initialBoxAlign() { return BSTRETCH; } | 1089 static EBoxAlignment initialBoxAlign() { return BSTRETCH; } |
1078 EBoxAlignment boxAlign() const { | 1090 EBoxAlignment boxAlign() const { |
1079 return static_cast<EBoxAlignment>( | 1091 return static_cast<EBoxAlignment>( |
1080 m_rareNonInheritedData->m_deprecatedFlexibleBox->align); | 1092 m_rareNonInheritedData->m_deprecatedFlexibleBox->align); |
1081 } | 1093 } |
1082 void setBoxAlign(EBoxAlignment a) { | 1094 void setBoxAlign(EBoxAlignment a) { |
1083 SET_NESTED_VAR(m_rareNonInheritedData, m_deprecatedFlexibleBox, align, a); | 1095 SET_NESTED_VAR(m_rareNonInheritedData, m_deprecatedFlexibleBox, align, a); |
1084 } | 1096 } |
1085 | 1097 |
1086 // -webkit-box-decoration-break | 1098 // -webkit-box-decoration-break |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 static float initialOpacity() { return 1.0f; } | 1484 static float initialOpacity() { return 1.0f; } |
1473 float opacity() const { return m_rareNonInheritedData->opacity; } | 1485 float opacity() const { return m_rareNonInheritedData->opacity; } |
1474 void setOpacity(float f) { | 1486 void setOpacity(float f) { |
1475 float v = clampTo<float>(f, 0, 1); | 1487 float v = clampTo<float>(f, 0, 1); |
1476 SET_VAR(m_rareNonInheritedData, opacity, v); | 1488 SET_VAR(m_rareNonInheritedData, opacity, v); |
1477 } | 1489 } |
1478 | 1490 |
1479 // order (aka -webkit-order) | 1491 // order (aka -webkit-order) |
1480 static int initialOrder() { return 0; } | 1492 static int initialOrder() { return 0; } |
1481 int order() const { return m_rareNonInheritedData->m_order; } | 1493 int order() const { return m_rareNonInheritedData->m_order; } |
1482 // We restrict the smallest value to int min + 2 because we use int min and in
t min + 1 as special values in a hash set. | 1494 // We restrict the smallest value to int min + 2 because we use int min and |
| 1495 // int min + 1 as special values in a hash set. |
1483 void setOrder(int o) { | 1496 void setOrder(int o) { |
1484 SET_VAR(m_rareNonInheritedData, m_order, | 1497 SET_VAR(m_rareNonInheritedData, m_order, |
1485 max(std::numeric_limits<int>::min() + 2, o)); | 1498 max(std::numeric_limits<int>::min() + 2, o)); |
1486 } | 1499 } |
1487 | 1500 |
1488 // Outline properties. | 1501 // Outline properties. |
1489 // outline-color | 1502 // outline-color |
1490 void setOutlineColor(const StyleColor& v) { | 1503 void setOutlineColor(const StyleColor& v) { |
1491 SET_BORDERVALUE_COLOR(m_background, m_outline, v); | 1504 SET_BORDERVALUE_COLOR(m_background, m_outline, v); |
1492 } | 1505 } |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 FontWeight fontWeight() const; | 2518 FontWeight fontWeight() const; |
2506 | 2519 |
2507 // font-stretch | 2520 // font-stretch |
2508 FontStretch fontStretch() const; | 2521 FontStretch fontStretch() const; |
2509 | 2522 |
2510 // -webkit-locale | 2523 // -webkit-locale |
2511 const AtomicString& locale() const { | 2524 const AtomicString& locale() const { |
2512 return LayoutLocale::localeString(getFontDescription().locale()); | 2525 return LayoutLocale::localeString(getFontDescription().locale()); |
2513 } | 2526 } |
2514 | 2527 |
2515 // FIXME: Remove letter-spacing/word-spacing and replace them with respective
FontBuilder calls. | 2528 // FIXME: Remove letter-spacing/word-spacing and replace them with respective |
2516 // letter-spacing | 2529 // FontBuilder calls. letter-spacing |
2517 static float initialLetterWordSpacing() { return 0.0f; } | 2530 static float initialLetterWordSpacing() { return 0.0f; } |
2518 float letterSpacing() const; | 2531 float letterSpacing() const; |
2519 void setLetterSpacing(float); | 2532 void setLetterSpacing(float); |
2520 | 2533 |
2521 // word-spacing | 2534 // word-spacing |
2522 float wordSpacing() const; | 2535 float wordSpacing() const; |
2523 void setWordSpacing(float); | 2536 void setWordSpacing(float); |
2524 | 2537 |
2525 // SVG properties. | 2538 // SVG properties. |
2526 const SVGComputedStyle& svgStyle() const { return *m_svgStyle.get(); } | 2539 const SVGComputedStyle& svgStyle() const { return *m_svgStyle.get(); } |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 SET_VAR(m_rareNonInheritedData, m_hasAuthorBackground, authorBackground); | 2794 SET_VAR(m_rareNonInheritedData, m_hasAuthorBackground, authorBackground); |
2782 } | 2795 } |
2783 | 2796 |
2784 bool hasAuthorBorder() const { | 2797 bool hasAuthorBorder() const { |
2785 return m_rareNonInheritedData->m_hasAuthorBorder; | 2798 return m_rareNonInheritedData->m_hasAuthorBorder; |
2786 }; | 2799 }; |
2787 void setHasAuthorBorder(bool authorBorder) { | 2800 void setHasAuthorBorder(bool authorBorder) { |
2788 SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); | 2801 SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); |
2789 } | 2802 } |
2790 | 2803 |
2791 // A stacking context is painted atomically and defines a stacking order, wher
eas | 2804 // A stacking context is painted atomically and defines a stacking order, |
2792 // a containing stacking context defines in which order the stacking contexts | 2805 // whereas a containing stacking context defines in which order the stacking |
2793 // below are painted. | 2806 // contexts below are painted. |
2794 // See CSS 2.1, Appendix E (https://www.w3.org/TR/CSS21/zindex.html) for more
details. | 2807 // See CSS 2.1, Appendix E (https://www.w3.org/TR/CSS21/zindex.html) for more |
| 2808 // details. |
2795 bool isStackingContext() const { | 2809 bool isStackingContext() const { |
2796 return m_rareNonInheritedData->m_isStackingContext; | 2810 return m_rareNonInheritedData->m_isStackingContext; |
2797 } | 2811 } |
2798 void setIsStackingContext(bool b) { | 2812 void setIsStackingContext(bool b) { |
2799 SET_VAR(m_rareNonInheritedData, m_isStackingContext, b); | 2813 SET_VAR(m_rareNonInheritedData, m_isStackingContext, b); |
2800 } | 2814 } |
2801 | 2815 |
2802 // A unique style is one that has matches something that makes it impossible t
o share. | 2816 // A unique style is one that has matches something that makes it impossible |
| 2817 // to share. |
2803 bool unique() const { return m_nonInheritedData.m_unique; } | 2818 bool unique() const { return m_nonInheritedData.m_unique; } |
2804 void setUnique() { m_nonInheritedData.m_unique = true; } | 2819 void setUnique() { m_nonInheritedData.m_unique = true; } |
2805 | 2820 |
2806 float textAutosizingMultiplier() const { | 2821 float textAutosizingMultiplier() const { |
2807 return m_styleInheritedData->textAutosizingMultiplier; | 2822 return m_styleInheritedData->textAutosizingMultiplier; |
2808 } | 2823 } |
2809 void setTextAutosizingMultiplier(float); | 2824 void setTextAutosizingMultiplier(float); |
2810 | 2825 |
2811 bool selfOrAncestorHasDirAutoAttribute() const { | 2826 bool selfOrAncestorHasDirAutoAttribute() const { |
2812 return m_rareInheritedData->m_selfOrAncestorHasDirAutoAttribute; | 2827 return m_rareInheritedData->m_selfOrAncestorHasDirAutoAttribute; |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3433 void resetPageSizeType() { | 3448 void resetPageSizeType() { |
3434 SET_VAR(m_rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); | 3449 SET_VAR(m_rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); |
3435 } | 3450 } |
3436 | 3451 |
3437 // Outline utility functions. | 3452 // Outline utility functions. |
3438 bool hasOutline() const { | 3453 bool hasOutline() const { |
3439 return outlineWidth() > 0 && outlineStyle() > BorderStyleHidden; | 3454 return outlineWidth() > 0 && outlineStyle() > BorderStyleHidden; |
3440 } | 3455 } |
3441 int outlineOutsetExtent() const; | 3456 int outlineOutsetExtent() const; |
3442 bool isOutlineEquivalent(const ComputedStyle* otherStyle) const { | 3457 bool isOutlineEquivalent(const ComputedStyle* otherStyle) const { |
3443 // No other style, so we don't have an outline then we consider them to be t
he same. | 3458 // No other style, so we don't have an outline then we consider them to be |
| 3459 // the same. |
3444 if (!otherStyle) | 3460 if (!otherStyle) |
3445 return !hasOutline(); | 3461 return !hasOutline(); |
3446 return m_background->outline().visuallyEqual( | 3462 return m_background->outline().visuallyEqual( |
3447 otherStyle->m_background->outline()); | 3463 otherStyle->m_background->outline()); |
3448 } | 3464 } |
3449 void setOutlineFromStyle(const ComputedStyle& o) { | 3465 void setOutlineFromStyle(const ComputedStyle& o) { |
3450 DCHECK(!isOutlineEquivalent(&o)); | 3466 DCHECK(!isOutlineEquivalent(&o)); |
3451 m_background.access()->m_outline = o.m_background->m_outline; | 3467 m_background.access()->m_outline = o.m_background->m_outline; |
3452 } | 3468 } |
3453 | 3469 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3555 | 3571 |
3556 // Overflow utility functions. | 3572 // Overflow utility functions. |
3557 | 3573 |
3558 EOverflow overflowInlineDirection() const { | 3574 EOverflow overflowInlineDirection() const { |
3559 return isHorizontalWritingMode() ? overflowX() : overflowY(); | 3575 return isHorizontalWritingMode() ? overflowX() : overflowY(); |
3560 } | 3576 } |
3561 EOverflow overflowBlockDirection() const { | 3577 EOverflow overflowBlockDirection() const { |
3562 return isHorizontalWritingMode() ? overflowY() : overflowX(); | 3578 return isHorizontalWritingMode() ? overflowY() : overflowX(); |
3563 } | 3579 } |
3564 | 3580 |
3565 // It's sufficient to just check one direction, since it's illegal to have vis
ible on only one overflow value. | 3581 // It's sufficient to just check one direction, since it's illegal to have |
| 3582 // visible on only one overflow value. |
3566 bool isOverflowVisible() const { | 3583 bool isOverflowVisible() const { |
3567 DCHECK(overflowX() != OverflowVisible || overflowX() == overflowY()); | 3584 DCHECK(overflowX() != OverflowVisible || overflowX() == overflowY()); |
3568 return overflowX() == OverflowVisible; | 3585 return overflowX() == OverflowVisible; |
3569 } | 3586 } |
3570 bool isOverflowPaged() const { | 3587 bool isOverflowPaged() const { |
3571 return overflowY() == OverflowPagedX || overflowY() == OverflowPagedY; | 3588 return overflowY() == OverflowPagedX || overflowY() == OverflowPagedY; |
3572 } | 3589 } |
3573 | 3590 |
3574 // Animation utility functions. | 3591 // Animation utility functions. |
3575 bool shouldCompositeForCurrentAnimations() const { | 3592 bool shouldCompositeForCurrentAnimations() const { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3629 ApplyTransformOrigin, | 3646 ApplyTransformOrigin, |
3630 ApplyMotionPath, | 3647 ApplyMotionPath, |
3631 ApplyIndependentTransformProperties) const; | 3648 ApplyIndependentTransformProperties) const; |
3632 | 3649 |
3633 // Returns |true| if any property that renders using filter operations is | 3650 // Returns |true| if any property that renders using filter operations is |
3634 // used (including, but not limited to, 'filter' and 'box-reflect'). | 3651 // used (including, but not limited to, 'filter' and 'box-reflect'). |
3635 bool hasFilterInducingProperty() const { | 3652 bool hasFilterInducingProperty() const { |
3636 return hasFilter() || hasBoxReflect(); | 3653 return hasFilter() || hasBoxReflect(); |
3637 } | 3654 } |
3638 | 3655 |
3639 // Returns |true| if opacity should be considered to have non-initial value fo
r the purpose | 3656 // Returns |true| if opacity should be considered to have non-initial value |
3640 // of creating stacking contexts. | 3657 // for the purpose of creating stacking contexts. |
3641 bool hasNonInitialOpacity() const { | 3658 bool hasNonInitialOpacity() const { |
3642 return hasOpacity() || hasWillChangeOpacityHint() || | 3659 return hasOpacity() || hasWillChangeOpacityHint() || |
3643 hasCurrentOpacityAnimation(); | 3660 hasCurrentOpacityAnimation(); |
3644 } | 3661 } |
3645 | 3662 |
3646 // Returns whether this style contains any grouping property as defined by [cs
s-transforms]. | 3663 // Returns whether this style contains any grouping property as defined by |
3647 // The main purpose of this is to adjust the used value of transform-style pro
perty. | 3664 // [css-transforms]. The main purpose of this is to adjust the used value of |
3648 // Note: We currently don't include every grouping property on the spec to mai
ntain | 3665 // transform-style property. |
3649 // backward compatibility. | 3666 // Note: We currently don't include every grouping property on the spec to |
3650 // [css-transforms] https://drafts.csswg.org/css-transforms/#grouping-property
-values | 3667 // maintain backward compatibility. [css-transforms] |
| 3668 // https://drafts.csswg.org/css-transforms/#grouping-property-values |
3651 bool hasGroupingProperty() const { | 3669 bool hasGroupingProperty() const { |
3652 return !isOverflowVisible() || hasFilterInducingProperty() || | 3670 return !isOverflowVisible() || hasFilterInducingProperty() || |
3653 hasNonInitialOpacity(); | 3671 hasNonInitialOpacity(); |
3654 } | 3672 } |
3655 | 3673 |
3656 // Return true if any transform related property (currently transform/motionPa
th, transformStyle3D, perspective, | 3674 // Return true if any transform related property (currently |
3657 // or will-change:transform) indicates that we are transforming. will-change:t
ransform should result in | 3675 // transform/motionPath, transformStyle3D, perspective, or |
3658 // the same rendering behavior as having a transform, including the creation o
f a containing block | 3676 // will-change:transform) indicates that we are transforming. |
3659 // for fixed position descendants. | 3677 // will-change:transform should result in the same rendering behavior as |
| 3678 // having a transform, including the creation of a containing block for fixed |
| 3679 // position descendants. |
3660 bool hasTransformRelatedProperty() const { | 3680 bool hasTransformRelatedProperty() const { |
3661 return hasTransform() || preserves3D() || hasPerspective() || | 3681 return hasTransform() || preserves3D() || hasPerspective() || |
3662 hasWillChangeTransformHint(); | 3682 hasWillChangeTransformHint(); |
3663 } | 3683 } |
3664 | 3684 |
3665 // Paint utility functions. | 3685 // Paint utility functions. |
3666 void addPaintImage(StyleImage*); | 3686 void addPaintImage(StyleImage*); |
3667 | 3687 |
3668 // FIXME: reflections should belong to this helper function but they are curre
ntly handled | 3688 // FIXME: reflections should belong to this helper function but they are |
3669 // through their self-painting layers. So the layout code doesn't account for
them. | 3689 // currently handled through their self-painting layers. So the layout code |
| 3690 // doesn't account for them. |
3670 bool hasVisualOverflowingEffect() const { | 3691 bool hasVisualOverflowingEffect() const { |
3671 return boxShadow() || hasBorderImageOutsets() || hasOutline(); | 3692 return boxShadow() || hasBorderImageOutsets() || hasOutline(); |
3672 } | 3693 } |
3673 | 3694 |
3674 // Stacking contexts and positioned elements[1] are stacked (sorted in negZOrd
erList | 3695 // Stacking contexts and positioned elements[1] are stacked (sorted in |
| 3696 // negZOrderList |
3675 // and posZOrderList) in their enclosing stacking contexts. | 3697 // and posZOrderList) in their enclosing stacking contexts. |
3676 // | 3698 // |
3677 // [1] According to CSS2.1, Appendix E.2.8 (https://www.w3.org/TR/CSS21/zindex
.html), | 3699 // [1] According to CSS2.1, Appendix E.2.8 |
3678 // positioned elements with 'z-index: auto' are "treated as if it created a ne
w | 3700 // (https://www.w3.org/TR/CSS21/zindex.html), |
3679 // stacking context" and z-ordered together with other elements with 'z-index:
0'. | 3701 // positioned elements with 'z-index: auto' are "treated as if it created a |
3680 // The difference of them from normal stacking contexts is that they don't det
ermine | 3702 // new stacking context" and z-ordered together with other elements with |
3681 // the stacking of the elements underneath them. | 3703 // 'z-index: 0'. The difference of them from normal stacking contexts is that |
3682 // (Note: There are also other elements treated as stacking context during pai
nting, | 3704 // they don't determine the stacking of the elements underneath them. (Note: |
| 3705 // There are also other elements treated as stacking context during painting, |
3683 // but not managed in stacks. See ObjectPainter::paintAllPhasesAtomically().) | 3706 // but not managed in stacks. See ObjectPainter::paintAllPhasesAtomically().) |
3684 void updateIsStackingContext(bool isDocumentElement, bool isInTopLayer); | 3707 void updateIsStackingContext(bool isDocumentElement, bool isInTopLayer); |
3685 bool isStacked() const { | 3708 bool isStacked() const { |
3686 return isStackingContext() || position() != StaticPosition; | 3709 return isStackingContext() || position() != StaticPosition; |
3687 } | 3710 } |
3688 | 3711 |
3689 // Pseudo-styles | 3712 // Pseudo-styles |
3690 bool hasAnyPublicPseudoStyles() const; | 3713 bool hasAnyPublicPseudoStyles() const; |
3691 bool hasPseudoStyle(PseudoId) const; | 3714 bool hasPseudoStyle(PseudoId) const; |
3692 void setHasPseudoStyle(PseudoId); | 3715 void setHasPseudoStyle(PseudoId); |
3693 bool hasUniquePseudoStyle() const; | 3716 bool hasUniquePseudoStyle() const; |
3694 bool hasPseudoElementStyle() const; | 3717 bool hasPseudoElementStyle() const; |
3695 | 3718 |
3696 // Note: canContainAbsolutePositionObjects should return true if canContainFix
edPositionObjects. | 3719 // Note: canContainAbsolutePositionObjects should return true if |
3697 // We currently never use this value directly, always OR'ing it with canContai
nFixedPositionObjects. | 3720 // canContainFixedPositionObjects. We currently never use this value |
| 3721 // directly, always OR'ing it with canContainFixedPositionObjects. |
3698 bool canContainAbsolutePositionObjects() const { | 3722 bool canContainAbsolutePositionObjects() const { |
3699 return position() != StaticPosition; | 3723 return position() != StaticPosition; |
3700 } | 3724 } |
3701 bool canContainFixedPositionObjects() const { | 3725 bool canContainFixedPositionObjects() const { |
3702 return hasTransformRelatedProperty() || containsPaint(); | 3726 return hasTransformRelatedProperty() || containsPaint(); |
3703 } | 3727 } |
3704 | 3728 |
3705 // Whitespace utility functions. | 3729 // Whitespace utility functions. |
3706 static bool autoWrap(EWhiteSpace ws) { | 3730 static bool autoWrap(EWhiteSpace ws) { |
3707 // Nowrap and pre don't automatically wrap. | 3731 // Nowrap and pre don't automatically wrap. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3743 return (wordBreak() == BreakWordBreak || | 3767 return (wordBreak() == BreakWordBreak || |
3744 overflowWrap() == BreakOverflowWrap) && | 3768 overflowWrap() == BreakOverflowWrap) && |
3745 whiteSpace() != PRE && whiteSpace() != NOWRAP; | 3769 whiteSpace() != PRE && whiteSpace() != NOWRAP; |
3746 } | 3770 } |
3747 | 3771 |
3748 // Text direction utility functions. | 3772 // Text direction utility functions. |
3749 bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { | 3773 bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { |
3750 return !isLeftToRightDirection() && isHorizontalWritingMode(); | 3774 return !isLeftToRightDirection() && isHorizontalWritingMode(); |
3751 } | 3775 } |
3752 bool hasInlinePaginationAxis() const { | 3776 bool hasInlinePaginationAxis() const { |
3753 // If the pagination axis is parallel with the writing mode inline axis, col
umns may be laid | 3777 // If the pagination axis is parallel with the writing mode inline axis, |
3754 // out along the inline axis, just like for regular multicol. Otherwise, we
need to lay out | 3778 // columns may be laid out along the inline axis, just like for regular |
3755 // along the block axis. | 3779 // multicol. Otherwise, we need to lay out along the block axis. |
3756 if (isOverflowPaged()) | 3780 if (isOverflowPaged()) |
3757 return (overflowY() == OverflowPagedX) == isHorizontalWritingMode(); | 3781 return (overflowY() == OverflowPagedX) == isHorizontalWritingMode(); |
3758 return false; | 3782 return false; |
3759 } | 3783 } |
3760 | 3784 |
3761 // Border utility functions. | 3785 // Border utility functions. |
3762 bool borderObscuresBackground() const; | 3786 bool borderObscuresBackground() const; |
3763 void getBorderEdgeInfo(BorderEdge edges[], | 3787 void getBorderEdgeInfo(BorderEdge edges[], |
3764 bool includeLogicalLeftEdge = true, | 3788 bool includeLogicalLeftEdge = true, |
3765 bool includeLogicalRightEdge = true) const; | 3789 bool includeLogicalRightEdge = true) const; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 return shadowListHasCurrentColor(boxShadow()); | 3824 return shadowListHasCurrentColor(boxShadow()); |
3801 } | 3825 } |
3802 bool hasBackground() const { | 3826 bool hasBackground() const { |
3803 Color color = visitedDependentColor(CSSPropertyBackgroundColor); | 3827 Color color = visitedDependentColor(CSSPropertyBackgroundColor); |
3804 if (color.alpha()) | 3828 if (color.alpha()) |
3805 return true; | 3829 return true; |
3806 return hasBackgroundImage(); | 3830 return hasBackgroundImage(); |
3807 } | 3831 } |
3808 | 3832 |
3809 // Color utility functions. | 3833 // Color utility functions. |
3810 // TODO(sashab): Rename this to just getColor(), and add a comment explaining
how it works. | 3834 // TODO(sashab): Rename this to just getColor(), and add a comment explaining |
| 3835 // how it works. |
3811 Color visitedDependentColor(int colorProperty) const; | 3836 Color visitedDependentColor(int colorProperty) const; |
3812 | 3837 |
3813 // -webkit-appearance utility functions. | 3838 // -webkit-appearance utility functions. |
3814 bool hasAppearance() const { return appearance() != NoControlPart; } | 3839 bool hasAppearance() const { return appearance() != NoControlPart; } |
3815 | 3840 |
3816 // Other utility functions. | 3841 // Other utility functions. |
3817 bool isStyleAvailable() const; | 3842 bool isStyleAvailable() const; |
3818 bool isSharable() const; | 3843 bool isSharable() const; |
3819 | 3844 |
3820 private: | 3845 private: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3883 return display == EDisplay::Table || display == EDisplay::InlineTable || | 3908 return display == EDisplay::Table || display == EDisplay::InlineTable || |
3884 display == EDisplay::TableRowGroup || | 3909 display == EDisplay::TableRowGroup || |
3885 display == EDisplay::TableHeaderGroup || | 3910 display == EDisplay::TableHeaderGroup || |
3886 display == EDisplay::TableFooterGroup || | 3911 display == EDisplay::TableFooterGroup || |
3887 display == EDisplay::TableRow || | 3912 display == EDisplay::TableRow || |
3888 display == EDisplay::TableColumnGroup || | 3913 display == EDisplay::TableColumnGroup || |
3889 display == EDisplay::TableColumn || display == EDisplay::TableCell || | 3914 display == EDisplay::TableColumn || display == EDisplay::TableCell || |
3890 display == EDisplay::TableCaption; | 3915 display == EDisplay::TableCaption; |
3891 } | 3916 } |
3892 | 3917 |
3893 // Color accessors are all private to make sure callers use visitedDependentCo
lor instead to access them. | 3918 // Color accessors are all private to make sure callers use |
| 3919 // visitedDependentColor instead to access them. |
3894 StyleColor borderLeftColor() const { | 3920 StyleColor borderLeftColor() const { |
3895 return m_surround->border.left().color(); | 3921 return m_surround->border.left().color(); |
3896 } | 3922 } |
3897 StyleColor borderRightColor() const { | 3923 StyleColor borderRightColor() const { |
3898 return m_surround->border.right().color(); | 3924 return m_surround->border.right().color(); |
3899 } | 3925 } |
3900 StyleColor borderTopColor() const { return m_surround->border.top().color(); } | 3926 StyleColor borderTopColor() const { return m_surround->border.top().color(); } |
3901 StyleColor borderBottomColor() const { | 3927 StyleColor borderBottomColor() const { |
3902 return m_surround->border.bottom().color(); | 3928 return m_surround->border.bottom().color(); |
3903 } | 3929 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1); | 4097 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1); |
4072 } | 4098 } |
4073 | 4099 |
4074 inline bool ComputedStyle::hasPseudoElementStyle() const { | 4100 inline bool ComputedStyle::hasPseudoElementStyle() const { |
4075 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; | 4101 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; |
4076 } | 4102 } |
4077 | 4103 |
4078 } // namespace blink | 4104 } // namespace blink |
4079 | 4105 |
4080 #endif // ComputedStyle_h | 4106 #endif // ComputedStyle_h |
OLD | NEW |