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

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

Powered by Google App Engine
This is Rietveld 408576698