| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) | 36 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) |
| 37 : m_clipped(false) | 37 : m_clipped(false) |
| 38 , m_cachedOffsetsEnabled(true) | 38 , m_cachedOffsetsEnabled(true) |
| 39 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 39 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 40 , m_paintInvalidationContainer(paintInvalidationContainer) | 40 , m_paintInvalidationContainer(paintInvalidationContainer) |
| 41 , m_renderer(renderer) | 41 , m_renderer(renderer) |
| 42 { | 42 { |
| 43 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 | 43 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 |
| 44 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | 44 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; |
| 45 bool fixed = m_renderer.style()->position() == FixedPosition; | |
| 46 | 45 |
| 47 if (establishesPaintInvalidationContainer) { | 46 if (establishesPaintInvalidationContainer) { |
| 48 // When we hit a new paint invalidation container, we don't need to | 47 // When we hit a new paint invalidation container, we don't need to |
| 49 // continue forcing a check for paint invalidation because movement | 48 // continue forcing a check for paint invalidation because movement |
| 50 // from our parents will just move the whole invalidation container. | 49 // from our parents will just move the whole invalidation container. |
| 51 m_forceCheckForPaintInvalidation = false; | 50 m_forceCheckForPaintInvalidation = false; |
| 52 } else { | 51 } else { |
| 53 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { | 52 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { |
| 54 m_cachedOffsetsEnabled = false; | 53 m_cachedOffsetsEnabled = false; |
| 55 } else { | 54 } else { |
| 56 if (fixed) { | 55 LayoutSize offset = m_renderer.isBox() ? toRenderBox(renderer).locat
ionOffset() : LayoutSize(); |
| 57 FloatPoint fixedOffset = m_renderer.localToContainerPoint(FloatP
oint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); | 56 m_paintOffset = next.m_paintOffset + offset; |
| 58 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); | |
| 59 } else { | |
| 60 LayoutSize offset = m_renderer.isBox() ? toRenderBox(renderer).l
ocationOffset() : LayoutSize(); | |
| 61 m_paintOffset = next.m_paintOffset + offset; | |
| 62 } | |
| 63 | 57 |
| 64 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | 58 if (m_renderer.isOutOfFlowPositioned()) { |
| 65 if (RenderObject* container = m_renderer.container()) { | 59 if (RenderObject* container = m_renderer.container()) { |
| 66 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) | 60 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) |
| 67 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); | 61 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); |
| 68 } | 62 } |
| 69 } | 63 } |
| 70 | 64 |
| 71 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | 65 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) |
| 72 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 66 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
| 73 } | 67 } |
| 74 | 68 |
| 75 m_clipped = !fixed && next.m_clipped; | 69 m_clipped = next.m_clipped; |
| 76 if (m_clipped) | 70 if (m_clipped) |
| 77 m_clipRect = next.m_clipRect; | 71 m_clipRect = next.m_clipRect; |
| 78 } | 72 } |
| 79 | 73 |
| 80 applyClipIfNeeded(renderer); | 74 applyClipIfNeeded(renderer); |
| 81 | 75 |
| 82 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. | 76 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. |
| 83 } | 77 } |
| 84 | 78 |
| 85 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) | 79 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) |
| 86 { | 80 { |
| 87 if (!renderer.hasOverflowClip()) | 81 if (!renderer.hasOverflowClip()) |
| 88 return; | 82 return; |
| 89 | 83 |
| 90 const RenderBox& box = toRenderBox(renderer); | 84 const RenderBox& box = toRenderBox(renderer); |
| 91 LayoutRect clipRect(toPoint(m_paintOffset), box.layer()->size()); | 85 LayoutRect clipRect(toPoint(m_paintOffset), box.layer()->size()); |
| 92 if (m_clipped) { | 86 if (m_clipped) { |
| 93 m_clipRect.intersect(clipRect); | 87 m_clipRect.intersect(clipRect); |
| 94 } else { | 88 } else { |
| 95 m_clipRect = clipRect; | 89 m_clipRect = clipRect; |
| 96 m_clipped = true; | 90 m_clipped = true; |
| 97 } | 91 } |
| 98 m_paintOffset -= box.scrolledContentOffset(); | 92 m_paintOffset -= box.scrolledContentOffset(); |
| 99 } | 93 } |
| 100 | 94 |
| 101 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |