Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutInline.h" | 7 #include "core/layout/LayoutInline.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/layout/svg/LayoutSVGModelObject.h" | 9 #include "core/layout/svg/LayoutSVGModelObject.h" |
| 10 #include "core/layout/svg/LayoutSVGRoot.h" | 10 #include "core/layout/svg/LayoutSVGRoot.h" |
| 11 #include "core/layout/svg/SVGLayoutSupport.h" | |
| 11 #include "core/paint/PaintLayer.h" | 12 #include "core/paint/PaintLayer.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, const PaintInvalidationSta te* ownerPaintInvalidationState) | 16 static LayoutSize computeViewPaintOffset(const LayoutView& layoutView, const Lay outBoxModelObject& paintInvalidationContainer) |
|
chrishtr
2016/03/24 00:53:52
computePaintOffsetFromViewToContainer.
Rename pai
Xianzhu
2016/03/25 16:35:54
Inlined this into the only call site after the oth
| |
| 17 { | |
| 18 LayoutView::setViewClippingAndScrollOffsetDisabled(true); | |
| 19 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &paintInval idationContainer, TraverseDocumentBoundaries); | |
| 20 LayoutView::setViewClippingAndScrollOffsetDisabled(false); | |
| 21 return LayoutSize(point.x(), point.y()); | |
| 22 } | |
| 23 | |
| 24 static bool supportsCachedOffsets(const LayoutObject& object) | |
| 25 { | |
| 26 // TODO(wangxianzhu): Move some conditions to fast path if possible. | |
| 27 return !object.hasTransformRelatedProperty() | |
| 28 && !object.hasReflection() | |
| 29 && !object.hasFilter() | |
| 30 && !object.isLayoutFlowThread(); | |
| 31 } | |
| 32 | |
| 33 static bool supportsCachedOffsetsForChildren(const LayoutObject& object) | |
|
chrishtr
2016/03/24 16:58:53
What's the purpose of distinguishing this from sup
Xianzhu
2016/03/25 16:35:54
The old code didn't separate paintOffset adjustmen
| |
| 34 { | |
| 35 ASSERT(supportsCachedOffsets(object)); | |
| 36 return !object.styleRef().isFlippedBlocksWritingMode(); | |
| 37 } | |
| 38 | |
| 39 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations) | |
| 16 : m_currentObject(layoutView) | 40 : m_currentObject(layoutView) |
| 17 , m_clipped(false) | 41 , m_clipped(false) |
| 18 , m_cachedOffsetsEnabled(true) | 42 , m_cachedOffsetsEnabled(true) |
| 19 , m_forcedSubtreeInvalidationWithinContainer(false) | 43 , m_forcedSubtreeInvalidationWithinContainer(false) |
| 20 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) | 44 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) |
| 21 , m_viewClippingAndScrollOffsetDisabled(false) | |
| 22 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) | 45 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) |
| 23 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) | 46 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) |
| 24 , m_enclosingSelfPaintingLayer(*layoutView.layer()) | 47 , m_enclosingSelfPaintingLayer(*layoutView.layer()) |
| 25 #if ENABLE(ASSERT) | 48 #if ENABLE(ASSERT) |
| 26 , m_didUpdatePaintOffsetAndClipForChildren(true) | 49 , m_didUpdateForChildren(false) |
| 27 #endif | 50 #endif |
| 28 { | 51 { |
| 29 ASSERT(!ownerPaintInvalidationState || ownerPaintInvalidationState->m_didUpd atePaintOffsetAndClipForChildren); | 52 if (!supportsCachedOffsets(layoutView)) { |
| 53 m_cachedOffsetsEnabled = false; | |
| 54 return; | |
| 55 } | |
| 30 | 56 |
| 31 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; | 57 m_paintOffset = computeViewPaintOffset(layoutView, m_paintInvalidationContai ner); |
| 32 if (!establishesPaintInvalidationContainer) { | |
| 33 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled) | |
| 34 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { | |
| 35 m_cachedOffsetsEnabled = false; | |
| 36 return; | |
| 37 } | |
| 38 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer) | |
| 39 m_forcedSubtreeInvalidationWithinContainer = true; | |
| 40 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries); | |
| 41 m_paintOffset = LayoutSize(point.x(), point.y()); | |
| 42 } | |
| 43 m_clipRect = layoutView.viewRect(); | |
| 44 m_clipRect.move(m_paintOffset); | |
| 45 m_clipped = true; | |
| 46 } | 58 } |
| 47 | 59 |
| 48 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid ationContainer is different from | 60 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid ationContainer is different from |
| 49 // the one we find during tree walk. Remove this after we fix the issue with tre e walk in DOM-order. | 61 // the one we find during tree walk. Remove this after we fix the issue with tre e walk in DOM-order. |
| 50 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer) | 62 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer) |
| 51 : m_currentObject(currentObject) | 63 : m_currentObject(currentObject) |
| 52 , m_clipped(parentState.m_clipped) | 64 , m_clipped(parentState.m_clipped) |
| 53 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) | 65 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) |
| 54 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) | 66 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) |
| 55 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) | 67 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) |
| 56 , m_viewClippingAndScrollOffsetDisabled(false) | |
| 57 , m_clipRect(parentState.m_clipRect) | 68 , m_clipRect(parentState.m_clipRect) |
| 58 , m_paintOffset(parentState.m_paintOffset) | 69 , m_paintOffset(parentState.m_paintOffset) |
| 59 , m_paintInvalidationContainer(paintInvalidationContainer) | 70 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 60 , m_svgTransform(parentState.m_svgTransform) | 71 , m_svgTransform(parentState.m_svgTransform) |
| 61 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) | 72 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) |
| 62 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) | 73 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) |
| 63 #if ENABLE(ASSERT) | 74 #if ENABLE(ASSERT) |
| 64 , m_didUpdatePaintOffsetAndClipForChildren(true) | 75 , m_didUpdateForChildren(true) |
| 65 #endif | 76 #endif |
| 66 { | 77 { |
| 67 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); | 78 ASSERT(parentState.m_didUpdateForChildren); |
| 68 ASSERT(!m_cachedOffsetsEnabled); | 79 ASSERT(!m_cachedOffsetsEnabled); |
| 69 } | 80 } |
| 70 | 81 |
| 71 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject) | 82 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject) |
| 72 : m_currentObject(currentObject) | 83 : m_currentObject(currentObject) |
| 73 , m_clipped(parentState.m_clipped) | 84 , m_clipped(parentState.m_clipped) |
| 74 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) | 85 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) |
| 75 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) | 86 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) |
| 76 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) | 87 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) |
| 77 , m_viewClippingAndScrollOffsetDisabled(false) | |
| 78 , m_clipRect(parentState.m_clipRect) | 88 , m_clipRect(parentState.m_clipRect) |
| 79 , m_paintOffset(parentState.m_paintOffset) | 89 , m_paintOffset(parentState.m_paintOffset) |
| 80 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er) | 90 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er) |
| 81 , m_svgTransform(parentState.m_svgTransform) | 91 , m_svgTransform(parentState.m_svgTransform) |
| 82 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) | 92 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) |
| 83 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) | 93 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) |
| 84 #if ENABLE(ASSERT) | 94 #if ENABLE(ASSERT) |
| 85 , m_didUpdatePaintOffsetAndClipForChildren(false) | 95 , m_didUpdateForChildren(false) |
| 86 #endif | 96 #endif |
| 87 { | 97 { |
| 88 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); | 98 if (currentObject == parentState.m_currentObject) { |
| 89 } | 99 // Sometimes we create a new PaintInvalidationState from parentState on the same object. |
|
chrishtr
2016/03/24 16:58:53
Are the cases the "horribly-slow" exceptions in La
Xianzhu
2016/03/25 16:35:54
Yes, and another case is LayoutView. FrameView/Lay
| |
| 90 | 100 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai ntInvalidationEnabled(). |
| 91 void PaintInvalidationState::updatePaintOffsetAndClipForChildren() | |
| 92 { | |
| 93 #if ENABLE(ASSERT) | 101 #if ENABLE(ASSERT) |
| 94 ASSERT(!m_didUpdatePaintOffsetAndClipForChildren); | 102 m_didUpdateForChildren = parentState.m_didUpdateForChildren; |
| 95 m_didUpdatePaintOffsetAndClipForChildren = true; | |
| 96 #endif | 103 #endif |
| 97 | |
| 98 bool establishesPaintInvalidationContainer = m_currentObject == m_paintInval idationContainer; | |
| 99 | |
| 100 if (!m_currentObject.isBoxModelObject()) { | |
| 101 // TODO(wangxianzhu): SVG could probably benefit from a stack-based opti mization like html does. crbug.com/391054. | |
| 102 ASSERT(m_currentObject.isSVG()); | |
| 103 ASSERT(!establishesPaintInvalidationContainer); | |
| 104 if (m_cachedOffsetsEnabled) | |
| 105 m_svgTransform = AffineTransform(m_svgTransform * m_currentObject.lo calToSVGParentTransform()); | |
| 106 return; | 104 return; |
| 107 } | 105 } |
| 108 | 106 |
| 109 bool fixed = m_currentObject.style()->position() == FixedPosition; | 107 ASSERT(parentState.m_didUpdateForChildren); |
| 110 | 108 |
| 111 if (!m_currentObject.supportsPaintInvalidationStateCachedOffsets()) | 109 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) |
| 112 m_cachedOffsetsEnabled = false; | 110 return; |
| 113 if (establishesPaintInvalidationContainer) { | 111 |
| 112 if (m_cachedOffsetsEnabled) { | |
|
chrishtr
2016/03/24 16:58:53
Can this just be (combining also logic from line 1
Xianzhu
2016/03/25 16:35:54
Rearranged the code to set m_svgTransform regardle
| |
| 113 if (!supportsCachedOffsets(currentObject)) | |
| 114 m_cachedOffsetsEnabled = false; | |
| 115 else if (currentObject.isSVGRoot()) | |
| 116 m_svgTransform = AffineTransform(toLayoutSVGRoot(currentObject).loca lToBorderBoxTransform()); | |
| 117 } | |
| 118 | |
| 119 if (currentObject == m_paintInvalidationContainer) { | |
| 114 // When we hit a new paint invalidation container, we don't need to | 120 // When we hit a new paint invalidation container, we don't need to |
| 115 // continue forcing a check for paint invalidation, since we're | 121 // continue forcing a check for paint invalidation, since we're |
| 116 // descending into a different invalidation container. (For instance if | 122 // descending into a different invalidation container. (For instance if |
| 117 // our parents were moved, the entire container will just move.) | 123 // our parents were moved, the entire container will just move.) |
| 118 m_forcedSubtreeInvalidationWithinContainer = false; | 124 m_forcedSubtreeInvalidationWithinContainer = false; |
| 119 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false; | 125 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false; |
| 120 | 126 |
| 121 m_clipped = false; // Will be updated in applyClipIfNeeded(). | 127 m_clipped = false; // Will be updated in updateForChildren(). |
| 122 m_paintOffset = LayoutSize(); | 128 m_paintOffset = LayoutSize(); |
| 123 } else { | 129 return; |
| 124 if (m_cachedOffsetsEnabled) { | |
| 125 if (fixed) { | |
| 126 FloatPoint fixedOffset = m_currentObject.localToAncestorPoint(Fl oatPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); | |
| 127 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); | |
| 128 } else if (m_currentObject.isBox() && !m_currentObject.isTableRow()) { | |
| 129 // We don't add locationOffset of table row because the child ce lls' location offsets include the row's location offset. | |
| 130 m_paintOffset += toLayoutBox(m_currentObject).locationOffset(); | |
| 131 } | |
| 132 | |
| 133 if (m_currentObject.isOutOfFlowPositioned() && !fixed) { | |
| 134 if (LayoutObject* container = m_currentObject.container()) { | |
| 135 if (container->isInFlowPositioned() && container->isLayoutIn line()) | |
| 136 m_paintOffset += toLayoutInline(container)->offsetForInF lowPositionedInline(toLayoutBox(m_currentObject)); | |
| 137 } | |
| 138 } | |
| 139 | |
| 140 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer ()) | |
| 141 m_paintOffset += toLayoutBoxModelObject(m_currentObject).layer() ->offsetForInFlowPosition(); | |
| 142 } | |
| 143 | |
| 144 m_clipped = !fixed && m_clipped; | |
| 145 } | 130 } |
| 146 | 131 |
| 147 if (m_cachedOffsetsEnabled && m_currentObject.isSVGRoot()) { | 132 if (!m_cachedOffsetsEnabled) |
| 133 return; | |
| 134 | |
| 135 if (currentObject.isSVG() && !currentObject.isSVGRoot()) { | |
| 136 // TODO(wangxianzhu): SVG could probably benefit from a stack-based opti mization like html does. crbug.com/391054. | |
| 137 m_svgTransform = AffineTransform(m_svgTransform * currentObject.localToS VGParentTransform()); | |
|
chrishtr
2016/03/24 01:05:42
How about a collection of unittests for all of the
chrishtr
2016/03/24 16:58:53
Another option: make this method a helper method,
Xianzhu
2016/03/25 16:35:54
Added ASSERTs in debug mode.
| |
| 138 return; | |
| 139 } | |
| 140 | |
| 141 if (currentObject.isLayoutView()) { | |
| 142 m_paintOffset = computeViewPaintOffset(toLayoutView(currentObject), m_pa intInvalidationContainer); | |
|
chrishtr
2016/03/24 00:53:52
This is an O(tree depth) computation. Is there no
Xianzhu
2016/03/25 16:35:54
Done.
| |
| 143 return; | |
| 144 } | |
| 145 | |
| 146 if (currentObject.styleRef().position() == FixedPosition) { | |
| 147 // TODO(wangxianzhu): Replace localToAncestorPoint with fast path. | |
| 148 FloatPoint fixedOffset = currentObject.localToAncestorPoint(FloatPoint() , &m_paintInvalidationContainer, TraverseDocumentBoundaries); | |
| 149 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); | |
| 150 m_clipped = false; | |
| 151 return; | |
| 152 } | |
| 153 | |
| 154 if (currentObject.isBox()) { | |
| 155 m_paintOffset += toLayoutBox(currentObject).locationOffset(); | |
|
chrishtr
2016/03/24 16:58:53
This code looks different than the old code. The o
Xianzhu
2016/03/25 16:35:54
In this CL, paintOffset adjustment for the current
| |
| 156 if (currentObject.isTableCell()) { | |
| 157 // A table cell's locationOffset() includes its row's locationOffset (). | |
| 158 m_paintOffset -= toLayoutBox(currentObject.parent())->locationOffset (); | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 if (currentObject.styleRef().position() == AbsolutePosition) { | |
| 163 if (LayoutObject* container = currentObject.container()) { | |
| 164 if (container->isInFlowPositioned() && container->isLayoutInline()) | |
| 165 m_paintOffset += toLayoutInline(container)->offsetForInFlowPosit ionedInline(toLayoutBox(currentObject)); | |
| 166 } | |
| 167 return; | |
| 168 } | |
| 169 | |
| 170 if (currentObject.isInFlowPositioned() && currentObject.hasLayer()) | |
| 171 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offsetFo rInFlowPosition(); | |
| 172 } | |
| 173 | |
| 174 void PaintInvalidationState::updateForChildren() | |
| 175 { | |
| 176 #if ENABLE(ASSERT) | |
| 177 ASSERT(!m_didUpdateForChildren); | |
| 178 m_didUpdateForChildren = true; | |
| 179 #endif | |
| 180 | |
| 181 if (!m_cachedOffsetsEnabled) | |
| 182 return; | |
| 183 | |
| 184 if (!supportsCachedOffsetsForChildren(m_currentObject)) { | |
| 185 m_cachedOffsetsEnabled = false; | |
| 186 return; | |
| 187 } | |
| 188 | |
| 189 if (!m_currentObject.isBoxModelObject() && !m_currentObject.isSVG()) | |
| 190 return; | |
|
chrishtr
2016/03/24 16:58:53
The old code asserted that isSVG is true...why the
Xianzhu
2016/03/25 16:35:54
Previously we didn't create new PaintInvalidationS
| |
| 191 | |
| 192 if (m_currentObject.isLayoutView()) { | |
| 193 if (m_currentObject != m_paintInvalidationContainer) { | |
| 194 // TODO(wangxianzhu): Replace localToAncestorPoint with fast path. | |
|
chrishtr
2016/03/24 00:53:52
Looks like this is referring to the fast path I su
Xianzhu
2016/03/25 16:35:54
Done.
| |
| 195 FloatPoint viewOffset = m_currentObject.localToAncestorPoint(FloatPo int(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); | |
| 196 m_paintOffset = LayoutSize(viewOffset.x(), viewOffset.y()); | |
| 197 m_clipRect = toLayoutView(m_currentObject).viewRect(); | |
| 198 m_clipRect.move(m_paintOffset); | |
| 199 m_clipped = true; | |
| 200 return; | |
| 201 } | |
| 202 } else if (m_currentObject.isSVGRoot()) { | |
| 148 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject); | 203 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject); |
| 149 m_svgTransform = AffineTransform(svgRoot.localToBorderBoxTransform()); | |
| 150 if (svgRoot.shouldApplyViewportClip()) | 204 if (svgRoot.shouldApplyViewportClip()) |
| 151 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ())); | 205 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ())); |
| 152 } | 206 } |
| 153 | 207 |
| 154 applyClipIfNeeded(); | 208 if (!m_currentObject.hasOverflowClip()) |
| 209 return; | |
| 210 | |
| 211 const LayoutBox& box = toLayoutBox(m_currentObject); | |
| 212 | |
| 213 // Do not clip scroll layer contents because the compositor expects the whol e layer | |
| 214 // to be always invalidated in-time. | |
| 215 if (box.usesCompositedScrolling()) | |
| 216 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. | |
| 217 else | |
| 218 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | |
| 219 | |
| 220 m_paintOffset -= box.scrolledContentOffset(); | |
| 155 | 221 |
| 156 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | 222 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. |
| 157 } | 223 } |
| 158 | 224 |
| 159 void PaintInvalidationState::mapObjectRectToAncestor(const LayoutObject& object, const LayoutBoxModelObject* ancestor, LayoutRect& rect) const | 225 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const |
| 160 { | 226 { |
| 161 ASSERT(canMapToAncestor(ancestor)); | 227 FloatPoint point; |
| 162 | 228 if (m_paintInvalidationContainer != m_currentObject) { |
| 163 if (ancestor == &object) { | 229 if (m_cachedOffsetsEnabled) { |
| 164 if (object.isBox() && object.styleRef().isFlippedBlocksWritingMode()) | 230 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) |
| 165 toLayoutBox(object).flipForWritingMode(rect); | 231 point = m_svgTransform.mapPoint(point); |
| 166 return; | 232 point += FloatPoint(m_paintOffset); |
| 233 } else { | |
| 234 // Fallback to slow path. | |
| 235 point = m_currentObject.localToAncestorPoint(FloatPoint(), &m_paintI nvalidationContainer); | |
| 236 } | |
| 167 } | 237 } |
| 168 | 238 |
| 169 if (object.hasLayer()) { | 239 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 170 if (const TransformationMatrix* transform = toLayoutBoxModelObject(objec t).layer()->transform()) | 240 PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalid ationContainer, point); |
| 171 rect = LayoutRect(transform->mapRect(pixelSnappedIntRect(rect))); | |
| 172 | 241 |
| 173 if (object.isInFlowPositioned()) | 242 return LayoutPoint(point); |
| 174 rect.move(toLayoutBoxModelObject(object).layer()->offsetForInFlowPos ition()); | 243 } |
| 244 | |
| 245 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const | |
| 246 { | |
| 247 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) | |
| 248 return computePaintInvalidationRectInBackingForSVG(); | |
| 249 | |
| 250 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation(); | |
| 251 mapLocalRectToPaintInvalidationBacking(rect); | |
| 252 return rect; | |
| 253 } | |
| 254 | |
| 255 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const | |
| 256 { | |
| 257 LayoutRect rect; | |
| 258 if (m_cachedOffsetsEnabled) { | |
| 259 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat ion(m_currentObject); | |
| 260 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject, m_svgTransform, svgRect); | |
| 261 rect.move(m_paintOffset); | |
| 262 if (m_clipped) | |
| 263 rect.intersect(m_clipRect); | |
| 264 } else { | |
| 265 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre ntObject, m_paintInvalidationContainer); | |
| 175 } | 266 } |
| 176 | 267 |
| 177 if (object.isBox()) | 268 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 178 rect.moveBy(toLayoutBox(object).location()); | 269 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect); |
| 270 return rect; | |
| 271 } | |
| 179 | 272 |
| 180 rect.move(m_paintOffset); | 273 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect& rect) const |
| 274 { | |
| 275 if (m_cachedOffsetsEnabled) { | |
| 276 rect.move(m_paintOffset); | |
| 277 if (m_clipped) | |
| 278 rect.intersect(m_clipRect); | |
| 279 } else { | |
| 280 // Fallback to slow path. | |
| 281 m_currentObject.mapToVisibleRectInAncestorSpace(&m_paintInvalidationCont ainer, rect); | |
| 282 } | |
| 181 | 283 |
| 182 if (m_clipped) | 284 if (m_paintInvalidationContainer.layer()->groupedMapping()) |
| 183 rect.intersect(m_clipRect); | 285 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect); |
| 184 } | 286 } |
| 185 | 287 |
| 186 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) | 288 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) |
| 187 { | 289 { |
| 188 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); | 290 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); |
| 189 if (m_clipped) { | 291 if (m_clipped) { |
| 190 m_clipRect.intersect(clipRect); | 292 m_clipRect.intersect(clipRect); |
| 191 } else { | 293 } else { |
| 192 m_clipRect = clipRect; | 294 m_clipRect = clipRect; |
| 193 m_clipped = true; | 295 m_clipped = true; |
| 194 } | 296 } |
| 195 } | 297 } |
| 196 | 298 |
| 197 void PaintInvalidationState::applyClipIfNeeded() | |
| 198 { | |
| 199 if (!m_currentObject.hasOverflowClip()) | |
| 200 return; | |
| 201 | |
| 202 const LayoutBox& box = toLayoutBox(m_currentObject); | |
| 203 | |
| 204 // Do not clip scroll layer contents because the compositor expects the whol e layer | |
| 205 // to be always invalidated in-time. | |
| 206 if (box.usesCompositedScrolling()) | |
| 207 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. | |
| 208 else | |
| 209 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | |
| 210 | |
| 211 m_paintOffset -= box.scrolledContentOffset(); | |
| 212 } | |
| 213 | |
| 214 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const | 299 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const |
| 215 { | 300 { |
| 216 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) | 301 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) |
| 217 return *toLayoutBoxModelObject(layoutObject).layer(); | 302 return *toLayoutBoxModelObject(layoutObject).layer(); |
| 218 | 303 |
| 219 return m_enclosingSelfPaintingLayer; | 304 return m_enclosingSelfPaintingLayer; |
| 220 } | 305 } |
| 221 | 306 |
| 222 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |