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/rendering/PaintInvalidationState.h" | 6 #include "core/rendering/PaintInvalidationState.h" |
| 7 | 7 |
| 8 #include "core/rendering/RenderInline.h" | 8 #include "core/rendering/RenderInline.h" |
| 9 #include "core/rendering/RenderLayer.h" | 9 #include "core/rendering/RenderLayer.h" |
| 10 #include "core/rendering/RenderView.h" | 10 #include "core/rendering/RenderView.h" |
| 11 #include "core/rendering/svg/RenderSVGModelObject.h" | 11 #include "core/rendering/svg/RenderSVGModelObject.h" |
| 12 #include "platform/Partitions.h" | 12 #include "platform/Partitions.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 PaintInvalidationState::PaintInvalidationState(RenderObject& renderer) | 16 PaintInvalidationState::PaintInvalidationState(const RenderView& renderView) |
| 17 : m_clipped(false) | 17 : m_clipped(false) |
| 18 , m_cachedOffsetsEnabled(true) | 18 , m_cachedOffsetsEnabled(true) |
| 19 , m_forceCheckForPaintInvalidation(false) | 19 , m_forceCheckForPaintInvalidation(false) |
| 20 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) | 20 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) |
| 21 , m_renderer(renderer) | 21 , m_renderer(renderView) |
| 22 { | 22 { |
| 23 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | 23 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; |
| 24 if (!establishesPaintInvalidationContainer) { | 24 if (!establishesPaintInvalidationContainer) { |
| 25 if (!renderer.supportsPaintInvalidationStateCachedOffsets()) { | 25 if (!renderView.supportsPaintInvalidationStateCachedOffsets()) { |
| 26 m_cachedOffsetsEnabled = false; | 26 m_cachedOffsetsEnabled = false; |
| 27 return; | 27 return; |
| 28 } | 28 } |
| 29 bool invalidationContainerSkipped; | 29 FloatPoint point = renderView.localToContainerPoint(FloatPoint(), &m_pai ntInvalidationContainer, TraverseDocumentBoundaries); |
| 30 RenderObject* container = renderer.container(&m_paintInvalidationContain er, &invalidationContainerSkipped); | 30 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 31 if (container && !invalidationContainerSkipped) { | |
| 32 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m _paintInvalidationContainer); | |
| 33 if (container->isTableRow()) | |
| 34 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); | |
| 35 m_paintOffset = LayoutSize(point.x(), point.y()); | |
| 36 | |
| 37 applyClipIfNeeded(*container); | |
| 38 } | |
| 39 } else { | |
| 40 applyClipIfNeeded(m_renderer); | |
| 41 } | 31 } |
| 32 m_clipRect = renderView.viewRect(); | |
| 33 m_clipRect.move(m_paintOffset); | |
| 34 m_clipped = true; | |
| 42 } | 35 } |
| 43 | 36 |
| 44 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida tionContainer) | 37 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida tionContainer) |
| 45 : m_clipped(false) | 38 : m_clipped(false) |
| 46 , m_cachedOffsetsEnabled(true) | 39 , m_cachedOffsetsEnabled(true) |
| 47 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 40 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 48 , m_paintInvalidationContainer(paintInvalidationContainer) | 41 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 49 , m_renderer(renderer) | 42 , m_renderer(renderer) |
| 50 { | 43 { |
| 51 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 | 44 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 |
| 52 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | 45 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; |
| 53 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | 46 bool fixed = m_renderer.style()->position() == FixedPosition; |
| 54 | 47 |
| 55 if (establishesPaintInvalidationContainer) { | 48 if (establishesPaintInvalidationContainer) { |
| 56 // When we hit a new paint invalidation container, we don't need to | 49 // When we hit a new paint invalidation container, we don't need to |
| 57 // continue forcing a check for paint invalidation because movement | 50 // continue forcing a check for paint invalidation because movement |
| 58 // from our parents will just move the whole invalidation container. | 51 // from our parents will just move the whole invalidation container. |
| 59 m_forceCheckForPaintInvalidation = false; | 52 m_forceCheckForPaintInvalidation = false; |
| 60 } else { | 53 } else { |
| 61 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) { | 54 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) { |
| 62 m_cachedOffsetsEnabled = false; | 55 m_cachedOffsetsEnabled = false; |
| 63 } else { | 56 } else { |
| 64 LayoutSize offset = m_renderer.isBox() && !m_renderer.isTableRow() ? toRenderBox(renderer).locationOffset() : LayoutSize(); | |
| 65 if (fixed) { | 57 if (fixed) { |
| 66 // FIXME: This doesn't work correctly with transforms. | 58 FloatPoint fixedOffset = m_renderer.localToContainerPoint(FloatP oint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); |
| 67 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | 59 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); |
| 68 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | |
|
chrishtr
2014/08/19 21:18:02
Adding offset here was wrong, and resulted in the
| |
| 69 } else { | 60 } else { |
| 61 LayoutSize offset = m_renderer.isBox() && !m_renderer.isTableRow () ? toRenderBox(renderer).locationOffset() : LayoutSize(); | |
| 70 m_paintOffset = next.m_paintOffset + offset; | 62 m_paintOffset = next.m_paintOffset + offset; |
| 71 } | 63 } |
| 72 | 64 |
| 73 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | 65 if (m_renderer.isOutOfFlowPositioned() && !fixed) { |
| 74 if (RenderObject* container = m_renderer.container()) { | 66 if (RenderObject* container = m_renderer.container()) { |
| 75 if (container->style()->hasInFlowPosition() && container->is RenderInline()) | 67 if (container->style()->hasInFlowPosition() && container->is RenderInline()) |
| 76 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(toRenderBox(renderer)); | 68 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(toRenderBox(renderer)); |
| 77 } | 69 } |
| 78 } | 70 } |
| 79 | 71 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 101 if (m_clipped) { | 93 if (m_clipped) { |
| 102 m_clipRect.intersect(clipRect); | 94 m_clipRect.intersect(clipRect); |
| 103 } else { | 95 } else { |
| 104 m_clipRect = clipRect; | 96 m_clipRect = clipRect; |
| 105 m_clipped = true; | 97 m_clipped = true; |
| 106 } | 98 } |
| 107 m_paintOffset -= box.scrolledContentOffset(); | 99 m_paintOffset -= box.scrolledContentOffset(); |
| 108 } | 100 } |
| 109 | 101 |
| 110 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |