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 | 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; | 191 std::unique_ptr<PseudoStyleCache> m_cachedPseudoStyles; |
| 192 | 192 |
| 193 DataRef<SVGComputedStyle> m_svgStyle; | 193 DataRef<SVGComputedStyle> m_svgStyle; |
| 194 | 194 |
| 195 // !START SYNC!: Keep this in sync with the copy constructor in | 195 // !START SYNC!: Keep this in sync with the copy constructor in |
| 196 // ComputedStyle.cpp and implicitlyInherited() in StyleResolver.cpp | 196 // ComputedStyle.cpp and implicitlyInherited() in StyleResolver.cpp |
| 197 | 197 |
| 198 // inherit | 198 // inherit |
| 199 struct InheritedData { | 199 struct InheritedData { |
| 200 bool operator==(const InheritedData& other) const { | 200 bool operator==(const InheritedData& other) const { |
| 201 return compareEqualIndependent(other) && | 201 return compareEqualNonIndependent(other); |
|
sashab
2016/12/12 01:52:56
Move all checks into here, delete compareEqualNonI
napper
2016/12/12 05:31:41
Done.
| |
| 202 compareEqualNonIndependent(other); | |
| 203 } | 202 } |
| 204 | 203 |
| 205 bool operator!=(const InheritedData& other) const { | 204 bool operator!=(const InheritedData& other) const { |
| 206 return !(*this == other); | 205 return !(*this == other); |
| 207 } | 206 } |
| 208 | 207 |
| 209 inline bool compareEqualIndependent(const InheritedData& other) const { | |
| 210 // These must match the properties tagged 'independent' in | |
| 211 // CSSProperties.in. | |
|
sashab
2016/12/12 01:52:56
Move this comment to the generated compareEqualInd
napper
2016/12/12 05:31:41
Not sure what you mean here. The compareEqualIndep
| |
| 212 // TODO(napper): Remove this once all independent properties are | |
| 213 // generated and replace with a private function used only in | |
| 214 // stylePropagationDiff(). | |
| 215 return (m_pointerEvents == other.m_pointerEvents); | |
| 216 } | |
| 217 | |
| 218 inline bool compareEqualNonIndependent(const InheritedData& other) const { | 208 inline bool compareEqualNonIndependent(const InheritedData& other) const { |
| 219 return (m_listStyleType == other.m_listStyleType) && | 209 return (m_listStyleType == other.m_listStyleType) && |
| 220 (m_textAlign == other.m_textAlign) && | 210 (m_textAlign == other.m_textAlign) && |
| 221 (m_hasSimpleUnderline == other.m_hasSimpleUnderline) && | 211 (m_hasSimpleUnderline == other.m_hasSimpleUnderline) && |
| 222 (m_cursorStyle == other.m_cursorStyle) && | 212 (m_cursorStyle == other.m_cursorStyle) && |
| 223 (m_direction == other.m_direction) && | 213 (m_direction == other.m_direction) && |
| 224 (m_boxDirection == other.m_boxDirection) && | 214 (m_boxDirection == other.m_boxDirection) && |
| 225 (m_rtlOrdering == other.m_rtlOrdering) && | 215 (m_rtlOrdering == other.m_rtlOrdering) && |
| 226 (m_printColorAdjust == other.m_printColorAdjust) && | 216 (m_printColorAdjust == other.m_printColorAdjust) && |
| 227 (m_insideLink == other.m_insideLink) && | 217 (m_insideLink == other.m_insideLink) && |
| 228 (m_writingMode == other.m_writingMode); | 218 (m_writingMode == other.m_writingMode); |
| 229 } | 219 } |
| 230 | 220 |
| 231 unsigned m_listStyleType : 7; // EListStyleType | 221 unsigned m_listStyleType : 7; // EListStyleType |
| 232 unsigned m_textAlign : 4; // ETextAlign | 222 unsigned m_textAlign : 4; // ETextAlign |
| 233 unsigned m_hasSimpleUnderline : 1; // True if 'underline solid' is the only | 223 unsigned m_hasSimpleUnderline : 1; // True if 'underline solid' is the only |
| 234 // text decoration on this element. | 224 // text decoration on this element. |
| 235 unsigned m_cursorStyle : 6; // ECursor | 225 unsigned m_cursorStyle : 6; // ECursor |
| 236 unsigned m_direction : 1; // TextDirection | 226 unsigned m_direction : 1; // TextDirection |
| 237 unsigned m_boxDirection : 1; // EBoxDirection (CSS3 box_direction property, | 227 unsigned m_boxDirection : 1; // EBoxDirection (CSS3 box_direction property, |
| 238 // flexible box layout module) | 228 // flexible box layout module) |
| 239 // 32 bits | 229 // 32 bits |
| 240 | 230 |
| 241 // non CSS2 inherited | 231 // non CSS2 inherited |
| 242 unsigned m_rtlOrdering : 1; // EOrder | 232 unsigned m_rtlOrdering : 1; // EOrder |
| 243 unsigned m_printColorAdjust : 1; // PrintColorAdjust | 233 unsigned m_printColorAdjust : 1; // PrintColorAdjust |
| 244 unsigned m_pointerEvents : 4; // EPointerEvents | |
| 245 unsigned m_insideLink : 2; // EInsideLink | 234 unsigned m_insideLink : 2; // EInsideLink |
| 246 | 235 |
| 247 // CSS Text Layout Module Level 3: Vertical writing support | 236 // CSS Text Layout Module Level 3: Vertical writing support |
| 248 unsigned m_writingMode : 2; // WritingMode | 237 unsigned m_writingMode : 2; // WritingMode |
| 249 // 42 bits | 238 // 42 bits |
| 250 } m_inheritedData; | 239 } m_inheritedData; |
| 251 | 240 |
| 252 // don't inherit | 241 // don't inherit |
| 253 struct NonInheritedData { | 242 struct NonInheritedData { |
| 254 // Compare computed styles, differences in inherited bits or other flags | 243 // Compare computed styles, differences in inherited bits or other flags |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 unsigned m_affectedByHover : 1; | 309 unsigned m_affectedByHover : 1; |
| 321 unsigned m_affectedByActive : 1; | 310 unsigned m_affectedByActive : 1; |
| 322 unsigned m_affectedByDrag : 1; | 311 unsigned m_affectedByDrag : 1; |
| 323 | 312 |
| 324 // 64 bits | 313 // 64 bits |
| 325 | 314 |
| 326 unsigned m_isLink : 1; | 315 unsigned m_isLink : 1; |
| 327 | 316 |
| 328 mutable unsigned m_hasRemUnits : 1; | 317 mutable unsigned m_hasRemUnits : 1; |
| 329 | 318 |
| 330 // For each independent inherited property, store a 1 if the stored | |
| 331 // value was inherited from its parent, or 0 if it is explicitly set on | |
| 332 // this element. | |
| 333 // Eventually, all properties will have a bit in here to store whether | |
| 334 // they were inherited from their parent or not. | |
| 335 // Although two ComputedStyles are equal if their nonInheritedData is | |
| 336 // equal regardless of the isInherited flags, this struct is stored next | |
| 337 // to the existing flags to take advantage of packing as much as possible. | |
|
sashab
2016/12/12 01:52:56
Move this comment somewhere... Maybe into make_com
napper
2016/12/12 05:31:41
As discussed offline, I have reviewed the relevanc
| |
| 338 // TODO(sashab): Move these flags closer to inheritedData so that it's | |
| 339 // clear which inherited properties have a flag stored and which don't. | |
| 340 // Keep this list of fields in sync with: | |
| 341 // - setBitDefaults() | |
| 342 // - The ComputedStyle setter, which must take an extra boolean parameter | |
| 343 // and set this - propagateIndependentInheritedProperties() in | |
| 344 // ComputedStyle.cpp | |
| 345 // - The compareEqual() methods in the corresponding class | |
| 346 // InheritedFlags | |
| 347 unsigned m_isPointerEventsInherited : 1; | |
| 348 | |
| 349 // If you add more style bits here, you will also need to update | 319 // If you add more style bits here, you will also need to update |
| 350 // ComputedStyle::copyNonInheritedFromCached() 68 bits | 320 // ComputedStyle::copyNonInheritedFromCached() 68 bits |
| 351 } m_nonInheritedData; | 321 } m_nonInheritedData; |
| 352 | 322 |
| 353 // !END SYNC! | 323 // !END SYNC! |
| 354 | 324 |
| 355 void setBitDefaults() { | 325 void setBitDefaults() { |
| 356 ComputedStyleBase::setBitDefaults(); | 326 ComputedStyleBase::setBitDefaults(); |
| 357 m_inheritedData.m_listStyleType = | 327 m_inheritedData.m_listStyleType = |
| 358 static_cast<unsigned>(initialListStyleType()); | 328 static_cast<unsigned>(initialListStyleType()); |
| 359 m_inheritedData.m_textAlign = static_cast<unsigned>(initialTextAlign()); | 329 m_inheritedData.m_textAlign = static_cast<unsigned>(initialTextAlign()); |
| 360 m_inheritedData.m_hasSimpleUnderline = false; | 330 m_inheritedData.m_hasSimpleUnderline = false; |
| 361 m_inheritedData.m_cursorStyle = static_cast<unsigned>(initialCursor()); | 331 m_inheritedData.m_cursorStyle = static_cast<unsigned>(initialCursor()); |
| 362 m_inheritedData.m_direction = initialDirection(); | 332 m_inheritedData.m_direction = initialDirection(); |
| 363 m_inheritedData.m_rtlOrdering = static_cast<unsigned>(initialRTLOrdering()); | 333 m_inheritedData.m_rtlOrdering = static_cast<unsigned>(initialRTLOrdering()); |
| 364 m_inheritedData.m_boxDirection = | 334 m_inheritedData.m_boxDirection = |
| 365 static_cast<unsigned>(initialBoxDirection()); | 335 static_cast<unsigned>(initialBoxDirection()); |
| 366 m_inheritedData.m_printColorAdjust = | 336 m_inheritedData.m_printColorAdjust = |
| 367 static_cast<unsigned>(initialPrintColorAdjust()); | 337 static_cast<unsigned>(initialPrintColorAdjust()); |
| 368 m_inheritedData.m_pointerEvents = | |
| 369 static_cast<unsigned>(initialPointerEvents()); | |
| 370 m_inheritedData.m_insideLink = NotInsideLink; | 338 m_inheritedData.m_insideLink = NotInsideLink; |
| 371 m_inheritedData.m_writingMode = initialWritingMode(); | 339 m_inheritedData.m_writingMode = initialWritingMode(); |
| 372 | 340 |
| 373 m_nonInheritedData.m_effectiveDisplay = | 341 m_nonInheritedData.m_effectiveDisplay = |
| 374 m_nonInheritedData.m_originalDisplay = | 342 m_nonInheritedData.m_originalDisplay = |
| 375 static_cast<unsigned>(initialDisplay()); | 343 static_cast<unsigned>(initialDisplay()); |
| 376 m_nonInheritedData.m_overflowAnchor = initialOverflowAnchor(); | 344 m_nonInheritedData.m_overflowAnchor = initialOverflowAnchor(); |
| 377 m_nonInheritedData.m_overflowX = initialOverflowX(); | 345 m_nonInheritedData.m_overflowX = initialOverflowX(); |
| 378 m_nonInheritedData.m_overflowY = initialOverflowY(); | 346 m_nonInheritedData.m_overflowY = initialOverflowY(); |
| 379 m_nonInheritedData.m_verticalAlign = initialVerticalAlign(); | 347 m_nonInheritedData.m_verticalAlign = initialVerticalAlign(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 390 m_nonInheritedData.m_variableReference = false; | 358 m_nonInheritedData.m_variableReference = false; |
| 391 m_nonInheritedData.m_unique = false; | 359 m_nonInheritedData.m_unique = false; |
| 392 m_nonInheritedData.m_emptyState = false; | 360 m_nonInheritedData.m_emptyState = false; |
| 393 m_nonInheritedData.m_hasViewportUnits = false; | 361 m_nonInheritedData.m_hasViewportUnits = false; |
| 394 m_nonInheritedData.m_affectedByFocus = false; | 362 m_nonInheritedData.m_affectedByFocus = false; |
| 395 m_nonInheritedData.m_affectedByHover = false; | 363 m_nonInheritedData.m_affectedByHover = false; |
| 396 m_nonInheritedData.m_affectedByActive = false; | 364 m_nonInheritedData.m_affectedByActive = false; |
| 397 m_nonInheritedData.m_affectedByDrag = false; | 365 m_nonInheritedData.m_affectedByDrag = false; |
| 398 m_nonInheritedData.m_isLink = false; | 366 m_nonInheritedData.m_isLink = false; |
| 399 m_nonInheritedData.m_hasRemUnits = false; | 367 m_nonInheritedData.m_hasRemUnits = false; |
| 400 | |
| 401 // All independently inherited properties default to being inherited. | |
| 402 m_nonInheritedData.m_isPointerEventsInherited = true; | |
| 403 } | 368 } |
| 404 | 369 |
| 405 private: | 370 private: |
| 406 // TODO(sashab): Move these to the bottom of ComputedStyle. | 371 // TODO(sashab): Move these to the bottom of ComputedStyle. |
| 407 ALWAYS_INLINE ComputedStyle(); | 372 ALWAYS_INLINE ComputedStyle(); |
| 408 | 373 |
| 409 enum InitialStyleTag { InitialStyle }; | 374 enum InitialStyleTag { InitialStyle }; |
| 410 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); | 375 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); |
| 411 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); | 376 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); |
| 412 | 377 |
| (...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 | 2090 |
| 2126 // overflow-wrap (aka word-wrap) | 2091 // overflow-wrap (aka word-wrap) |
| 2127 static EOverflowWrap initialOverflowWrap() { return NormalOverflowWrap; } | 2092 static EOverflowWrap initialOverflowWrap() { return NormalOverflowWrap; } |
| 2128 EOverflowWrap overflowWrap() const { | 2093 EOverflowWrap overflowWrap() const { |
| 2129 return static_cast<EOverflowWrap>(m_rareInheritedData->overflowWrap); | 2094 return static_cast<EOverflowWrap>(m_rareInheritedData->overflowWrap); |
| 2130 } | 2095 } |
| 2131 void setOverflowWrap(EOverflowWrap b) { | 2096 void setOverflowWrap(EOverflowWrap b) { |
| 2132 SET_VAR(m_rareInheritedData, overflowWrap, b); | 2097 SET_VAR(m_rareInheritedData, overflowWrap, b); |
| 2133 } | 2098 } |
| 2134 | 2099 |
| 2135 // pointer-events | |
| 2136 static EPointerEvents initialPointerEvents() { return EPointerEvents::Auto; } | |
| 2137 EPointerEvents pointerEvents() const { | |
| 2138 return static_cast<EPointerEvents>(m_inheritedData.m_pointerEvents); | |
| 2139 } | |
| 2140 void setPointerEvents(EPointerEvents p) { | |
| 2141 m_inheritedData.m_pointerEvents = static_cast<unsigned>(p); | |
| 2142 } | |
| 2143 void setPointerEventsIsInherited(bool isInherited) { | |
| 2144 m_nonInheritedData.m_isPointerEventsInherited = isInherited; | |
| 2145 } | |
| 2146 | |
| 2147 // quotes | 2100 // quotes |
| 2148 static QuotesData* initialQuotes() { return 0; } | 2101 static QuotesData* initialQuotes() { return 0; } |
| 2149 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } | 2102 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } |
| 2150 void setQuotes(PassRefPtr<QuotesData>); | 2103 void setQuotes(PassRefPtr<QuotesData>); |
| 2151 | 2104 |
| 2152 // snap-height | 2105 // snap-height |
| 2153 uint8_t snapHeightPosition() const { | 2106 uint8_t snapHeightPosition() const { |
| 2154 return m_rareInheritedData->m_snapHeightPosition; | 2107 return m_rareInheritedData->m_snapHeightPosition; |
| 2155 } | 2108 } |
| 2156 uint8_t snapHeightUnit() const { | 2109 uint8_t snapHeightUnit() const { |
| (...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4076 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1); | 4029 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1); |
| 4077 } | 4030 } |
| 4078 | 4031 |
| 4079 inline bool ComputedStyle::hasPseudoElementStyle() const { | 4032 inline bool ComputedStyle::hasPseudoElementStyle() const { |
| 4080 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; | 4033 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; |
| 4081 } | 4034 } |
| 4082 | 4035 |
| 4083 } // namespace blink | 4036 } // namespace blink |
| 4084 | 4037 |
| 4085 #endif // ComputedStyle_h | 4038 #endif // ComputedStyle_h |
| OLD | NEW |