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 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 |
(...skipping 145 matching lines...) Loading... | |
156 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; | 156 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; |
157 | 157 |
158 DataRef<SVGComputedStyle> m_svgStyle; | 158 DataRef<SVGComputedStyle> m_svgStyle; |
159 | 159 |
160 // !START SYNC!: Keep this in sync with the copy constructor in ComputedStyle.cp p and implicitlyInherited() in StyleResolver.cpp | 160 // !START SYNC!: Keep this in sync with the copy constructor in ComputedStyle.cp p and implicitlyInherited() in StyleResolver.cpp |
161 | 161 |
162 // inherit | 162 // inherit |
163 struct InheritedData { | 163 struct InheritedData { |
164 bool operator==(const InheritedData& other) const | 164 bool operator==(const InheritedData& other) const |
165 { | 165 { |
166 return compareEqualIndependent(other) | |
167 && compareEqualNonIndependent(other); | |
168 } | |
169 | |
170 bool operator!=(const InheritedData& other) const { return !(*this == ot her); } | |
171 | |
172 inline bool compareEqualIndependent(const InheritedData& other) const | |
173 { | |
174 return (m_visibility == other.m_visibility) | |
esprehn
2016/07/19 03:46:26
add a comment that these must match the .in file a
sashab
2016/07/19 06:32:38
Nice, yup done. Also added a TODO to generate this
| |
175 && (m_pointerEvents == other.m_pointerEvents); | |
176 } | |
177 | |
178 inline bool compareEqualNonIndependent(const InheritedData& other) const | |
179 { | |
166 return (m_emptyCells == other.m_emptyCells) | 180 return (m_emptyCells == other.m_emptyCells) |
167 && (m_captionSide == other.m_captionSide) | 181 && (m_captionSide == other.m_captionSide) |
168 && (m_listStyleType == other.m_listStyleType) | 182 && (m_listStyleType == other.m_listStyleType) |
169 && (m_listStylePosition == other.m_listStylePosition) | 183 && (m_listStylePosition == other.m_listStylePosition) |
170 && (m_visibility == other.m_visibility) | |
171 && (m_textAlign == other.m_textAlign) | 184 && (m_textAlign == other.m_textAlign) |
172 && (m_textTransform == other.m_textTransform) | 185 && (m_textTransform == other.m_textTransform) |
173 && (m_textUnderline == other.m_textUnderline) | 186 && (m_textUnderline == other.m_textUnderline) |
174 && (m_cursorStyle == other.m_cursorStyle) | 187 && (m_cursorStyle == other.m_cursorStyle) |
175 && (m_direction == other.m_direction) | 188 && (m_direction == other.m_direction) |
176 && (m_whiteSpace == other.m_whiteSpace) | 189 && (m_whiteSpace == other.m_whiteSpace) |
177 && (m_borderCollapse == other.m_borderCollapse) | 190 && (m_borderCollapse == other.m_borderCollapse) |
178 && (m_boxDirection == other.m_boxDirection) | 191 && (m_boxDirection == other.m_boxDirection) |
179 && (m_rtlOrdering == other.m_rtlOrdering) | 192 && (m_rtlOrdering == other.m_rtlOrdering) |
180 && (m_printColorAdjust == other.m_printColorAdjust) | 193 && (m_printColorAdjust == other.m_printColorAdjust) |
181 && (m_pointerEvents == other.m_pointerEvents) | |
182 && (m_insideLink == other.m_insideLink) | 194 && (m_insideLink == other.m_insideLink) |
183 && (m_writingMode == other.m_writingMode); | 195 && (m_writingMode == other.m_writingMode); |
184 } | 196 } |
185 | 197 |
186 bool operator!=(const InheritedData& other) const { return !(*this == ot her); } | |
187 | |
188 unsigned m_emptyCells : 1; // EEmptyCells | 198 unsigned m_emptyCells : 1; // EEmptyCells |
189 unsigned m_captionSide : 2; // ECaptionSide | 199 unsigned m_captionSide : 2; // ECaptionSide |
190 unsigned m_listStyleType : 7; // EListStyleType | 200 unsigned m_listStyleType : 7; // EListStyleType |
191 unsigned m_listStylePosition : 1; // EListStylePosition | 201 unsigned m_listStylePosition : 1; // EListStylePosition |
192 unsigned m_visibility : 2; // EVisibility | 202 unsigned m_visibility : 2; // EVisibility |
193 unsigned m_textAlign : 4; // ETextAlign | 203 unsigned m_textAlign : 4; // ETextAlign |
194 unsigned m_textTransform : 2; // ETextTransform | 204 unsigned m_textTransform : 2; // ETextTransform |
195 unsigned m_textUnderline : 1; | 205 unsigned m_textUnderline : 1; |
196 unsigned m_cursorStyle : 6; // ECursor | 206 unsigned m_cursorStyle : 6; // ECursor |
197 unsigned m_direction : 1; // TextDirection | 207 unsigned m_direction : 1; // TextDirection |
(...skipping 82 matching lines...) Loading... | |
280 | 290 |
281 // 64 bits | 291 // 64 bits |
282 | 292 |
283 unsigned m_isLink : 1; | 293 unsigned m_isLink : 1; |
284 | 294 |
285 mutable unsigned m_hasRemUnits : 1; | 295 mutable unsigned m_hasRemUnits : 1; |
286 // If you add more style bits here, you will also need to update Compute dStyle::copyNonInheritedFromCached() | 296 // If you add more style bits here, you will also need to update Compute dStyle::copyNonInheritedFromCached() |
287 // 66 bits | 297 // 66 bits |
288 } m_nonInheritedData; | 298 } m_nonInheritedData; |
289 | 299 |
300 // For each inherited property, store a 1 if the stored value was inherited | |
301 // from its parent, or 0 if it is explicitly set on this element. | |
302 // Each bit in this struct corresponds to a single inherited property; | |
303 // eventually, all properties will have a bit in here to store whether they | |
304 // were inherited from their parent or not. | |
305 // Since two ComputedStyles are equal if their nonInheritedData is equal | |
306 // regardless of the isInherited flags, this struct is stored separately | |
307 // to avoid too many subset comparison functions. | |
308 // TODO(sashab): Move isInheritedFlags closer to inheritedData so that it's | |
309 // clear which inherited properties have a flag stored and which don't. | |
310 struct IsInheritedFlags { | |
311 bool operator==(const IsInheritedFlags& other) const | |
312 { | |
313 return m_isPointerEventsInherited == other.m_isPointerEventsInherite d | |
314 && m_isVisibilityInherited == other.m_isVisibilityInherited; | |
315 } | |
316 | |
317 bool operator!=(const IsInheritedFlags& other) const { return !(*this == other); } | |
318 | |
319 // Keep this list of fields in sync with: | |
320 // - setBitDefaults() | |
321 // - The ComputedStyle setter, which must take an extra boolean paramete r and set this | |
322 // - propagateIndependentInheritedProperties() in ComputedStyle.cpp | |
323 // - The compareEqual() methods in the corresponding class | |
324 // InheritedFlags | |
325 unsigned m_isPointerEventsInherited : 1; | |
esprehn
2016/07/19 03:46:26
no m_ on public fields, ComputedStyle is a huge me
sashab
2016/07/19 06:32:39
?? Oh, they are all called m_, so I just changed t
| |
326 unsigned m_isVisibilityInherited : 1; | |
esprehn
2016/07/19 03:46:26
why can't we put this in NonInheritedFlags to avoi
sashab
2016/07/19 06:32:38
Yeah, that's a good point. Originally I didn't do
| |
327 } m_isInheritedFlags; | |
328 | |
290 // !END SYNC! | 329 // !END SYNC! |
291 | 330 |
292 protected: | 331 protected: |
293 void setBitDefaults() | 332 void setBitDefaults() |
294 { | 333 { |
295 m_inheritedData.m_emptyCells = initialEmptyCells(); | 334 m_inheritedData.m_emptyCells = initialEmptyCells(); |
296 m_inheritedData.m_captionSide = initialCaptionSide(); | 335 m_inheritedData.m_captionSide = initialCaptionSide(); |
297 m_inheritedData.m_listStyleType = initialListStyleType(); | 336 m_inheritedData.m_listStyleType = initialListStyleType(); |
298 m_inheritedData.m_listStylePosition = initialListStylePosition(); | 337 m_inheritedData.m_listStylePosition = initialListStylePosition(); |
299 m_inheritedData.m_visibility = initialVisibility(); | 338 m_inheritedData.m_visibility = initialVisibility(); |
(...skipping 29 matching lines...) Loading... | |
329 m_nonInheritedData.m_variableReference = false; | 368 m_nonInheritedData.m_variableReference = false; |
330 m_nonInheritedData.m_unique = false; | 369 m_nonInheritedData.m_unique = false; |
331 m_nonInheritedData.m_emptyState = false; | 370 m_nonInheritedData.m_emptyState = false; |
332 m_nonInheritedData.m_hasViewportUnits = false; | 371 m_nonInheritedData.m_hasViewportUnits = false; |
333 m_nonInheritedData.m_affectedByFocus = false; | 372 m_nonInheritedData.m_affectedByFocus = false; |
334 m_nonInheritedData.m_affectedByHover = false; | 373 m_nonInheritedData.m_affectedByHover = false; |
335 m_nonInheritedData.m_affectedByActive = false; | 374 m_nonInheritedData.m_affectedByActive = false; |
336 m_nonInheritedData.m_affectedByDrag = false; | 375 m_nonInheritedData.m_affectedByDrag = false; |
337 m_nonInheritedData.m_isLink = false; | 376 m_nonInheritedData.m_isLink = false; |
338 m_nonInheritedData.m_hasRemUnits = false; | 377 m_nonInheritedData.m_hasRemUnits = false; |
378 | |
379 // All independently inherited properties default to being inherited. | |
380 m_isInheritedFlags.m_isPointerEventsInherited = true; | |
381 m_isInheritedFlags.m_isVisibilityInherited = true; | |
339 } | 382 } |
340 | 383 |
341 private: | 384 private: |
342 ALWAYS_INLINE ComputedStyle(); | 385 ALWAYS_INLINE ComputedStyle(); |
343 | 386 |
344 enum InitialStyleTag { | 387 enum InitialStyleTag { |
345 InitialStyle | 388 InitialStyle |
346 }; | 389 }; |
347 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); | 390 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); |
348 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); | 391 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); |
349 | 392 |
350 static PassRefPtr<ComputedStyle> createInitialStyle(); | 393 static PassRefPtr<ComputedStyle> createInitialStyle(); |
351 static inline ComputedStyle& mutableInitialStyle() | 394 static inline ComputedStyle& mutableInitialStyle() |
352 { | 395 { |
353 LEAK_SANITIZER_DISABLED_SCOPE; | 396 LEAK_SANITIZER_DISABLED_SCOPE; |
354 DEFINE_STATIC_REF(ComputedStyle, s_initialStyle, (ComputedStyle::createI nitialStyle())); | 397 DEFINE_STATIC_REF(ComputedStyle, s_initialStyle, (ComputedStyle::createI nitialStyle())); |
355 return *s_initialStyle; | 398 return *s_initialStyle; |
356 } | 399 } |
357 | 400 |
358 public: | 401 public: |
359 static PassRefPtr<ComputedStyle> create(); | 402 static PassRefPtr<ComputedStyle> create(); |
360 static PassRefPtr<ComputedStyle> createAnonymousStyleWithDisplay(const Compu tedStyle& parentStyle, EDisplay); | 403 static PassRefPtr<ComputedStyle> createAnonymousStyleWithDisplay(const Compu tedStyle& parentStyle, EDisplay); |
361 static PassRefPtr<ComputedStyle> clone(const ComputedStyle&); | 404 static PassRefPtr<ComputedStyle> clone(const ComputedStyle&); |
362 static const ComputedStyle& initialStyle() { return mutableInitialStyle(); } | 405 static const ComputedStyle& initialStyle() { return mutableInitialStyle(); } |
363 static void invalidateInitialStyle(); | 406 static void invalidateInitialStyle(); |
364 | 407 |
365 // Computes how the style change should be propagated down the tree. | 408 // Computes how the style change should be propagated down the tree. |
366 static StyleRecalcChange stylePropagationDiff(const ComputedStyle* oldStyle, const ComputedStyle* newStyle); | 409 static StyleRecalcChange stylePropagationDiff(const ComputedStyle* oldStyle, const ComputedStyle* newStyle); |
367 | 410 |
411 // Copies the values of any independent inherited properties from parent to | |
412 // child that are not explicitly set in child. | |
413 static void propagateIndependentInheritedProperties(const ComputedStyle& par ent, ComputedStyle& child); | |
Timothy Loh
2016/07/19 01:29:32
Why static?
sashab
2016/07/19 03:31:35
Done.
| |
414 | |
368 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const; | 415 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const; |
369 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const; | 416 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const; |
370 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const; | 417 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const; |
371 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const; | 418 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const; |
372 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const; | 419 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const; |
373 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); | 420 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); |
374 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ); | 421 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ); |
375 | 422 |
376 StyleDifference visualInvalidationDiff(const ComputedStyle&) const; | 423 StyleDifference visualInvalidationDiff(const ComputedStyle&) const; |
377 | 424 |
(...skipping 1237 matching lines...) Loading... | |
1615 void clearResetDirectives(); | 1662 void clearResetDirectives(); |
1616 | 1663 |
1617 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } | 1664 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } |
1618 void setQuotes(PassRefPtr<QuotesData>); | 1665 void setQuotes(PassRefPtr<QuotesData>); |
1619 | 1666 |
1620 const AtomicString& hyphenString() const; | 1667 const AtomicString& hyphenString() const; |
1621 | 1668 |
1622 bool inheritedEqual(const ComputedStyle&) const; | 1669 bool inheritedEqual(const ComputedStyle&) const; |
1623 bool nonInheritedEqual(const ComputedStyle&) const; | 1670 bool nonInheritedEqual(const ComputedStyle&) const; |
1624 bool loadingCustomFontsEqual(const ComputedStyle&) const; | 1671 bool loadingCustomFontsEqual(const ComputedStyle&) const; |
1672 | |
1673 inline bool independentInheritedEqual(const ComputedStyle&) const; | |
1674 inline bool nonIndependentInheritedEqual(const ComputedStyle&) const; | |
1675 | |
1625 bool inheritedDataShared(const ComputedStyle&) const; | 1676 bool inheritedDataShared(const ComputedStyle&) const; |
1626 | 1677 |
1627 bool isDisplayReplacedType() const { return isDisplayReplacedType(display()) ; } | 1678 bool isDisplayReplacedType() const { return isDisplayReplacedType(display()) ; } |
1628 bool isDisplayInlineType() const { return isDisplayInlineType(display()); } | 1679 bool isDisplayInlineType() const { return isDisplayInlineType(display()); } |
1629 bool isOriginalDisplayInlineType() const { return isDisplayInlineType(origin alDisplay()); } | 1680 bool isOriginalDisplayInlineType() const { return isDisplayInlineType(origin alDisplay()); } |
1630 bool isDisplayFlexibleOrGridBox() const { return isDisplayFlexibleBox(displa y()) || isDisplayGridBox(display()); } | 1681 bool isDisplayFlexibleOrGridBox() const { return isDisplayFlexibleBox(displa y()) || isDisplayGridBox(display()); } |
1631 bool isDisplayFlexibleBox() const { return isDisplayFlexibleBox(display()); } | 1682 bool isDisplayFlexibleBox() const { return isDisplayFlexibleBox(display()); } |
1632 | 1683 |
1633 | 1684 |
1634 bool setWritingMode(WritingMode v) | 1685 bool setWritingMode(WritingMode v) |
(...skipping 40 matching lines...) Loading... | |
1675 bool borderObscuresBackground() const; | 1726 bool borderObscuresBackground() const; |
1676 void getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLeftEdge = tru e, bool includeLogicalRightEdge = true) const; | 1727 void getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLeftEdge = tru e, bool includeLogicalRightEdge = true) const; |
1677 | 1728 |
1678 void setHasAuthorBackground(bool authorBackground) { SET_VAR(m_rareNonInheri tedData, m_hasAuthorBackground, authorBackground); } | 1729 void setHasAuthorBackground(bool authorBackground) { SET_VAR(m_rareNonInheri tedData, m_hasAuthorBackground, authorBackground); } |
1679 void setHasAuthorBorder(bool authorBorder) { SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); } | 1730 void setHasAuthorBorder(bool authorBorder) { SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); } |
1680 bool hasAuthorBackground() const { return m_rareNonInheritedData->m_hasAutho rBackground; }; | 1731 bool hasAuthorBackground() const { return m_rareNonInheritedData->m_hasAutho rBackground; }; |
1681 bool hasAuthorBorder() const { return m_rareNonInheritedData->m_hasAuthorBor der; }; | 1732 bool hasAuthorBorder() const { return m_rareNonInheritedData->m_hasAuthorBor der; }; |
1682 | 1733 |
1683 void addPaintImage(StyleImage*); | 1734 void addPaintImage(StyleImage*); |
1684 | 1735 |
1736 // Inherited setters. | |
1737 void setPointerEventsIsInherited(bool isInherited) { m_isInheritedFlags.m_is PointerEventsInherited = isInherited; } | |
1738 void setVisibilityIsInherited(bool isInherited) { m_isInheritedFlags.m_isVis ibilityInherited = isInherited; } | |
1739 | |
1685 // Initial values for all the properties | 1740 // Initial values for all the properties |
1686 static EBorderCollapse initialBorderCollapse() { return BorderCollapseSepara te; } | 1741 static EBorderCollapse initialBorderCollapse() { return BorderCollapseSepara te; } |
1687 static EBorderStyle initialBorderStyle() { return BorderStyleNone; } | 1742 static EBorderStyle initialBorderStyle() { return BorderStyleNone; } |
1688 static OutlineIsAuto initialOutlineStyleIsAuto() { return OutlineIsAutoOff; } | 1743 static OutlineIsAuto initialOutlineStyleIsAuto() { return OutlineIsAutoOff; } |
1689 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } | 1744 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } |
1690 static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed) , Length(0, Fixed)); } | 1745 static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed) , Length(0, Fixed)); } |
1691 static ECaptionSide initialCaptionSide() { return CaptionSideTop; } | 1746 static ECaptionSide initialCaptionSide() { return CaptionSideTop; } |
1692 static EClear initialClear() { return ClearNone; } | 1747 static EClear initialClear() { return ClearNone; } |
1693 static LengthBox initialClip() { return LengthBox(); } | 1748 static LengthBox initialClip() { return LengthBox(); } |
1694 static Containment initialContain() { return ContainsNone; } | 1749 static Containment initialContain() { return ContainsNone; } |
(...skipping 360 matching lines...) Loading... | |
2055 } | 2110 } |
2056 | 2111 |
2057 inline bool ComputedStyle::hasPseudoElementStyle() const | 2112 inline bool ComputedStyle::hasPseudoElementStyle() const |
2058 { | 2113 { |
2059 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; | 2114 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; |
2060 } | 2115 } |
2061 | 2116 |
2062 } // namespace blink | 2117 } // namespace blink |
2063 | 2118 |
2064 #endif // ComputedStyle_h | 2119 #endif // ComputedStyle_h |
OLD | NEW |