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

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

Issue 250773002: Reland "Recompute overflow after transform changes" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@build_hack
Patch Set: again... Created 6 years, 7 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
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/style/StyleDifference.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 childlist->insertChildNode(parent(), block, this); 1855 childlist->insertChildNode(parent(), block, this);
1856 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this)); 1856 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this));
1857 } 1857 }
1858 } 1858 }
1859 } 1859 }
1860 1860
1861 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const 1861 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const
1862 { 1862 {
1863 // FIXME: The calls to hasDirectReasonsForCompositing are using state that m ay not be up to date. 1863 // FIXME: The calls to hasDirectReasonsForCompositing are using state that m ay not be up to date.
1864 DisableCompositingQueryAsserts disabler; 1864 DisableCompositingQueryAsserts disabler;
1865 // If transform changed, and the layer does not paint into its own separate backing, then we need to do a layout. 1865
1866 // FIXME: The comment above is what the code does, but it is technically not following spec. This means we will 1866 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG( ))
1867 // not to layout for 3d transforms, but we should be invoking a simplified r elayout. Is it possible we are avoiding 1867 diff.setNeedsFullLayout();
1868 // doing this for some performance reason at this time? 1868
1869 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { 1869 // If transform changed, and the layer does not paint into its own separate backing, then we need to repaint.
1870 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !diff .needsLayout()) {
1870 // Text nodes share style with their parents but transforms don't apply to them, 1871 // Text nodes share style with their parents but transforms don't apply to them,
1871 // hence the !isText() check. 1872 // hence the !isText() check.
1872 // FIXME: when transforms are taken into account for overflow, we will n eed to do a layout. 1873 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1873 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) { 1874 diff.setNeedsRepaintLayer();
1874 // We need to set at least SimplifiedLayout, but if PositionedMoveme ntOnly is already set 1875 else
1875 // then we actually need SimplifiedLayoutAndPositionedMovement.
1876 if (!hasLayer())
1877 diff.setNeedsFullLayout(); // FIXME: Do this for now since Simpl ifiedLayout cannot handle updating floating objects lists.
1878 else
1879 diff.setNeedsSimplifiedLayout();
1880 } else {
1881 diff.setNeedsRecompositeLayer(); 1876 diff.setNeedsRecompositeLayer();
1882 }
1883 } 1877 }
1884 1878
1885 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to repaint (also 1879 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to repaint (also
1886 // ignoring text nodes) 1880 // ignoring text nodes)
1887 if ((contextSensitiveProperties & (ContextSensitivePropertyOpacity | Context SensitivePropertyZIndex)) && !diff.needsLayout()) { 1881 if ((contextSensitiveProperties & (ContextSensitivePropertyOpacity | Context SensitivePropertyZIndex)) && !diff.needsLayout()) {
1888 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) 1882 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1889 diff.setNeedsRepaintLayer(); 1883 diff.setNeedsRepaintLayer();
1890 else 1884 else
1891 diff.setNeedsRecompositeLayer(); 1885 diff.setNeedsRecompositeLayer();
1892 } 1886 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 return true; 1945 return true;
1952 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { 1946 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) {
1953 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) 1947 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace())
1954 return true; 1948 return true;
1955 if (r->style()->hasOutline() || r->style()->hasBorder()) 1949 if (r->style()->hasOutline() || r->style()->hasBorder())
1956 return true; 1950 return true;
1957 } 1951 }
1958 return false; 1952 return false;
1959 } 1953 }
1960 1954
1955 void RenderObject::markContainingBlocksForOverflowRecalc()
1956 {
1957 for (RenderBlock* container = containingBlock(); container && !container->ch ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock ())
1958 container->setChildNeedsOverflowRecalcAfterStyleChange(true);
1959 }
1960
1961 void RenderObject::setNeedsOverflowRecalcAfterStyleChange()
1962 {
1963 bool neededRecalc = needsOverflowRecalcAfterStyleChange();
1964 setSelfNeedsOverflowRecalcAfterStyleChange(true);
1965 if (!neededRecalc)
1966 markContainingBlocksForOverflowRecalc();
1967 }
1968
1961 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) 1969 void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
1962 { 1970 {
1963 ASSERT(style); 1971 ASSERT(style);
1964 1972
1965 if (m_style == style) { 1973 if (m_style == style) {
1966 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so 1974 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so
1967 // style sharing is disabled for them. That should ensure that we never hit this code path. 1975 // style sharing is disabled for them. That should ensure that we never hit this code path.
1968 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); 1976 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas());
1969 return; 1977 return;
1970 } 1978 }
(...skipping 27 matching lines...) Expand all
1998 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition 2006 // we will safely bail out with the doesNotNeedLayout flag. We might want to broaden this condition
1999 // in the future as we move renderer changes out of layout and into style ch anges. 2007 // in the future as we move renderer changes out of layout and into style ch anges.
2000 if (doesNotNeedLayout) 2008 if (doesNotNeedLayout)
2001 return; 2009 return;
2002 2010
2003 // Now that the layer (if any) has been updated, we need to adjust the diff again, 2011 // Now that the layer (if any) has been updated, we need to adjust the diff again,
2004 // check whether we should layout now, and decide if we need to repaint. 2012 // check whether we should layout now, and decide if we need to repaint.
2005 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties); 2013 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties);
2006 2014
2007 if (!diff.needsFullLayout()) { 2015 if (!diff.needsFullLayout()) {
2008 if (updatedDiff.needsFullLayout()) { 2016 if (updatedDiff.needsFullLayout())
2009 setNeedsLayoutAndPrefWidthsRecalc(); 2017 setNeedsLayoutAndPrefWidthsRecalc();
2010 } else { 2018 else if (updatedDiff.needsPositionedMovementLayout())
2011 if (updatedDiff.needsPositionedMovementLayout()) 2019 setNeedsPositionedMovementLayout();
2012 setNeedsPositionedMovementLayout(); 2020 }
2013 if (updatedDiff.needsSimplifiedLayout()) 2021
2014 setNeedsSimplifiedNormalFlowLayout(); 2022 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs Layout()) {
2015 } 2023 if (RenderBlock* container = containingBlock())
2024 container->setNeedsOverflowRecalcAfterStyleChange();
2025 if (isBox())
2026 toRenderBox(this)->updateLayerTransform();
2016 } 2027 }
2017 2028
2018 if (updatedDiff.needsRepaint()) { 2029 if (updatedDiff.needsRepaint()) {
2019 // Do a repaint with the new style now, e.g., for example if we go from 2030 // 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. 2031 // not having an outline to having an outline.
2021 repaint(); 2032 repaint();
2022 } 2033 }
2023 } 2034 }
2024 2035
2025 static inline bool rendererHasBackground(const RenderObject* renderer) 2036 static inline bool rendererHasBackground(const RenderObject* renderer)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 } 2150 }
2140 2151
2141 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) 2152 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle)
2142 { 2153 {
2143 if (s_affectsParentBlock) 2154 if (s_affectsParentBlock)
2144 handleDynamicFloatPositionChange(); 2155 handleDynamicFloatPositionChange();
2145 2156
2146 if (!m_parent) 2157 if (!m_parent)
2147 return; 2158 return;
2148 2159
2149 if (diff.needsFullLayout() || diff.needsSimplifiedLayout()) { 2160 if (diff.needsFullLayout()) {
2150 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); 2161 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get());
2151 2162
2152 // If the object already needs layout, then setNeedsLayout won't do 2163 // 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 2164 // 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 2165 // 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 2166 // directly affect the containing block of this object is a change to
2156 // the position style. 2167 // the position style.
2157 if (needsLayout() && oldStyle->position() != m_style->position()) 2168 if (needsLayout() && oldStyle->position() != m_style->position())
2158 markContainingBlocksForLayout(); 2169 markContainingBlocksForLayout();
2159 2170
2171 // Ditto.
2172 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s tyle->position())
2173 markContainingBlocksForOverflowRecalc();
2174
2160 if (diff.needsFullLayout()) 2175 if (diff.needsFullLayout())
2161 setNeedsLayoutAndPrefWidthsRecalc(); 2176 setNeedsLayoutAndPrefWidthsRecalc();
2162 else 2177 } else if (diff.needsPositionedMovementLayout())
2163 setNeedsSimplifiedNormalFlowLayout();
2164 }
2165 if (diff.needsPositionedMovementLayout())
2166 setNeedsPositionedMovementLayout(); 2178 setNeedsPositionedMovementLayout();
2167 2179
2168 // Don't check for repaint here; we need to wait until the layer has been 2180 // Don't check for repaint here; we need to wait until the layer has been
2169 // updated by subclasses before we know if we have to repaint (in setStyle() ). 2181 // updated by subclasses before we know if we have to repaint (in setStyle() ).
2170 2182
2171 if (oldStyle && !areCursorsEqual(oldStyle, style())) { 2183 if (oldStyle && !areCursorsEqual(oldStyle, style())) {
2172 if (LocalFrame* frame = this->frame()) 2184 if (LocalFrame* frame = this->frame())
2173 frame->eventHandler().scheduleCursorUpdate(); 2185 frame->eventHandler().scheduleCursorUpdate();
2174 } 2186 }
2175 } 2187 }
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 { 3410 {
3399 if (object1) { 3411 if (object1) {
3400 const WebCore::RenderObject* root = object1; 3412 const WebCore::RenderObject* root = object1;
3401 while (root->parent()) 3413 while (root->parent())
3402 root = root->parent(); 3414 root = root->parent();
3403 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3415 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3404 } 3416 }
3405 } 3417 }
3406 3418
3407 #endif 3419 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/style/StyleDifference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698