Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.h

Issue 2187493004: Add a generated ComputedStyleBase class that ComputedStyle extends (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_make_visibility_enum_class_rebase
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 r ights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef ComputedStyle_h 25 #ifndef ComputedStyle_h
26 #define ComputedStyle_h 26 #define ComputedStyle_h
27 27
28 #include "core/BaseComputedStyle.h"
28 #include "core/CSSPropertyNames.h" 29 #include "core/CSSPropertyNames.h"
29 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
30 #include "core/style/BorderValue.h" 31 #include "core/style/BorderValue.h"
31 #include "core/style/ComputedStyleConstants.h" 32 #include "core/style/ComputedStyleConstants.h"
32 #include "core/style/CounterDirectives.h" 33 #include "core/style/CounterDirectives.h"
33 #include "core/style/DataRef.h" 34 #include "core/style/DataRef.h"
34 #include "core/style/LineClampValue.h" 35 #include "core/style/LineClampValue.h"
35 #include "core/style/NinePieceImage.h" 36 #include "core/style/NinePieceImage.h"
36 #include "core/style/SVGComputedStyle.h" 37 #include "core/style/SVGComputedStyle.h"
37 #include "core/style/StyleBackgroundData.h" 38 #include "core/style/StyleBackgroundData.h"
(...skipping 26 matching lines...) Expand all
64 #include "platform/fonts/FontDescription.h" 65 #include "platform/fonts/FontDescription.h"
65 #include "platform/geometry/FloatRoundedRect.h" 66 #include "platform/geometry/FloatRoundedRect.h"
66 #include "platform/geometry/LayoutRectOutsets.h" 67 #include "platform/geometry/LayoutRectOutsets.h"
67 #include "platform/graphics/Color.h" 68 #include "platform/graphics/Color.h"
68 #include "platform/scroll/ScrollTypes.h" 69 #include "platform/scroll/ScrollTypes.h"
69 #include "platform/text/TextDirection.h" 70 #include "platform/text/TextDirection.h"
70 #include "platform/text/UnicodeBidi.h" 71 #include "platform/text/UnicodeBidi.h"
71 #include "platform/transforms/TransformOperations.h" 72 #include "platform/transforms/TransformOperations.h"
72 #include "wtf/Forward.h" 73 #include "wtf/Forward.h"
73 #include "wtf/LeakAnnotations.h" 74 #include "wtf/LeakAnnotations.h"
74 #include "wtf/RefCounted.h"
75 #include "wtf/Vector.h" 75 #include "wtf/Vector.h"
76 #include <memory> 76 #include <memory>
77 77
78 template<typename T, typename U> inline bool compareEqual(const T& t, const U& u ) { return t == static_cast<T>(u); } 78 template<typename T, typename U> inline bool compareEqual(const T& t, const U& u ) { return t == static_cast<T>(u); }
79 79
80 #define SET_VAR(group, variable, value) \ 80 #define SET_VAR(group, variable, value) \
81 if (!compareEqual(group->variable, value)) \ 81 if (!compareEqual(group->variable, value)) \
82 group.access()->variable = value 82 group.access()->variable = value
83 83
84 #define SET_NESTED_VAR(group, base, variable, value) \ 84 #define SET_NESTED_VAR(group, base, variable, value) \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 class StyleInheritedData; 116 class StyleInheritedData;
117 class StylePath; 117 class StylePath;
118 class StyleResolver; 118 class StyleResolver;
119 class TransformationMatrix; 119 class TransformationMatrix;
120 class TranslateTransformOperation; 120 class TranslateTransformOperation;
121 121
122 class ContentData; 122 class ContentData;
123 123
124 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache; 124 typedef Vector<RefPtr<ComputedStyle>, 4> PseudoStyleCache;
125 125
126 class CORE_EXPORT ComputedStyle: public RefCounted<ComputedStyle> { 126 // ComputedStyle stores the final style for an element and provides the
127 // interface between the style engine and the rest of Blink.
128 //
129 // It contains all the resolved styles for an element, and is densely packed and
130 // optimized for memory and performance. Enums and small fields are packed in
131 // bit fields, while large fields are stored in pointers and shared where not
132 // modified from their parent value (see the DataRef class).
133 //
134 // Currently, ComputedStyle is hand-written and BaseComputedStyle is generated.
135 // Over time, methods will be moved to BaseComputedStyle and the generator will
136 // be expanded to handle more and more types of properties. Eventually, all
137 // methods will be on BaseComputedStyle (with custom methods defined in a class
138 // such as BaseComputedStyle.cpp) and ComputedStyle will be removed.
139 class CORE_EXPORT ComputedStyle: public BaseComputedStyle {
127 friend class AnimatedStyleBuilder; // Used by Web Animations CSS. Sets the c olor styles 140 friend class AnimatedStyleBuilder; // Used by Web Animations CSS. Sets the c olor styles
128 friend class CSSAnimatableValueFactory; // Used by Web Animations CSS. Gets visited and unvisited colors separately. 141 friend class CSSAnimatableValueFactory; // Used by Web Animations CSS. Gets visited and unvisited colors separately.
129 friend class CSSPropertyEquality; // Used by CSS animations. We can't allow them to animate based off visited colors. 142 friend class CSSPropertyEquality; // Used by CSS animations. We can't allow them to animate based off visited colors.
130 friend class ApplyStyleCommand; // Editing has to only reveal unvisited info . 143 friend class ApplyStyleCommand; // Editing has to only reveal unvisited info .
131 friend class EditingStyle; // Editing has to only reveal unvisited info. 144 friend class EditingStyle; // Editing has to only reveal unvisited info.
132 friend class ComputedStyleCSSValueMapping; // Needs to be able to see visite d and unvisited colors for devtools. 145 friend class ComputedStyleCSSValueMapping; // Needs to be able to see visite d and unvisited colors for devtools.
133 friend class StyleBuilderFunctions; // Sets color styles 146 friend class StyleBuilderFunctions; // Sets color styles
134 friend class CachedUAStyle; // Saves Border/Background information for later comparison. 147 friend class CachedUAStyle; // Saves Border/Background information for later comparison.
135 friend class ColorPropertyFunctions; // Accesses visited and unvisited color s. 148 friend class ColorPropertyFunctions; // Accesses visited and unvisited color s.
136 149
(...skipping 24 matching lines...) Expand all
161 // !START SYNC!: Keep this in sync with the copy constructor in ComputedStyle.cp p and implicitlyInherited() in StyleResolver.cpp 174 // !START SYNC!: Keep this in sync with the copy constructor in ComputedStyle.cp p and implicitlyInherited() in StyleResolver.cpp
162 175
163 // inherit 176 // inherit
164 struct InheritedData { 177 struct InheritedData {
165 bool operator==(const InheritedData& other) const 178 bool operator==(const InheritedData& other) const
166 { 179 {
167 return (m_emptyCells == other.m_emptyCells) 180 return (m_emptyCells == other.m_emptyCells)
168 && (m_captionSide == other.m_captionSide) 181 && (m_captionSide == other.m_captionSide)
169 && (m_listStyleType == other.m_listStyleType) 182 && (m_listStyleType == other.m_listStyleType)
170 && (m_listStylePosition == other.m_listStylePosition) 183 && (m_listStylePosition == other.m_listStylePosition)
171 && (m_visibility == other.m_visibility)
172 && (m_textAlign == other.m_textAlign) 184 && (m_textAlign == other.m_textAlign)
173 && (m_textTransform == other.m_textTransform) 185 && (m_textTransform == other.m_textTransform)
174 && (m_textUnderline == other.m_textUnderline) 186 && (m_textUnderline == other.m_textUnderline)
175 && (m_cursorStyle == other.m_cursorStyle) 187 && (m_cursorStyle == other.m_cursorStyle)
176 && (m_direction == other.m_direction) 188 && (m_direction == other.m_direction)
177 && (m_whiteSpace == other.m_whiteSpace) 189 && (m_whiteSpace == other.m_whiteSpace)
178 && (m_borderCollapse == other.m_borderCollapse) 190 && (m_borderCollapse == other.m_borderCollapse)
179 && (m_boxDirection == other.m_boxDirection) 191 && (m_boxDirection == other.m_boxDirection)
180 && (m_rtlOrdering == other.m_rtlOrdering) 192 && (m_rtlOrdering == other.m_rtlOrdering)
181 && (m_printColorAdjust == other.m_printColorAdjust) 193 && (m_printColorAdjust == other.m_printColorAdjust)
182 && (m_pointerEvents == other.m_pointerEvents) 194 && (m_pointerEvents == other.m_pointerEvents)
183 && (m_insideLink == other.m_insideLink) 195 && (m_insideLink == other.m_insideLink)
184 && (m_writingMode == other.m_writingMode); 196 && (m_writingMode == other.m_writingMode);
185 } 197 }
186 198
187 bool operator!=(const InheritedData& other) const { return !(*this == ot her); } 199 bool operator!=(const InheritedData& other) const { return !(*this == ot her); }
188 200
189 unsigned m_emptyCells : 1; // EEmptyCells 201 unsigned m_emptyCells : 1; // EEmptyCells
190 unsigned m_captionSide : 2; // ECaptionSide 202 unsigned m_captionSide : 2; // ECaptionSide
191 unsigned m_listStyleType : 7; // EListStyleType 203 unsigned m_listStyleType : 7; // EListStyleType
192 unsigned m_listStylePosition : 1; // EListStylePosition 204 unsigned m_listStylePosition : 1; // EListStylePosition
193 unsigned m_visibility : 2; // EVisibility
194 unsigned m_textAlign : 4; // ETextAlign 205 unsigned m_textAlign : 4; // ETextAlign
195 unsigned m_textTransform : 2; // ETextTransform 206 unsigned m_textTransform : 2; // ETextTransform
196 unsigned m_textUnderline : 1; 207 unsigned m_textUnderline : 1;
197 unsigned m_cursorStyle : 6; // ECursor 208 unsigned m_cursorStyle : 6; // ECursor
198 unsigned m_direction : 1; // TextDirection 209 unsigned m_direction : 1; // TextDirection
199 unsigned m_whiteSpace : 3; // EWhiteSpace 210 unsigned m_whiteSpace : 3; // EWhiteSpace
200 unsigned m_borderCollapse : 1; // EBorderCollapse 211 unsigned m_borderCollapse : 1; // EBorderCollapse
201 unsigned m_boxDirection : 1; // EBoxDirection (CSS3 box_direction proper ty, flexible box layout module) 212 unsigned m_boxDirection : 1; // EBoxDirection (CSS3 box_direction proper ty, flexible box layout module)
202 // 32 bits 213 // 32 bits
203 214
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 298
288 mutable unsigned m_hasRemUnits : 1; 299 mutable unsigned m_hasRemUnits : 1;
289 // If you add more style bits here, you will also need to update Compute dStyle::copyNonInheritedFromCached() 300 // If you add more style bits here, you will also need to update Compute dStyle::copyNonInheritedFromCached()
290 // 66 bits 301 // 66 bits
291 } m_nonInheritedData; 302 } m_nonInheritedData;
292 303
293 // !END SYNC! 304 // !END SYNC!
294 305
295 void setBitDefaults() 306 void setBitDefaults()
296 { 307 {
308 BaseComputedStyle::setBitDefaults();
297 m_inheritedData.m_emptyCells = initialEmptyCells(); 309 m_inheritedData.m_emptyCells = initialEmptyCells();
298 m_inheritedData.m_captionSide = initialCaptionSide(); 310 m_inheritedData.m_captionSide = initialCaptionSide();
299 m_inheritedData.m_listStyleType = initialListStyleType(); 311 m_inheritedData.m_listStyleType = initialListStyleType();
300 m_inheritedData.m_listStylePosition = initialListStylePosition(); 312 m_inheritedData.m_listStylePosition = initialListStylePosition();
301 m_inheritedData.m_visibility = static_cast<unsigned>(initialVisibility() );
302 m_inheritedData.m_textAlign = initialTextAlign(); 313 m_inheritedData.m_textAlign = initialTextAlign();
303 m_inheritedData.m_textTransform = initialTextTransform(); 314 m_inheritedData.m_textTransform = initialTextTransform();
304 m_inheritedData.m_textUnderline = false; 315 m_inheritedData.m_textUnderline = false;
305 m_inheritedData.m_cursorStyle = initialCursor(); 316 m_inheritedData.m_cursorStyle = initialCursor();
306 m_inheritedData.m_direction = initialDirection(); 317 m_inheritedData.m_direction = initialDirection();
307 m_inheritedData.m_whiteSpace = initialWhiteSpace(); 318 m_inheritedData.m_whiteSpace = initialWhiteSpace();
308 m_inheritedData.m_borderCollapse = initialBorderCollapse(); 319 m_inheritedData.m_borderCollapse = initialBorderCollapse();
309 m_inheritedData.m_rtlOrdering = initialRTLOrdering(); 320 m_inheritedData.m_rtlOrdering = initialRTLOrdering();
310 m_inheritedData.m_boxDirection = initialBoxDirection(); 321 m_inheritedData.m_boxDirection = initialBoxDirection();
311 m_inheritedData.m_printColorAdjust = initialPrintColorAdjust(); 322 m_inheritedData.m_printColorAdjust = initialPrintColorAdjust();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const; 383 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const;
373 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const; 384 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const;
374 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const; 385 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const;
375 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const; 386 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const;
376 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const; 387 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const;
377 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); 388 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject);
378 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ); 389 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject );
379 390
380 StyleDifference visualInvalidationDiff(const ComputedStyle&) const; 391 StyleDifference visualInvalidationDiff(const ComputedStyle&) const;
381 392
382 enum IsAtShadowBoundary {
383 AtShadowBoundary,
384 NotAtShadowBoundary,
385 };
386
387 void inheritFrom(const ComputedStyle& inheritParent, IsAtShadowBoundary = No tAtShadowBoundary); 393 void inheritFrom(const ComputedStyle& inheritParent, IsAtShadowBoundary = No tAtShadowBoundary);
388 void copyNonInheritedFromCached(const ComputedStyle&); 394 void copyNonInheritedFromCached(const ComputedStyle&);
389 395
390 PseudoId styleType() const { return static_cast<PseudoId>(m_nonInheritedData .m_styleType); } 396 PseudoId styleType() const { return static_cast<PseudoId>(m_nonInheritedData .m_styleType); }
391 void setStyleType(PseudoId styleType) { m_nonInheritedData.m_styleType = sty leType; } 397 void setStyleType(PseudoId styleType) { m_nonInheritedData.m_styleType = sty leType; }
392 398
393 ComputedStyle* getCachedPseudoStyle(PseudoId) const; 399 ComputedStyle* getCachedPseudoStyle(PseudoId) const;
394 ComputedStyle* addCachedPseudoStyle(PassRefPtr<ComputedStyle>); 400 ComputedStyle* addCachedPseudoStyle(PassRefPtr<ComputedStyle>);
395 void removeCachedPseudoStyle(PseudoId); 401 void removeCachedPseudoStyle(PseudoId);
396 402
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 // text-size-adjust (aka -webkit-text-size-adjust) 1466 // text-size-adjust (aka -webkit-text-size-adjust)
1461 static TextSizeAdjust initialTextSizeAdjust() { return TextSizeAdjust::adjus tAuto(); } 1467 static TextSizeAdjust initialTextSizeAdjust() { return TextSizeAdjust::adjus tAuto(); }
1462 TextSizeAdjust getTextSizeAdjust() const { return m_rareInheritedData->m_tex tSizeAdjust; } 1468 TextSizeAdjust getTextSizeAdjust() const { return m_rareInheritedData->m_tex tSizeAdjust; }
1463 void setTextSizeAdjust(TextSizeAdjust sizeAdjust) { SET_VAR(m_rareInheritedD ata, m_textSizeAdjust, sizeAdjust); } 1469 void setTextSizeAdjust(TextSizeAdjust sizeAdjust) { SET_VAR(m_rareInheritedD ata, m_textSizeAdjust, sizeAdjust); }
1464 1470
1465 // text-transform (aka -epub-text-transform) 1471 // text-transform (aka -epub-text-transform)
1466 static ETextTransform initialTextTransform() { return TTNONE; } 1472 static ETextTransform initialTextTransform() { return TTNONE; }
1467 ETextTransform textTransform() const { return static_cast<ETextTransform>(m_ inheritedData.m_textTransform); } 1473 ETextTransform textTransform() const { return static_cast<ETextTransform>(m_ inheritedData.m_textTransform); }
1468 void setTextTransform(ETextTransform v) { m_inheritedData.m_textTransform = v; } 1474 void setTextTransform(ETextTransform v) { m_inheritedData.m_textTransform = v; }
1469 1475
1470 // visibility
1471 static EVisibility initialVisibility() { return EVisibility::Visible; }
1472 EVisibility visibility() const { return static_cast<EVisibility>(m_inherited Data.m_visibility); }
1473 void setVisibility(EVisibility v) { m_inheritedData.m_visibility = static_ca st<unsigned>(v); }
1474
1475 // white-space inherited 1476 // white-space inherited
1476 static EWhiteSpace initialWhiteSpace() { return NORMAL; } 1477 static EWhiteSpace initialWhiteSpace() { return NORMAL; }
1477 EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(m_inherited Data.m_whiteSpace); } 1478 EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(m_inherited Data.m_whiteSpace); }
1478 void setWhiteSpace(EWhiteSpace v) { m_inheritedData.m_whiteSpace = v; } 1479 void setWhiteSpace(EWhiteSpace v) { m_inheritedData.m_whiteSpace = v; }
1479 1480
1480 // word-break inherited (aka -epub-word-break) 1481 // word-break inherited (aka -epub-word-break)
1481 static EWordBreak initialWordBreak() { return NormalWordBreak; } 1482 static EWordBreak initialWordBreak() { return NormalWordBreak; }
1482 EWordBreak wordBreak() const { return static_cast<EWordBreak>(m_rareInherite dData->wordBreak); } 1483 EWordBreak wordBreak() const { return static_cast<EWordBreak>(m_rareInherite dData->wordBreak); }
1483 void setWordBreak(EWordBreak b) { SET_VAR(m_rareInheritedData, wordBreak, b) ; } 1484 void setWordBreak(EWordBreak b) { SET_VAR(m_rareInheritedData, wordBreak, b) ; }
1484 1485
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 } 2555 }
2555 2556
2556 inline bool ComputedStyle::hasPseudoElementStyle() const 2557 inline bool ComputedStyle::hasPseudoElementStyle() const
2557 { 2558 {
2558 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; 2559 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask;
2559 } 2560 }
2560 2561
2561 } // namespace blink 2562 } // namespace blink
2562 2563
2563 #endif // ComputedStyle_h 2564 #endif // ComputedStyle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698