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

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

Issue 2963773002: Stop exporting ComputedStyle. (Closed)
Patch Set: tests whack-a-mole Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // This means that the interface to ComputedStyle is split between this file and 156 // This means that the interface to ComputedStyle is split between this file and
157 // ComputedStyleBase.h. 157 // ComputedStyleBase.h.
158 // 158 //
159 // [1] https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value 159 // [1] https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value
160 // 160 //
161 // NOTE: 161 // NOTE:
162 // 162 //
163 // Currently, some properties are stored in ComputedStyle and some in 163 // Currently, some properties are stored in ComputedStyle and some in
164 // ComputedStyleBase. Eventually, the storage of all properties (except SVG 164 // ComputedStyleBase. Eventually, the storage of all properties (except SVG
165 // ones) will be in ComputedStyleBase. 165 // ones) will be in ComputedStyleBase.
166 class CORE_EXPORT ComputedStyle : public ComputedStyleBase, 166 //
167 public RefCounted<ComputedStyle> { 167 // Since this class is huge, do not mark all of it CORE_EXPORT. Instead,
168 // export only the methods you need below.
169 class ComputedStyle : public ComputedStyleBase,
170 public RefCounted<ComputedStyle> {
168 // Needed to allow access to private/protected getters of fields to allow diff 171 // Needed to allow access to private/protected getters of fields to allow diff
169 // generation 172 // generation
170 friend class ComputedStyleBase; 173 friend class ComputedStyleBase;
171 // Used by Web Animations CSS. Sets the color styles. 174 // Used by Web Animations CSS. Sets the color styles.
172 friend class AnimatedStyleBuilder; 175 friend class AnimatedStyleBuilder;
173 // Used by Web Animations CSS. Gets visited and unvisited colors separately. 176 // Used by Web Animations CSS. Gets visited and unvisited colors separately.
174 friend class CSSAnimatableValueFactory; 177 friend class CSSAnimatableValueFactory;
175 // Used by CSS animations. We can't allow them to animate based off visited 178 // Used by CSS animations. We can't allow them to animate based off visited
176 // colors. 179 // colors.
177 friend class CSSPropertyEquality; 180 friend class CSSPropertyEquality;
(...skipping 24 matching lines...) Expand all
202 205
203 DataRef<SVGComputedStyle> svg_style_; 206 DataRef<SVGComputedStyle> svg_style_;
204 207
205 private: 208 private:
206 // TODO(sashab): Move these private members to the bottom of ComputedStyle. 209 // TODO(sashab): Move these private members to the bottom of ComputedStyle.
207 ALWAYS_INLINE ComputedStyle(); 210 ALWAYS_INLINE ComputedStyle();
208 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); 211 ALWAYS_INLINE ComputedStyle(const ComputedStyle&);
209 212
210 static RefPtr<ComputedStyle> CreateInitialStyle(); 213 static RefPtr<ComputedStyle> CreateInitialStyle();
211 // TODO(shend): Remove this. Initial style should not be mutable. 214 // TODO(shend): Remove this. Initial style should not be mutable.
212 static ComputedStyle& MutableInitialStyle(); 215 CORE_EXPORT static ComputedStyle& MutableInitialStyle();
213 216
214 public: 217 public:
215 static RefPtr<ComputedStyle> Create(); 218 CORE_EXPORT static RefPtr<ComputedStyle> Create();
216 static RefPtr<ComputedStyle> CreateAnonymousStyleWithDisplay( 219 static RefPtr<ComputedStyle> CreateAnonymousStyleWithDisplay(
217 const ComputedStyle& parent_style, 220 const ComputedStyle& parent_style,
218 EDisplay); 221 EDisplay);
219 static RefPtr<ComputedStyle> Clone(const ComputedStyle&); 222 CORE_EXPORT static RefPtr<ComputedStyle> Clone(const ComputedStyle&);
220 static const ComputedStyle& InitialStyle() { return MutableInitialStyle(); } 223 static const ComputedStyle& InitialStyle() { return MutableInitialStyle(); }
221 static void InvalidateInitialStyle(); 224 static void InvalidateInitialStyle();
222 225
223 // Computes how the style change should be propagated down the tree. 226 // Computes how the style change should be propagated down the tree.
224 static StyleRecalcChange StylePropagationDiff(const ComputedStyle* old_style, 227 static StyleRecalcChange StylePropagationDiff(const ComputedStyle* old_style,
225 const ComputedStyle* new_style); 228 const ComputedStyle* new_style);
226 229
227 // Copies the values of any independent inherited properties from the parent 230 // Copies the values of any independent inherited properties from the parent
228 // that are not explicitly set in this style. 231 // that are not explicitly set in this style.
229 void PropagateIndependentInheritedProperties( 232 void PropagateIndependentInheritedProperties(
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 990
988 // Inherited properties. 991 // Inherited properties.
989 992
990 // color 993 // color
991 static Color InitialColor() { return Color::kBlack; } 994 static Color InitialColor() { return Color::kBlack; }
992 void SetColor(const Color&); 995 void SetColor(const Color&);
993 996
994 // line-height 997 // line-height
995 static Length InitialLineHeight() { return Length(-100.0, kPercent); } 998 static Length InitialLineHeight() { return Length(-100.0, kPercent); }
996 Length LineHeight() const; 999 Length LineHeight() const;
997 void SetLineHeight(const Length& specified_line_height); 1000 CORE_EXPORT void SetLineHeight(const Length& specified_line_height);
998 1001
999 // List style properties. 1002 // List style properties.
1000 // list-style-image 1003 // list-style-image
1001 static StyleImage* InitialListStyleImage() { return 0; } 1004 static StyleImage* InitialListStyleImage() { return 0; }
1002 StyleImage* ListStyleImage() const; 1005 StyleImage* ListStyleImage() const;
1003 void SetListStyleImage(StyleImage*); 1006 void SetListStyleImage(StyleImage*);
1004 1007
1005 // quotes 1008 // quotes
1006 static QuotesData* InitialQuotes() { return 0; } 1009 static QuotesData* InitialQuotes() { return 0; }
1007 QuotesData* Quotes() const { return QuotesInternal().Get(); } 1010 QuotesData* Quotes() const { return QuotesInternal().Get(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1053 }
1051 1054
1052 // caret-color 1055 // caret-color
1053 void SetCaretColor(const StyleAutoColor& color) { 1056 void SetCaretColor(const StyleAutoColor& color) {
1054 SetCaretColorInternal(color.Resolve(Color())); 1057 SetCaretColorInternal(color.Resolve(Color()));
1055 SetCaretColorIsCurrentColorInternal(color.IsCurrentColor()); 1058 SetCaretColorIsCurrentColorInternal(color.IsCurrentColor());
1056 SetCaretColorIsAutoInternal(color.IsAutoColor()); 1059 SetCaretColorIsAutoInternal(color.IsAutoColor());
1057 } 1060 }
1058 1061
1059 // Font properties. 1062 // Font properties.
1060 const Font& GetFont() const; 1063 CORE_EXPORT const Font& GetFont() const;
1061 void SetFont(const Font&); 1064 CORE_EXPORT void SetFont(const Font&);
1062 const FontDescription& GetFontDescription() const; 1065 CORE_EXPORT const FontDescription& GetFontDescription() const;
1063 bool SetFontDescription(const FontDescription&); 1066 CORE_EXPORT bool SetFontDescription(const FontDescription&);
1064 bool HasIdenticalAscentDescentAndLineGap(const ComputedStyle& other) const; 1067 bool HasIdenticalAscentDescentAndLineGap(const ComputedStyle& other) const;
1065 1068
1066 // font-size 1069 // font-size
1067 int FontSize() const; 1070 int FontSize() const;
1068 float SpecifiedFontSize() const; 1071 CORE_EXPORT float SpecifiedFontSize() const;
1069 float ComputedFontSize() const; 1072 CORE_EXPORT float ComputedFontSize() const;
1070 LayoutUnit ComputedFontSizeAsFixed() const; 1073 LayoutUnit ComputedFontSizeAsFixed() const;
1071 1074
1072 // font-size-adjust 1075 // font-size-adjust
1073 float FontSizeAdjust() const; 1076 float FontSizeAdjust() const;
1074 bool HasFontSizeAdjust() const; 1077 bool HasFontSizeAdjust() const;
1075 1078
1076 // font-weight 1079 // font-weight
1077 FontWeight GetFontWeight() const; 1080 CORE_EXPORT FontWeight GetFontWeight() const;
1078 1081
1079 // font-stretch 1082 // font-stretch
1080 FontStretch GetFontStretch() const; 1083 FontStretch GetFontStretch() const;
1081 1084
1082 // -webkit-locale 1085 // -webkit-locale
1083 const AtomicString& Locale() const { 1086 const AtomicString& Locale() const {
1084 return LayoutLocale::LocaleString(GetFontDescription().Locale()); 1087 return LayoutLocale::LocaleString(GetFontDescription().Locale());
1085 } 1088 }
1086 AtomicString LocaleForLineBreakIterator() const; 1089 AtomicString LocaleForLineBreakIterator() const;
1087 1090
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1196
1194 // stroke-width 1197 // stroke-width
1195 const UnzoomedLength& StrokeWidth() const { return SvgStyle().StrokeWidth(); } 1198 const UnzoomedLength& StrokeWidth() const { return SvgStyle().StrokeWidth(); }
1196 void SetStrokeWidth(const UnzoomedLength& w) { 1199 void SetStrokeWidth(const UnzoomedLength& w) {
1197 AccessSVGStyle().SetStrokeWidth(w); 1200 AccessSVGStyle().SetStrokeWidth(w);
1198 } 1201 }
1199 1202
1200 // Comparison operators 1203 // Comparison operators
1201 // TODO(shend): Replace callers of operator== wth a named method instead, e.g. 1204 // TODO(shend): Replace callers of operator== wth a named method instead, e.g.
1202 // inheritedEquals(). 1205 // inheritedEquals().
1203 bool operator==(const ComputedStyle& other) const; 1206 CORE_EXPORT bool operator==(const ComputedStyle& other) const;
1204 bool operator!=(const ComputedStyle& other) const { 1207 bool operator!=(const ComputedStyle& other) const {
1205 return !(*this == other); 1208 return !(*this == other);
1206 } 1209 }
1207 1210
1208 bool InheritedEqual(const ComputedStyle&) const; 1211 bool InheritedEqual(const ComputedStyle&) const;
1209 bool NonInheritedEqual(const ComputedStyle&) const; 1212 bool NonInheritedEqual(const ComputedStyle&) const;
1210 inline bool IndependentInheritedEqual(const ComputedStyle&) const; 1213 inline bool IndependentInheritedEqual(const ComputedStyle&) const;
1211 inline bool NonIndependentInheritedEqual(const ComputedStyle&) const; 1214 inline bool NonIndependentInheritedEqual(const ComputedStyle&) const;
1212 bool LoadingCustomFontsEqual(const ComputedStyle&) const; 1215 bool LoadingCustomFontsEqual(const ComputedStyle&) const;
1213 bool InheritedDataShared(const ComputedStyle&) const; 1216 bool InheritedDataShared(const ComputedStyle&) const;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 // Non-property flags. 1293 // Non-property flags.
1291 bool EmptyState() const { return EmptyStateInternal(); } 1294 bool EmptyState() const { return EmptyStateInternal(); }
1292 void SetEmptyState(bool b) { 1295 void SetEmptyState(bool b) {
1293 SetUnique(); 1296 SetUnique();
1294 SetEmptyStateInternal(b); 1297 SetEmptyStateInternal(b);
1295 } 1298 }
1296 1299
1297 float TextAutosizingMultiplier() const { 1300 float TextAutosizingMultiplier() const {
1298 return TextAutosizingMultiplierInternal(); 1301 return TextAutosizingMultiplierInternal();
1299 } 1302 }
1300 void SetTextAutosizingMultiplier(float); 1303 CORE_EXPORT void SetTextAutosizingMultiplier(float);
1301 1304
1302 // Column utility functions. 1305 // Column utility functions.
1303 void ClearMultiCol(); 1306 void ClearMultiCol();
1304 bool SpecifiesColumns() const { 1307 bool SpecifiesColumns() const {
1305 return !HasAutoColumnCount() || !HasAutoColumnWidth(); 1308 return !HasAutoColumnCount() || !HasAutoColumnWidth();
1306 } 1309 }
1307 bool ColumnRuleIsTransparent() const { 1310 bool ColumnRuleIsTransparent() const {
1308 return !ColumnRuleColorIsCurrentColor() && 1311 return !ColumnRuleColorIsCurrentColor() &&
1309 !ColumnRuleColorInternal().Alpha(); 1312 !ColumnRuleColorInternal().Alpha();
1310 } 1313 }
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 return Direction() == TextDirection::kLtr; 1936 return Direction() == TextDirection::kLtr;
1934 } 1937 }
1935 1938
1936 // Perspective utility functions. 1939 // Perspective utility functions.
1937 bool HasPerspective() const { return Perspective() > 0; } 1940 bool HasPerspective() const { return Perspective() > 0; }
1938 1941
1939 // Outline utility functions. 1942 // Outline utility functions.
1940 bool HasOutline() const { 1943 bool HasOutline() const {
1941 return OutlineWidth() > 0 && OutlineStyle() > EBorderStyle::kHidden; 1944 return OutlineWidth() > 0 && OutlineStyle() > EBorderStyle::kHidden;
1942 } 1945 }
1943 int OutlineOutsetExtent() const; 1946 CORE_EXPORT int OutlineOutsetExtent() const;
1944 float GetOutlineStrokeWidthForFocusRing() const; 1947 CORE_EXPORT float GetOutlineStrokeWidthForFocusRing() const;
1945 bool HasOutlineWithCurrentColor() const { 1948 bool HasOutlineWithCurrentColor() const {
1946 return HasOutline() && OutlineColor().IsCurrentColor(); 1949 return HasOutline() && OutlineColor().IsCurrentColor();
1947 } 1950 }
1948 1951
1949 // Position utility functions. 1952 // Position utility functions.
1950 bool HasOutOfFlowPosition() const { 1953 bool HasOutOfFlowPosition() const {
1951 return GetPosition() == EPosition::kAbsolute || 1954 return GetPosition() == EPosition::kAbsolute ||
1952 GetPosition() == EPosition::kFixed; 1955 GetPosition() == EPosition::kFixed;
1953 } 1956 }
1954 bool HasInFlowPosition() const { 1957 bool HasInFlowPosition() const {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 // and posZOrderList) in their enclosing stacking contexts. 2203 // and posZOrderList) in their enclosing stacking contexts.
2201 // 2204 //
2202 // [1] According to CSS2.1, Appendix E.2.8 2205 // [1] According to CSS2.1, Appendix E.2.8
2203 // (https://www.w3.org/TR/CSS21/zindex.html), 2206 // (https://www.w3.org/TR/CSS21/zindex.html),
2204 // positioned elements with 'z-index: auto' are "treated as if it created a 2207 // positioned elements with 'z-index: auto' are "treated as if it created a
2205 // new stacking context" and z-ordered together with other elements with 2208 // new stacking context" and z-ordered together with other elements with
2206 // 'z-index: 0'. The difference of them from normal stacking contexts is that 2209 // 'z-index: 0'. The difference of them from normal stacking contexts is that
2207 // they don't determine the stacking of the elements underneath them. (Note: 2210 // they don't determine the stacking of the elements underneath them. (Note:
2208 // There are also other elements treated as stacking context during painting, 2211 // There are also other elements treated as stacking context during painting,
2209 // but not managed in stacks. See ObjectPainter::PaintAllPhasesAtomically().) 2212 // but not managed in stacks. See ObjectPainter::PaintAllPhasesAtomically().)
2210 void UpdateIsStackingContext(bool is_document_element, bool is_in_top_layer); 2213 CORE_EXPORT void UpdateIsStackingContext(bool is_document_element,
2214 bool is_in_top_layer);
2211 bool IsStacked() const { 2215 bool IsStacked() const {
2212 return IsStackingContext() || GetPosition() != EPosition::kStatic; 2216 return IsStackingContext() || GetPosition() != EPosition::kStatic;
2213 } 2217 }
2214 2218
2215 // Pseudo-styles 2219 // Pseudo-styles
2216 bool HasAnyPublicPseudoStyles() const; 2220 bool HasAnyPublicPseudoStyles() const;
2217 bool HasPseudoStyle(PseudoId) const; 2221 bool HasPseudoStyle(PseudoId) const;
2218 void SetHasPseudoStyle(PseudoId); 2222 void SetHasPseudoStyle(PseudoId);
2219 bool HasUniquePseudoStyle() const; 2223 bool HasUniquePseudoStyle() const;
2220 bool HasPseudoElementStyle() const; 2224 bool HasPseudoElementStyle() const;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 bool HasBackground() const { 2336 bool HasBackground() const {
2333 Color color = VisitedDependentColor(CSSPropertyBackgroundColor); 2337 Color color = VisitedDependentColor(CSSPropertyBackgroundColor);
2334 if (color.Alpha()) 2338 if (color.Alpha())
2335 return true; 2339 return true;
2336 return HasBackgroundImage(); 2340 return HasBackgroundImage();
2337 } 2341 }
2338 2342
2339 // Color utility functions. 2343 // Color utility functions.
2340 // TODO(sashab): Rename this to just getColor(), and add a comment explaining 2344 // TODO(sashab): Rename this to just getColor(), and add a comment explaining
2341 // how it works. 2345 // how it works.
2342 Color VisitedDependentColor(int color_property) const; 2346 CORE_EXPORT Color VisitedDependentColor(int color_property) const;
2343 2347
2344 // -webkit-appearance utility functions. 2348 // -webkit-appearance utility functions.
2345 bool HasAppearance() const { return Appearance() != kNoControlPart; } 2349 bool HasAppearance() const { return Appearance() != kNoControlPart; }
2346 2350
2347 // Other utility functions. 2351 // Other utility functions.
2348 bool IsStyleAvailable() const; 2352 bool IsStyleAvailable() const;
2349 bool IsSharable() const; 2353 bool IsSharable() const;
2350 2354
2351 bool RequireTransformOrigin(ApplyTransformOrigin apply_origin, 2355 bool RequireTransformOrigin(ApplyTransformOrigin apply_origin,
2352 ApplyMotionPath) const; 2356 ApplyMotionPath) const;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 const StyleDifference&) const; 2586 const StyleDifference&) const;
2583 bool DiffNeedsFullLayoutAndPaintInvalidation( 2587 bool DiffNeedsFullLayoutAndPaintInvalidation(
2584 const ComputedStyle& other) const; 2588 const ComputedStyle& other) const;
2585 bool DiffNeedsFullLayout(const ComputedStyle& other) const; 2589 bool DiffNeedsFullLayout(const ComputedStyle& other) const;
2586 bool DiffNeedsPaintInvalidationSubtree(const ComputedStyle& other) const; 2590 bool DiffNeedsPaintInvalidationSubtree(const ComputedStyle& other) const;
2587 bool DiffNeedsPaintInvalidationObject(const ComputedStyle& other) const; 2591 bool DiffNeedsPaintInvalidationObject(const ComputedStyle& other) const;
2588 bool DiffNeedsPaintInvalidationObjectForPaintImage( 2592 bool DiffNeedsPaintInvalidationObjectForPaintImage(
2589 const StyleImage&, 2593 const StyleImage&,
2590 const ComputedStyle& other) const; 2594 const ComputedStyle& other) const;
2591 bool DiffNeedsVisualRectUpdate(const ComputedStyle& other) const; 2595 bool DiffNeedsVisualRectUpdate(const ComputedStyle& other) const;
2592 void UpdatePropertySpecificDifferences(const ComputedStyle& other, 2596 CORE_EXPORT void UpdatePropertySpecificDifferences(const ComputedStyle& other,
2593 StyleDifference&) const; 2597 StyleDifference&) const;
2594 2598
2595 static bool ShadowListHasCurrentColor(const ShadowList*); 2599 static bool ShadowListHasCurrentColor(const ShadowList*);
2596 2600
2597 StyleInheritedVariables& MutableInheritedVariables(); 2601 StyleInheritedVariables& MutableInheritedVariables();
2598 StyleNonInheritedVariables& MutableNonInheritedVariables(); 2602 StyleNonInheritedVariables& MutableNonInheritedVariables();
2599 2603
2600 PhysicalToLogical<const Length&> PhysicalMarginToLogical( 2604 PhysicalToLogical<const Length&> PhysicalMarginToLogical(
2601 const ComputedStyle& other) const { 2605 const ComputedStyle& other) const {
2602 return PhysicalToLogical<const Length&>( 2606 return PhysicalToLogical<const Length&>(
2603 other.GetWritingMode(), other.Direction(), MarginTop(), MarginRight(), 2607 other.GetWritingMode(), other.Direction(), MarginTop(), MarginRight(),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId))); 2723 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
2720 } 2724 }
2721 2725
2722 inline bool ComputedStyle::HasPseudoElementStyle() const { 2726 inline bool ComputedStyle::HasPseudoElementStyle() const {
2723 return PseudoBitsInternal() & kElementPseudoIdMask; 2727 return PseudoBitsInternal() & kElementPseudoIdMask;
2724 } 2728 }
2725 2729
2726 } // namespace blink 2730 } // namespace blink
2727 2731
2728 #endif // ComputedStyle_h 2732 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698