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

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

Issue 2856373002: [blink] Unify PaintLayerClipper behavior with kIgnoreOverflowClip (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/PaintLayerClipper.h" 5 #include "core/paint/PaintLayerClipper.h"
6 6
7 #include "core/layout/LayoutBoxModelObject.h" 7 #include "core/layout/LayoutBoxModelObject.h"
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 LayoutRect layer_bounds(infinite_rect); 505 LayoutRect layer_bounds(infinite_rect);
506 ClipRect background_rect(infinite_rect); 506 ClipRect background_rect(infinite_rect);
507 ClipRect foreground_rect(infinite_rect); 507 ClipRect foreground_rect(infinite_rect);
508 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds, 508 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
509 background_rect, foreground_rect); 509 background_rect, foreground_rect);
510 510
511 EXPECT_EQ(LayoutRect(-12, -9, 124, 224), background_rect.Rect()); 511 EXPECT_EQ(LayoutRect(-12, -9, 124, 224), background_rect.Rect());
512 EXPECT_EQ(LayoutRect(0, 0, 100, 200), foreground_rect.Rect()); 512 EXPECT_EQ(LayoutRect(0, 0, 100, 200), foreground_rect.Rect());
513 } 513 }
514 514
515 // Computed infinite clip rects may not match LayoutRect::InfiniteIntRect()
516 // due to floating point errors.
517 static bool IsInfinite(const LayoutRect& rect) {
518 return rect.X().Round() < -10000000 && rect.MaxX().Round() > 10000000
519 && rect.Y().Round() < -10000000 && rect.MaxY().Round() > 10000000;
520 }
521
522 TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithCSSClip) {
523 SetBodyInnerHTML(
524 "<style>"
525 " #root { "
526 " width: 400px; height: 400px;"
527 " position: absolute; clip: rect(0, 50px, 100px, 0);"
528 " }"
529 " #target {"
530 " position: relative;"
531 " }"
532 "</style>"
533 "<div id='root'>"
534 " <div id='target'></div>"
535 "</div>");
536
537 PaintLayer* root =
538 ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
539 PaintLayer* target =
540 ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
541 ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
542 PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
543 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
544 option = PaintLayer::kUseGeometryMapper;
545 LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
546 LayoutRect layer_bounds(infinite_rect);
547 ClipRect background_rect(infinite_rect);
548 ClipRect foreground_rect(infinite_rect);
549 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
550 background_rect, foreground_rect);
551
552 EXPECT_TRUE(IsInfinite(background_rect.Rect()));
553 EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
554 }
555
556 TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithOverflowClip) {
557 SetBodyInnerHTML(
558 "<style>"
559 " #root { "
560 " width: 400px; height: 400px;"
561 " overflow: hidden;"
562 " }"
563 " #target {"
564 " position: relative;"
565 " }"
566 "</style>"
567 "<div id='root'>"
568 " <div id='target'></div>"
569 "</div>");
570
571 PaintLayer* root =
572 ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
573 PaintLayer* target =
574 ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
575 ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
576 PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
577 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
578 option = PaintLayer::kUseGeometryMapper;
579 LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
580 LayoutRect layer_bounds(infinite_rect);
581 ClipRect background_rect(infinite_rect);
582 ClipRect foreground_rect(infinite_rect);
583 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
584 background_rect, foreground_rect);
585
586 EXPECT_TRUE(IsInfinite(background_rect.Rect()));
587 EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
588 }
589
590 TEST_P(PaintLayerClipperTest, IgnoreRootLayerClipWithBothClip) {
591 SetBodyInnerHTML(
592 "<style>"
593 " #root { "
594 " width: 400px; height: 400px;"
595 " position: absolute; clip: rect(0, 50px, 100px, 0);"
596 " overflow: hidden;"
597 " }"
598 " #target {"
599 " position: relative;"
600 " }"
601 "</style>"
602 "<div id='root'>"
603 " <div id='target'></div>"
604 "</div>");
605
606 PaintLayer* root =
607 ToLayoutBoxModelObject(GetLayoutObjectByElementId("root"))->Layer();
608 PaintLayer* target =
609 ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
610 ClipRectsContext context(root, kPaintingClipRectsIgnoringOverflowClip);
611 PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper;
612 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
613 option = PaintLayer::kUseGeometryMapper;
614 LayoutRect infinite_rect(LayoutRect::InfiniteIntRect());
615 LayoutRect layer_bounds(infinite_rect);
616 ClipRect background_rect(infinite_rect);
617 ClipRect foreground_rect(infinite_rect);
618 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds,
619 background_rect, foreground_rect);
620
621 EXPECT_TRUE(IsInfinite(background_rect.Rect()));
622 EXPECT_TRUE(IsInfinite(foreground_rect.Rect()));
623 }
624
515 } // namespace blink 625 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698