Changeset 207755 in webkit
- Timestamp:
- Oct 24, 2016, 2:50:47 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207754 r207755 1 2016-10-23 Antti Koivisto <antti@apple.com> 2 3 Avoid unnecessary full style resolution in getComputedStyle for non-inherited properties 4 https://bugs.webkit.org/show_bug.cgi?id=163875 5 6 Reviewed by Andreas Kling. 7 8 * fast/css/getComputedStyle/getComputedStyle-style-resolution-expected.txt: Added. 9 * fast/css/getComputedStyle/getComputedStyle-style-resolution.html: Added. 10 1 11 2016-10-24 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r207754 r207755 1 2016-10-23 Antti Koivisto <antti@apple.com> 2 3 Avoid unnecessary full style resolution in getComputedStyle for non-inherited properties 4 https://bugs.webkit.org/show_bug.cgi?id=163875 5 6 Reviewed by Andreas Kling. 7 8 Test: fast/css/getComputedStyle/getComputedStyle-style-resolution.html 9 10 * css/CSSComputedStyleDeclaration.cpp: 11 (WebCore::hasValidStyleForProperty): 12 13 For non-inherited properties we don't need to update style even if some ancestor style is invalid 14 as long as explicit 'inherit' is not being used. 15 We still need to update if we find out that the whole subtree we are in is invalid. 16 17 (WebCore::updateStyleIfNeededForProperty): 18 19 Pass the property. 20 21 (WebCore::ComputedStyleExtractor::customPropertyValue): 22 (WebCore::ComputedStyleExtractor::propertyValue): 23 (WebCore::CSSComputedStyleDeclaration::length): 24 (WebCore::elementOrItsAncestorNeedsStyleRecalc): Deleted. 25 (WebCore::updateStyleIfNeededForElement): Deleted. 26 * css/StyleResolver.cpp: 27 (WebCore::StyleResolver::colorFromPrimitiveValue): 28 29 Mark style as using explicit inheritance if 'currentcolor' value is used. 30 1 31 2016-10-24 Youenn Fablet <youenn@apple.com> 2 32 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r207686 r207755 58 58 #include "FontTaggedSettings.h" 59 59 #include "HTMLFrameOwnerElement.h" 60 #include "NodeRenderStyle.h" 60 61 #include "Pair.h" 61 62 #include "PseudoElement.h" … … 2338 2339 } 2339 2340 2341 static bool isImplicitlyInheritedGridOrFlexProperty(CSSPropertyID propertyID) 2342 { 2343 // It would be nice if grid and flex worked within normal CSS mechanisms and not invented their own inheritance system. 2344 switch (propertyID) { 2345 case CSSPropertyAlignSelf: 2346 #if ENABLE(CSS_GRID_LAYOUT) 2347 case CSSPropertyJustifySelf: 2348 case CSSPropertyJustifyItems: 2349 #endif 2350 // FIXME: In StyleResolver::adjustRenderStyle z-index is adjusted based on the parent display property for grid/flex. 2351 case CSSPropertyZIndex: 2352 return true; 2353 default: 2354 return false; 2355 } 2356 } 2357 2340 2358 RefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 2341 2359 { … … 2348 2366 } 2349 2367 2350 static inline bool elementOrItsAncestorNeedsStyleRecalc(Element& element) 2351 { 2352 if (element.needsStyleRecalc()) 2368 static inline bool hasValidStyleForProperty(Element& element, CSSPropertyID propertyID) 2369 { 2370 if (element.styleValidity() != Style::Validity::Valid) 2371 return false; 2372 if (element.document().hasPendingForcedStyleRecalc()) 2373 return false; 2374 if (!element.document().childNeedsStyleRecalc()) 2353 2375 return true; 2354 if (element.document().hasPendingForcedStyleRecalc()) 2355 return true; 2356 if (!element.document().childNeedsStyleRecalc()) 2357 return false; 2376 2377 bool isInherited = CSSProperty::isInheritedProperty(propertyID) || isImplicitlyInheritedGridOrFlexProperty(propertyID); 2378 bool maybeExplicitlyInherited = !isInherited; 2358 2379 2359 2380 const auto* currentElement = &element; 2360 2381 for (auto& ancestor : composedTreeAncestors(element)) { 2361 if (ancestor.needsStyleRecalc()) 2362 return true; 2382 if (ancestor.styleValidity() >= Style::Validity::SubtreeInvalid) 2383 return false; 2384 2385 if (maybeExplicitlyInherited) { 2386 auto* style = currentElement->renderStyle(); 2387 maybeExplicitlyInherited = !style || style->hasExplicitlyInheritedProperties(); 2388 } 2389 2390 if ((isInherited || maybeExplicitlyInherited) && ancestor.styleValidity() == Style::Validity::ElementInvalid) 2391 return false; 2363 2392 2364 2393 if (ancestor.directChildNeedsStyleRecalc() && currentElement->styleIsAffectedByPreviousSibling()) 2365 return true;2394 return false; 2366 2395 2367 2396 currentElement = &ancestor; 2368 2397 } 2369 return false; 2370 } 2371 2372 static bool updateStyleIfNeededForElement(Element& element) 2398 2399 return true; 2400 } 2401 2402 static bool updateStyleIfNeededForProperty(Element& element, CSSPropertyID propertyID) 2373 2403 { 2374 2404 auto& document = element.document(); … … 2376 2406 document.styleScope().flushPendingUpdate(); 2377 2407 2378 if ( !elementOrItsAncestorNeedsStyleRecalc(element))2408 if (hasValidStyleForProperty(element, propertyID)) 2379 2409 return false; 2380 2410 … … 2469 2499 return nullptr; 2470 2500 2471 if (updateStyleIfNeededFor Element(*styledElement)) {2501 if (updateStyleIfNeededForProperty(*styledElement, CSSPropertyCustom)) { 2472 2502 // Style update may change styledElement() to PseudoElement or back. 2473 2503 styledElement = this->styledElement(); … … 2501 2531 Document& document = m_element->document(); 2502 2532 2503 if (updateStyleIfNeededFor Element(*styledElement)) {2533 if (updateStyleIfNeededForProperty(*styledElement, propertyID)) { 2504 2534 // Style update may change styledElement() to PseudoElement or back. 2505 2535 styledElement = this->styledElement(); … … 3978 4008 unsigned CSSComputedStyleDeclaration::length() const 3979 4009 { 3980 updateStyleIfNeededFor Element(m_element.get());4010 updateStyleIfNeededForProperty(m_element.get(), CSSPropertyCustom); 3981 4011 3982 4012 auto* style = m_element->computedStyle(m_pseudoElementSpecifier); -
trunk/Source/WebCore/css/StyleResolver.cpp
r207669 r207755 1818 1818 return RenderTheme::focusRingColor(); 1819 1819 case CSSValueCurrentcolor: 1820 // Color is an inherited property so depending on it effectively makes the property inherited. 1821 state.style()->setHasExplicitlyInheritedProperties(); 1820 1822 return state.style()->color(); 1821 1823 default: {
Note:
See TracChangeset
for help on using the changeset viewer.