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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 247583003: Revert of Separate repaint and layout requirements of StyleDifference (Step 1) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Local revert Created 6 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 } 1849 }
1850 } 1850 }
1851 } 1851 }
1852 1852
1853 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const 1853 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const
1854 { 1854 {
1855 // FIXME: The calls to hasDirectReasonsForCompositing are using state that m ay not be up to date. 1855 // FIXME: The calls to hasDirectReasonsForCompositing are using state that m ay not be up to date.
1856 DisableCompositingQueryAsserts disabler; 1856 DisableCompositingQueryAsserts disabler;
1857 1857
1858 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG( )) 1858 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG( ))
1859 diff.setNeedsFullLayout(); 1859 diff = StyleDifferenceLayout;
1860 1860
1861 // If transform changed, and the layer does not paint into its own separate backing, then we need to repaint. 1861 // If transform changed, and the layer does not paint into its own separate backing, then we need to repaint.
1862 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !diff. needsLayout()) { 1862 if (contextSensitiveProperties & ContextSensitivePropertyTransform && diff <= StyleDifferenceRepaintLayer) {
1863 // Text nodes share style with their parents but transforms don't apply to them, 1863 // Text nodes share style with their parents but transforms don't apply to them,
1864 // hence the !isText() check. 1864 // hence the !isText() check.
1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) 1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1866 diff.setNeedsRepaintLayer(); 1866 diff = StyleDifferenceRepaintLayer;
1867 else 1867 else if (diff < StyleDifferenceRecompositeLayer)
1868 diff.setNeedsRecompositeLayer(); 1868 diff = StyleDifferenceRecompositeLayer;
1869 } 1869 }
1870 1870
1871 // If opacity or filters changed, and the layer does not paint into its own separate backing, then we need to repaint (also 1871 // If opacity or filters changed, and the layer does not paint into its own separate backing, then we need to repaint (also
1872 // ignoring text nodes) 1872 // ignoring text nodes)
1873 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && !diff.ne edsLayout()) { 1873 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <= StyleDifferenceRepaintLayer) {
1874 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) 1874 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1875 diff.setNeedsRepaintLayer(); 1875 diff = StyleDifferenceRepaintLayer;
1876 else 1876 else if (diff < StyleDifferenceRecompositeLayer)
1877 diff.setNeedsRecompositeLayer(); 1877 diff = StyleDifferenceRecompositeLayer;
1878 } 1878 }
1879 1879
1880 if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLaye r() && !diff.needsLayout()) { 1880 if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLaye r() && diff <= StyleDifferenceRepaintLayer) {
1881 RenderLayer* layer = toRenderLayerModelObject(this)->layer(); 1881 RenderLayer* layer = toRenderLayerModelObject(this)->layer();
1882 if (!layer->hasDirectReasonsForCompositing() || layer->paintsWithFilters ()) 1882 if (!layer->hasDirectReasonsForCompositing() || layer->paintsWithFilters ())
1883 diff.setNeedsRepaintLayer(); 1883 diff = StyleDifferenceRepaintLayer;
1884 else 1884 else if (diff < StyleDifferenceRecompositeLayer)
1885 diff.setNeedsRecompositeLayer(); 1885 diff = StyleDifferenceRecompositeLayer;
1886 } 1886 }
1887 1887
1888 if ((contextSensitiveProperties & ContextSensitivePropertyTextOrColor) && !d iff.needsRepaint() && !diff.needsLayout() 1888 if ((contextSensitiveProperties & ContextSensitivePropertyTextOrColor) && di ff < StyleDifferenceRepaint
1889 && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColor()) 1889 && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColor())
1890 diff.setNeedsRepaintObject(); 1890 diff = StyleDifferenceRepaint;
1891 1891
1892 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual 1892 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual
1893 // style changing, since it depends on whether we decide to composite these elements. When the 1893 // style changing, since it depends on whether we decide to composite these elements. When the
1894 // layer status of one of these elements changes, we need to force a layout. 1894 // layer status of one of these elements changes, we need to force a layout.
1895 if (diff.hasNoChange() && style() && isLayerModelObject()) { 1895 if (diff == StyleDifferenceEqual && style() && isLayerModelObject()) {
1896 bool requiresLayer = toRenderLayerModelObject(this)->layerTypeRequired() != NoLayer; 1896 bool requiresLayer = toRenderLayerModelObject(this)->layerTypeRequired() != NoLayer;
1897 if (hasLayer() != requiresLayer) 1897 if (hasLayer() != requiresLayer)
1898 diff.setNeedsFullLayout(); 1898 diff = StyleDifferenceLayout;
1899 } 1899 }
1900 1900
1901 // If we have no layer(), just treat a RepaintLayer hint as a normal Repaint . 1901 // If we have no layer(), just treat a RepaintLayer hint as a normal Repaint .
1902 if (diff.needsRepaintLayer() && !hasLayer()) { 1902 if (diff == StyleDifferenceRepaintLayer && !hasLayer())
1903 diff.clearNeedsRepaint(); 1903 diff = StyleDifferenceRepaint;
1904 diff.setNeedsRepaintObject();
1905 }
1906 1904
1907 return diff; 1905 return diff;
1908 } 1906 }
1909 1907
1910 void RenderObject::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle) 1908 void RenderObject::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle)
1911 { 1909 {
1912 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT ER); 1910 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT ER);
1913 1911
1914 // FIXME: We should consider just making all pseudo items use an inherited s tyle. 1912 // FIXME: We should consider just making all pseudo items use an inherited s tyle.
1915 1913
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 { 1957 {
1960 ASSERT(style); 1958 ASSERT(style);
1961 1959
1962 if (m_style == style) { 1960 if (m_style == style) {
1963 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so 1961 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so
1964 // style sharing is disabled for them. That should ensure that we never hit this code path. 1962 // style sharing is disabled for them. That should ensure that we never hit this code path.
1965 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); 1963 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas());
1966 return; 1964 return;
1967 } 1965 }
1968 1966
1969 StyleDifference diff; 1967 StyleDifference diff = StyleDifferenceEqual;
1970 unsigned contextSensitiveProperties = ContextSensitivePropertyNone; 1968 unsigned contextSensitiveProperties = ContextSensitivePropertyNone;
1971 if (m_style) 1969 if (m_style)
1972 diff = m_style->visualInvalidationDiff(*style, contextSensitivePropertie s); 1970 diff = m_style->visualInvalidationDiff(*style, contextSensitivePropertie s);
1973 1971
1974 diff = adjustStyleDifference(diff, contextSensitiveProperties); 1972 diff = adjustStyleDifference(diff, contextSensitiveProperties);
1975 1973
1976 styleWillChange(diff, *style); 1974 styleWillChange(diff, *style);
1977 1975
1978 RefPtr<RenderStyle> oldStyle = m_style.release(); 1976 RefPtr<RenderStyle> oldStyle = m_style.release();
1979 setStyleInternal(style); 1977 setStyleInternal(style);
(...skipping 14 matching lines...) Expand all
1994 // its first-letter block gets an update in RenderTextFragment::styleDidChan ge. For RenderTextFragment(s), 1992 // its first-letter block gets an update in RenderTextFragment::styleDidChan ge. For RenderTextFragment(s),
1995 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition 1993 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition
1996 // in the future as we move renderer changes out of layout and into style ch anges. 1994 // in the future as we move renderer changes out of layout and into style ch anges.
1997 if (doesNotNeedLayout) 1995 if (doesNotNeedLayout)
1998 return; 1996 return;
1999 1997
2000 // Now that the layer (if any) has been updated, we need to adjust the diff again, 1998 // Now that the layer (if any) has been updated, we need to adjust the diff again,
2001 // check whether we should layout now, and decide if we need to repaint. 1999 // check whether we should layout now, and decide if we need to repaint.
2002 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties); 2000 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties);
2003 2001
2004 if (!diff.needsFullLayout()) { 2002 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) {
2005 if (updatedDiff.needsFullLayout()) 2003 if (updatedDiff == StyleDifferenceLayout)
2006 setNeedsLayoutAndPrefWidthsRecalc(); 2004 setNeedsLayoutAndPrefWidthsRecalc();
2007 else if (updatedDiff.needsPositionedMovementLayoutOnly()) 2005 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly)
2008 setNeedsPositionedMovementLayout(); 2006 setNeedsPositionedMovementLayout();
2009 } 2007 }
2010 2008
2011 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs Layout()) { 2009 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs Layout()) {
2012 if (RenderBlock* container = containingBlock()) 2010 if (RenderBlock* container = containingBlock())
2013 container->setNeedsOverflowRecalcAfterStyleChange(); 2011 container->setNeedsOverflowRecalcAfterStyleChange();
2014 if (isBox()) 2012 if (isBox())
2015 toRenderBox(this)->updateLayerTransform(); 2013 toRenderBox(this)->updateLayerTransform();
2016 } 2014 }
2017 2015
2018 if (updatedDiff.needsRepaint()) { 2016 if (updatedDiff == StyleDifferenceRepaint || updatedDiff == StyleDifferenceR epaintLayer) {
2019 // Do a repaint with the new style now, e.g., for example if we go from 2017 // Do a repaint with the new style now, e.g., for example if we go from
2020 // not having an outline to having an outline. 2018 // not having an outline to having an outline.
2021 repaint(); 2019 repaint();
2022 } 2020 }
2023 } 2021 }
2024 2022
2025 static inline bool rendererHasBackground(const RenderObject* renderer) 2023 static inline bool rendererHasBackground(const RenderObject* renderer)
2026 { 2024 {
2027 return renderer && renderer->hasBackground(); 2025 return renderer && renderer->hasBackground();
2028 } 2026 }
(...skipping 13 matching lines...) Expand all
2042 } 2040 }
2043 2041
2044 // Keep layer hierarchy visibility bits up to date if visibility changes . 2042 // Keep layer hierarchy visibility bits up to date if visibility changes .
2045 if (m_style->visibility() != newStyle.visibility()) { 2043 if (m_style->visibility() != newStyle.visibility()) {
2046 // We might not have an enclosing layer yet because we might not be in the tree. 2044 // We might not have an enclosing layer yet because we might not be in the tree.
2047 if (RenderLayer* layer = enclosingLayer()) { 2045 if (RenderLayer* layer = enclosingLayer()) {
2048 if (newStyle.visibility() == VISIBLE) { 2046 if (newStyle.visibility() == VISIBLE) {
2049 layer->setHasVisibleContent(); 2047 layer->setHasVisibleContent();
2050 } else if (layer->hasVisibleContent() && (this == layer->rendere r() || layer->renderer()->style()->visibility() != VISIBLE)) { 2048 } else if (layer->hasVisibleContent() && (this == layer->rendere r() || layer->renderer()->style()->visibility() != VISIBLE)) {
2051 layer->dirtyVisibleContentStatus(); 2049 layer->dirtyVisibleContentStatus();
2052 if (diff.needsLayout()) 2050 if (diff > StyleDifferenceRepaintLayer)
2053 repaint(); 2051 repaint();
2054 } 2052 }
2055 } 2053 }
2056 } 2054 }
2057 2055
2058 if (m_parent && diff.needsRepaintObjectOnly()) 2056 if (m_parent && diff == StyleDifferenceRepaint)
2059 repaint(); 2057 repaint();
2060 if (isFloating() && (m_style->floating() != newStyle.floating())) 2058 if (isFloating() && (m_style->floating() != newStyle.floating()))
2061 // For changes in float styles, we need to conceivably remove oursel ves 2059 // For changes in float styles, we need to conceivably remove oursel ves
2062 // from the floating objects list. 2060 // from the floating objects list.
2063 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); 2061 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists();
2064 else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.pos ition())) 2062 else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.pos ition()))
2065 // For changes in positioning styles, we need to conceivably remove ourselves 2063 // For changes in positioning styles, we need to conceivably remove ourselves
2066 // from the positioned objects list. 2064 // from the positioned objects list.
2067 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); 2065 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists();
2068 2066
2069 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() 2067 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned()
2070 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) 2068 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition())
2071 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI nline()); 2069 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI nline());
2072 2070
2073 // Clearing these bits is required to avoid leaving stale renderers. 2071 // Clearing these bits is required to avoid leaving stale renderers.
2074 // FIXME: We shouldn't need that hack if our logic was totally correct. 2072 // FIXME: We shouldn't need that hack if our logic was totally correct.
2075 if (diff.needsFullLayout() || diff.needsPositionedMovementLayoutOnly()) { 2073 if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositi onedMovementOnly) {
2076 setFloating(false); 2074 setFloating(false);
2077 clearPositionedState(); 2075 clearPositionedState();
2078 } 2076 }
2079 } else { 2077 } else
2080 s_affectsParentBlock = false; 2078 s_affectsParentBlock = false;
2081 }
2082 2079
2083 if (view()->frameView()) { 2080 if (view()->frameView()) {
2084 bool shouldBlitOnFixedBackgroundImage = false; 2081 bool shouldBlitOnFixedBackgroundImage = false;
2085 #if ENABLE(FAST_MOBILE_SCROLLING) 2082 #if ENABLE(FAST_MOBILE_SCROLLING)
2086 // On low-powered/mobile devices, preventing blitting on a scroll can ca use noticeable delays 2083 // On low-powered/mobile devices, preventing blitting on a scroll can ca use noticeable delays
2087 // when scrolling a page with a fixed background image. As an optimizati on, assuming there are 2084 // when scrolling a page with a fixed background image. As an optimizati on, assuming there are
2088 // no fixed positoned elements on the page, we can acclerate scrolling ( via blitting) if we 2085 // no fixed positoned elements on the page, we can acclerate scrolling ( via blitting) if we
2089 // ignore the CSS property "background-attachment: fixed". 2086 // ignore the CSS property "background-attachment: fixed".
2090 shouldBlitOnFixedBackgroundImage = true; 2087 shouldBlitOnFixedBackgroundImage = true;
2091 #endif 2088 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 } 2136 }
2140 2137
2141 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) 2138 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle)
2142 { 2139 {
2143 if (s_affectsParentBlock) 2140 if (s_affectsParentBlock)
2144 handleDynamicFloatPositionChange(); 2141 handleDynamicFloatPositionChange();
2145 2142
2146 if (!m_parent) 2143 if (!m_parent)
2147 return; 2144 return;
2148 2145
2149 if (diff.needsFullLayout()) { 2146 if (diff == StyleDifferenceLayout) {
2150 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); 2147 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get());
2151 2148
2152 // If the object already needs layout, then setNeedsLayout won't do 2149 // If the object already needs layout, then setNeedsLayout won't do
2153 // any work. But if the containing block has changed, then we may need 2150 // any work. But if the containing block has changed, then we may need
2154 // to mark the new containing blocks for layout. The change that can 2151 // to mark the new containing blocks for layout. The change that can
2155 // directly affect the containing block of this object is a change to 2152 // directly affect the containing block of this object is a change to
2156 // the position style. 2153 // the position style.
2157 if (needsLayout() && oldStyle->position() != m_style->position()) 2154 if (needsLayout() && oldStyle->position() != m_style->position())
2158 markContainingBlocksForLayout(); 2155 markContainingBlocksForLayout();
2159 2156
2160 // Ditto. 2157 // Ditto.
2161 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s tyle->position()) 2158 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s tyle->position())
2162 markContainingBlocksForOverflowRecalc(); 2159 markContainingBlocksForOverflowRecalc();
2163 2160
2164 setNeedsLayoutAndPrefWidthsRecalc(); 2161 if (diff == StyleDifferenceLayout)
2165 } else if (diff.needsPositionedMovementLayoutOnly()) { 2162 setNeedsLayoutAndPrefWidthsRecalc();
2163 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly)
2166 setNeedsPositionedMovementLayout(); 2164 setNeedsPositionedMovementLayout();
2167 }
2168 2165
2169 // Don't check for repaint here; we need to wait until the layer has been 2166 // Don't check for repaint here; we need to wait until the layer has been
2170 // updated by subclasses before we know if we have to repaint (in setStyle() ). 2167 // updated by subclasses before we know if we have to repaint (in setStyle() ).
2171 2168
2172 if (oldStyle && !areCursorsEqual(oldStyle, style())) { 2169 if (oldStyle && !areCursorsEqual(oldStyle, style())) {
2173 if (LocalFrame* frame = this->frame()) 2170 if (LocalFrame* frame = this->frame())
2174 frame->eventHandler().scheduleCursorUpdate(); 2171 frame->eventHandler().scheduleCursorUpdate();
2175 } 2172 }
2176 } 2173 }
2177 2174
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3399 { 3396 {
3400 if (object1) { 3397 if (object1) {
3401 const WebCore::RenderObject* root = object1; 3398 const WebCore::RenderObject* root = object1;
3402 while (root->parent()) 3399 while (root->parent())
3403 root = root->parent(); 3400 root = root->parent();
3404 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3401 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3405 } 3402 }
3406 } 3403 }
3407 3404
3408 #endif 3405 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerModelObject.cpp ('k') | Source/core/rendering/RenderScrollbarPart.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698