| 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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 7 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 #include "core/rendering/RenderLayerModelObject.h" | 26 #include "core/layout/LayoutLayerModelObject.h" |
| 27 | 27 |
| 28 #include "core/frame/LocalFrame.h" | 28 #include "core/frame/LocalFrame.h" |
| 29 #include "core/layout/Layer.h" |
| 29 #include "core/layout/compositing/CompositedLayerMapping.h" | 30 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 30 #include "core/rendering/RenderLayer.h" | |
| 31 #include "core/rendering/RenderView.h" | 31 #include "core/rendering/RenderView.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 bool RenderLayerModelObject::s_wasFloating = false; | 35 bool LayoutLayerModelObject::s_wasFloating = false; |
| 36 | 36 |
| 37 RenderLayerModelObject::RenderLayerModelObject(ContainerNode* node) | 37 LayoutLayerModelObject::LayoutLayerModelObject(ContainerNode* node) |
| 38 : RenderObject(node) | 38 : RenderObject(node) |
| 39 { | 39 { |
| 40 } | 40 } |
| 41 | 41 |
| 42 RenderLayerModelObject::~RenderLayerModelObject() | 42 LayoutLayerModelObject::~LayoutLayerModelObject() |
| 43 { | 43 { |
| 44 // Our layer should have been destroyed and cleared by now | 44 // Our layer should have been destroyed and cleared by now |
| 45 ASSERT(!hasLayer()); | 45 ASSERT(!hasLayer()); |
| 46 ASSERT(!m_layer); | 46 ASSERT(!m_layer); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void RenderLayerModelObject::destroyLayer() | 49 void LayoutLayerModelObject::destroyLayer() |
| 50 { | 50 { |
| 51 setHasLayer(false); | 51 setHasLayer(false); |
| 52 m_layer = nullptr; | 52 m_layer = nullptr; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void RenderLayerModelObject::createLayer(LayerType type) | 55 void LayoutLayerModelObject::createLayer(LayerType type) |
| 56 { | 56 { |
| 57 ASSERT(!m_layer); | 57 ASSERT(!m_layer); |
| 58 m_layer = adoptPtr(new RenderLayer(this, type)); | 58 m_layer = adoptPtr(new Layer(this, type)); |
| 59 setHasLayer(true); | 59 setHasLayer(true); |
| 60 m_layer->insertOnlyThisLayer(); | 60 m_layer->insertOnlyThisLayer(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool RenderLayerModelObject::hasSelfPaintingLayer() const | 63 bool LayoutLayerModelObject::hasSelfPaintingLayer() const |
| 64 { | 64 { |
| 65 return m_layer && m_layer->isSelfPaintingLayer(); | 65 return m_layer && m_layer->isSelfPaintingLayer(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 RenderLayerScrollableArea* RenderLayerModelObject::scrollableArea() const | 68 LayerScrollableArea* LayoutLayerModelObject::scrollableArea() const |
| 69 { | 69 { |
| 70 return m_layer ? m_layer->scrollableArea() : 0; | 70 return m_layer ? m_layer->scrollableArea() : 0; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void RenderLayerModelObject::willBeDestroyed() | 73 void LayoutLayerModelObject::willBeDestroyed() |
| 74 { | 74 { |
| 75 if (isPositioned()) { | 75 if (isPositioned()) { |
| 76 // Don't use this->view() because the document's renderView has been set
to 0 during destruction. | 76 // Don't use this->view() because the document's renderView has been set
to 0 during destruction. |
| 77 if (LocalFrame* frame = this->frame()) { | 77 if (LocalFrame* frame = this->frame()) { |
| 78 if (FrameView* frameView = frame->view()) { | 78 if (FrameView* frameView = frame->view()) { |
| 79 if (style()->hasViewportConstrainedPosition()) | 79 if (style()->hasViewportConstrainedPosition()) |
| 80 frameView->removeViewportConstrainedObject(this); | 80 frameView->removeViewportConstrainedObject(this); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 RenderObject::willBeDestroyed(); | 85 RenderObject::willBeDestroyed(); |
| 86 | 86 |
| 87 destroyLayer(); | 87 destroyLayer(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void RenderLayerModelObject::styleWillChange(StyleDifference diff, const RenderS
tyle& newStyle) | 90 void LayoutLayerModelObject::styleWillChange(StyleDifference diff, const RenderS
tyle& newStyle) |
| 91 { | 91 { |
| 92 s_wasFloating = isFloating(); | 92 s_wasFloating = isFloating(); |
| 93 | 93 |
| 94 if (RenderStyle* oldStyle = style()) { | 94 if (RenderStyle* oldStyle = style()) { |
| 95 if (parent() && diff.needsPaintInvalidationLayer()) { | 95 if (parent() && diff.needsPaintInvalidationLayer()) { |
| 96 if (oldStyle->hasAutoClip() != newStyle.hasAutoClip() | 96 if (oldStyle->hasAutoClip() != newStyle.hasAutoClip() |
| 97 || oldStyle->clip() != newStyle.clip()) | 97 || oldStyle->clip() != newStyle.clip()) |
| 98 layer()->clipper().clearClipRectsIncludingDescendants(); | 98 layer()->clipper().clearClipRectsIncludingDescendants(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 RenderObject::styleWillChange(diff, newStyle); | 102 RenderObject::styleWillChange(diff, newStyle); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderSt
yle* oldStyle) | 105 void LayoutLayerModelObject::styleDidChange(StyleDifference diff, const RenderSt
yle* oldStyle) |
| 106 { | 106 { |
| 107 bool hadTransform = hasTransformRelatedProperty(); | 107 bool hadTransform = hasTransformRelatedProperty(); |
| 108 bool hadLayer = hasLayer(); | 108 bool hadLayer = hasLayer(); |
| 109 bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer(); | 109 bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer(); |
| 110 | 110 |
| 111 RenderObject::styleDidChange(diff, oldStyle); | 111 RenderObject::styleDidChange(diff, oldStyle); |
| 112 updateFromStyle(); | 112 updateFromStyle(); |
| 113 | 113 |
| 114 LayerType type = layerTypeRequired(); | 114 LayerType type = layerTypeRequired(); |
| 115 if (type != NoLayer) { | 115 if (type != NoLayer) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo
nstrainedPosition(); | 147 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo
nstrainedPosition(); |
| 148 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { | 148 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { |
| 149 if (newStyleIsViewportConstained && layer()) | 149 if (newStyleIsViewportConstained && layer()) |
| 150 frameView->addViewportConstrainedObject(this); | 150 frameView->addViewportConstrainedObject(this); |
| 151 else | 151 else |
| 152 frameView->removeViewportConstrainedObject(this); | 152 frameView->removeViewportConstrainedObject(this); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 void RenderLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, cons
t RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& c
ontainerRect) const | 157 void LayoutLayerModelObject::addLayerHitTestRects(LayerHitTestRects& rects, cons
t Layer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& contain
erRect) const |
| 158 { | 158 { |
| 159 if (hasLayer()) { | 159 if (hasLayer()) { |
| 160 if (isRenderView()) { | 160 if (isRenderView()) { |
| 161 // RenderView is handled with a special fast-path, but it needs to k
now the current layer. | 161 // RenderView is handled with a special fast-path, but it needs to k
now the current layer. |
| 162 RenderObject::addLayerHitTestRects(rects, layer(), LayoutPoint(), La
youtRect()); | 162 RenderObject::addLayerHitTestRects(rects, layer(), LayoutPoint(), La
youtRect()); |
| 163 } else { | 163 } else { |
| 164 // Since a RenderObject never lives outside it's container RenderLay
er, we can switch | 164 // Since a RenderObject never lives outside it's container Layer, we
can switch |
| 165 // to marking entire layers instead. This may sometimes mark more th
an necessary (when | 165 // to marking entire layers instead. This may sometimes mark more th
an necessary (when |
| 166 // a layer is made of disjoint objects) but in practice is a signifi
cant performance | 166 // a layer is made of disjoint objects) but in practice is a signifi
cant performance |
| 167 // savings. | 167 // savings. |
| 168 layer()->addLayerHitTestRects(rects); | 168 layer()->addLayerHitTestRects(rects); |
| 169 } | 169 } |
| 170 } else { | 170 } else { |
| 171 RenderObject::addLayerHitTestRects(rects, currentLayer, layerOffset, con
tainerRect); | 171 RenderObject::addLayerHitTestRects(rects, currentLayer, layerOffset, con
tainerRect); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 void RenderLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState
& paintInvalidationState) | 175 void LayoutLayerModelObject::invalidateTreeIfNeeded(const PaintInvalidationState
& paintInvalidationState) |
| 176 { | 176 { |
| 177 ASSERT(!needsLayout()); | 177 ASSERT(!needsLayout()); |
| 178 | 178 |
| 179 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) | 179 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 bool establishesNewPaintInvalidationContainer = isPaintInvalidationContainer
(); | 182 bool establishesNewPaintInvalidationContainer = isPaintInvalidationContainer
(); |
| 183 const RenderLayerModelObject& newPaintInvalidationContainer = *adjustComposi
tedContainerForSpecialAncestors(establishesNewPaintInvalidationContainer ? this
: &paintInvalidationState.paintInvalidationContainer()); | 183 const LayoutLayerModelObject& newPaintInvalidationContainer = *adjustComposi
tedContainerForSpecialAncestors(establishesNewPaintInvalidationContainer ? this
: &paintInvalidationState.paintInvalidationContainer()); |
| 184 // FIXME: This assert should be re-enabled when we move paint invalidation t
o after compositing update. crbug.com/360286 | 184 // FIXME: This assert should be re-enabled when we move paint invalidation t
o after compositing update. crbug.com/360286 |
| 185 // ASSERT(&newPaintInvalidationContainer == containerForPaintInvalidation())
; | 185 // ASSERT(&newPaintInvalidationContainer == containerForPaintInvalidation())
; |
| 186 | 186 |
| 187 PaintInvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationSt
ate, newPaintInvalidationContainer); | 187 PaintInvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationSt
ate, newPaintInvalidationContainer); |
| 188 clearPaintInvalidationState(paintInvalidationState); | 188 clearPaintInvalidationState(paintInvalidationState); |
| 189 | 189 |
| 190 PaintInvalidationState childTreeWalkState(paintInvalidationState, *this, new
PaintInvalidationContainer); | 190 PaintInvalidationState childTreeWalkState(paintInvalidationState, *this, new
PaintInvalidationContainer); |
| 191 if (reason == PaintInvalidationLocationChange) | 191 if (reason == PaintInvalidationLocationChange) |
| 192 childTreeWalkState.setForceCheckForPaintInvalidation(); | 192 childTreeWalkState.setForceCheckForPaintInvalidation(); |
| 193 invalidatePaintOfSubtreesIfNeeded(childTreeWalkState); | 193 invalidatePaintOfSubtreesIfNeeded(childTreeWalkState); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void RenderLayerModelObject::setBackingNeedsPaintInvalidationInRect(const Layout
Rect& r, PaintInvalidationReason invalidationReason) const | 196 void LayoutLayerModelObject::setBackingNeedsPaintInvalidationInRect(const Layout
Rect& r, PaintInvalidationReason invalidationReason) const |
| 197 { | 197 { |
| 198 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible
crash here, | 198 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible
crash here, |
| 199 // so assert but check that the layer is composited. | 199 // so assert but check that the layer is composited. |
| 200 ASSERT(compositingState() != NotComposited); | 200 ASSERT(compositingState() != NotComposited); |
| 201 | 201 |
| 202 // FIXME: generalize accessors to backing GraphicsLayers so that this code i
s squashing-agnostic. | 202 // FIXME: generalize accessors to backing GraphicsLayers so that this code i
s squashing-agnostic. |
| 203 if (layer()->groupedMapping()) { | 203 if (layer()->groupedMapping()) { |
| 204 LayoutRect paintInvalidationRect = r; | 204 LayoutRect paintInvalidationRect = r; |
| 205 if (GraphicsLayer* squashingLayer = layer()->groupedMapping()->squashing
Layer()) { | 205 if (GraphicsLayer* squashingLayer = layer()->groupedMapping()->squashing
Layer()) { |
| 206 // Note: the subpixel accumulation of layer() does not need to be ad
ded here. It is already taken into account. | 206 // Note: the subpixel accumulation of layer() does not need to be ad
ded here. It is already taken into account. |
| 207 squashingLayer->setNeedsDisplayInRect(pixelSnappedIntRect(paintInval
idationRect), invalidationReason); | 207 squashingLayer->setNeedsDisplayInRect(pixelSnappedIntRect(paintInval
idationRect), invalidationReason); |
| 208 } | 208 } |
| 209 } else { | 209 } else { |
| 210 layer()->compositedLayerMapping()->setContentsNeedDisplayInRect(r, inval
idationReason); | 210 layer()->compositedLayerMapping()->setContentsNeedDisplayInRect(r, inval
idationReason); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 void RenderLayerModelObject::addChildFocusRingRects(Vector<LayoutRect>& rects, c
onst LayoutPoint& additionalOffset) const | 214 void LayoutLayerModelObject::addChildFocusRingRects(Vector<LayoutRect>& rects, c
onst LayoutPoint& additionalOffset) const |
| 215 { | 215 { |
| 216 for (RenderObject* current = slowFirstChild(); current; current = current->n
extSibling()) { | 216 for (RenderObject* current = slowFirstChild(); current; current = current->n
extSibling()) { |
| 217 if (current->isText() || current->isListMarker()) | 217 if (current->isText() || current->isListMarker()) |
| 218 continue; | 218 continue; |
| 219 | 219 |
| 220 if (!current->isBox()) { | 220 if (!current->isBox()) { |
| 221 current->addFocusRingRects(rects, additionalOffset); | 221 current->addFocusRingRects(rects, additionalOffset); |
| 222 continue; | 222 continue; |
| 223 } | 223 } |
| 224 | 224 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 236 if (!rect.isEmpty()) { | 236 if (!rect.isEmpty()) { |
| 237 rect.moveBy(additionalOffset); | 237 rect.moveBy(additionalOffset); |
| 238 rects.append(rect); | 238 rects.append(rect); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace blink | 244 } // namespace blink |
| 245 | 245 |
| OLD | NEW |