Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: Source/core/paint/LayerPainter.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/paint/LayerPainter.h" 6 #include "core/paint/LayerPainter.h"
7 7
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/FilterEffectRenderer.h" 10 #include "core/layout/FilterEffectRenderer.h"
(...skipping 16 matching lines...) Expand all
27 #include "platform/graphics/paint/DisplayItemList.h" 27 #include "platform/graphics/paint/DisplayItemList.h"
28 #include "platform/graphics/paint/Transform3DDisplayItem.h" 28 #include "platform/graphics/paint/Transform3DDisplayItem.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 static inline bool shouldSuppressPaintingLayer(Layer* layer) 32 static inline bool shouldSuppressPaintingLayer(Layer* layer)
33 { 33 {
34 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 34 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
35 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 35 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
36 // will do a full paintInvalidationForWholeRenderer(). 36 // will do a full paintInvalidationForWholeRenderer().
37 if (layer->renderer()->document().didLayoutWithPendingStylesheets() && !laye r->isRootLayer() && !layer->renderer()->isDocumentElement()) 37 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
38 return true; 38 return true;
39 39
40 return false; 40 return false;
41 } 41 }
42 42
43 void LayerPainter::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot, PaintLayerFlags paintF lags) 43 void LayerPainter::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot, PaintLayerFlags paintF lags)
44 { 44 {
45 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot); 45 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot);
46 if (shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags)) 46 if (shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags))
47 paintLayer(context, paintingInfo, paintFlags); 47 paintLayer(context, paintingInfo, paintFlags);
(...skipping 10 matching lines...) Expand all
58 DisableCompositingQueryAsserts disabler; 58 DisableCompositingQueryAsserts disabler;
59 59
60 if (m_renderLayer.compositingState() != NotComposited) { 60 if (m_renderLayer.compositingState() != NotComposited) {
61 if (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) { 61 if (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) {
62 // FIXME: ok, but what about PaintBehaviorFlattenCompositingLayers? That's for printing. 62 // FIXME: ok, but what about PaintBehaviorFlattenCompositingLayers? That's for printing.
63 // FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call? 63 // FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call?
64 paintFlags |= PaintLayerUncachedClipRects; 64 paintFlags |= PaintLayerUncachedClipRects;
65 } 65 }
66 } 66 }
67 67
68 // Non self-painting leaf layers don't need to be painted as their renderer( ) should properly paint itself. 68 // Non self-painting leaf layers don't need to be painted as their layoutObj ect() should properly paint itself.
69 if (!m_renderLayer.isSelfPaintingLayer() && !m_renderLayer.hasSelfPaintingLa yerDescendant()) 69 if (!m_renderLayer.isSelfPaintingLayer() && !m_renderLayer.hasSelfPaintingLa yerDescendant())
70 return; 70 return;
71 71
72 if (shouldSuppressPaintingLayer(&m_renderLayer)) 72 if (shouldSuppressPaintingLayer(&m_renderLayer))
73 return; 73 return;
74 74
75 // If this layer is totally invisible then there is nothing to paint. 75 // If this layer is totally invisible then there is nothing to paint.
76 if (!m_renderLayer.renderer()->opacity()) 76 if (!m_renderLayer.layoutObject()->opacity())
77 return; 77 return;
78 78
79 if (m_renderLayer.paintsWithTransparency(paintingInfo.paintBehavior)) 79 if (m_renderLayer.paintsWithTransparency(paintingInfo.paintBehavior))
80 paintFlags |= PaintLayerHaveTransparency; 80 paintFlags |= PaintLayerHaveTransparency;
81 81
82 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice. 82 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice.
83 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) { 83 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) {
84 paintLayerWithTransform(context, paintingInfo, paintFlags); 84 paintLayerWithTransform(context, paintingInfo, paintFlags);
85 return; 85 return;
86 } 86 }
(...skipping 14 matching lines...) Expand all
101 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; 101 localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
102 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); 102 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy);
103 } 103 }
104 104
105 class ClipPathHelper { 105 class ClipPathHelper {
106 public: 106 public:
107 ClipPathHelper(GraphicsContext* context, const Layer& renderLayer, const Lay erPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRelative BoundsComputed, 107 ClipPathHelper(GraphicsContext* context, const Layer& renderLayer, const Lay erPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRelative BoundsComputed,
108 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) 108 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags)
109 : m_resourceClipper(0), m_renderLayer(renderLayer), m_context(context) 109 : m_resourceClipper(0), m_renderLayer(renderLayer), m_context(context)
110 { 110 {
111 const LayoutStyle& style = renderLayer.renderer()->styleRef(); 111 const LayoutStyle& style = renderLayer.layoutObject()->styleRef();
112 112
113 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container. 113 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container.
114 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the 114 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the
115 // scrolling contents and scrollbars. 115 // scrolling contents and scrollbars.
116 if (!renderLayer.renderer()->hasClipPath() || (renderLayer.needsComposit edScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) 116 if (!renderLayer.layoutObject()->hasClipPath() || (renderLayer.needsComp ositedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)))
117 return; 117 return;
118 118
119 m_clipperState = LayoutSVGResourceClipper::ClipperNotApplied; 119 m_clipperState = LayoutSVGResourceClipper::ClipperNotApplied;
120 120
121 ASSERT(style.clipPath()); 121 ASSERT(style.clipPath());
122 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { 122 if (style.clipPath()->type() == ClipPathOperation::SHAPE) {
123 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath()); 123 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath());
124 if (clipPath->isValid()) { 124 if (clipPath->isValid()) {
125 if (!rootRelativeBoundsComputed) { 125 if (!rootRelativeBoundsComputed) {
126 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 126 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
127 rootRelativeBoundsComputed = true; 127 rootRelativeBoundsComputed = true;
128 } 128 }
129 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren derLayer.renderer()->displayItemClient(), 129 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren derLayer.layoutObject()->displayItemClient(),
130 clipPath->path(rootRelativeBounds), clipPath->windRule())); 130 clipPath->path(rootRelativeBounds), clipPath->windRule()));
131 } 131 }
132 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { 132 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) {
133 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath()); 133 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath());
134 Document& document = renderLayer.renderer()->document(); 134 Document& document = renderLayer.layoutObject()->document();
135 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405) 135 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
136 Element* element = document.getElementById(referenceClipPathOperatio n->fragment()); 136 Element* element = document.getElementById(referenceClipPathOperatio n->fragment());
137 if (isSVGClipPathElement(element) && element->renderer()) { 137 if (isSVGClipPathElement(element) && element->layoutObject()) {
138 if (!rootRelativeBoundsComputed) { 138 if (!rootRelativeBoundsComputed) {
139 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 139 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
140 rootRelativeBoundsComputed = true; 140 rootRelativeBoundsComputed = true;
141 } 141 }
142 142
143 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->renderer())); 143 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->layoutObject()));
144 if (!m_resourceClipper->applyClippingToContext(renderLayer.rende rer(), rootRelativeBounds, 144 if (!m_resourceClipper->applyClippingToContext(renderLayer.layou tObject(), rootRelativeBounds,
145 paintingInfo.paintDirtyRect, context, m_clipperState)) { 145 paintingInfo.paintDirtyRect, context, m_clipperState)) {
146 // No need to post-apply the clipper if this failed. 146 // No need to post-apply the clipper if this failed.
147 m_resourceClipper = 0; 147 m_resourceClipper = 0;
148 } 148 }
149 } 149 }
150 } 150 }
151 } 151 }
152 152
153 ~ClipPathHelper() 153 ~ClipPathHelper()
154 { 154 {
155 if (m_resourceClipper) 155 if (m_resourceClipper)
156 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer( ), m_context, m_clipperState); 156 m_resourceClipper->postApplyStatefulResource(m_renderLayer.layoutObj ect(), m_context, m_clipperState);
157 } 157 }
158 private: 158 private:
159 LayoutSVGResourceClipper* m_resourceClipper; 159 LayoutSVGResourceClipper* m_resourceClipper;
160 OwnPtr<ClipPathRecorder> m_clipPathRecorder; 160 OwnPtr<ClipPathRecorder> m_clipPathRecorder;
161 LayoutSVGResourceClipper::ClipperState m_clipperState; 161 LayoutSVGResourceClipper::ClipperState m_clipperState;
162 const Layer& m_renderLayer; 162 const Layer& m_renderLayer;
163 GraphicsContext* m_context; 163 GraphicsContext* m_context;
164 }; 164 };
165 165
166 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy ) 166 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy )
(...skipping 11 matching lines...) Expand all
178 // the outline is painted in the background phase during composited scrollin g. 178 // the outline is painted in the background phase during composited scrollin g.
179 // If it were painted in the foreground phase, it would move with the scroll ed 179 // If it were painted in the foreground phase, it would move with the scroll ed
180 // content. When not composited scrolling, the outline is painted in the 180 // content. When not composited scrolling, the outline is painted in the
181 // foreground phase. Since scrolled contents are moved by paint invalidation in this 181 // foreground phase. Since scrolled contents are moved by paint invalidation in this
182 // case, the outline won't get 'dragged along'. 182 // case, the outline won't get 'dragged along'.
183 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar s 183 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar s
184 && ((isPaintingScrollingContent && isPaintingCompositedBackground) 184 && ((isPaintingScrollingContent && isPaintingCompositedBackground)
185 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); 185 || (!isPaintingScrollingContent && isPaintingCompositedForeground));
186 bool shouldPaintContent = m_renderLayer.hasVisibleContent() && isSelfPaintin gLayer && !isPaintingOverlayScrollbars; 186 bool shouldPaintContent = m_renderLayer.hasVisibleContent() && isSelfPaintin gLayer && !isPaintingOverlayScrollbars;
187 187
188 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_renderLayer.rend erer()->isLayoutView() && !m_renderLayer.renderer()->isDocumentElement()) 188 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_renderLayer.layo utObject()->isLayoutView() && !m_renderLayer.layoutObject()->isDocumentElement() )
189 return; 189 return;
190 190
191 // Ensure our lists are up-to-date. 191 // Ensure our lists are up-to-date.
192 m_renderLayer.stackingNode()->updateLayerListsIfNeeded(); 192 m_renderLayer.stackingNode()->updateLayerListsIfNeeded();
193 193
194 LayoutPoint offsetFromRoot; 194 LayoutPoint offsetFromRoot;
195 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 195 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
196 196
197 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) 197 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking)
198 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); 198 offsetFromRoot.move(m_renderLayer.subpixelAccumulation());
199 199
200 LayoutRect rootRelativeBounds; 200 LayoutRect rootRelativeBounds;
201 bool rootRelativeBoundsComputed = false; 201 bool rootRelativeBoundsComputed = false;
202 202
203 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 203 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
204 // so they are nested properly. 204 // so they are nested properly.
205 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 205 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);
206 206
207 OwnPtr<LayerClipRecorder> clipRecorder; 207 OwnPtr<LayerClipRecorder> clipRecorder;
208 OwnPtr<CompositingRecorder> compositingRecorder; 208 OwnPtr<CompositingRecorder> compositingRecorder;
209 // Blending operations must be performed only with the nearest ancestor stac king context. 209 // Blending operations must be performed only with the nearest ancestor stac king context.
210 // Note that there is no need to composite if we're painting the root. 210 // Note that there is no need to composite if we're painting the root.
211 // FIXME: this should be unified further into Layer::paintsWithTransparency( ). 211 // FIXME: this should be unified further into Layer::paintsWithTransparency( ).
212 bool shouldCompositeForBlendMode = (!m_renderLayer.renderer()->isDocumentEle ment() || m_renderLayer.renderer()->isSVGRoot()) && m_renderLayer.stackingNode() ->isStackingContext() && m_renderLayer.hasNonIsolatedDescendantWithBlendMode(); 212 bool shouldCompositeForBlendMode = (!m_renderLayer.layoutObject()->isDocumen tElement() || m_renderLayer.layoutObject()->isSVGRoot()) && m_renderLayer.stacki ngNode()->isStackingContext() && m_renderLayer.hasNonIsolatedDescendantWithBlend Mode();
213 if (shouldCompositeForBlendMode || m_renderLayer.paintsWithTransparency(pain tingInfo.paintBehavior)) { 213 if (shouldCompositeForBlendMode || m_renderLayer.paintsWithTransparency(pain tingInfo.paintBehavior)) {
214 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, DisplayItem::TransparencyClip, 214 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutObject (), context, DisplayItem::TransparencyClip,
215 m_renderLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.pa intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior), 215 m_renderLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.pa intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior),
216 &paintingInfo, LayoutPoint(), paintFlags)); 216 &paintingInfo, LayoutPoint(), paintFlags));
217 217
218 compositingRecorder = adoptPtr(new CompositingRecorder(context, m_render Layer.renderer()->displayItemClient(), 218 compositingRecorder = adoptPtr(new CompositingRecorder(context, m_render Layer.layoutObject()->displayItemClient(),
219 WebCoreCompositeToSkiaComposite(context->compositeOperationDeprecate d(), m_renderLayer.renderer()->style()->blendMode()), 219 WebCoreCompositeToSkiaComposite(context->compositeOperationDeprecate d(), m_renderLayer.layoutObject()->style()->blendMode()),
220 m_renderLayer.renderer()->opacity())); 220 m_renderLayer.layoutObject()->opacity()));
221 } 221 }
222 222
223 LayerPaintingInfo localPaintingInfo(paintingInfo); 223 LayerPaintingInfo localPaintingInfo(paintingInfo);
224 224
225 LayerFragments layerFragments; 225 LayerFragments layerFragments;
226 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 226 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
227 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 227 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
228 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 228 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
229 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_renderLayer.renderer()); 229 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_renderLayer.layoutObject());
230 if (fragmentPolicy == ForceSingleFragment) 230 if (fragmentPolicy == ForceSingleFragment)
231 m_renderLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignor eOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.s ubPixelAccumulation); 231 m_renderLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignor eOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.s ubPixelAccumulation);
232 else 232 else
233 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.roo tLayer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 233 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.roo tLayer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
234 if (shouldPaintContent) 234 if (shouldPaintContent)
235 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 235 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot);
236 } 236 }
237 237
238 bool selectionOnly = localPaintingInfo.paintBehavior & PaintBehaviorSelectio nOnly; 238 bool selectionOnly = localPaintingInfo.paintBehavior & PaintBehaviorSelectio nOnly;
239 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which 239 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which
240 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set). 240 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set).
241 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along 241 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along
242 // so it will be tested against as we descend through the renderers. 242 // so it will be tested against as we descend through the renderers.
243 LayoutObject* paintingRootForRenderer = 0; 243 LayoutObject* paintingRootForRenderer = 0;
244 if (localPaintingInfo.paintingRoot && !m_renderLayer.renderer()->isDescendan tOf(localPaintingInfo.paintingRoot)) 244 if (localPaintingInfo.paintingRoot && !m_renderLayer.layoutObject()->isDesce ndantOf(localPaintingInfo.paintingRoot))
245 paintingRootForRenderer = localPaintingInfo.paintingRoot; 245 paintingRootForRenderer = localPaintingInfo.paintingRoot;
246 246
247 { // Begin block for the lifetime of any filter. 247 { // Begin block for the lifetime of any filter.
248 FilterPainter filterPainter(m_renderLayer, context, offsetFromRoot, laye rFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPaint ingInfo, paintFlags, 248 FilterPainter filterPainter(m_renderLayer, context, offsetFromRoot, laye rFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPaint ingInfo, paintFlags,
249 rootRelativeBounds, rootRelativeBoundsComputed); 249 rootRelativeBounds, rootRelativeBoundsComputed);
250 250
251 ASSERT(!(localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)) ; 251 ASSERT(!(localPaintingInfo.paintBehavior & PaintBehaviorForceBlackText)) ;
252 252
253 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 253 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
254 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 254 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
(...skipping 23 matching lines...) Expand all
278 if (shouldPaintOutline) 278 if (shouldPaintOutline)
279 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags); 279 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags);
280 280
281 if (shouldPaintNormalFlowAndPosZOrderLists) 281 if (shouldPaintNormalFlowAndPosZOrderLists)
282 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags); 282 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags);
283 283
284 if (shouldPaintOverlayScrollbars) 284 if (shouldPaintOverlayScrollbars)
285 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 285 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
286 } // FilterPainter block 286 } // FilterPainter block
287 287
288 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_renderLayer.renderer()->hasMask() && !selectionOnly; 288 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_renderLayer.layoutObject()->hasMask() && !selectionO nly;
289 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 289 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
290 290
291 if (shouldPaintMask) 291 if (shouldPaintMask)
292 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer, paintFlags); 292 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer, paintFlags);
293 if (shouldPaintClippingMask) { 293 if (shouldPaintClippingMask) {
294 // Paint the border radius mask for the fragments. 294 // Paint the border radius mask for the fragments.
295 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForRenderer, paintFlags); 295 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForRenderer, paintFlags);
296 } 296 }
297 } 297 }
298 298
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return; 330 return;
331 331
332 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here. 332 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here.
333 // m_renderLayer may be the "root", and then we should avoid looking at its parent. 333 // m_renderLayer may be the "root", and then we should avoid looking at its parent.
334 Layer* parentLayer = m_renderLayer.parent(); 334 Layer* parentLayer = m_renderLayer.parent();
335 335
336 ClipRect ancestorBackgroundClipRect; 336 ClipRect ancestorBackgroundClipRect;
337 if (parentLayer) { 337 if (parentLayer) {
338 // Calculate the clip rectangle that the ancestors establish. 338 // Calculate the clip rectangle that the ancestors establish.
339 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize); 339 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver layScrollbarSize);
340 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == I gnoreOverflowClip) 340 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.layoutObject()) == IgnoreOverflowClip)
341 clipRectsContext.setIgnoreOverflowClip(); 341 clipRectsContext.setIgnoreOverflowClip();
342 ancestorBackgroundClipRect = m_renderLayer.clipper().backgroundClipRect( clipRectsContext); 342 ancestorBackgroundClipRect = m_renderLayer.clipper().backgroundClipRect( clipRectsContext);
343 } 343 }
344 344
345 Layer* paginationLayer = m_renderLayer.enclosingPaginationLayer(); 345 Layer* paginationLayer = m_renderLayer.enclosingPaginationLayer();
346 LayerFragments fragments; 346 LayerFragments fragments;
347 if (paginationLayer) { 347 if (paginationLayer) {
348 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any 348 // FIXME: This is a mess. Look closely at this code and the code in Laye r and fix any
349 // issues in it & refactor to make it obvious from code structure what i t does and that it's 349 // issues in it & refactor to make it obvious from code structure what i t does and that it's
350 // correct. 350 // correct.
351 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 351 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
352 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_renderLayer.renderer()); 352 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_renderLayer.layoutObject());
353 // Calculate the transformed bounding box in the current coordinate spac e, to figure out 353 // Calculate the transformed bounding box in the current coordinate spac e, to figure out
354 // which fragmentainers (e.g. columns) we need to visit. 354 // which fragmentainers (e.g. columns) we need to visit.
355 LayoutRect transformedExtent = Layer::transparencyClipBox(&m_renderLayer , paginationLayer, Layer::PaintingTransparencyClipBox, Layer::RootOfTransparency ClipBox, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); 355 LayoutRect transformedExtent = Layer::transparencyClipBox(&m_renderLayer , paginationLayer, Layer::PaintingTransparencyClipBox, Layer::RootOfTransparency ClipBox, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior);
356 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here. 356 // FIXME: we don't check if paginationLayer is within paintingInfo.rootL ayer here.
357 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent); 357 paginationLayer->collectFragments(fragments, paintingInfo.rootLayer, pai ntingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflow Clip, 0, paintingInfo.subPixelAccumulation, &transformedExtent);
358 } else { 358 } else {
359 // We don't need to collect any fragments in the regular way here. We ha ve already 359 // We don't need to collect any fragments in the regular way here. We ha ve already
360 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this 360 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this
361 // layer is something that can be done further down the path, when the t ransform has 361 // layer is something that can be done further down the path, when the t ransform has
362 // been applied. 362 // been applied.
363 LayerFragment fragment; 363 LayerFragment fragment;
364 fragment.backgroundRect = paintingInfo.paintDirtyRect; 364 fragment.backgroundRect = paintingInfo.paintDirtyRect;
365 fragments.append(fragment); 365 fragments.append(fragment);
366 } 366 }
367 367
368 for (const auto& fragment: fragments) { 368 for (const auto& fragment: fragments) {
369 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 369 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
370 OwnPtr<LayerClipRecorder> clipRecorder; 370 OwnPtr<LayerClipRecorder> clipRecorder;
371 if (parentLayer) { 371 if (parentLayer) {
372 ClipRect clipRectForFragment(ancestorBackgroundClipRect); 372 ClipRect clipRectForFragment(ancestorBackgroundClipRect);
373 clipRectForFragment.moveBy(fragment.paginationOffset); 373 clipRectForFragment.moveBy(fragment.paginationOffset);
374 clipRectForFragment.intersect(fragment.backgroundRect); 374 clipRectForFragment.intersect(fragment.backgroundRect);
375 if (clipRectForFragment.isEmpty()) 375 if (clipRectForFragment.isEmpty())
376 continue; 376 continue;
377 if (needsToClip(paintingInfo, clipRectForFragment)) 377 if (needsToClip(paintingInfo, clipRectForFragment))
378 clipRecorder = adoptPtr(new LayerClipRecorder(parentLayer->rende rer(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &paintingInfo , fragment.paginationOffset, paintFlags)); 378 clipRecorder = adoptPtr(new LayerClipRecorder(parentLayer->layou tObject(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &painting Info, fragment.paginationOffset, paintFlags));
379 } 379 }
380 380
381 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset); 381 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset);
382 } 382 }
383 } 383 }
384 384
385 void LayerPainter::paintFragmentByApplyingTransform(GraphicsContext* context, co nst LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoi nt& fragmentTranslation) 385 void LayerPainter::paintFragmentByApplyingTransform(GraphicsContext* context, co nst LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoi nt& fragmentTranslation)
386 { 386 {
387 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 387 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
388 // the accumulated error for sub-pixel layout. 388 // the accumulated error for sub-pixel layout.
389 LayoutPoint delta; 389 LayoutPoint delta;
390 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); 390 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, delta);
391 delta.moveBy(fragmentTranslation); 391 delta.moveBy(fragmentTranslation);
392 TransformationMatrix transform(m_renderLayer.renderableTransform(paintingInf o.paintBehavior)); 392 TransformationMatrix transform(m_renderLayer.renderableTransform(paintingInf o.paintBehavior));
393 IntPoint roundedDelta = roundedIntPoint(delta); 393 IntPoint roundedDelta = roundedIntPoint(delta);
394 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 394 transform.translateRight(roundedDelta.x(), roundedDelta.y());
395 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 395 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
396 396
397 Transform3DRecorder transform3DRecorder(*context, m_renderLayer.renderer()-> displayItemClient(), transform); 397 Transform3DRecorder transform3DRecorder(*context, m_renderLayer.layoutObject ()->displayItemClient(), transform);
398 398
399 // Now do a paint with the root layer shifted to be us. 399 // Now do a paint with the root layer shifted to be us.
400 LayerPaintingInfo transformedPaintingInfo(&m_renderLayer, LayoutRect(enclosi ngIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), paintingIn fo.paintBehavior, 400 LayerPaintingInfo transformedPaintingInfo(&m_renderLayer, LayoutRect(enclosi ngIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), paintingIn fo.paintBehavior,
401 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); 401 adjustedSubPixelAccumulation, paintingInfo.paintingRoot);
402 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags , ForceSingleFragment); 402 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags , ForceSingleFragment);
403 } 403 }
404 404
405 void LayerPainter::paintChildren(unsigned childrenToVisit, GraphicsContext* cont ext, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 405 void LayerPainter::paintChildren(unsigned childrenToVisit, GraphicsContext* cont ext, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
406 { 406 {
407 if (!m_renderLayer.hasSelfPaintingLayerDescendant()) 407 if (!m_renderLayer.hasSelfPaintingLayerDescendant())
(...skipping 14 matching lines...) Expand all
422 if (!child->layer()->isPaginated()) 422 if (!child->layer()->isPaginated())
423 childPainter.paintLayer(context, paintingInfo, paintFlags); 423 childPainter.paintLayer(context, paintingInfo, paintFlags);
424 else 424 else
425 childPainter.paintPaginatedChildLayer(context, paintingInfo, paintFl ags); 425 childPainter.paintPaginatedChildLayer(context, paintingInfo, paintFl ags);
426 } 426 }
427 } 427 }
428 428
429 // FIXME: inline this. 429 // FIXME: inline this.
430 static bool paintForFixedRootBackground(const Layer* layer, PaintLayerFlags pain tFlags) 430 static bool paintForFixedRootBackground(const Layer* layer, PaintLayerFlags pain tFlags)
431 { 431 {
432 return layer->renderer()->isDocumentElement() && (paintFlags & PaintLayerPai ntingRootBackgroundOnly); 432 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly);
433 } 433 }
434 434
435 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags) 435 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags)
436 { 436 {
437 DisableCompositingQueryAsserts disabler; 437 DisableCompositingQueryAsserts disabler;
438 438
439 return m_renderLayer.compositingState() == NotComposited 439 return m_renderLayer.compositingState() == NotComposited
440 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) 440 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
441 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform()) 441 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform())
442 || paintForFixedRootBackground(&m_renderLayer, paintFlags); 442 || paintForFixedRootBackground(&m_renderLayer, paintFlags);
443 } 443 }
444 444
445 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel Accumulation, CompositingState compositingState) 445 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel Accumulation, CompositingState compositingState)
446 { 446 {
447 // Only apply the sub-pixel accumulation if we don't paint into our own back ing layer, otherwise the position 447 // Only apply the sub-pixel accumulation if we don't paint into our own back ing layer, otherwise the position
448 // of the renderer already includes any sub-pixel offset. 448 // of the renderer already includes any sub-pixel offset.
449 if (compositingState == PaintsIntoOwnBacking) 449 if (compositingState == PaintsIntoOwnBacking)
450 return LayoutSize(); 450 return LayoutSize();
451 return subPixelAccumulation; 451 return subPixelAccumulation;
452 } 452 }
453 453
454 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 454 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
455 { 455 {
456 for (size_t i = 0; i < layerFragments.size(); ++i) { 456 for (size_t i = 0; i < layerFragments.size(); ++i) {
457 const LayerFragment& fragment = layerFragments.at(i); 457 const LayerFragment& fragment = layerFragments.at(i);
458 458
459 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 459 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
460 OwnPtr<LayerClipRecorder> clipRecorder; 460 OwnPtr<LayerClipRecorder> clipRecorder;
461 461
462 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { 462 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
463 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer (), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &l ocalPaintingInfo, fragment.paginationOffset, paintFlags)); 463 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutOb ject(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect , &localPaintingInfo, fragment.paginationOffset, paintFlags));
464 } 464 }
465 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() ) 465 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() )
466 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout BoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulat ion, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroun dRect.rect()), true); 466 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout BoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulat ion, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroun dRect.rect()), true);
467 } 467 }
468 } 468 }
469 469
470 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer) 470 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer)
471 { 471 {
472 LayoutView* view = renderer->view(); 472 LayoutView* view = renderer->view();
473 LayoutBoxModelObject* prevBlock = renderer; 473 LayoutBoxModelObject* prevBlock = renderer;
(...skipping 14 matching lines...) Expand all
488 // Otherwise we are paginated by the columns block. 488 // Otherwise we are paginated by the columns block.
489 return true; 489 return true;
490 } 490 }
491 491
492 void LayerPainter::paintPaginatedChildLayer(GraphicsContext* context, const Laye rPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 492 void LayerPainter::paintPaginatedChildLayer(GraphicsContext* context, const Laye rPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
493 { 493 {
494 // We need to do multiple passes, breaking up our child layer into strips. 494 // We need to do multiple passes, breaking up our child layer into strips.
495 Vector<Layer*> columnLayers; 495 Vector<Layer*> columnLayers;
496 LayerStackingNode* ancestorNode = m_renderLayer.stackingNode()->isNormalFlow Only() ? m_renderLayer.parent()->stackingNode() : m_renderLayer.stackingNode()-> ancestorStackingContextNode(); 496 LayerStackingNode* ancestorNode = m_renderLayer.stackingNode()->isNormalFlow Only() ? m_renderLayer.parent()->stackingNode() : m_renderLayer.stackingNode()-> ancestorStackingContextNode();
497 for (Layer* curr = m_renderLayer.parent(); curr; curr = curr->parent()) { 497 for (Layer* curr = m_renderLayer.parent(); curr; curr = curr->parent()) {
498 if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagina tion(m_renderLayer.renderer(), curr->layoutBox())) 498 if (curr->layoutObject()->hasColumns() && checkContainingBlockChainForPa gination(m_renderLayer.layoutObject(), curr->layoutBox()))
499 columnLayers.append(curr); 499 columnLayers.append(curr);
500 if (curr->stackingNode() == ancestorNode) 500 if (curr->stackingNode() == ancestorNode)
501 break; 501 break;
502 } 502 }
503 503
504 // It is possible for paintLayer() to be called after the child layer ceases to be paginated but before 504 // It is possible for paintLayer() to be called after the child layer ceases to be paginated but before
505 // updatePaginationRecusive() is called and resets the isPaginated() flag, s ee <rdar://problem/10098679>. 505 // updatePaginationRecusive() is called and resets the isPaginated() flag, s ee <rdar://problem/10098679>.
506 // If this is the case, just bail out, since the upcoming call to updatePagi nationRecusive() will paint invalidate the layer. 506 // If this is the case, just bail out, since the upcoming call to updatePagi nationRecusive() will paint invalidate the layer.
507 // FIXME: Is this true anymore? This seems very suspicious. 507 // FIXME: Is this true anymore? This seems very suspicious.
508 if (!columnLayers.size()) 508 if (!columnLayers.size())
509 return; 509 return;
510 510
511 paintChildLayerIntoColumns(context, paintingInfo, paintFlags, columnLayers, columnLayers.size() - 1); 511 paintChildLayerIntoColumns(context, paintingInfo, paintFlags, columnLayers, columnLayers.size() - 1);
512 } 512 }
513 513
514 void LayerPainter::paintChildLayerIntoColumns(GraphicsContext* context, const La yerPaintingInfo& paintingInfo, 514 void LayerPainter::paintChildLayerIntoColumns(GraphicsContext* context, const La yerPaintingInfo& paintingInfo,
515 PaintLayerFlags paintFlags, const Vector<Layer*>& columnLayers, size_t colIn dex) 515 PaintLayerFlags paintFlags, const Vector<Layer*>& columnLayers, size_t colIn dex)
516 { 516 {
517 LayoutBlock* columnBlock = toLayoutBlock(columnLayers[colIndex]->renderer()) ; 517 LayoutBlock* columnBlock = toLayoutBlock(columnLayers[colIndex]->layoutObjec t());
518 518
519 ASSERT(columnBlock && columnBlock->hasColumns()); 519 ASSERT(columnBlock && columnBlock->hasColumns());
520 if (!columnBlock || !columnBlock->hasColumns()) 520 if (!columnBlock || !columnBlock->hasColumns())
521 return; 521 return;
522 522
523 LayoutPoint layerOffset; 523 LayoutPoint layerOffset;
524 // FIXME: It looks suspicious to call convertToLayerCoords here 524 // FIXME: It looks suspicious to call convertToLayerCoords here
525 // as canUseConvertToLayerCoords is true for this layer. 525 // as canUseConvertToLayerCoords is true for this layer.
526 columnBlock->layer()->convertToLayerCoords(paintingInfo.rootLayer, layerOffs et); 526 columnBlock->layer()->convertToLayerCoords(paintingInfo.rootLayer, layerOffs et);
527 527
(...skipping 21 matching lines...) Expand all
549 } 549 }
550 550
551 colRect.moveBy(layerOffset); 551 colRect.moveBy(layerOffset);
552 552
553 LayoutRect localDirtyRect(paintingInfo.paintDirtyRect); 553 LayoutRect localDirtyRect(paintingInfo.paintDirtyRect);
554 localDirtyRect.intersect(colRect); 554 localDirtyRect.intersect(colRect);
555 555
556 if (!localDirtyRect.isEmpty()) { 556 if (!localDirtyRect.isEmpty()) {
557 // Each strip pushes a clip, since column boxes are specified as bei ng 557 // Each strip pushes a clip, since column boxes are specified as bei ng
558 // like overflow:hidden. 558 // like overflow:hidden.
559 ClipRecorder clipRecorder(m_renderLayer.renderer()->displayItemClien t(), context, DisplayItem::ClipLayerColumnBounds, LayoutRect(enclosingIntRect(co lRect))); 559 ClipRecorder clipRecorder(m_renderLayer.layoutObject()->displayItemC lient(), context, DisplayItem::ClipLayerColumnBounds, LayoutRect(enclosingIntRec t(colRect)));
560 560
561 if (!colIndex) { 561 if (!colIndex) {
562 // Apply a translation transform to change where the layer paint s. 562 // Apply a translation transform to change where the layer paint s.
563 TransformationMatrix oldTransform; 563 TransformationMatrix oldTransform;
564 bool oldHasTransform = m_renderLayer.transform(); 564 bool oldHasTransform = m_renderLayer.transform();
565 if (oldHasTransform) 565 if (oldHasTransform)
566 oldTransform = *m_renderLayer.transform(); 566 oldTransform = *m_renderLayer.transform();
567 TransformationMatrix newTransform(oldTransform); 567 TransformationMatrix newTransform(oldTransform);
568 newTransform.translateRight(roundToInt(offset.width()), roundToI nt(offset.height())); 568 newTransform.translateRight(roundToInt(offset.width()), roundToI nt(offset.height()));
569 569
570 m_renderLayer.setTransform(adoptPtr(new TransformationMatrix(new Transform))); 570 m_renderLayer.setTransform(adoptPtr(new TransformationMatrix(new Transform)));
571 571
572 LayerPaintingInfo localPaintingInfo(paintingInfo); 572 LayerPaintingInfo localPaintingInfo(paintingInfo);
573 localPaintingInfo.paintDirtyRect = localDirtyRect; 573 localPaintingInfo.paintDirtyRect = localDirtyRect;
574 paintLayer(context, localPaintingInfo, paintFlags); 574 paintLayer(context, localPaintingInfo, paintFlags);
575 575
576 if (oldHasTransform) 576 if (oldHasTransform)
577 m_renderLayer.setTransform(adoptPtr(new TransformationMatrix (oldTransform))); 577 m_renderLayer.setTransform(adoptPtr(new TransformationMatrix (oldTransform)));
578 else 578 else
579 m_renderLayer.clearTransform(); 579 m_renderLayer.clearTransform();
580 } else { 580 } else {
581 // Adjust the transform such that the renderer's upper left corn er will paint at (0,0) in user space. 581 // Adjust the transform such that the renderer's upper left corn er will paint at (0,0) in user space.
582 // This involves subtracting out the position of the layer in ou r current coordinate space. 582 // This involves subtracting out the position of the layer in ou r current coordinate space.
583 LayoutPoint childOffset; 583 LayoutPoint childOffset;
584 columnLayers[colIndex - 1]->convertToLayerCoords(paintingInfo.ro otLayer, childOffset); 584 columnLayers[colIndex - 1]->convertToLayerCoords(paintingInfo.ro otLayer, childOffset);
585 TransformationMatrix transform; 585 TransformationMatrix transform;
586 transform.translateRight(roundToInt(childOffset.x() + offset.wid th()), roundToInt(childOffset.y() + offset.height())); 586 transform.translateRight(roundToInt(childOffset.x() + offset.wid th()), roundToInt(childOffset.y() + offset.height()));
587 587
588 Transform3DRecorder transform3DRecorder(*context, m_renderLayer. renderer()->displayItemClient(), transform); 588 Transform3DRecorder transform3DRecorder(*context, m_renderLayer. layoutObject()->displayItemClient(), transform);
589 589
590 // Now do a paint with the root layer shifted to be the next mul ticol block. 590 // Now do a paint with the root layer shifted to be the next mul ticol block.
591 LayerPaintingInfo columnPaintingInfo(paintingInfo); 591 LayerPaintingInfo columnPaintingInfo(paintingInfo);
592 columnPaintingInfo.rootLayer = columnLayers[colIndex - 1]; 592 columnPaintingInfo.rootLayer = columnLayers[colIndex - 1];
593 columnPaintingInfo.paintDirtyRect = transform.inverse().mapRect( localDirtyRect); 593 columnPaintingInfo.paintDirtyRect = transform.inverse().mapRect( localDirtyRect);
594 paintChildLayerIntoColumns(context, columnPaintingInfo, paintFla gs, columnLayers, colIndex - 1); 594 paintChildLayerIntoColumns(context, columnPaintingInfo, paintFla gs, columnLayers, colIndex - 1);
595 } 595 }
596 } 596 }
597 597
598 // Move to the next position. 598 // Move to the next position.
(...skipping 15 matching lines...) Expand all
614 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self. 614 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self.
615 case PaintPhaseSelfOutline: 615 case PaintPhaseSelfOutline:
616 case PaintPhaseMask: // Mask painting will handle clipping to self. 616 case PaintPhaseMask: // Mask painting will handle clipping to self.
617 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 617 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
618 break; 618 break;
619 default: 619 default:
620 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 620 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
621 break; 621 break;
622 } 622 }
623 623
624 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlag s, clippingRule)); 624 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutObject (), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paint Flags, clippingRule));
625 } 625 }
626 626
627 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); 627 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->layoutObject()) ;
628 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca tion() - m_renderLayer.layoutBoxLocation() + subPixelAccumulationIfNeeded(painti ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); 628 m_renderLayer.layoutObject()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.layoutBoxLocation() + subPixelAccumulationIfNeeded(pa intingInfo.subPixelAccumulation, m_renderLayer.compositingState())));
629 } 629 }
630 630
631 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context, 631 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context,
632 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 632 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
633 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 633 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
634 { 634 {
635 for (const auto& fragment: layerFragments) { 635 for (const auto& fragment: layerFragments) {
636 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 636 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
637 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped); 637 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped);
638 } 638 }
639 } 639 }
640 640
641 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context, 641 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context,
642 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 642 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
643 LayoutObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags) 643 LayoutObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags)
644 { 644 {
645 // Optimize clipping for the single fragment case. 645 // Optimize clipping for the single fragment case.
646 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 646 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
647 ClipState clipState = HasNotClipped; 647 ClipState clipState = HasNotClipped;
648 OwnPtr<LayerClipRecorder> clipRecorder; 648 OwnPtr<LayerClipRecorder> clipRecorder;
649 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 649 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
650 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect, &lo calPaintingInfo, layerFragments[0].paginationOffset, paintFlags)); 650 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutObject (), context, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, layerFragments[0].paginationOffset, paintFlags));
651 clipState = HasClipped; 651 clipState = HasClipped;
652 } 652 }
653 653
654 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 654 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
655 // interleaving of the fragments to work properly. 655 // interleaving of the fragments to work properly.
656 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, 656 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments,
657 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags, clipState); 657 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags, clipState);
658 658
659 if (!selectionOnly) { 659 if (!selectionOnly) {
660 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl ipState); 660 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl ipState);
661 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s, clipState); 661 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s, clipState);
662 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintF lags, clipState); 662 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintF lags, clipState);
663 } 663 }
664 } 664 }
665 665
666 void LayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, const LayerFragments& layerFragments, GraphicsContext* context, 666 void LayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, const LayerFragments& layerFragments, GraphicsContext* context,
667 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Lay outObject* paintingRootForRenderer, PaintLayerFlags paintFlags, ClipState clipSt ate) 667 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Lay outObject* paintingRootForRenderer, PaintLayerFlags paintFlags, ClipState clipSt ate)
668 { 668 {
669 for (const auto& fragment: layerFragments) { 669 for (const auto& fragment: layerFragments) {
670 if (!fragment.foregroundRect.isEmpty()) { 670 if (!fragment.foregroundRect.isEmpty()) {
671 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 671 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
672 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cli pState); 672 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cli pState);
673 } 673 }
674 } 674 }
675 } 675 }
676 676
677 void LayerPainter::paintOutlineForFragments(const LayerFragments& layerFragments , GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 677 void LayerPainter::paintOutlineForFragments(const LayerFragments& layerFragments , GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
678 PaintBehavior paintBehavior, LayoutObject* paintingRootForRenderer, PaintLay erFlags paintFlags) 678 PaintBehavior paintBehavior, LayoutObject* paintingRootForRenderer, PaintLay erFlags paintFlags)
679 { 679 {
680 for (const auto& fragment: layerFragments) { 680 for (const auto& fragment: layerFragments) {
681 if (!fragment.outlineRect.isEmpty()) { 681 if (!fragment.outlineRect.isEmpty()) {
682 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 682 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
683 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.outlineRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, pa intFlags, HasNotClipped); 683 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.outlineRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, pa intFlags, HasNotClipped);
684 } 684 }
685 } 685 }
686 } 686 }
687 687
688 void LayerPainter::paintMaskForFragments(const LayerFragments& layerFragments, G raphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 688 void LayerPainter::paintMaskForFragments(const LayerFragments& layerFragments, G raphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
689 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 689 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
690 { 690 {
691 for (const auto& fragment: layerFragments) { 691 for (const auto& fragment: layerFragments) {
692 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 692 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
693 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForRenderer, pain tFlags, HasNotClipped); 693 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForRenderer, pain tFlags, HasNotClipped);
694 } 694 }
695 } 695 }
696 696
697 void LayerPainter::paintChildClippingMaskForFragments(const LayerFragments& laye rFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo , 697 void LayerPainter::paintChildClippingMaskForFragments(const LayerFragments& laye rFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo ,
698 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 698 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
699 { 699 {
700 for (const auto& fragment: layerFragments) { 700 for (const auto& fragment: layerFragments) {
701 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 701 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
702 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForRender er, paintFlags, HasNotClipped); 702 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForRender er, paintFlags, HasNotClipped);
703 } 703 }
704 } 704 }
705 705
706 void LayerPainter::paintOverlayScrollbars(GraphicsContext* context, const Layout Rect& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot) 706 void LayerPainter::paintOverlayScrollbars(GraphicsContext* context, const Layout Rect& damageRect, PaintBehavior paintBehavior, LayoutObject* paintingRoot)
707 { 707 {
708 if (!m_renderLayer.containsDirtyOverlayScrollbars()) 708 if (!m_renderLayer.containsDirtyOverlayScrollbars())
709 return; 709 return;
710 710
711 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot); 711 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot);
712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
713 713
714 m_renderLayer.setContainsDirtyOverlayScrollbars(false); 714 m_renderLayer.setContainsDirtyOverlayScrollbars(false);
715 } 715 }
716 716
717 } // namespace blink 717 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698