Chromium Code Reviews| 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 "config.h" | |
| 6 #include "core/rendering/PaintInvalidationState.h" | |
| 7 | |
| 8 #include "core/rendering/RenderInline.h" | |
| 9 #include "core/rendering/RenderLayer.h" | |
| 10 #include "core/rendering/RenderView.h" | |
| 11 #include "core/rendering/svg/RenderSVGModelObject.h" | |
| 12 #include "platform/Partitions.h" | |
| 13 | |
| 14 namespace WebCore { | |
| 15 | |
| 16 PaintInvalidationState::PaintInvalidationState(RenderObject& renderer) | |
| 17 : m_clipped(false) | |
| 18 , m_cachedOffsetsEnabled(true) | |
| 19 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) | |
| 20 , m_renderer(renderer) | |
| 21 { | |
| 22 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 23 if (!establishesPaintInvalidationContainer) { | |
| 24 if (!renderer.supportsLayoutStateCachedOffsets()) { | |
| 25 m_cachedOffsetsEnabled = false; | |
| 26 return; | |
| 27 } | |
| 28 bool invalidationContainerSkipped; | |
| 29 RenderObject* container = renderer.container(&m_paintInvalidationContain er, &invalidationContainerSkipped); | |
| 30 if (container && !invalidationContainerSkipped) { | |
| 31 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m _paintInvalidationContainer); | |
| 32 if (container->isTableRow()) | |
|
Julien - ping for review
2014/07/07 22:09:59
FIXME: Table rows should behave like everyone else
| |
| 33 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); | |
| 34 m_paintOffset = LayoutSize(point.x(), point.y()); | |
| 35 | |
| 36 applyClipIfNeeded(*container); | |
| 37 } | |
| 38 } else { | |
| 39 applyClipIfNeeded(m_renderer); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintInvalidati onContainer) | |
| 44 : m_clipped(next.m_clipped) | |
| 45 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | |
| 46 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 47 , m_renderer(renderer) | |
| 48 { | |
| 49 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 | |
| 50 ASSERT(!m_cachedOffsetsEnabled); | |
| 51 } | |
| 52 | |
| 53 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderInline& renderer, const RenderLayerModelObject& paintInvalidationContai ner) | |
| 54 : m_clipped(next.m_clipped) | |
| 55 , m_cachedOffsetsEnabled(true) | |
| 56 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 57 , m_renderer(renderer) | |
| 58 { | |
| 59 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 60 if (!establishesPaintInvalidationContainer) { | |
| 61 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
| 62 m_cachedOffsetsEnabled = false; | |
| 63 } else if (m_cachedOffsetsEnabled) { | |
| 64 m_paintOffset = next.m_paintOffset; | |
| 65 // Handle relative positioned inline. | |
| 66 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | |
| 67 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
| 68 | |
| 69 // RenderInline can't be out-of-flow positioned. | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 // The following can't apply to RenderInline so we just propagate them. | |
| 74 m_clipped = next.m_clipped; | |
| 75 m_clipRect = next.m_clipRect; | |
| 76 } | |
| 77 | |
| 78 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderBox& renderer, const RenderLayerModelObject& paintInvalidationContainer ) | |
| 79 : m_clipped(false) | |
| 80 , m_cachedOffsetsEnabled(true) | |
| 81 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 82 , m_renderer(renderer) | |
| 83 { | |
| 84 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 85 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | |
| 86 | |
| 87 if (!establishesPaintInvalidationContainer) { | |
| 88 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
| 89 m_cachedOffsetsEnabled = false; | |
| 90 } else { | |
| 91 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); | |
| 92 if (fixed) { | |
| 93 // FIXME: This doesn't work correctly with transforms. | |
| 94 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | |
| 95 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | |
| 96 } else { | |
| 97 m_paintOffset = next.m_paintOffset + offset; | |
| 98 } | |
| 99 | |
| 100 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | |
| 101 if (RenderObject* container = m_renderer.container()) { | |
| 102 if (container->style()->hasInFlowPosition() && container->is RenderInline()) | |
| 103 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(renderer); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | |
| 108 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 m_clipped = !fixed && next.m_clipped; | |
| 113 if (m_clipped) | |
| 114 m_clipRect = next.m_clipRect; | |
| 115 | |
| 116 applyClipIfNeeded(renderer); | |
| 117 | |
| 118 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | |
| 119 } | |
| 120 | |
| 121 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) | |
| 122 { | |
| 123 if (!renderer.hasOverflowClip()) | |
| 124 return; | |
| 125 | |
| 126 const RenderBox* box = toRenderBox(&renderer); | |
|
Julien - ping for review
2014/07/07 22:09:59
We generate const RenderBox& toRenderBox(const Ren
| |
| 127 LayoutRect clipRect(toPoint(m_paintOffset), box->cachedSizeForOverflowClip() ); | |
| 128 if (m_clipped) { | |
| 129 m_clipRect.intersect(clipRect); | |
| 130 } else { | |
| 131 m_clipRect = clipRect; | |
| 132 m_clipped = true; | |
| 133 } | |
| 134 m_paintOffset -= box->scrolledContentOffset(); | |
| 135 } | |
| 136 | |
| 137 } // namespace WebCore | |
| OLD | NEW |