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" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); | 33 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); |
| 34 m_paintOffset = LayoutSize(point.x(), point.y()); | 34 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 35 | 35 |
| 36 applyClipIfNeeded(*container); | 36 applyClipIfNeeded(*container); |
| 37 } | 37 } |
| 38 } else { | 38 } else { |
| 39 applyClipIfNeeded(m_renderer); | 39 applyClipIfNeeded(m_renderer); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintInvalidati onContainer) | 43 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderLayerModelObject& renderer, const RenderLayerModelObject& paintInvalida tionContainer) |
| 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 | |
|
Julien - ping for review
2014/08/04 19:36:39
We removed this comment, does that mean that the b
leviw_travelin_and_unemployed
2014/08/05 22:34:44
No. I put it back.
| |
| 50 ASSERT(!m_cachedOffsetsEnabled); | |
| 51 } | |
| 52 | |
| 53 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex t, RenderInline& renderer, const RenderLayerModelObject& paintInvalidationContai ner) | |
| 54 : m_clipped(false) | 44 : m_clipped(false) |
| 55 , m_cachedOffsetsEnabled(true) | 45 , m_cachedOffsetsEnabled(true) |
| 56 , m_paintInvalidationContainer(paintInvalidationContainer) | 46 , 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 // The following can't apply to RenderInline so we just propagate them. | |
| 73 m_clipped = next.m_clipped; | |
| 74 m_clipRect = next.m_clipRect; | |
| 75 } | |
| 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) | 47 , m_renderer(renderer) |
| 83 { | 48 { |
| 84 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | 49 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; |
| 85 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | 50 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; |
| 86 | 51 |
| 87 if (!establishesPaintInvalidationContainer) { | 52 if (!establishesPaintInvalidationContainer) { |
| 88 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | 53 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { |
| 89 m_cachedOffsetsEnabled = false; | 54 m_cachedOffsetsEnabled = false; |
| 90 } else { | 55 } else { |
| 91 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); | 56 LayoutSize offset = m_renderer.isBox() && !m_renderer.isTableRow() ? toRenderBox(renderer).locationOffset() : LayoutSize(); |
| 92 if (fixed) { | 57 if (fixed) { |
| 93 // FIXME: This doesn't work correctly with transforms. | 58 // FIXME: This doesn't work correctly with transforms. |
| 94 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | 59 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); |
| 95 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | 60 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; |
| 96 } else { | 61 } else { |
| 97 m_paintOffset = next.m_paintOffset + offset; | 62 m_paintOffset = next.m_paintOffset + offset; |
| 98 } | 63 } |
| 99 | 64 |
| 100 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | 65 if (m_renderer.isOutOfFlowPositioned() && !fixed) { |
| 101 if (RenderObject* container = m_renderer.container()) { | 66 if (RenderObject* container = m_renderer.container()) { |
| 102 if (container->style()->hasInFlowPosition() && container->is RenderInline()) | 67 if (container->style()->hasInFlowPosition() && container->is RenderInline()) |
| 103 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(renderer); | 68 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(toRenderBox(renderer)); |
|
dsinclair
2014/08/05 15:09:47
renderer is a RenderLayerModelObject, does this ne
leviw_travelin_and_unemployed
2014/08/05 22:34:44
We're guaranteed that this is the case, but toRend
| |
| 104 } | 69 } |
| 105 } | 70 } |
| 106 | 71 |
| 107 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | 72 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) |
| 108 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 73 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
| 109 } | 74 } |
| 110 | 75 |
| 111 m_clipped = !fixed && next.m_clipped; | 76 m_clipped = !fixed && next.m_clipped; |
| 112 if (m_clipped) | 77 if (m_clipped) |
| 113 m_clipRect = next.m_clipRect; | 78 m_clipRect = next.m_clipRect; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 128 if (m_clipped) { | 93 if (m_clipped) { |
| 129 m_clipRect.intersect(clipRect); | 94 m_clipRect.intersect(clipRect); |
| 130 } else { | 95 } else { |
| 131 m_clipRect = clipRect; | 96 m_clipRect = clipRect; |
| 132 m_clipped = true; | 97 m_clipped = true; |
| 133 } | 98 } |
| 134 m_paintOffset -= box.scrolledContentOffset(); | 99 m_paintOffset -= box.scrolledContentOffset(); |
| 135 } | 100 } |
| 136 | 101 |
| 137 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |