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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2299533002: WIP: Construct SPV2's scroll paint property tree (Closed)
Patch Set: Add more paint property builder tests, update comments/documentation" Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/paint/PaintPropertyTreeBuilder.h" 5 #include "core/paint/PaintPropertyTreeBuilder.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutInline.h" 10 #include "core/layout/LayoutInline.h"
(...skipping 10 matching lines...) Expand all
21 21
22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro pertyTreeBuilderContext& context) 22 void PaintPropertyTreeBuilder::buildTreeRootNodes(FrameView& rootFrame, PaintPro pertyTreeBuilderContext& context)
23 { 23 {
24 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 24 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
25 return; 25 return;
26 26
27 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) { 27 if (!rootFrame.rootTransform() || rootFrame.rootTransform()->parent()) {
28 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T ransformationMatrix(), FloatPoint3D())); 28 rootFrame.setRootTransform(TransformPaintPropertyNode::create(nullptr, T ransformationMatrix(), FloatPoint3D()));
29 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect()))); 29 rootFrame.setRootClip(ClipPaintPropertyNode::create(nullptr, rootFrame.r ootTransform(), FloatRoundedRect(LayoutRect::infiniteIntRect())));
30 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0)); 30 rootFrame.setRootEffect(EffectPaintPropertyNode::create(nullptr, 1.0));
31 rootFrame.setRootScroll(ScrollPaintPropertyNode::create(nullptr, rootFra me.rootTransform(), FloatSize(), FloatSize(), false, false));
31 } else { 32 } else {
32 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent()); 33 DCHECK(rootFrame.rootClip() && !rootFrame.rootClip()->parent());
33 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent()); 34 DCHECK(rootFrame.rootEffect() && !rootFrame.rootEffect()->parent());
34 } 35 }
35 36
36 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootFrame.rootTransform(); 37 context.current.transform = context.absolutePosition.transform = context.fix edPosition.transform = rootFrame.rootTransform();
38 context.current.scroll = rootFrame.rootScroll();
37 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootFrame.rootClip(); 39 context.current.clip = context.absolutePosition.clip = context.fixedPosition .clip = rootFrame.rootClip();
38 context.currentEffect = rootFrame.rootEffect(); 40 context.currentEffect = rootFrame.rootEffect();
39 } 41 }
40 42
41 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert yTreeBuilderContext& context) 43 void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert yTreeBuilderContext& context)
42 { 44 {
43 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 45 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
44 LayoutView* layoutView = frameView.layoutView(); 46 LayoutView* layoutView = frameView.layoutView();
45 if (!layoutView) 47 if (!layoutView)
46 return; 48 return;
47 49
48 TransformationMatrix frameTranslate; 50 TransformationMatrix frameTranslate;
49 frameTranslate.translate( 51 frameTranslate.translate(
50 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(), 52 frameView.x() + layoutView->location().x() + context.current.paintOf fset.x(),
51 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y()); 53 frameView.y() + layoutView->location().y() + context.current.paintOf fset.y());
52 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation( 54 context.current.transform = layoutView->getMutableForPainting().ensureOb jectPaintProperties().createOrUpdatePaintOffsetTranslation(
53 context.current.transform, frameTranslate, FloatPoint3D()); 55 context.current.transform, frameTranslate, FloatPoint3D());
56 context.current.scroll = layoutView->getMutableForPainting().ensureObjec tPaintProperties().createOrUpdateScroll(
57 context.current.scroll, context.current.transform, FloatSize(), Floa tSize(), false, false);
54 context.current.paintOffset = LayoutPoint(); 58 context.current.paintOffset = LayoutPoint();
55 context.current.renderingContextID = 0; 59 context.current.renderingContextID = 0;
56 context.current.shouldFlattenInheritedTransform = true; 60 context.current.shouldFlattenInheritedTransform = true;
57 context.absolutePosition = context.current; 61 context.absolutePosition = context.current;
58 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext(). 62 context.containerForAbsolutePosition = nullptr; // This will get set in updateOutOfFlowContext().
59 context.fixedPosition = context.current; 63 context.fixedPosition = context.current;
60 return; 64 return;
61 } 65 }
62 66
63 TransformationMatrix frameTranslate; 67 TransformationMatrix frameTranslate;
(...skipping 10 matching lines...) Expand all
74 frameView.setContentClip(ClipPaintPropertyNode::create(context.current.c lip, frameView.preTranslation(), contentClip)); 78 frameView.setContentClip(ClipPaintPropertyNode::create(context.current.c lip, frameView.preTranslation(), contentClip));
75 79
76 DoubleSize scrollOffset = frameView.scrollOffsetDouble(); 80 DoubleSize scrollOffset = frameView.scrollOffsetDouble();
77 TransformationMatrix frameScroll; 81 TransformationMatrix frameScroll;
78 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); 82 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height());
79 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll Translation()) 83 if (TransformPaintPropertyNode* existingScrollTranslation = frameView.scroll Translation())
80 existingScrollTranslation->update(frameView.preTranslation(), frameScrol l, FloatPoint3D()); 84 existingScrollTranslation->update(frameView.preTranslation(), frameScrol l, FloatPoint3D());
81 else 85 else
82 frameView.setScrollTranslation(TransformPaintPropertyNode::create(frameV iew.preTranslation(), frameScroll, FloatPoint3D())); 86 frameView.setScrollTranslation(TransformPaintPropertyNode::create(frameV iew.preTranslation(), frameScroll, FloatPoint3D()));
83 87
88 FloatSize scrollClip = FloatSize(frameView.visibleContentSize());
89 FloatSize scrollBounds = FloatSize(frameView.contentsSize());
90 bool userScrollableHorizontal = frameView.userInputScrollable(HorizontalScro llbar);
91 bool userScrollableVertical = frameView.userInputScrollable(VerticalScrollba r);
92 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll())
93 existingScroll->update(context.current.scroll, frameView.scrollTranslati on(), scrollClip, scrollBounds, userScrollableHorizontal, userScrollableVertical );
94 else
95 frameView.setScroll(ScrollPaintPropertyNode::create(context.current.scro ll, frameView.scrollTranslation(), scrollClip, scrollBounds, userScrollableHoriz ontal, userScrollableVertical));
96
84 // Initialize the context for current, absolute and fixed position cases. 97 // Initialize the context for current, absolute and fixed position cases.
85 // They are the same, except that scroll translation does not apply to 98 // They are the same, except that scroll translation does not apply to
86 // fixed position descendants. 99 // fixed position descendants.
87 context.current.transform = frameView.scrollTranslation(); 100 context.current.transform = frameView.scrollTranslation();
88 context.current.paintOffset = LayoutPoint(); 101 context.current.paintOffset = LayoutPoint();
89 context.current.clip = frameView.contentClip(); 102 context.current.clip = frameView.contentClip();
103 context.current.scroll = frameView.scroll();
90 context.current.renderingContextID = 0; 104 context.current.renderingContextID = 0;
91 context.current.shouldFlattenInheritedTransform = true; 105 context.current.shouldFlattenInheritedTransform = true;
92 context.absolutePosition = context.current; 106 context.absolutePosition = context.current;
93 context.containerForAbsolutePosition = nullptr; 107 context.containerForAbsolutePosition = nullptr;
94 context.fixedPosition = context.current; 108 context.fixedPosition = context.current;
95 context.fixedPosition.transform = frameView.preTranslation(); 109 context.fixedPosition.transform = frameView.preTranslation();
96 } 110 }
97 111
98 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) 112 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
99 { 113 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o bject, PaintPropertyTreeBuilderContext& context) 244 void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o bject, PaintPropertyTreeBuilderContext& context)
231 { 245 {
232 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since we don't need them at the moment. 246 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since we don't need them at the moment.
233 if (!object.isBox() && !object.hasLayer()) 247 if (!object.isBox() && !object.hasLayer())
234 return; 248 return;
235 249
236 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo ntext = 250 std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxCo ntext =
237 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); 251 wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties);
238 borderBoxContext->paintOffset = context.current.paintOffset; 252 borderBoxContext->paintOffset = context.current.paintOffset;
239 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran sform, context.current.clip, context.currentEffect); 253 borderBoxContext->propertyTreeState = PropertyTreeState(context.current.tran sform, context.current.clip, context.currentEffect);
254 borderBoxContext->scroll = context.current.scroll;
240 255
241 if (!context.current.clip) { 256 if (!context.current.clip) {
242 DCHECK(object.isLayoutView()); 257 DCHECK(object.isLayoutView());
243 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); 258 DCHECK(toLayoutView(object).frameView()->frame().isMainFrame());
244 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); 259 DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled());
245 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create (nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec t())); 260 borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create (nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRec t()));
246 context.current.clip = borderBoxContext->propertyTreeState.clip.get(); 261 context.current.clip = borderBoxContext->propertyTreeState.clip.get();
247 } 262 }
248 263
249 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB oxProperties(std::move(borderBoxContext)); 264 object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderB oxProperties(std::move(borderBoxContext));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 properties->clearSvgLocalToBorderBoxTransform(); 362 properties->clearSvgLocalToBorderBoxTransform();
348 return; 363 return;
349 } 364 }
350 365
351 context.current.transform = object.getMutableForPainting().ensureObjectPaint Properties().createOrUpdateSvgLocalToBorderBoxTransform( 366 context.current.transform = object.getMutableForPainting().ensureObjectPaint Properties().createOrUpdateSvgLocalToBorderBoxTransform(
352 context.current.transform, transformToBorderBox, FloatPoint3D()); 367 context.current.transform, transformToBorderBox, FloatPoint3D());
353 context.current.shouldFlattenInheritedTransform = false; 368 context.current.shouldFlattenInheritedTransform = false;
354 context.current.renderingContextID = 0; 369 context.current.renderingContextID = 0;
355 } 370 }
356 371
357 void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& objec t, PaintPropertyTreeBuilderContext& context) 372 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(const LayoutObje ct& object, PaintPropertyTreeBuilderContext& context)
358 { 373 {
359 if (object.isBoxModelObject() && object.hasOverflowClip()) { 374 if (object.isBoxModelObject() && object.hasOverflowClip()) {
360 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); 375 PaintLayer* layer = toLayoutBoxModelObject(object).layer();
361 DCHECK(layer); 376 DCHECK(layer);
362 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); 377 DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset();
363 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl edFeatures::rootLayerScrollingEnabled(); 378 bool forceScrollingForLayoutView = object.isLayoutView() && RuntimeEnabl edFeatures::rootLayerScrollingEnabled();
364 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro llsOverflow()) { 379 if (forceScrollingForLayoutView || !scrollOffset.isZero() || layer->scro llsOverflow()) {
365 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height()); 380 TransformationMatrix matrix = TransformationMatrix().translate(-scro llOffset.width(), -scrollOffset.height());
366 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation( 381 context.current.transform = object.getMutableForPainting().ensureObj ectPaintProperties().createOrUpdateScrollTranslation(
367 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID); 382 context.current.transform, matrix, FloatPoint3D(), context.curre nt.shouldFlattenInheritedTransform, context.current.renderingContextID);
383
384 FloatSize scrollClip = FloatSize(layer->getScrollableArea()->visible ContentRect().size());
385 FloatSize scrollBounds = FloatSize(layer->getScrollableArea()->conte ntsSize());
386 bool userScrollableHorizontal = layer->getScrollableArea()->userInpu tScrollable(HorizontalScrollbar);
387 bool userScrollableVertical = layer->getScrollableArea()->userInputS crollable(VerticalScrollbar);
388 context.current.scroll = object.getMutableForPainting().ensureObject PaintProperties().createOrUpdateScroll(
389 context.current.scroll, context.current.transform, scrollClip, s crollBounds, userScrollableHorizontal, userScrollableVertical);
390
368 context.current.shouldFlattenInheritedTransform = false; 391 context.current.shouldFlattenInheritedTransform = false;
369 return; 392 return;
370 } 393 }
371 } 394 }
372 395
373 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) 396 if (ObjectPaintProperties* properties = object.getMutableForPainting().objec tPaintProperties()) {
374 properties->clearScrollTranslation(); 397 properties->clearScrollTranslation();
398 properties->clearScroll();
399 }
375 } 400 }
376 401
377 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context) 402 void PaintPropertyTreeBuilder::updateOutOfFlowContext(const LayoutObject& object , PaintPropertyTreeBuilderContext& context)
378 { 403 {
379 if (object.canContainAbsolutePositionObjects()) { 404 if (object.canContainAbsolutePositionObjects()) {
380 context.absolutePosition = context.current; 405 context.absolutePosition = context.current;
381 context.containerForAbsolutePosition = &object; 406 context.containerForAbsolutePosition = &object;
382 } 407 }
383 408
384 if (object.isLayoutView()) { 409 if (object.isLayoutView()) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 503 }
479 504
480 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj ect, PaintPropertyTreeBuilderContext& context) 505 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj ect, PaintPropertyTreeBuilderContext& context)
481 { 506 {
482 if (!object.isBoxModelObject() && !object.isSVG()) 507 if (!object.isBoxModelObject() && !object.isSVG())
483 return; 508 return;
484 509
485 updateOverflowClip(object, context); 510 updateOverflowClip(object, context);
486 updatePerspective(object, context); 511 updatePerspective(object, context);
487 updateSvgLocalToBorderBoxTransform(object, context); 512 updateSvgLocalToBorderBoxTransform(object, context);
488 updateScrollTranslation(object, context); 513 updateScrollAndScrollTranslation(object, context);
489 updateOutOfFlowContext(object, context); 514 updateOutOfFlowContext(object, context);
490 } 515 }
491 516
492 } // namespace blink 517 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698