| 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 | 1857 // If transform changed, and the layer does not paint into its own separate
backing, then we need to do a layout. |
| 1858 if (contextSensitiveProperties & ContextSensitivePropertyTransform && isSVG(
)) | 1858 // FIXME: The comment above is what the code does, but it is technically not
following spec. This means we will |
| 1859 diff = StyleDifferenceLayout; | 1859 // not to layout for 3d transforms, but we should be invoking a simplified r
elayout. Is it possible we are avoiding |
| 1860 | 1860 // doing this for some performance reason at this time? |
| 1861 // If transform changed, and the layer does not paint into its own separate
backing, then we need to repaint. | 1861 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { |
| 1862 if (contextSensitiveProperties & ContextSensitivePropertyTransform && diff
<= StyleDifferenceRepaintLayer) { | |
| 1863 // Text nodes share style with their parents but transforms don't apply
to them, | 1862 // Text nodes share style with their parents but transforms don't apply
to them, |
| 1864 // hence the !isText() check. | 1863 // hence the !isText() check. |
| 1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer(
)->hasDirectReasonsForCompositing())) | 1864 // FIXME: when transforms are taken into account for overflow, we will n
eed to do a layout. |
| 1866 diff = StyleDifferenceRepaintLayer; | 1865 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer(
)->hasDirectReasonsForCompositing())) { |
| 1867 else if (diff < StyleDifferenceRecompositeLayer) | 1866 // We need to set at least SimplifiedLayout, but if PositionedMoveme
ntOnly is already set |
| 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) |
| 1868 diff = StyleDifferenceRecompositeLayer; | 1875 diff = StyleDifferenceRecompositeLayer; |
| 1869 } | 1876 } |
| 1870 | 1877 |
| 1871 // If opacity or filters changed, and the layer does not paint into its own
separate backing, then we need to repaint (also | 1878 // 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) | 1879 // ignoring text nodes) |
| 1873 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <=
StyleDifferenceRepaintLayer) { | 1880 if (contextSensitiveProperties & ContextSensitivePropertyOpacity && diff <=
StyleDifferenceRepaintLayer) { |
| 1874 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer(
)->hasDirectReasonsForCompositing())) | 1881 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer(
)->hasDirectReasonsForCompositing())) |
| 1875 diff = StyleDifferenceRepaintLayer; | 1882 diff = StyleDifferenceRepaintLayer; |
| 1876 else if (diff < StyleDifferenceRecompositeLayer) | 1883 else if (diff < StyleDifferenceRecompositeLayer) |
| 1877 diff = StyleDifferenceRecompositeLayer; | 1884 diff = StyleDifferenceRecompositeLayer; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 return true; | 1941 return true; |
| 1935 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { | 1942 for (const RenderObject* r = firstChild(); r; r = r->nextSibling()) { |
| 1936 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) | 1943 if (r->isText() && !toRenderText(r)->isAllCollapsibleWhitespace()) |
| 1937 return true; | 1944 return true; |
| 1938 if (r->style()->hasOutline() || r->style()->hasBorder()) | 1945 if (r->style()->hasOutline() || r->style()->hasBorder()) |
| 1939 return true; | 1946 return true; |
| 1940 } | 1947 } |
| 1941 return false; | 1948 return false; |
| 1942 } | 1949 } |
| 1943 | 1950 |
| 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(); | |
| 1954 } | |
| 1955 | |
| 1956 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) | 1951 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) |
| 1957 { | 1952 { |
| 1958 ASSERT(style); | 1953 ASSERT(style); |
| 1959 | 1954 |
| 1960 if (m_style == style) { | 1955 if (m_style == style) { |
| 1961 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so | 1956 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so |
| 1962 // style sharing is disabled for them. That should ensure that we never
hit this code path. | 1957 // style sharing is disabled for them. That should ensure that we never
hit this code path. |
| 1963 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); | 1958 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); |
| 1964 return; | 1959 return; |
| 1965 } | 1960 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1997 | 1992 |
| 1998 // Now that the layer (if any) has been updated, we need to adjust the diff
again, | 1993 // Now that the layer (if any) has been updated, we need to adjust the diff
again, |
| 1999 // check whether we should layout now, and decide if we need to repaint. | 1994 // check whether we should layout now, and decide if we need to repaint. |
| 2000 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr
operties); | 1995 StyleDifference updatedDiff = adjustStyleDifference(diff, contextSensitivePr
operties); |
| 2001 | 1996 |
| 2002 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) { | 1997 if (diff <= StyleDifferenceLayoutPositionedMovementOnly) { |
| 2003 if (updatedDiff == StyleDifferenceLayout) | 1998 if (updatedDiff == StyleDifferenceLayout) |
| 2004 setNeedsLayoutAndPrefWidthsRecalc(); | 1999 setNeedsLayoutAndPrefWidthsRecalc(); |
| 2005 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly) | 2000 else if (updatedDiff == StyleDifferenceLayoutPositionedMovementOnly) |
| 2006 setNeedsPositionedMovementLayout(); | 2001 setNeedsPositionedMovementLayout(); |
| 2007 } | 2002 else if (updatedDiff == StyleDifferenceSimplifiedLayoutAndPositionedMove
ment) { |
| 2008 | 2003 setNeedsPositionedMovementLayout(); |
| 2009 if (contextSensitiveProperties & ContextSensitivePropertyTransform && !needs
Layout()) { | 2004 setNeedsSimplifiedNormalFlowLayout(); |
| 2010 if (RenderBlock* container = containingBlock()) | 2005 } else if (updatedDiff == StyleDifferenceSimplifiedLayout) |
| 2011 container->setNeedsOverflowRecalcAfterStyleChange(); | 2006 setNeedsSimplifiedNormalFlowLayout(); |
| 2012 if (isBox()) | |
| 2013 toRenderBox(this)->updateLayerTransform(); | |
| 2014 } | 2007 } |
| 2015 | 2008 |
| 2016 if (updatedDiff == StyleDifferenceRepaint || updatedDiff == StyleDifferenceR
epaintLayer) { | 2009 if (updatedDiff == StyleDifferenceRepaint || updatedDiff == StyleDifferenceR
epaintLayer) { |
| 2017 // Do a repaint with the new style now, e.g., for example if we go from | 2010 // Do a repaint with the new style now, e.g., for example if we go from |
| 2018 // not having an outline to having an outline. | 2011 // not having an outline to having an outline. |
| 2019 repaint(); | 2012 repaint(); |
| 2020 } | 2013 } |
| 2021 } | 2014 } |
| 2022 | 2015 |
| 2023 static inline bool rendererHasBackground(const RenderObject* renderer) | 2016 static inline bool rendererHasBackground(const RenderObject* renderer) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 } | 2129 } |
| 2137 | 2130 |
| 2138 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) | 2131 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) |
| 2139 { | 2132 { |
| 2140 if (s_affectsParentBlock) | 2133 if (s_affectsParentBlock) |
| 2141 handleDynamicFloatPositionChange(); | 2134 handleDynamicFloatPositionChange(); |
| 2142 | 2135 |
| 2143 if (!m_parent) | 2136 if (!m_parent) |
| 2144 return; | 2137 return; |
| 2145 | 2138 |
| 2146 if (diff == StyleDifferenceLayout) { | 2139 if (diff == StyleDifferenceLayout || diff == StyleDifferenceSimplifiedLayout
) { |
| 2147 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); | 2140 RenderCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); |
| 2148 | 2141 |
| 2149 // If the object already needs layout, then setNeedsLayout won't do | 2142 // If the object already needs layout, then setNeedsLayout won't do |
| 2150 // any work. But if the containing block has changed, then we may need | 2143 // any work. But if the containing block has changed, then we may need |
| 2151 // to mark the new containing blocks for layout. The change that can | 2144 // to mark the new containing blocks for layout. The change that can |
| 2152 // directly affect the containing block of this object is a change to | 2145 // directly affect the containing block of this object is a change to |
| 2153 // the position style. | 2146 // the position style. |
| 2154 if (needsLayout() && oldStyle->position() != m_style->position()) | 2147 if (needsLayout() && oldStyle->position() != m_style->position()) |
| 2155 markContainingBlocksForLayout(); | 2148 markContainingBlocksForLayout(); |
| 2156 | 2149 |
| 2157 // Ditto. | |
| 2158 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s
tyle->position()) | |
| 2159 markContainingBlocksForOverflowRecalc(); | |
| 2160 | |
| 2161 if (diff == StyleDifferenceLayout) | 2150 if (diff == StyleDifferenceLayout) |
| 2162 setNeedsLayoutAndPrefWidthsRecalc(); | 2151 setNeedsLayoutAndPrefWidthsRecalc(); |
| 2152 else |
| 2153 setNeedsSimplifiedNormalFlowLayout(); |
| 2154 } else if (diff == StyleDifferenceSimplifiedLayoutAndPositionedMovement) { |
| 2155 setNeedsPositionedMovementLayout(); |
| 2156 setNeedsSimplifiedNormalFlowLayout(); |
| 2163 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly) | 2157 } else if (diff == StyleDifferenceLayoutPositionedMovementOnly) |
| 2164 setNeedsPositionedMovementLayout(); | 2158 setNeedsPositionedMovementLayout(); |
| 2165 | 2159 |
| 2166 // Don't check for repaint here; we need to wait until the layer has been | 2160 // Don't check for repaint here; we need to wait until the layer has been |
| 2167 // updated by subclasses before we know if we have to repaint (in setStyle()
). | 2161 // updated by subclasses before we know if we have to repaint (in setStyle()
). |
| 2168 | 2162 |
| 2169 if (oldStyle && !areCursorsEqual(oldStyle, style())) { | 2163 if (oldStyle && !areCursorsEqual(oldStyle, style())) { |
| 2170 if (LocalFrame* frame = this->frame()) | 2164 if (LocalFrame* frame = this->frame()) |
| 2171 frame->eventHandler().scheduleCursorUpdate(); | 2165 frame->eventHandler().scheduleCursorUpdate(); |
| 2172 } | 2166 } |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3396 { | 3390 { |
| 3397 if (object1) { | 3391 if (object1) { |
| 3398 const WebCore::RenderObject* root = object1; | 3392 const WebCore::RenderObject* root = object1; |
| 3399 while (root->parent()) | 3393 while (root->parent()) |
| 3400 root = root->parent(); | 3394 root = root->parent(); |
| 3401 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3395 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3402 } | 3396 } |
| 3403 } | 3397 } |
| 3404 | 3398 |
| 3405 #endif | 3399 #endif |
| OLD | NEW |