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

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

Issue 2563753003: Moved pointer-events to be generated in ComputedStyleBase (Closed)
Patch Set: Rebase Created 4 years 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 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
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) &&
202 compareEqualNonIndependent(other);
203 }
204
205 bool operator!=(const InheritedData& other) const {
206 return !(*this == other);
207 }
208
209 inline bool compareEqualIndependent(const InheritedData& other) const {
210 // These must match the properties tagged 'independent' in
211 // CSSProperties.in.
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 {
219 return (m_listStyleType == other.m_listStyleType) && 201 return (m_listStyleType == other.m_listStyleType) &&
220 (m_textAlign == other.m_textAlign) && 202 (m_textAlign == other.m_textAlign) &&
221 (m_hasSimpleUnderline == other.m_hasSimpleUnderline) && 203 (m_hasSimpleUnderline == other.m_hasSimpleUnderline) &&
222 (m_cursorStyle == other.m_cursorStyle) && 204 (m_cursorStyle == other.m_cursorStyle) &&
223 (m_direction == other.m_direction) && 205 (m_direction == other.m_direction) &&
224 (m_rtlOrdering == other.m_rtlOrdering) && 206 (m_rtlOrdering == other.m_rtlOrdering) &&
225 (m_printColorAdjust == other.m_printColorAdjust) && 207 (m_printColorAdjust == other.m_printColorAdjust) &&
226 (m_insideLink == other.m_insideLink) && 208 (m_insideLink == other.m_insideLink) &&
227 (m_writingMode == other.m_writingMode); 209 (m_writingMode == other.m_writingMode);
228 } 210 }
229 211
212 bool operator!=(const InheritedData& other) const {
213 return !(*this == other);
214 }
215
230 unsigned m_listStyleType : 7; // EListStyleType 216 unsigned m_listStyleType : 7; // EListStyleType
231 unsigned m_textAlign : 4; // ETextAlign 217 unsigned m_textAlign : 4; // ETextAlign
232 unsigned m_hasSimpleUnderline : 1; // True if 'underline solid' is the only 218 unsigned m_hasSimpleUnderline : 1; // True if 'underline solid' is the only
233 // text decoration on this element. 219 // text decoration on this element.
234 unsigned m_cursorStyle : 6; // ECursor 220 unsigned m_cursorStyle : 6; // ECursor
235 unsigned m_direction : 1; // TextDirection 221 unsigned m_direction : 1; // TextDirection
236 // 32 bits 222 // 32 bits
237 223
238 // non CSS2 inherited 224 // non CSS2 inherited
239 unsigned m_rtlOrdering : 1; // EOrder 225 unsigned m_rtlOrdering : 1; // EOrder
240 unsigned m_printColorAdjust : 1; // PrintColorAdjust 226 unsigned m_printColorAdjust : 1; // PrintColorAdjust
241 unsigned m_pointerEvents : 4; // EPointerEvents
242 unsigned m_insideLink : 2; // EInsideLink 227 unsigned m_insideLink : 2; // EInsideLink
243 228
244 // CSS Text Layout Module Level 3: Vertical writing support 229 // CSS Text Layout Module Level 3: Vertical writing support
245 unsigned m_writingMode : 2; // WritingMode 230 unsigned m_writingMode : 2; // WritingMode
246 // 42 bits 231 // 42 bits
247 } m_inheritedData; 232 } m_inheritedData;
248 233
249 // don't inherit 234 // don't inherit
250 struct NonInheritedData { 235 struct NonInheritedData {
251 // Compare computed styles, differences in inherited bits or other flags 236 // Compare computed styles, differences in inherited bits or other flags
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 unsigned m_affectedByHover : 1; 302 unsigned m_affectedByHover : 1;
318 unsigned m_affectedByActive : 1; 303 unsigned m_affectedByActive : 1;
319 unsigned m_affectedByDrag : 1; 304 unsigned m_affectedByDrag : 1;
320 305
321 // 64 bits 306 // 64 bits
322 307
323 unsigned m_isLink : 1; 308 unsigned m_isLink : 1;
324 309
325 mutable unsigned m_hasRemUnits : 1; 310 mutable unsigned m_hasRemUnits : 1;
326 311
327 // For each independent inherited property, store a 1 if the stored
328 // value was inherited from its parent, or 0 if it is explicitly set on
329 // this element.
330 // Eventually, all properties will have a bit in here to store whether
331 // they were inherited from their parent or not.
332 // Although two ComputedStyles are equal if their nonInheritedData is
333 // equal regardless of the isInherited flags, this struct is stored next
334 // to the existing flags to take advantage of packing as much as possible.
335 // TODO(sashab): Move these flags closer to inheritedData so that it's
336 // clear which inherited properties have a flag stored and which don't.
337 // Keep this list of fields in sync with:
338 // - setBitDefaults()
339 // - The ComputedStyle setter, which must take an extra boolean parameter
340 // and set this - propagateIndependentInheritedProperties() in
341 // ComputedStyle.cpp
342 // - The compareEqual() methods in the corresponding class
343 // InheritedFlags
344 unsigned m_isPointerEventsInherited : 1;
345
346 // If you add more style bits here, you will also need to update 312 // If you add more style bits here, you will also need to update
347 // ComputedStyle::copyNonInheritedFromCached() 68 bits 313 // ComputedStyle::copyNonInheritedFromCached() 68 bits
348 } m_nonInheritedData; 314 } m_nonInheritedData;
349 315
350 // !END SYNC! 316 // !END SYNC!
351 317
352 void setBitDefaults() { 318 void setBitDefaults() {
353 ComputedStyleBase::setBitDefaults(); 319 ComputedStyleBase::setBitDefaults();
354 m_inheritedData.m_listStyleType = 320 m_inheritedData.m_listStyleType =
355 static_cast<unsigned>(initialListStyleType()); 321 static_cast<unsigned>(initialListStyleType());
356 m_inheritedData.m_textAlign = static_cast<unsigned>(initialTextAlign()); 322 m_inheritedData.m_textAlign = static_cast<unsigned>(initialTextAlign());
357 m_inheritedData.m_hasSimpleUnderline = false; 323 m_inheritedData.m_hasSimpleUnderline = false;
358 m_inheritedData.m_cursorStyle = static_cast<unsigned>(initialCursor()); 324 m_inheritedData.m_cursorStyle = static_cast<unsigned>(initialCursor());
359 m_inheritedData.m_direction = initialDirection(); 325 m_inheritedData.m_direction = initialDirection();
360 m_inheritedData.m_rtlOrdering = static_cast<unsigned>(initialRTLOrdering()); 326 m_inheritedData.m_rtlOrdering = static_cast<unsigned>(initialRTLOrdering());
361 m_inheritedData.m_printColorAdjust = 327 m_inheritedData.m_printColorAdjust =
362 static_cast<unsigned>(initialPrintColorAdjust()); 328 static_cast<unsigned>(initialPrintColorAdjust());
363 m_inheritedData.m_pointerEvents =
364 static_cast<unsigned>(initialPointerEvents());
365 m_inheritedData.m_insideLink = NotInsideLink; 329 m_inheritedData.m_insideLink = NotInsideLink;
366 m_inheritedData.m_writingMode = initialWritingMode(); 330 m_inheritedData.m_writingMode = initialWritingMode();
367 331
368 m_nonInheritedData.m_effectiveDisplay = 332 m_nonInheritedData.m_effectiveDisplay =
369 m_nonInheritedData.m_originalDisplay = 333 m_nonInheritedData.m_originalDisplay =
370 static_cast<unsigned>(initialDisplay()); 334 static_cast<unsigned>(initialDisplay());
371 m_nonInheritedData.m_overflowAnchor = 335 m_nonInheritedData.m_overflowAnchor =
372 static_cast<unsigned>(initialOverflowAnchor()); 336 static_cast<unsigned>(initialOverflowAnchor());
373 m_nonInheritedData.m_overflowX = initialOverflowX(); 337 m_nonInheritedData.m_overflowX = initialOverflowX();
374 m_nonInheritedData.m_overflowY = initialOverflowY(); 338 m_nonInheritedData.m_overflowY = initialOverflowY();
(...skipping 11 matching lines...) Expand all
386 m_nonInheritedData.m_variableReference = false; 350 m_nonInheritedData.m_variableReference = false;
387 m_nonInheritedData.m_unique = false; 351 m_nonInheritedData.m_unique = false;
388 m_nonInheritedData.m_emptyState = false; 352 m_nonInheritedData.m_emptyState = false;
389 m_nonInheritedData.m_hasViewportUnits = false; 353 m_nonInheritedData.m_hasViewportUnits = false;
390 m_nonInheritedData.m_affectedByFocus = false; 354 m_nonInheritedData.m_affectedByFocus = false;
391 m_nonInheritedData.m_affectedByHover = false; 355 m_nonInheritedData.m_affectedByHover = false;
392 m_nonInheritedData.m_affectedByActive = false; 356 m_nonInheritedData.m_affectedByActive = false;
393 m_nonInheritedData.m_affectedByDrag = false; 357 m_nonInheritedData.m_affectedByDrag = false;
394 m_nonInheritedData.m_isLink = false; 358 m_nonInheritedData.m_isLink = false;
395 m_nonInheritedData.m_hasRemUnits = false; 359 m_nonInheritedData.m_hasRemUnits = false;
396
397 // All independently inherited properties default to being inherited.
398 m_nonInheritedData.m_isPointerEventsInherited = true;
399 } 360 }
400 361
401 private: 362 private:
402 // TODO(sashab): Move these to the bottom of ComputedStyle. 363 // TODO(sashab): Move these to the bottom of ComputedStyle.
403 ALWAYS_INLINE ComputedStyle(); 364 ALWAYS_INLINE ComputedStyle();
404 365
405 enum InitialStyleTag { InitialStyle }; 366 enum InitialStyleTag { InitialStyle };
406 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag); 367 ALWAYS_INLINE explicit ComputedStyle(InitialStyleTag);
407 ALWAYS_INLINE ComputedStyle(const ComputedStyle&); 368 ALWAYS_INLINE ComputedStyle(const ComputedStyle&);
408 369
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 2084
2124 // overflow-wrap (aka word-wrap) 2085 // overflow-wrap (aka word-wrap)
2125 static EOverflowWrap initialOverflowWrap() { return NormalOverflowWrap; } 2086 static EOverflowWrap initialOverflowWrap() { return NormalOverflowWrap; }
2126 EOverflowWrap overflowWrap() const { 2087 EOverflowWrap overflowWrap() const {
2127 return static_cast<EOverflowWrap>(m_rareInheritedData->overflowWrap); 2088 return static_cast<EOverflowWrap>(m_rareInheritedData->overflowWrap);
2128 } 2089 }
2129 void setOverflowWrap(EOverflowWrap b) { 2090 void setOverflowWrap(EOverflowWrap b) {
2130 SET_VAR(m_rareInheritedData, overflowWrap, b); 2091 SET_VAR(m_rareInheritedData, overflowWrap, b);
2131 } 2092 }
2132 2093
2133 // pointer-events
2134 static EPointerEvents initialPointerEvents() { return EPointerEvents::Auto; }
2135 EPointerEvents pointerEvents() const {
2136 return static_cast<EPointerEvents>(m_inheritedData.m_pointerEvents);
2137 }
2138 void setPointerEvents(EPointerEvents p) {
2139 m_inheritedData.m_pointerEvents = static_cast<unsigned>(p);
2140 }
2141 void setPointerEventsIsInherited(bool isInherited) {
2142 m_nonInheritedData.m_isPointerEventsInherited = isInherited;
2143 }
2144
2145 // quotes 2094 // quotes
2146 static QuotesData* initialQuotes() { return 0; } 2095 static QuotesData* initialQuotes() { return 0; }
2147 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); } 2096 QuotesData* quotes() const { return m_rareInheritedData->quotes.get(); }
2148 void setQuotes(PassRefPtr<QuotesData>); 2097 void setQuotes(PassRefPtr<QuotesData>);
2149 2098
2150 // snap-height 2099 // snap-height
2151 uint8_t snapHeightPosition() const { 2100 uint8_t snapHeightPosition() const {
2152 return m_rareInheritedData->m_snapHeightPosition; 2101 return m_rareInheritedData->m_snapHeightPosition;
2153 } 2102 }
2154 uint8_t snapHeightUnit() const { 2103 uint8_t snapHeightUnit() const {
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1); 4016 m_nonInheritedData.m_pseudoBits |= 1 << (pseudo - 1);
4068 } 4017 }
4069 4018
4070 inline bool ComputedStyle::hasPseudoElementStyle() const { 4019 inline bool ComputedStyle::hasPseudoElementStyle() const {
4071 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask; 4020 return m_nonInheritedData.m_pseudoBits & ElementPseudoIdMask;
4072 } 4021 }
4073 4022
4074 } // namespace blink 4023 } // namespace blink
4075 4024
4076 #endif // ComputedStyle_h 4025 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSProperties.in ('k') | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698