| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/config.h" | |
| 6 #include "sky/engine/core/rendering/PaintInvalidationState.h" | |
| 7 | |
| 8 #include "sky/engine/core/rendering/RenderInline.h" | |
| 9 #include "sky/engine/core/rendering/RenderLayer.h" | |
| 10 #include "sky/engine/core/rendering/RenderView.h" | |
| 11 #include "sky/engine/platform/Partitions.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 PaintInvalidationState::PaintInvalidationState(const RenderView& renderView) | |
| 16 : m_clipped(false) | |
| 17 , m_cachedOffsetsEnabled(true) | |
| 18 , m_forceCheckForPaintInvalidation(false) | |
| 19 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) | |
| 20 , m_renderer(renderView) | |
| 21 { | |
| 22 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida
tionContainer; | |
| 23 if (!establishesPaintInvalidationContainer) { | |
| 24 if (!renderView.supportsPaintInvalidationStateCachedOffsets()) { | |
| 25 m_cachedOffsetsEnabled = false; | |
| 26 return; | |
| 27 } | |
| 28 FloatPoint point = renderView.localToContainerPoint(FloatPoint(), &m_pai
ntInvalidationContainer, TraverseDocumentBoundaries); | |
| 29 m_paintOffset = LayoutSize(point.x(), point.y()); | |
| 30 } | |
| 31 m_clipRect = renderView.viewRect(); | |
| 32 m_clipRect.move(m_paintOffset); | |
| 33 m_clipped = true; | |
| 34 } | |
| 35 | |
| 36 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida
tionContainer) | |
| 37 : m_clipped(false) | |
| 38 , m_cachedOffsetsEnabled(true) | |
| 39 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | |
| 40 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 41 , m_renderer(renderer) | |
| 42 { | |
| 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; | |
| 45 | |
| 46 if (establishesPaintInvalidationContainer) { | |
| 47 // When we hit a new paint invalidation container, we don't need to | |
| 48 // continue forcing a check for paint invalidation because movement | |
| 49 // from our parents will just move the whole invalidation container. | |
| 50 m_forceCheckForPaintInvalidation = false; | |
| 51 } else { | |
| 52 if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) { | |
| 53 m_cachedOffsetsEnabled = false; | |
| 54 } else { | |
| 55 LayoutSize offset = m_renderer.isBox() ? toRenderBox(renderer).locat
ionOffset() : LayoutSize(); | |
| 56 m_paintOffset = next.m_paintOffset + offset; | |
| 57 | |
| 58 if (m_renderer.isOutOfFlowPositioned()) { | |
| 59 if (RenderObject* container = m_renderer.container()) { | |
| 60 if (container->style()->hasInFlowPosition() && container->is
RenderInline()) | |
| 61 m_paintOffset += toRenderInline(container)->offsetForInF
lowPositionedInline(toRenderBox(renderer)); | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | |
| 66 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
| 67 } | |
| 68 | |
| 69 m_clipped = next.m_clipped; | |
| 70 if (m_clipped) | |
| 71 m_clipRect = next.m_clipRect; | |
| 72 } | |
| 73 | |
| 74 applyClipIfNeeded(renderer); | |
| 75 | |
| 76 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. | |
| 77 } | |
| 78 | |
| 79 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) | |
| 80 { | |
| 81 if (!renderer.hasOverflowClip()) | |
| 82 return; | |
| 83 | |
| 84 const RenderBox& box = toRenderBox(renderer); | |
| 85 LayoutRect clipRect(toPoint(m_paintOffset), box.layer()->size()); | |
| 86 if (m_clipped) { | |
| 87 m_clipRect.intersect(clipRect); | |
| 88 } else { | |
| 89 m_clipRect = clipRect; | |
| 90 m_clipped = true; | |
| 91 } | |
| 92 m_paintOffset -= box.scrolledContentOffset(); | |
| 93 } | |
| 94 | |
| 95 } // namespace blink | |
| OLD | NEW |