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

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

Issue 203463007: Recompute overflow after transform changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tests had been missing 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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock() ; 1790 RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock() ;
1791 RenderObjectChildList* childlist = parent()->virtualChildren(); 1791 RenderObjectChildList* childlist = parent()->virtualChildren();
1792 childlist->insertChildNode(parent(), block, this); 1792 childlist->insertChildNode(parent(), block, this);
1793 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this)); 1793 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this));
1794 } 1794 }
1795 } 1795 }
1796 } 1796 }
1797 1797
1798 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const 1798 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const
1799 { 1799 {
1800 // If transform changed, and the layer does not paint into its own separate backing, then we need to do a layout. 1800 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG( ))
1801 // FIXME: The comment above is what the code does, but it is technically not following spec. This means we will 1801 diff = StyleDifferenceLayout;
esprehn 2014/04/10 23:46:14 Why the special case for SVG?
trchen 2014/04/11 22:04:55 Because SVG is special. They do rely on layout to
1802 // not to layout for 3d transforms, but we should be invoking a simplified r elayout. Is it possible we are avoiding 1802
1803 // doing this for some performance reason at this time? 1803 // If transform changed, and the layer does not paint into its own separate backing, then we need to repaint.
1804 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { 1804 if (contextSensitiveProperties & ContextSensitivePropertyTransform && diff <= StyleDifferenceRepaintLayer) {
1805 // Text nodes share style with their parents but transforms don't apply to them, 1805 // Text nodes share style with their parents but transforms don't apply to them,
1806 // hence the !isText() check. 1806 // hence the !isText() check.
1807 // FIXME: when transforms are taken into account for overflow, we will n eed to do a layout. 1807 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1808 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) { 1808 diff = StyleDifferenceRepaintLayer;
1809 // We need to set at least SimplifiedLayout, but if PositionedMoveme ntOnly is already set 1809 else if (diff < StyleDifferenceRecompositeLayer)
1810 // then we actually need SimplifiedLayoutAndPositionedMovement.
1811 if (!hasLayer())
1812 diff = StyleDifferenceLayout; // FIXME: Do this for now since Si mplifiedLayout cannot handle updating floating objects lists.
1813 else if (diff < StyleDifferenceLayoutPositionedMovementOnly)
1814 diff = StyleDifferenceSimplifiedLayout;
1815 else if (diff < StyleDifferenceSimplifiedLayout)
1816 diff = StyleDifferenceSimplifiedLayoutAndPositionedMovement;
1817 } else if (diff < StyleDifferenceRecompositeLayer)
1818 diff = StyleDifferenceRecompositeLayer; 1810 diff = StyleDifferenceRecompositeLayer;
1819 } 1811 }
1820 1812
1821 // If opacity or filters changed, and the layer does not paint into its own separate backing, then we need to repaint (also 1813 // If opacity or filters changed, and the layer does not paint into its own separate backing, then we need to repaint (also
1822 // ignoring text nodes) 1814 // ignoring text nodes)
1823 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <= StyleDifferenceRepaintLayer) { 1815 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <= StyleDifferenceRepaintLayer) {
1824 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) 1816 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing()))
1825 diff = StyleDifferenceRepaintLayer; 1817 diff = StyleDifferenceRepaintLayer;
1826 else if (diff < StyleDifferenceRecompositeLayer) 1818 else if (diff < StyleDifferenceRecompositeLayer)
1827 diff = StyleDifferenceRecompositeLayer; 1819 diff = StyleDifferenceRecompositeLayer;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 return true; 1877 return true;
1886 } 1878 }
1887 return false; 1879 return false;
1888 } 1880 }
1889 1881
1890 inline bool RenderObject::shouldRepaintForStyleDifference(StyleDifference diff) const 1882 inline bool RenderObject::shouldRepaintForStyleDifference(StyleDifference diff) const
1891 { 1883 {
1892 return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfTe xtOrColorChange && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColo r()); 1884 return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfTe xtOrColorChange && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColo r());
1893 } 1885 }
1894 1886
1887 void RenderObject::markContainingBlocksForOverflowRecalc()
1888 {
1889 for (RenderBlock* container = containingBlock(); container && !container->ch ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock ())
1890 container->setChildNeedsOverflowRecalcAfterStyleChange(true);
1891 }
1892
1893 void RenderObject::setNeedsOverflowRecalcAfterStyleChange()
1894 {
1895 setSelfNeedsOverflowRecalcAfterStyleChange(true);
1896 markContainingBlocksForOverflowRecalc();
1897 }
1898
1895 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) 1899 void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
1896 { 1900 {
1897 if (m_style == style) { 1901 if (m_style == style) {
1898 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so 1902 // We need to run through adjustStyleDifference() for iframes, plugins, and canvas so
1899 // style sharing is disabled for them. That should ensure that we never hit this code path. 1903 // style sharing is disabled for them. That should ensure that we never hit this code path.
1900 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); 1904 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas());
1901 return; 1905 return;
1902 } 1906 }
1903 1907
1904 StyleDifference diff = StyleDifferenceEqual; 1908 StyleDifference diff = StyleDifferenceEqual;
(...skipping 29 matching lines...) Expand all
1934 1938
1935 // Now that the layer (if any) has been updated, we need to adjust the diff again, 1939 // Now that the layer (if any) has been updated, we need to adjust the diff again,
1936 // check whether we should layout now, and decide if we need to repaint. 1940 // check whether we should layout now, and decide if we need to repaint.
1937 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties); 1941 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties);
1938 1942
1939 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) { 1943 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) {
1940 if (updatedDiff == StyleDifferenceLayout) 1944 if (updatedDiff == StyleDifferenceLayout)
1941 setNeedsLayoutAndPrefWidthsRecalc(); 1945 setNeedsLayoutAndPrefWidthsRecalc();
1942 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly) 1946 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly)
1943 setNeedsPositionedMovementLayout(); 1947 setNeedsPositionedMovementLayout();
1944 else if (updatedDiff == StyleDifferenceSimplifiedLayoutAndPositionedMove ment) { 1948 }
1945 setNeedsPositionedMovementLayout(); 1949
1946 setNeedsSimplifiedNormalFlowLayout(); 1950 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs Layout()) {
1947 } else if (updatedDiff == StyleDifferenceSimplifiedLayout) 1951 if (RenderBlock* container = containingBlock())
1948 setNeedsSimplifiedNormalFlowLayout(); 1952 container->setNeedsOverflowRecalcAfterStyleChange();
1953 if (isBox())
1954 toRenderBox(this)->updateLayerTransform();
1949 } 1955 }
1950 1956
1951 if (updatedDiff == StyleDifferenceRepaintLayer || shouldRepaintForStyleDiffe rence(updatedDiff)) { 1957 if (updatedDiff == StyleDifferenceRepaintLayer || shouldRepaintForStyleDiffe rence(updatedDiff)) {
1952 // Do a repaint with the new style now, e.g., for example if we go from 1958 // Do a repaint with the new style now, e.g., for example if we go from
1953 // not having an outline to having an outline. 1959 // not having an outline to having an outline.
1954 repaint(); 1960 repaint();
1955 } 1961 }
1956 } 1962 }
1957 1963
1958 static inline bool rendererHasBackground(const RenderObject* renderer) 1964 static inline bool rendererHasBackground(const RenderObject* renderer)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 } 2079 }
2074 2080
2075 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) 2081 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle)
2076 { 2082 {
2077 if (s_affectsParentBlock) 2083 if (s_affectsParentBlock)
2078 handleDynamicFloatPositionChange(); 2084 handleDynamicFloatPositionChange();
2079 2085
2080 if (!m_parent) 2086 if (!m_parent)
2081 return; 2087 return;
2082 2088
2083 if (diff == StyleDifferenceLayout || diff == StyleDifferenceSimplifiedLayout ) { 2089 if (diff == StyleDifferenceLayout) {
2084 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); 2090 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get());
2085 2091
2086 // If the object already needs layout, then setNeedsLayout won't do 2092 // If the object already needs layout, then setNeedsLayout won't do
2087 // any work. But if the containing block has changed, then we may need 2093 // any work. But if the containing block has changed, then we may need
2088 // to mark the new containing blocks for layout. The change that can 2094 // to mark the new containing blocks for layout. The change that can
2089 // directly affect the containing block of this object is a change to 2095 // directly affect the containing block of this object is a change to
2090 // the position style. 2096 // the position style.
2091 if (needsLayout() && oldStyle->position() != m_style->position()) 2097 if (needsLayout() && oldStyle->position() != m_style->position())
2092 markContainingBlocksForLayout(); 2098 markContainingBlocksForLayout();
2093 2099
2100 // Ditto.
2101 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s tyle->position()) {
2102 if (RenderBlock* container = containingBlock())
2103 container->markContainingBlocksForOverflowRecalc();
esprehn 2014/04/10 23:46:14 This doesn't look right, you want to call markCont
trchen 2014/04/11 22:04:55 Done.
2104 }
2105
2094 if (diff == StyleDifferenceLayout) 2106 if (diff == StyleDifferenceLayout)
2095 setNeedsLayoutAndPrefWidthsRecalc(); 2107 setNeedsLayoutAndPrefWidthsRecalc();
2096 else
2097 setNeedsSimplifiedNormalFlowLayout();
2098 } else if (diff == StyleDifferenceSimplifiedLayoutAndPositionedMovement) {
2099 setNeedsPositionedMovementLayout();
2100 setNeedsSimplifiedNormalFlowLayout();
2101 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly) 2108 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly)
2102 setNeedsPositionedMovementLayout(); 2109 setNeedsPositionedMovementLayout();
2103 2110
2104 // Don't check for repaint here; we need to wait until the layer has been 2111 // Don't check for repaint here; we need to wait until the layer has been
2105 // updated by subclasses before we know if we have to repaint (in setStyle() ). 2112 // updated by subclasses before we know if we have to repaint (in setStyle() ).
2106 2113
2107 if (oldStyle && !areCursorsEqual(oldStyle, style())) { 2114 if (oldStyle && !areCursorsEqual(oldStyle, style())) {
2108 if (LocalFrame* frame = this->frame()) 2115 if (LocalFrame* frame = this->frame())
2109 frame->eventHandler().scheduleCursorUpdate(); 2116 frame->eventHandler().scheduleCursorUpdate();
2110 } 2117 }
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3328 { 3335 {
3329 if (object1) { 3336 if (object1) {
3330 const WebCore::RenderObject* root = object1; 3337 const WebCore::RenderObject* root = object1;
3331 while (root->parent()) 3338 while (root->parent())
3332 root = root->parent(); 3339 root = root->parent();
3333 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3340 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3334 } 3341 }
3335 } 3342 }
3336 3343
3337 #endif 3344 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698