Changeset 150259 in webkit
- Timestamp:
- May 17, 2013 8:26:30 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150258 r150259 1 2013-05-16 Andreas Kling <akling@apple.com> 2 3 Changes in text-only properties shouldn't cause repaints unless there is actually text. 4 <http://webkit.org/b/116250> 5 6 Reviewed by Antti Koivisto. 7 8 Add a new StyleDifferenceRepaintIfText value to the repertoire of RenderStyle::diff(). 9 This result means that the renderer only needs to repaint if one of its immediate children contains text. 10 11 This lets us avoid repainting the same pixels when hovering over constructs like: 12 13 <style> 14 a { text-decoration: none; } 15 a:hover { text-decoration: underline; } 16 </style> 17 <a href="http://is.gd/andersca"> 18 <img src="cool-hat.jpg"> 19 </a> 20 21 Since the change in text-decoration has no effect on the rendering of the <img> element, 22 we'll now be smart enough to avoid repainting it. 23 24 * rendering/style/RenderStyleConstants.h: 25 * rendering/style/RenderStyle.cpp: 26 (WebCore::RenderStyle::diff): 27 28 Move checking of text-only properties until the very end, and return StyleDifferenceRepaintIfText 29 in case a difference is found, giving precedence to StyleDifferenceRepaint. 30 31 * rendering/RenderObject.h: 32 * rendering/RenderObject.cpp: 33 (WebCore::RenderObject::hasImmediateNonWhitespaceTextChild): 34 35 Helper to check if a RenderObject has at least one RenderText child containing more than just 36 collapsible whitespace. 37 38 (WebCore::RenderObject::shouldRepaintForStyleDifference): 39 40 Helper to check if a StyleDifference is either ...Repaint or ...RepaintIfText and the renderer 41 has an immediate text child. 42 43 (WebCore::RenderObject::styleWillChange): 44 (WebCore::RenderObject::setStyle): 45 46 Don't repaint for StyleDifferenceRepaintIfText unless hasImmediateNonWhitespaceTextChild(). 47 48 * rendering/RenderBox.cpp: 49 (WebCore::RenderBox::styleDidChange): 50 * rendering/svg/SVGResourcesCache.cpp: 51 (WebCore::SVGResourcesCache::clientStyleChanged): 52 53 Tweak for new StyleDifference enum value. 54 55 * rendering/RenderText.h: 56 * rendering/RenderText.cpp: 57 (WebCore::RenderText::isAllCollapsibleWhitespace): 58 59 Made this const. 60 1 61 2013-05-17 Lamarque V. Souza <Lamarque.Souza@basyskom.com> 2 62 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r150214 r150259 277 277 278 278 // Our opaqueness might have changed without triggering layout. 279 if (diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer) {279 if (diff >= StyleDifferenceRepaint && diff <= StyleDifferenceRepaintLayer) { 280 280 RenderObject* parentToInvalidate = parent(); 281 281 for (unsigned i = 0; i < backgroundObscurationTestMaxDepth && parentToInvalidate; ++i) { -
trunk/Source/WebCore/rendering/RenderObject.cpp
r150108 r150259 1759 1759 } 1760 1760 1761 inline bool RenderObject::hasImmediateNonWhitespaceTextChild() const 1762 { 1763 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { 1764 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) 1765 return true; 1766 } 1767 return false; 1768 } 1769 1770 inline bool RenderObject::shouldRepaintForStyleDifference(StyleDifference diff) const 1771 { 1772 return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfText && hasImmediateNonWhitespaceTextChild()); 1773 } 1774 1761 1775 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) 1762 1776 { … … 1819 1833 setNeedsSimplifiedNormalFlowLayout(); 1820 1834 } 1821 1822 if (updatedDiff == StyleDifferenceRepaintLayer || updatedDiff == StyleDifferenceRepaint) {1835 1836 if (updatedDiff == StyleDifferenceRepaintLayer || shouldRepaintForStyleDifference(updatedDiff)) { 1823 1837 // Do a repaint with the new style now, e.g., for example if we go from 1824 1838 // not having an outline to having an outline. … … 1864 1878 } 1865 1879 1866 if (m_parent && ( diff == StyleDifferenceRepaint || newStyle->outlineSize() < m_style->outlineSize()))1880 if (m_parent && (newStyle->outlineSize() < m_style->outlineSize() || shouldRepaintForStyleDifference(diff))) 1867 1881 repaint(); 1868 1882 if (isFloating() && (m_style->floating() != newStyle->floating())) -
trunk/Source/WebCore/rendering/RenderObject.h
r149653 r150259 1024 1024 void removeFromRenderFlowThread(); 1025 1025 void removeFromRenderFlowThreadRecursive(RenderFlowThread*); 1026 1027 bool shouldRepaintForStyleDifference(StyleDifference) const; 1028 bool hasImmediateNonWhitespaceTextChild() const; 1026 1029 1027 1030 RenderStyle* cachedFirstLineStyle() const; -
trunk/Source/WebCore/rendering/RenderText.cpp
r149673 r150259 1181 1181 } 1182 1182 1183 bool RenderText::isAllCollapsibleWhitespace() 1183 bool RenderText::isAllCollapsibleWhitespace() const 1184 1184 { 1185 1185 unsigned length = textLength(); -
trunk/Source/WebCore/rendering/RenderText.h
r149967 r150259 131 131 void checkConsistency() const; 132 132 133 bool isAllCollapsibleWhitespace() ;133 bool isAllCollapsibleWhitespace() const; 134 134 135 135 bool canUseSimpleFontCodePath() const { return m_canUseSimpleFontCodePath; } -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r149700 r150259 676 676 return StyleDifferenceRepaintLayer; 677 677 678 if (inherited->color != other->inherited->color 679 || inherited_flags._visibility != other->inherited_flags._visibility 680 || inherited_flags._text_decorations != other->inherited_flags._text_decorations 678 if (inherited_flags._visibility != other->inherited_flags._visibility 681 679 || inherited_flags.m_printColorAdjust != other->inherited_flags.m_printColorAdjust 682 680 || inherited_flags._insideLink != other->inherited_flags._insideLink 683 681 || surround->border != other->surround->border 684 682 || *m_background.get() != *other->m_background.get() 685 || visual->textDecoration != other->visual->textDecoration686 683 || rareInheritedData->userModify != other->rareInheritedData->userModify 687 684 || rareInheritedData->userSelect != other->rareInheritedData->userSelect 688 685 || rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag 689 686 || rareNonInheritedData->m_borderFit != other->rareNonInheritedData->m_borderFit 690 #if ENABLE(CSS3_TEXT)691 || rareNonInheritedData->m_textDecorationStyle != other->rareNonInheritedData->m_textDecorationStyle692 || rareNonInheritedData->m_textDecorationColor != other->rareNonInheritedData->m_textDecorationColor693 #endif // CSS3_TEXT694 || rareInheritedData->textFillColor != other->rareInheritedData->textFillColor695 || rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor696 || rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor697 || rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill698 687 || rareInheritedData->m_imageRendering != other->rareInheritedData->m_imageRendering) 699 688 return StyleDifferenceRepaint; … … 710 699 return StyleDifferenceRepaint; 711 700 712 713 701 #if USE(ACCELERATED_COMPOSITING) 714 702 if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) { … … 721 709 } 722 710 #endif 711 712 if (inherited->color != other->inherited->color 713 || inherited_flags._text_decorations != other->inherited_flags._text_decorations 714 || visual->textDecoration != other->visual->textDecoration 715 #if ENABLE(CSS3_TEXT) 716 || rareNonInheritedData->m_textDecorationStyle != other->rareNonInheritedData->m_textDecorationStyle 717 || rareNonInheritedData->m_textDecorationColor != other->rareNonInheritedData->m_textDecorationColor 718 #endif // CSS3_TEXT 719 || rareInheritedData->textFillColor != other->rareInheritedData->textFillColor 720 || rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor 721 || rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor 722 || rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill) 723 return StyleDifferenceRepaintIfText; 723 724 724 725 // Cursors are not checked, since they will be set appropriately in response to mouse events, -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.h
r148949 r150259 36 36 37 37 // The difference between two styles. The following values are used: 38 // (1) StyleDifferenceEqual - The two styles are identical 39 // (2) StyleDifferenceRecompositeLayer - The layer needs its position and transform updated, but no repaint 40 // (3) StyleDifferenceRepaint - The object just needs to be repainted. 41 // (4) StyleDifferenceRepaintLayer - The layer and its descendant layers needs to be repainted. 42 // (5) StyleDifferenceLayoutPositionedMovementOnly - Only the position of this positioned object has been updated 43 // (6) StyleDifferenceSimplifiedLayout - Only overflow needs to be recomputed 44 // (7) StyleDifferenceSimplifiedLayoutAndPositionedMovement - Both positioned movement and simplified layout updates are required. 45 // (8) StyleDifferenceLayout - A full layout is required. 38 // - StyleDifferenceEqual - The two styles are identical 39 // - StyleDifferenceRecompositeLayer - The layer needs its position and transform updated, but no repaint 40 // - StyleDifferenceRepaint - The object just needs to be repainted. 41 // - StyleDifferenceRepaintIfText - The object needs to be repainted if it contains text. 42 // - StyleDifferenceRepaintLayer - The layer and its descendant layers needs to be repainted. 43 // - StyleDifferenceLayoutPositionedMovementOnly - Only the position of this positioned object has been updated 44 // - StyleDifferenceSimplifiedLayout - Only overflow needs to be recomputed 45 // - StyleDifferenceSimplifiedLayoutAndPositionedMovement - Both positioned movement and simplified layout updates are required. 46 // - StyleDifferenceLayout - A full layout is required. 46 47 enum StyleDifference { 47 48 StyleDifferenceEqual, … … 50 51 #endif 51 52 StyleDifferenceRepaint, 53 StyleDifferenceRepaintIfText, 52 54 StyleDifferenceRepaintLayer, 53 55 StyleDifferenceLayoutPositionedMovementOnly, -
trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp
r149684 r150259 130 130 131 131 // In this case the proper SVGFE*Element will decide whether the modified CSS properties require a relayout or repaint. 132 if (renderer->isSVGResourceFilterPrimitive() && diff == StyleDifferenceRepaint)132 if (renderer->isSVGResourceFilterPrimitive() && (diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintIfText)) 133 133 return; 134 134
Note: See TracChangeset
for help on using the changeset viewer.