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 "config.h" | 5 #include "config.h" |
| 6 #include "core/layout/PaintInvalidationState.h" | 6 #include "core/layout/PaintInvalidationState.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/layout/svg/LayoutSVGModelObject.h" | 10 #include "core/layout/svg/LayoutSVGModelObject.h" |
| 11 #include "core/layout/svg/LayoutSVGRoot.h" | 11 #include "core/layout/svg/LayoutSVGRoot.h" |
| 12 #include "core/paint/DeprecatedPaintLayer.h" | 12 #include "core/paint/DeprecatedPaintLayer.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState) | 16 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState) |
| 17 : m_clipped(false) | 17 : m_clipped(false) |
| 18 , m_cachedOffsetsEnabled(true) | 18 , m_cachedOffsetsEnabled(true) |
| 19 , m_ancestorHadPaintInvalidationForLocationChange(false) | 19 , m_forcedPaintInvalidation(false) |
| 20 , m_paintInvalidationContainer(*layoutView.containerForPaintInvalidation()) | 20 , m_paintInvalidationContainer(*layoutView.containerForPaintInvalidation()) |
| 21 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) | 21 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) |
| 22 { | 22 { |
| 23 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; | 23 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; |
| 24 if (!establishesPaintInvalidationContainer) { | 24 if (!establishesPaintInvalidationContainer) { |
| 25 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled) | 25 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled) |
| 26 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { | 26 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { |
| 27 m_cachedOffsetsEnabled = false; | 27 m_cachedOffsetsEnabled = false; |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_ancest orHadPaintInvalidationForLocationChange) | 30 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced PaintInvalidation) |
| 31 m_ancestorHadPaintInvalidationForLocationChange = true; | 31 m_forcedPaintInvalidation = true; |
| 32 FloatPoint point = layoutView.localToContainerPoint(FloatPoint(), &m_pai ntInvalidationContainer, TraverseDocumentBoundaries); | 32 FloatPoint point = layoutView.localToContainerPoint(FloatPoint(), &m_pai ntInvalidationContainer, TraverseDocumentBoundaries); |
| 33 m_paintOffset = LayoutSize(point.x(), point.y()); | 33 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 34 } | 34 } |
| 35 m_clipRect = layoutView.viewRect(); | 35 m_clipRect = layoutView.viewRect(); |
| 36 m_clipRect.move(m_paintOffset); | 36 m_clipRect.move(m_paintOffset); |
| 37 m_clipped = true; | 37 m_clipped = true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo ntainer) | 40 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo ntainer) |
| 41 : m_clipped(false) | 41 : m_clipped(false) |
| 42 , m_cachedOffsetsEnabled(true) | 42 , m_cachedOffsetsEnabled(true) |
| 43 , m_ancestorHadPaintInvalidationForLocationChange(next.m_ancestorHadPaintInv alidationForLocationChange) | 43 , m_forcedPaintInvalidation(next.m_forcedPaintInvalidation) |
| 44 , m_paintInvalidationContainer(paintInvalidationContainer) | 44 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 45 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) | 45 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) |
| 46 { | 46 { |
| 47 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 | 47 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 |
| 48 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer; | 48 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer; |
| 49 bool fixed = layoutObject.style()->position() == FixedPosition; | 49 bool fixed = layoutObject.style()->position() == FixedPosition; |
| 50 | 50 |
| 51 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) | 51 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) |
| 52 m_cachedOffsetsEnabled = false; | 52 m_cachedOffsetsEnabled = false; |
| 53 if (establishesPaintInvalidationContainer) { | 53 if (establishesPaintInvalidationContainer) { |
| 54 // When we hit a new paint invalidation container, we don't need to | 54 // When we hit a new paint invalidation container, we don't need to |
| 55 // continue forcing a check for paint invalidation because movement | 55 // continue forcing a check for paint invalidation because movement |
| 56 // from our parents will just move the whole invalidation container. | 56 // from our parents will just move the whole invalidation container. |
|
pdr.
2015/09/15 02:33:39
Can you update this comment?
fs
2015/09/15 08:44:35
Done.
| |
| 57 m_ancestorHadPaintInvalidationForLocationChange = false; | 57 m_forcedPaintInvalidation = false; |
| 58 } else { | 58 } else { |
| 59 if (m_cachedOffsetsEnabled) { | 59 if (m_cachedOffsetsEnabled) { |
| 60 if (fixed) { | 60 if (fixed) { |
| 61 FloatPoint fixedOffset = layoutObject.localToContainerPoint(Floa tPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); | 61 FloatPoint fixedOffset = layoutObject.localToContainerPoint(Floa tPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); |
| 62 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); | 62 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); |
| 63 } else { | 63 } else { |
| 64 LayoutSize offset = layoutObject.isBox() && !layoutObject.isTabl eRow() ? toLayoutBox(layoutObject).locationOffset() : LayoutSize(); | 64 LayoutSize offset = layoutObject.isBox() && !layoutObject.isTabl eRow() ? toLayoutBox(layoutObject).locationOffset() : LayoutSize(); |
| 65 m_paintOffset = next.m_paintOffset + offset; | 65 m_paintOffset = next.m_paintOffset + offset; |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 89 } | 89 } |
| 90 | 90 |
| 91 applyClipIfNeeded(layoutObject); | 91 applyClipIfNeeded(layoutObject); |
| 92 | 92 |
| 93 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | 93 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. |
| 94 } | 94 } |
| 95 | 95 |
| 96 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutSVGModelObject& layoutObject) | 96 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutSVGModelObject& layoutObject) |
| 97 : m_clipped(next.m_clipped) | 97 : m_clipped(next.m_clipped) |
| 98 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | 98 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) |
| 99 , m_ancestorHadPaintInvalidationForLocationChange(next.m_ancestorHadPaintInv alidationForLocationChange) | 99 , m_forcedPaintInvalidation(next.m_forcedPaintInvalidation) |
| 100 , m_clipRect(next.m_clipRect) | 100 , m_clipRect(next.m_clipRect) |
| 101 , m_paintOffset(next.m_paintOffset) | 101 , m_paintOffset(next.m_paintOffset) |
| 102 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) | 102 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) |
| 103 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) | 103 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) |
| 104 { | 104 { |
| 105 ASSERT(layoutObject != m_paintInvalidationContainer); | 105 ASSERT(layoutObject != m_paintInvalidationContainer); |
| 106 | 106 |
| 107 if (m_cachedOffsetsEnabled) | 107 if (m_cachedOffsetsEnabled) |
| 108 m_svgTransform = adoptPtr(new AffineTransform(next.svgTransform() * layo utObject.localToParentTransform())); | 108 m_svgTransform = adoptPtr(new AffineTransform(next.svgTransform() * layo utObject.localToParentTransform())); |
| 109 } | 109 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 130 // to be always invalidated in-time. | 130 // to be always invalidated in-time. |
| 131 if (box.usesCompositedScrolling()) | 131 if (box.usesCompositedScrolling()) |
| 132 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. | 132 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. |
| 133 else | 133 else |
| 134 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | 134 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); |
| 135 | 135 |
| 136 m_paintOffset -= box.scrolledContentOffset(); | 136 m_paintOffset -= box.scrolledContentOffset(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace blink | 139 } // namespace blink |
| OLD | NEW |