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

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

Issue 2368043002: [SPv2] Separate SVG root viewport clip from overflow clip. (Closed)
Patch Set: none Created 4 years, 2 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return; 370 return;
371 const LayoutBox& box = toLayoutBox(object); 371 const LayoutBox& box = toLayoutBox(object);
372 372
373 // The <input> elements can't have contents thus CSS overflow property doesn 't apply. 373 // The <input> elements can't have contents thus CSS overflow property doesn 't apply.
374 // However for layout purposes we do generate child layout objects for them, e.g. button label. 374 // However for layout purposes we do generate child layout objects for them, e.g. button label.
375 // We should clip the overflow from those children. This is called control c lip and we 375 // We should clip the overflow from those children. This is called control c lip and we
376 // technically treat them like overflow clip. 376 // technically treat them like overflow clip.
377 LayoutRect clipRect; 377 LayoutRect clipRect;
378 if (box.hasControlClip()) { 378 if (box.hasControlClip()) {
379 clipRect = box.controlClipRect(context.current.paintOffset); 379 clipRect = box.controlClipRect(context.current.paintOffset);
380 } else if (box.hasOverflowClip() || (box.isSVGRoot() && toLayoutSVGRoot(box) .shouldApplyViewportClip())) { 380 } else if (box.hasOverflowClip()) {
381 clipRect = box.overflowClipRect(context.current.paintOffset); 381 clipRect = box.overflowClipRect(context.current.paintOffset);
382 } else { 382 } else {
383 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties()) 383 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties())
384 properties->clearOverflowClip(); 384 properties->clearOverflowClip();
385 return; 385 return;
386 } 386 }
387 387
388 // This need to be in top-level block to hold the reference until we finish creating the normal clip node. 388 // This need to be in top-level block to hold the reference until we finish creating the normal clip node.
389 RefPtr<ClipPaintPropertyNode> borderRadiusClip; 389 RefPtr<ClipPaintPropertyNode> borderRadiusClip;
390 if (box.styleRef().hasBorderRadius()) { 390 if (box.styleRef().hasBorderRadius()) {
391 auto innerBorder = box.styleRef().getRoundedInnerBorderFor( 391 auto innerBorder = box.styleRef().getRoundedInnerBorderFor(
392 LayoutRect(context.current.paintOffset, box.size())); 392 LayoutRect(context.current.paintOffset, box.size()));
393 borderRadiusClip = ClipPaintPropertyNode::create(context.current.clip, c ontext.current.transform, innerBorder); 393 borderRadiusClip = ClipPaintPropertyNode::create(context.current.clip, c ontext.current.transform, innerBorder);
394 context.current.clip = borderRadiusClip.get(); 394 context.current.clip = borderRadiusClip.get();
395 } 395 }
396 396
397 context.current.clip = object.getMutableForPainting().ensureObjectPaintPrope rties().createOrUpdateOverflowClip( 397 context.current.clip = object.getMutableForPainting().ensureObjectPaintPrope rties().createOrUpdateOverflowClip(
398 context.current.clip, context.current.transform, FloatRoundedRect(FloatR ect(clipRect))); 398 context.current.clip, context.current.transform, FloatRoundedRect(FloatR ect(clipRect)));
399 } 399 }
400 400
401 void PaintPropertyTreeBuilder::updateSvgRootViewportClip(const LayoutObject& obj ect, PaintPropertyTreeBuilderContext& context)
402 {
403 if (!object.isBox())
404 return;
405 const LayoutBox& box = toLayoutBox(object);
406
407 LayoutRect clipRect;
408 if (box.isSVGRoot() && toLayoutSVGRoot(box).shouldApplyViewportClip()) {
409 clipRect = box.overflowClipRect(context.current.paintOffset);
410 } else {
411 if (ObjectPaintProperties* properties = object.getMutableForPainting().o bjectPaintProperties())
412 properties->clearSvgRootViewportClip();
413 return;
414 }
415
416 context.current.clip = object.getMutableForPainting().ensureObjectPaintPrope rties().createOrUpdateSvgRootViewportClip(
417 context.current.clip, context.current.transform, FloatRoundedRect(FloatR ect(clipRect)));
418 }
419
401 static FloatPoint perspectiveOrigin(const LayoutBox& box) 420 static FloatPoint perspectiveOrigin(const LayoutBox& box)
402 { 421 {
403 const ComputedStyle& style = box.styleRef(); 422 const ComputedStyle& style = box.styleRef();
404 FloatSize borderBoxSize(box.size()); 423 FloatSize borderBoxSize(box.size());
405 return FloatPoint( 424 return FloatPoint(
406 floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()), 425 floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()),
407 floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())) ; 426 floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())) ;
408 } 427 }
409 428
410 void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai ntPropertyTreeBuilderContext& context) 429 void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai ntPropertyTreeBuilderContext& context)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 updateScrollbarPaintOffset(object, context); 602 updateScrollbarPaintOffset(object, context);
584 updateMainThreadScrollingReasons(object, context); 603 updateMainThreadScrollingReasons(object, context);
585 } 604 }
586 605
587 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj ect, PaintPropertyTreeBuilderContext& context) 606 void PaintPropertyTreeBuilder::buildTreeNodesForChildren(const LayoutObject& obj ect, PaintPropertyTreeBuilderContext& context)
588 { 607 {
589 if (!object.isBoxModelObject() && !object.isSVG()) 608 if (!object.isBoxModelObject() && !object.isSVG())
590 return; 609 return;
591 610
592 updateOverflowClip(object, context); 611 updateOverflowClip(object, context);
612 updateSvgRootViewportClip(object, context);
593 updatePerspective(object, context); 613 updatePerspective(object, context);
594 updateSvgLocalToBorderBoxTransform(object, context); 614 updateSvgLocalToBorderBoxTransform(object, context);
595 updateScrollAndScrollTranslation(object, context); 615 updateScrollAndScrollTranslation(object, context);
596 updateOutOfFlowContext(object, context); 616 updateOutOfFlowContext(object, context);
597 } 617 }
598 618
599 } // namespace blink 619 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698