Chromium Code Reviews| 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...) Expand 10 before | Expand all | Expand 10 after 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 bool compareEqualIndependent(const InheritedData& other) const | |
| 173 { | |
| 174 return (m_visibility == other.m_visibility) | |
| 175 && (m_pointerEvents == other.m_pointerEvents); | |
| 176 } | |
| 177 | |
| 178 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...) Expand 10 before | Expand all | Expand 10 after 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 struct IsInheritedFlags { | |
| 303 bool operator==(const IsInheritedFlags& other) const | |
| 304 { | |
| 305 return m_isPointerEventsInherited == other.m_isPointerEventsInherite d | |
| 306 && m_isVisibilityInherited == other.m_isVisibilityInherited; | |
| 307 } | |
| 308 | |
| 309 bool operator!=(const IsInheritedFlags& other) const { return !(*this == other); } | |
| 310 | |
| 311 // Keep this list of fields in sync with: | |
| 312 // - setBitDefaults() | |
| 313 // - The ComputedStyle setter, which must take an extra boolean paramete r and set this | |
| 314 // - propagateIndependentInheritedProperties() in ComputedStyle.cpp | |
| 315 // - The compareEqual() methods in the corresponding class | |
| 316 // InheritedFlags | |
| 317 unsigned m_isPointerEventsInherited : 1; | |
| 318 unsigned m_isVisibilityInherited : 1; | |
| 319 } m_isInheritedFlags; | |
|
meade_UTC10
2016/07/13 07:29:13
It's not clear to me how m_inheritedData and m_isI
sashab
2016/07/14 05:08:42
Added a comment to explain the better way to imple
| |
| 320 | |
| 290 // !END SYNC! | 321 // !END SYNC! |
| 291 | 322 |
| 292 protected: | 323 protected: |
| 293 void setBitDefaults() | 324 void setBitDefaults() |
| 294 { | 325 { |
| 295 m_inheritedData.m_emptyCells = initialEmptyCells(); | 326 m_inheritedData.m_emptyCells = initialEmptyCells(); |
| 296 m_inheritedData.m_captionSide = initialCaptionSide(); | 327 m_inheritedData.m_captionSide = initialCaptionSide(); |
| 297 m_inheritedData.m_listStyleType = initialListStyleType(); | 328 m_inheritedData.m_listStyleType = initialListStyleType(); |
| 298 m_inheritedData.m_listStylePosition = initialListStylePosition(); | 329 m_inheritedData.m_listStylePosition = initialListStylePosition(); |
| 299 m_inheritedData.m_visibility = initialVisibility(); | 330 m_inheritedData.m_visibility = initialVisibility(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 329 m_nonInheritedData.m_variableReference = false; | 360 m_nonInheritedData.m_variableReference = false; |
| 330 m_nonInheritedData.m_unique = false; | 361 m_nonInheritedData.m_unique = false; |
| 331 m_nonInheritedData.m_emptyState = false; | 362 m_nonInheritedData.m_emptyState = false; |
| 332 m_nonInheritedData.m_hasViewportUnits = false; | 363 m_nonInheritedData.m_hasViewportUnits = false; |
| 333 m_nonInheritedData.m_affectedByFocus = false; | 364 m_nonInheritedData.m_affectedByFocus = false; |
| 334 m_nonInheritedData.m_affectedByHover = false; | 365 m_nonInheritedData.m_affectedByHover = false; |
| 335 m_nonInheritedData.m_affectedByActive = false; | 366 m_nonInheritedData.m_affectedByActive = false; |
| 336 m_nonInheritedData.m_affectedByDrag = false; | 367 m_nonInheritedData.m_affectedByDrag = false; |
| 337 m_nonInheritedData.m_isLink = false; | 368 m_nonInheritedData.m_isLink = false; |
| 338 m_nonInheritedData.m_hasRemUnits = false; | 369 m_nonInheritedData.m_hasRemUnits = false; |
| 370 | |
| 371 // All properties default to being inherited. | |
|
meade_UTC10
2016/07/13 07:29:13
All independently inherited properties?
sashab
2016/07/14 05:08:41
Thanks!! Done.
sashab
2016/07/14 05:08:41
Thanks!! Done.
| |
| 372 m_isInheritedFlags.m_isPointerEventsInherited = true; | |
| 373 m_isInheritedFlags.m_isVisibilityInherited = true; | |
| 339 } | 374 } |
| 340 | 375 |
| 341 private: | 376 private: |
| 342 ALWAYS_INLINE ComputedStyle(); | 377 ALWAYS_INLINE ComputedStyle(); |
| 343 | 378 |
| 344 enum InitialStyleTag { | 379 enum InitialStyleTag { |
| 345 InitialStyle | 380 InitialStyle |
| 346 }; | 381 }; |
| 347 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); | 382 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); |
| 348 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); | 383 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); |
| 349 | 384 |
| 350 static PassRefPtr<ComputedStyle> createInitialStyle(); | 385 static PassRefPtr<ComputedStyle> createInitialStyle(); |
| 351 static inline ComputedStyle& mutableInitialStyle() | 386 static inline ComputedStyle& mutableInitialStyle() |
| 352 { | 387 { |
| 353 LEAK_SANITIZER_DISABLED_SCOPE; | 388 LEAK_SANITIZER_DISABLED_SCOPE; |
| 354 DEFINE_STATIC_REF(ComputedStyle, s_initialStyle, (ComputedStyle::createI nitialStyle())); | 389 DEFINE_STATIC_REF(ComputedStyle, s_initialStyle, (ComputedStyle::createI nitialStyle())); |
| 355 return *s_initialStyle; | 390 return *s_initialStyle; |
| 356 } | 391 } |
| 357 | 392 |
| 358 public: | 393 public: |
| 359 static PassRefPtr<ComputedStyle> create(); | 394 static PassRefPtr<ComputedStyle> create(); |
| 360 static PassRefPtr<ComputedStyle> createAnonymousStyleWithDisplay(const Compu tedStyle& parentStyle, EDisplay); | 395 static PassRefPtr<ComputedStyle> createAnonymousStyleWithDisplay(const Compu tedStyle& parentStyle, EDisplay); |
| 361 static PassRefPtr<ComputedStyle> clone(const ComputedStyle&); | 396 static PassRefPtr<ComputedStyle> clone(const ComputedStyle&); |
| 362 static const ComputedStyle& initialStyle() { return mutableInitialStyle(); } | 397 static const ComputedStyle& initialStyle() { return mutableInitialStyle(); } |
| 363 static void invalidateInitialStyle(); | 398 static void invalidateInitialStyle(); |
| 364 | 399 |
| 365 // Computes how the style change should be propagated down the tree. | 400 // Computes how the style change should be propagated down the tree. |
| 366 static StyleRecalcChange stylePropagationDiff(const ComputedStyle* oldStyle, const ComputedStyle* newStyle); | 401 static StyleRecalcChange stylePropagationDiff(const ComputedStyle* oldStyle, const ComputedStyle* newStyle); |
| 367 | 402 |
| 403 // Copies the values of any independent inherited properties from parent to child | |
| 404 // child that are not explicitly set in child. | |
|
meade_UTC10
2016/07/13 07:29:13
You have the word "child" twice :)
sashab
2016/07/14 05:08:41
Haha thanks :) Nice find
| |
| 405 static void propagateIndependentInheritedProperties(const ComputedStyle& par ent, ComputedStyle& child); | |
| 406 | |
| 368 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const; | 407 ContentPosition resolvedJustifyContentPosition(const StyleContentAlignmentDa ta& normalValueBehavior) const; |
| 369 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const; | 408 ContentDistributionType resolvedJustifyContentDistribution(const StyleConten tAlignmentData& normalValueBehavior) const; |
| 370 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const; | 409 ContentPosition resolvedAlignContentPosition(const StyleContentAlignmentData & normalValueBehavior) const; |
| 371 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const; | 410 ContentDistributionType resolvedAlignContentDistribution(const StyleContentA lignmentData& normalValueBehavior) const; |
| 372 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const; | 411 const StyleSelfAlignmentData resolvedAlignment(const ComputedStyle& parentSt yle, ItemPosition resolvedAutoPositionForLayoutObject) const; |
| 373 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); | 412 static ItemPosition resolveAlignment(const ComputedStyle& parentStyle, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); |
| 374 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ); | 413 static ItemPosition resolveJustification(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ); |
| 375 | 414 |
| 376 StyleDifference visualInvalidationDiff(const ComputedStyle&) const; | 415 StyleDifference visualInvalidationDiff(const ComputedStyle&) const; |
| 377 | 416 |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1615 void clearResetDirectives(); | 1654 void clearResetDirectives(); |
| 1616 | 1655 |
| 1617 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } | 1656 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } |
| 1618 void setQuotes(PassRefPtr<QuotesData>); | 1657 void setQuotes(PassRefPtr<QuotesData>); |
| 1619 | 1658 |
| 1620 const AtomicString& hyphenString() const; | 1659 const AtomicString& hyphenString() const; |
| 1621 | 1660 |
| 1622 bool inheritedEqual(const ComputedStyle&) const; | 1661 bool inheritedEqual(const ComputedStyle&) const; |
| 1623 bool nonInheritedEqual(const ComputedStyle&) const; | 1662 bool nonInheritedEqual(const ComputedStyle&) const; |
| 1624 bool loadingCustomFontsEqual(const ComputedStyle&) const; | 1663 bool loadingCustomFontsEqual(const ComputedStyle&) const; |
| 1664 | |
| 1665 bool independentInheritedEqual(const ComputedStyle&) const; | |
| 1666 bool nonIndependentInheritedEqual(const ComputedStyle&) const; | |
| 1667 | |
| 1625 bool inheritedDataShared(const ComputedStyle&) const; | 1668 bool inheritedDataShared(const ComputedStyle&) const; |
| 1626 | 1669 |
| 1627 bool isDisplayReplacedType() const { return isDisplayReplacedType(display()) ; } | 1670 bool isDisplayReplacedType() const { return isDisplayReplacedType(display()) ; } |
| 1628 bool isDisplayInlineType() const { return isDisplayInlineType(display()); } | 1671 bool isDisplayInlineType() const { return isDisplayInlineType(display()); } |
| 1629 bool isOriginalDisplayInlineType() const { return isDisplayInlineType(origin alDisplay()); } | 1672 bool isOriginalDisplayInlineType() const { return isDisplayInlineType(origin alDisplay()); } |
| 1630 bool isDisplayFlexibleOrGridBox() const { return isDisplayFlexibleBox(displa y()) || isDisplayGridBox(display()); } | 1673 bool isDisplayFlexibleOrGridBox() const { return isDisplayFlexibleBox(displa y()) || isDisplayGridBox(display()); } |
| 1631 bool isDisplayFlexibleBox() const { return isDisplayFlexibleBox(display()); } | 1674 bool isDisplayFlexibleBox() const { return isDisplayFlexibleBox(display()); } |
| 1632 | 1675 |
| 1633 | 1676 |
| 1634 bool setWritingMode(WritingMode v) | 1677 bool setWritingMode(WritingMode v) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1675 bool borderObscuresBackground() const; | 1718 bool borderObscuresBackground() const; |
| 1676 void getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLeftEdge = tru e, bool includeLogicalRightEdge = true) const; | 1719 void getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLeftEdge = tru e, bool includeLogicalRightEdge = true) const; |
| 1677 | 1720 |
| 1678 void setHasAuthorBackground(bool authorBackground) { SET_VAR(m_rareNonInheri tedData, m_hasAuthorBackground, authorBackground); } | 1721 void setHasAuthorBackground(bool authorBackground) { SET_VAR(m_rareNonInheri tedData, m_hasAuthorBackground, authorBackground); } |
| 1679 void setHasAuthorBorder(bool authorBorder) { SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); } | 1722 void setHasAuthorBorder(bool authorBorder) { SET_VAR(m_rareNonInheritedData, m_hasAuthorBorder, authorBorder); } |
| 1680 bool hasAuthorBackground() const { return m_rareNonInheritedData->m_hasAutho rBackground; }; | 1723 bool hasAuthorBackground() const { return m_rareNonInheritedData->m_hasAutho rBackground; }; |
| 1681 bool hasAuthorBorder() const { return m_rareNonInheritedData->m_hasAuthorBor der; }; | 1724 bool hasAuthorBorder() const { return m_rareNonInheritedData->m_hasAuthorBor der; }; |
| 1682 | 1725 |
| 1683 void addPaintImage(StyleImage*); | 1726 void addPaintImage(StyleImage*); |
| 1684 | 1727 |
| 1728 // Inherited setters. | |
| 1729 void setPointerEventsIsInherited(bool isInherited) { m_isInheritedFlags.m_is PointerEventsInherited = isInherited; } | |
| 1730 void setVisibilityIsInherited(bool isInherited) { m_isInheritedFlags.m_isVis ibilityInherited = isInherited; } | |
| 1731 | |
| 1685 // Initial values for all the properties | 1732 // Initial values for all the properties |
| 1686 static EBorderCollapse initialBorderCollapse() { return BorderCollapseSepara te; } | 1733 static EBorderCollapse initialBorderCollapse() { return BorderCollapseSepara te; } |
| 1687 static EBorderStyle initialBorderStyle() { return BorderStyleNone; } | 1734 static EBorderStyle initialBorderStyle() { return BorderStyleNone; } |
| 1688 static OutlineIsAuto initialOutlineStyleIsAuto() { return OutlineIsAutoOff; } | 1735 static OutlineIsAuto initialOutlineStyleIsAuto() { return OutlineIsAutoOff; } |
| 1689 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } | 1736 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } |
| 1690 static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed) , Length(0, Fixed)); } | 1737 static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed) , Length(0, Fixed)); } |
| 1691 static ECaptionSide initialCaptionSide() { return CaptionSideTop; } | 1738 static ECaptionSide initialCaptionSide() { return CaptionSideTop; } |
| 1692 static EClear initialClear() { return ClearNone; } | 1739 static EClear initialClear() { return ClearNone; } |
| 1693 static LengthBox initialClip() { return LengthBox(); } | 1740 static LengthBox initialClip() { return LengthBox(); } |
| 1694 static Containment initialContain() { return ContainsNone; } | 1741 static Containment initialContain() { return ContainsNone; } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 } | 2102 } |
| 2056 | 2103 |
| 2057 inline bool ComputedStyle::hasPseudoElementStyle() const | 2104 inline bool ComputedStyle::hasPseudoElementStyle() const |
| 2058 { | 2105 { |
| 2059 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; | 2106 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; |
| 2060 } | 2107 } |
| 2061 | 2108 |
| 2062 } // namespace blink | 2109 } // namespace blink |
| 2063 | 2110 |
| 2064 #endif // ComputedStyle_h | 2111 #endif // ComputedStyle_h |
| OLD | NEW |