OLD | NEW |
---|---|
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 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1847 childlist->insertChildNode(parent(), block, this); | 1847 childlist->insertChildNode(parent(), block, this); |
1848 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this)); | 1848 block->children()->appendChildNode(block, childlist->removeChildNode (parent(), this)); |
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 // If transform changed, and the layer does not paint into its own separate backing, then we need to do a layout. | 1857 |
1858 // FIXME: The comment above is what the code does, but it is technically not following spec. This means we will | 1858 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG( )) |
1859 // not to layout for 3d transforms, but we should be invoking a simplified r elayout. Is it possible we are avoiding | 1859 diff = StyleDifferenceLayout; |
1860 // doing this for some performance reason at this time? | 1860 |
1861 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { | 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 <= StyleDifferenceRepaintLayer) { | |
1862 // 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, |
1863 // hence the !isText() check. | 1864 // hence the !isText() check. |
1864 // FIXME: when transforms are taken into account for overflow, we will n eed to do a layout. | 1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) |
1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) { | 1866 diff = StyleDifferenceRepaintLayer; |
1866 // We need to set at least SimplifiedLayout, but if PositionedMoveme ntOnly is already set | 1867 else if (diff < StyleDifferenceRecompositeLayer) |
1867 // then we actually need SimplifiedLayoutAndPositionedMovement. | |
1868 if (!hasLayer()) | |
1869 diff = StyleDifferenceLayout; // FIXME: Do this for now since Si mplifiedLayout cannot handle updating floating objects lists. | |
1870 else if (diff < StyleDifferenceLayoutPositionedMovementOnly) | |
1871 diff = StyleDifferenceSimplifiedLayout; | |
1872 else if (diff < StyleDifferenceSimplifiedLayout) | |
1873 diff = StyleDifferenceSimplifiedLayoutAndPositionedMovement; | |
1874 } else if (diff < StyleDifferenceRecompositeLayer) | |
1875 diff = StyleDifferenceRecompositeLayer; | 1868 diff = StyleDifferenceRecompositeLayer; |
1876 } | 1869 } |
1877 | 1870 |
1878 // 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 |
1879 // ignoring text nodes) | 1872 // ignoring text nodes) |
1880 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <= StyleDifferenceRepaintLayer) { | 1873 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <= StyleDifferenceRepaintLayer) { |
1881 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) | 1874 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->hasDirectReasonsForCompositing())) |
1882 diff = StyleDifferenceRepaintLayer; | 1875 diff = StyleDifferenceRepaintLayer; |
1883 else if (diff < StyleDifferenceRecompositeLayer) | 1876 else if (diff < StyleDifferenceRecompositeLayer) |
1884 diff = StyleDifferenceRecompositeLayer; | 1877 diff = StyleDifferenceRecompositeLayer; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1941 return true; | 1934 return true; |
1942 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { | 1935 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { |
1943 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) | 1936 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) |
1944 return true; | 1937 return true; |
1945 if (r->style()->hasOutline() || r->style()->hasBorder()) | 1938 if (r->style()->hasOutline() || r->style()->hasBorder()) |
1946 return true; | 1939 return true; |
1947 } | 1940 } |
1948 return false; | 1941 return false; |
1949 } | 1942 } |
1950 | 1943 |
1944 void RenderObject::markContainingBlocksForOverflowRecalc() | |
1945 { | |
1946 for (RenderBlock* container = containingBlock(); container && !container->ch ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock ()) | |
1947 container->setChildNeedsOverflowRecalcAfterStyleChange(true); | |
1948 } | |
1949 | |
1950 void RenderObject::setNeedsOverflowRecalcAfterStyleChange() | |
1951 { | |
1952 setSelfNeedsOverflowRecalcAfterStyleChange(true); | |
1953 markContainingBlocksForOverflowRecalc(); | |
ojan
2014/04/19 02:19:30
Not sure if this matters, but you probably want to
trchen
2014/04/19 05:08:21
Yes I think we should do the early exit. Will do i
| |
1954 } | |
1955 | |
1951 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) | 1956 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) |
1952 { | 1957 { |
1953 ASSERT(style); | 1958 ASSERT(style); |
1954 | 1959 |
1955 if (m_style == style) { | 1960 if (m_style == style) { |
1956 // 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 |
1957 // 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. |
1958 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); | 1963 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); |
1959 return; | 1964 return; |
1960 } | 1965 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1992 | 1997 |
1993 // 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, |
1994 // 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. |
1995 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties); | 2000 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr operties); |
1996 | 2001 |
1997 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) { | 2002 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) { |
1998 if (updatedDiff == StyleDifferenceLayout) | 2003 if (updatedDiff == StyleDifferenceLayout) |
1999 setNeedsLayoutAndPrefWidthsRecalc(); | 2004 setNeedsLayoutAndPrefWidthsRecalc(); |
2000 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly) | 2005 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly) |
2001 setNeedsPositionedMovementLayout(); | 2006 setNeedsPositionedMovementLayout(); |
2002 else if (updatedDiff == StyleDifferenceSimplifiedLayoutAndPositionedMove ment) { | 2007 } |
2003 setNeedsPositionedMovementLayout(); | 2008 |
2004 setNeedsSimplifiedNormalFlowLayout(); | 2009 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs Layout()) { |
2005 } else if (updatedDiff == StyleDifferenceSimplifiedLayout) | 2010 if (RenderBlock* container = containingBlock()) |
2006 setNeedsSimplifiedNormalFlowLayout(); | 2011 container->setNeedsOverflowRecalcAfterStyleChange(); |
2012 if (isBox()) | |
2013 toRenderBox(this)->updateLayerTransform(); | |
2007 } | 2014 } |
2008 | 2015 |
2009 if (updatedDiff == StyleDifferenceRepaint || updatedDiff == StyleDifferenceR epaintLayer) { | 2016 if (updatedDiff == StyleDifferenceRepaint || updatedDiff == StyleDifferenceR epaintLayer) { |
2010 // 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 |
2011 // not having an outline to having an outline. | 2018 // not having an outline to having an outline. |
2012 repaint(); | 2019 repaint(); |
2013 } | 2020 } |
2014 } | 2021 } |
2015 | 2022 |
2016 static inline bool rendererHasBackground(const RenderObject* renderer) | 2023 static inline bool rendererHasBackground(const RenderObject* renderer) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2129 } | 2136 } |
2130 | 2137 |
2131 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) | 2138 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) |
2132 { | 2139 { |
2133 if (s_affectsParentBlock) | 2140 if (s_affectsParentBlock) |
2134 handleDynamicFloatPositionChange(); | 2141 handleDynamicFloatPositionChange(); |
2135 | 2142 |
2136 if (!m_parent) | 2143 if (!m_parent) |
2137 return; | 2144 return; |
2138 | 2145 |
2139 if (diff == StyleDifferenceLayout || diff == StyleDifferenceSimplifiedLayout ) { | 2146 if (diff == StyleDifferenceLayout) { |
2140 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); | 2147 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); |
2141 | 2148 |
2142 // If the object already needs layout, then setNeedsLayout won't do | 2149 // If the object already needs layout, then setNeedsLayout won't do |
2143 // 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 |
2144 // 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 |
2145 // 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 |
2146 // the position style. | 2153 // the position style. |
2147 if (needsLayout() && oldStyle->position() != m_style->position()) | 2154 if (needsLayout() && oldStyle->position() != m_style->position()) |
2148 markContainingBlocksForLayout(); | 2155 markContainingBlocksForLayout(); |
2149 | 2156 |
2157 // Ditto. | |
2158 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s tyle->position()) | |
2159 markContainingBlocksForOverflowRecalc(); | |
2160 | |
2150 if (diff == StyleDifferenceLayout) | 2161 if (diff == StyleDifferenceLayout) |
2151 setNeedsLayoutAndPrefWidthsRecalc(); | 2162 setNeedsLayoutAndPrefWidthsRecalc(); |
2152 else | |
2153 setNeedsSimplifiedNormalFlowLayout(); | |
2154 } else if (diff == StyleDifferenceSimplifiedLayoutAndPositionedMovement) { | |
2155 setNeedsPositionedMovementLayout(); | |
2156 setNeedsSimplifiedNormalFlowLayout(); | |
2157 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly) | 2163 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly) |
2158 setNeedsPositionedMovementLayout(); | 2164 setNeedsPositionedMovementLayout(); |
2159 | 2165 |
2160 // 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 |
2161 // 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() ). |
2162 | 2168 |
2163 if (oldStyle && !areCursorsEqual(oldStyle, style())) { | 2169 if (oldStyle && !areCursorsEqual(oldStyle, style())) { |
2164 if (LocalFrame* frame = this->frame()) | 2170 if (LocalFrame* frame = this->frame()) |
2165 frame->eventHandler().scheduleCursorUpdate(); | 2171 frame->eventHandler().scheduleCursorUpdate(); |
2166 } | 2172 } |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3390 { | 3396 { |
3391 if (object1) { | 3397 if (object1) { |
3392 const WebCore::RenderObject* root = object1; | 3398 const WebCore::RenderObject* root = object1; |
3393 while (root->parent()) | 3399 while (root->parent()) |
3394 root = root->parent(); | 3400 root = root->parent(); |
3395 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3401 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3396 } | 3402 } |
3397 } | 3403 } |
3398 | 3404 |
3399 #endif | 3405 #endif |
OLD | NEW |