Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "core/rendering/InvalidationTreeWalkState.h" | |
| 33 | |
| 34 #include "core/rendering/RenderInline.h" | |
| 35 #include "core/rendering/RenderLayer.h" | |
| 36 #include "core/rendering/RenderView.h" | |
| 37 #include "core/rendering/svg/RenderSVGModelObject.h" | |
| 38 #include "platform/Partitions.h" | |
| 39 | |
| 40 namespace WebCore { | |
| 41 | |
| 42 InvalidationTreeWalkState::InvalidationTreeWalkState(RenderObject& renderer) | |
| 43 : m_clipped(false) | |
| 44 , m_cachedOffsetsEnabled(true) | |
| 45 , m_paintInvalidationContainer(*renderer.containerForPaintInvalidation()) | |
| 46 , m_renderer(renderer) | |
| 47 { | |
| 48 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 49 if (!establishesPaintInvalidationContainer) { | |
| 50 if (!renderer.supportsLayoutStateCachedOffsets()) { | |
| 51 m_cachedOffsetsEnabled = false; | |
| 52 return; | |
| 53 } | |
| 54 bool invalidationContainerSkipped; | |
| 55 RenderObject* container = renderer.container(&m_paintInvalidationContain er, &invalidationContainerSkipped); | |
| 56 if (container && !invalidationContainerSkipped) { | |
| 57 // m_diabled = true; | |
|
dsinclair
2014/07/02 18:48:24
remove
| |
| 58 FloatPoint point = container->localToContainerPoint(FloatPoint(), &m _paintInvalidationContainer); | |
| 59 if (container->isTableRow()) | |
| 60 point = FloatPoint(point.x() - toRenderBox(container)->x().toFlo at(), point.y() - toRenderBox(container)->y().toFloat()); | |
| 61 m_paintOffset = LayoutSize(point.x(), point.y()); | |
| 62 | |
| 63 applyClipIfNeeded(*container); | |
| 64 } | |
| 65 } else { | |
| 66 applyClipIfNeeded(m_renderer); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderSVGModelObject& renderer, const RenderLayerModelObject& paintI nvalidationContainer) | |
| 71 : m_clipped(next.m_clipped) | |
| 72 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | |
| 73 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 74 , m_renderer(renderer) | |
| 75 { | |
| 76 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. | |
|
dsinclair
2014/07/02 18:48:24
bug?
| |
| 77 ASSERT(!m_cachedOffsetsEnabled); | |
| 78 } | |
| 79 | |
| 80 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderInline& renderer, const RenderLayerModelObject& paintInvalidat ionContainer) | |
| 81 : m_clipped(next.m_clipped) | |
| 82 , m_cachedOffsetsEnabled(true) | |
| 83 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 84 , m_renderer(renderer) | |
| 85 { | |
| 86 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 87 if (!establishesPaintInvalidationContainer) { | |
| 88 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
| 89 m_cachedOffsetsEnabled = false; | |
| 90 } else if (m_cachedOffsetsEnabled) { | |
| 91 m_paintOffset = next.m_paintOffset; | |
| 92 // Handle relative positioned inline. | |
| 93 if (renderer.style()->hasInFlowPosition() && renderer.layer()) | |
| 94 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
| 95 | |
| 96 // RenderInline can't be out-of-flow positioned. | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 // The following can't apply to RenderInline so we just propagate them. | |
| 101 m_clipped = next.m_clipped; | |
| 102 m_clipRect = next.m_clipRect; | |
| 103 } | |
| 104 | |
| 105 InvalidationTreeWalkState::InvalidationTreeWalkState(const InvalidationTreeWalkS tate& next, RenderBox& renderer, const RenderLayerModelObject& paintInvalidation Container) | |
| 106 : m_clipped(false) | |
| 107 , m_cachedOffsetsEnabled(true) | |
| 108 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 109 , m_renderer(renderer) | |
| 110 { | |
| 111 ASSERT(&m_paintInvalidationContainer == renderer.containerForPaintInvalidati on() || !next.m_cachedOffsetsEnabled); | |
| 112 bool establishesPaintInvalidationContainer = &m_renderer == &m_paintInvalida tionContainer; | |
| 113 bool fixed = m_renderer.isOutOfFlowPositioned() && m_renderer.style()->posit ion() == FixedPosition; | |
| 114 | |
| 115 if (!establishesPaintInvalidationContainer) { | |
| 116 if (!renderer.supportsLayoutStateCachedOffsets() || !next.m_cachedOffset sEnabled) { | |
| 117 m_cachedOffsetsEnabled = false; | |
| 118 } else { | |
| 119 LayoutSize offset = m_renderer.isTableRow() ? LayoutSize() : rendere r.locationOffset(); | |
| 120 if (fixed) { | |
| 121 // FIXME: This doesn't work correctly with transforms. | |
| 122 FloatPoint fixedOffset = m_renderer.view()->localToAbsolute(Floa tPoint(), IsFixed); | |
| 123 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + o ffset; | |
| 124 } else { | |
| 125 m_paintOffset = next.m_paintOffset + offset; | |
| 126 } | |
| 127 | |
| 128 if (m_renderer.isOutOfFlowPositioned() && !fixed) { | |
| 129 if (RenderObject* container = m_renderer.container()) { | |
| 130 if (container->style()->hasInFlowPosition() && container->is RenderInline()) | |
| 131 m_paintOffset += toRenderInline(container)->offsetForInF lowPositionedInline(renderer); | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 if (m_renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | |
| 136 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | |
| 137 } | |
| 138 } | |
| 139 | |
| 140 m_clipped = !fixed && next.m_clipped; | |
| 141 if (m_clipped) | |
| 142 m_clipRect = next.m_clipRect; | |
| 143 | |
| 144 applyClipIfNeeded(renderer); | |
| 145 | |
| 146 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. | |
| 147 } | |
| 148 | |
| 149 void InvalidationTreeWalkState::applyClipIfNeeded(const RenderObject& renderer) | |
| 150 { | |
| 151 if (renderer.hasOverflowClip()) { | |
|
dsinclair
2014/07/02 18:48:24
if (!renderer.hasOverflowClip())
return;
| |
| 152 const RenderBox* box = toRenderBox(&renderer); | |
| 153 LayoutRect clipRect(toPoint(m_paintOffset), box->cachedSizeForOverflowCl ip()); | |
| 154 if (m_clipped) { | |
| 155 m_clipRect.intersect(clipRect); | |
| 156 } else { | |
| 157 m_clipRect = clipRect; | |
| 158 m_clipped = true; | |
| 159 } | |
| 160 m_paintOffset -= box->scrolledContentOffset(); | |
| 161 } | |
| 162 } | |
| 163 | |
| 164 } // namespace WebCore | |
| OLD | NEW |