| OLD | NEW |
| 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/PaintPropertyTreeBuilderTest.h" | 5 #include "core/paint/PaintPropertyTreeBuilderTest.h" |
| 6 | 6 |
| 7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
| 8 #include "core/layout/LayoutTreeAsText.h" | 8 #include "core/layout/LayoutTreeAsText.h" |
| 9 #include "core/paint/ObjectPaintProperties.h" | 9 #include "core/paint/ObjectPaintProperties.h" |
| 10 #include "core/paint/PaintPropertyTreePrinter.h" | 10 #include "core/paint/PaintPropertyTreePrinter.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 RenderingTest::TearDown(); | 78 RenderingTest::TearDown(); |
| 79 | 79 |
| 80 Settings::SetMockScrollbarsEnabled(false); | 80 Settings::SetMockScrollbarsEnabled(false); |
| 81 } | 81 } |
| 82 | 82 |
| 83 #define CHECK_VISUAL_RECT(expected, sourceObject, ancestorObject, slopFactor) \ | 83 #define CHECK_VISUAL_RECT(expected, sourceObject, ancestorObject, slopFactor) \ |
| 84 do { \ | 84 do { \ |
| 85 if ((sourceObject)->HasLayer() && (ancestorObject)->HasLayer()) { \ | 85 if ((sourceObject)->HasLayer() && (ancestorObject)->HasLayer()) { \ |
| 86 LayoutRect source((sourceObject)->LocalVisualRect()); \ | 86 LayoutRect source((sourceObject)->LocalVisualRect()); \ |
| 87 source.MoveBy((sourceObject)->PaintOffset()); \ | 87 source.MoveBy((sourceObject)->PaintOffset()); \ |
| 88 const auto& contents_properties = \ | 88 auto contents_properties = (ancestorObject)->ContentsProperties(); \ |
| 89 *(ancestorObject)->ContentsProperties(); \ | |
| 90 FloatClipRect actual_float_rect((FloatRect(source))); \ | 89 FloatClipRect actual_float_rect((FloatRect(source))); \ |
| 91 GeometryMapper::SourceToDestinationVisualRect( \ | 90 GeometryMapper::SourceToDestinationVisualRect( \ |
| 92 *(sourceObject)->LocalBorderBoxProperties(), contents_properties, \ | 91 *(sourceObject)->LocalBorderBoxProperties(), contents_properties, \ |
| 93 actual_float_rect); \ | 92 actual_float_rect); \ |
| 94 LayoutRect actual(actual_float_rect.Rect()); \ | 93 LayoutRect actual(actual_float_rect.Rect()); \ |
| 95 actual.MoveBy(-(ancestorObject)->PaintOffset()); \ | 94 actual.MoveBy(-(ancestorObject)->PaintOffset()); \ |
| 96 SCOPED_TRACE("GeometryMapper: "); \ | 95 SCOPED_TRACE("GeometryMapper: "); \ |
| 97 EXPECT_EQ(expected, actual); \ | 96 EXPECT_EQ(expected, actual); \ |
| 98 } \ | 97 } \ |
| 99 \ | 98 \ |
| (...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 LayoutObject* child = | 2393 LayoutObject* child = |
| 2395 GetDocument().GetElementById("child")->GetLayoutObject(); | 2394 GetDocument().GetElementById("child")->GetLayoutObject(); |
| 2396 | 2395 |
| 2397 // No scroll translation because the document does not scroll (not enough | 2396 // No scroll translation because the document does not scroll (not enough |
| 2398 // content). | 2397 // content). |
| 2399 EXPECT_TRUE(!FrameScrollTranslation()); | 2398 EXPECT_TRUE(!FrameScrollTranslation()); |
| 2400 EXPECT_EQ(FramePreTranslation(), | 2399 EXPECT_EQ(FramePreTranslation(), |
| 2401 clipper->LocalBorderBoxProperties()->Transform()); | 2400 clipper->LocalBorderBoxProperties()->Transform()); |
| 2402 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); | 2401 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); |
| 2403 | 2402 |
| 2404 const auto& contents_properties = *clipper->ContentsProperties(); | 2403 auto contents_properties = clipper->ContentsProperties(); |
| 2405 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); | 2404 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); |
| 2406 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); | 2405 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); |
| 2407 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); | 2406 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); |
| 2408 | 2407 |
| 2409 EXPECT_EQ(FramePreTranslation(), | 2408 EXPECT_EQ(FramePreTranslation(), |
| 2410 child->LocalBorderBoxProperties()->Transform()); | 2409 child->LocalBorderBoxProperties()->Transform()); |
| 2411 EXPECT_EQ(clip_properties->OverflowClip(), | 2410 EXPECT_EQ(clip_properties->OverflowClip(), |
| 2412 child->LocalBorderBoxProperties()->Clip()); | 2411 child->LocalBorderBoxProperties()->Clip()); |
| 2413 | 2412 |
| 2414 EXPECT_NE(nullptr, child->LocalBorderBoxProperties()->Effect()); | 2413 EXPECT_NE(nullptr, child->LocalBorderBoxProperties()->Effect()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2430 LayoutObject* child = | 2429 LayoutObject* child = |
| 2431 GetDocument().GetElementById("child")->GetLayoutObject(); | 2430 GetDocument().GetElementById("child")->GetLayoutObject(); |
| 2432 | 2431 |
| 2433 // No scroll translation because the document does not scroll (not enough | 2432 // No scroll translation because the document does not scroll (not enough |
| 2434 // content). | 2433 // content). |
| 2435 EXPECT_TRUE(!FrameScrollTranslation()); | 2434 EXPECT_TRUE(!FrameScrollTranslation()); |
| 2436 EXPECT_EQ(FramePreTranslation(), | 2435 EXPECT_EQ(FramePreTranslation(), |
| 2437 clipper->LocalBorderBoxProperties()->Transform()); | 2436 clipper->LocalBorderBoxProperties()->Transform()); |
| 2438 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); | 2437 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); |
| 2439 | 2438 |
| 2440 const auto& contents_properties = *clipper->ContentsProperties(); | 2439 auto contents_properties = clipper->ContentsProperties(); |
| 2441 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); | 2440 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); |
| 2442 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); | 2441 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); |
| 2443 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); | 2442 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); |
| 2444 | 2443 |
| 2445 EXPECT_EQ(FramePreTranslation(), | 2444 EXPECT_EQ(FramePreTranslation(), |
| 2446 child->LocalBorderBoxProperties()->Transform()); | 2445 child->LocalBorderBoxProperties()->Transform()); |
| 2447 EXPECT_EQ(clip_properties->OverflowClip(), | 2446 EXPECT_EQ(clip_properties->OverflowClip(), |
| 2448 child->LocalBorderBoxProperties()->Clip()); | 2447 child->LocalBorderBoxProperties()->Clip()); |
| 2449 | 2448 |
| 2450 EXPECT_NE(nullptr, child->LocalBorderBoxProperties()->Effect()); | 2449 EXPECT_NE(nullptr, child->LocalBorderBoxProperties()->Effect()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2470 LayoutBoxModelObject* clipper = | 2469 LayoutBoxModelObject* clipper = |
| 2471 ToLayoutBoxModelObject(clipper_element->GetLayoutObject()); | 2470 ToLayoutBoxModelObject(clipper_element->GetLayoutObject()); |
| 2472 const ObjectPaintProperties* clip_properties = clipper->PaintProperties(); | 2471 const ObjectPaintProperties* clip_properties = clipper->PaintProperties(); |
| 2473 LayoutObject* child = | 2472 LayoutObject* child = |
| 2474 GetDocument().GetElementById("child")->GetLayoutObject(); | 2473 GetDocument().GetElementById("child")->GetLayoutObject(); |
| 2475 | 2474 |
| 2476 EXPECT_EQ(FrameScrollTranslation(), | 2475 EXPECT_EQ(FrameScrollTranslation(), |
| 2477 clipper->LocalBorderBoxProperties()->Transform()); | 2476 clipper->LocalBorderBoxProperties()->Transform()); |
| 2478 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); | 2477 EXPECT_EQ(FrameContentClip(), clipper->LocalBorderBoxProperties()->Clip()); |
| 2479 | 2478 |
| 2480 const auto& contents_properties = *clipper->ContentsProperties(); | 2479 auto contents_properties = clipper->ContentsProperties(); |
| 2481 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); | 2480 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); |
| 2482 EXPECT_EQ(clip_properties->ScrollTranslation(), | 2481 EXPECT_EQ(clip_properties->ScrollTranslation(), |
| 2483 contents_properties.Transform()); | 2482 contents_properties.Transform()); |
| 2484 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); | 2483 EXPECT_EQ(clip_properties->OverflowClip(), contents_properties.Clip()); |
| 2485 | 2484 |
| 2486 EXPECT_EQ(clip_properties->ScrollTranslation(), | 2485 EXPECT_EQ(clip_properties->ScrollTranslation(), |
| 2487 child->LocalBorderBoxProperties()->Transform()); | 2486 child->LocalBorderBoxProperties()->Transform()); |
| 2488 EXPECT_EQ(clip_properties->OverflowClip(), | 2487 EXPECT_EQ(clip_properties->OverflowClip(), |
| 2489 child->LocalBorderBoxProperties()->Clip()); | 2488 child->LocalBorderBoxProperties()->Clip()); |
| 2490 | 2489 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 | 2555 |
| 2557 // No scroll translation because the document does not scroll (not enough | 2556 // No scroll translation because the document does not scroll (not enough |
| 2558 // content). | 2557 // content). |
| 2559 EXPECT_TRUE(!FrameScrollTranslation()); | 2558 EXPECT_TRUE(!FrameScrollTranslation()); |
| 2560 EXPECT_EQ(FramePreTranslation(), | 2559 EXPECT_EQ(FramePreTranslation(), |
| 2561 clipper->LocalBorderBoxProperties()->Transform()); | 2560 clipper->LocalBorderBoxProperties()->Transform()); |
| 2562 // CSS clip on an element causes it to clip itself, not just descendants. | 2561 // CSS clip on an element causes it to clip itself, not just descendants. |
| 2563 EXPECT_EQ(clip_properties->CssClip(), | 2562 EXPECT_EQ(clip_properties->CssClip(), |
| 2564 clipper->LocalBorderBoxProperties()->Clip()); | 2563 clipper->LocalBorderBoxProperties()->Clip()); |
| 2565 | 2564 |
| 2566 const auto& contents_properties = *clipper->ContentsProperties(); | 2565 auto contents_properties = clipper->ContentsProperties(); |
| 2567 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); | 2566 EXPECT_EQ(LayoutPoint(30, 20), clipper->PaintOffset()); |
| 2568 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); | 2567 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); |
| 2569 EXPECT_EQ(clip_properties->CssClip(), contents_properties.Clip()); | 2568 EXPECT_EQ(clip_properties->CssClip(), contents_properties.Clip()); |
| 2570 | 2569 |
| 2571 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); | 2570 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); |
| 2572 } | 2571 } |
| 2573 | 2572 |
| 2574 TEST_P(PaintPropertyTreeBuilderTest, | 2573 TEST_P(PaintPropertyTreeBuilderTest, |
| 2575 SvgLocalToBorderBoxTransformContentsTreeState) { | 2574 SvgLocalToBorderBoxTransformContentsTreeState) { |
| 2576 SetBodyInnerHTML( | 2575 SetBodyInnerHTML( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2589 "100 100'>" | 2588 "100 100'>" |
| 2590 " <rect id='rect' width='100px' height='100px' />" | 2589 " <rect id='rect' width='100px' height='100px' />" |
| 2591 "</svg>"); | 2590 "</svg>"); |
| 2592 | 2591 |
| 2593 LayoutObject& svg_with_view_box = | 2592 LayoutObject& svg_with_view_box = |
| 2594 *GetDocument().GetElementById("svgWithViewBox")->GetLayoutObject(); | 2593 *GetDocument().GetElementById("svgWithViewBox")->GetLayoutObject(); |
| 2595 EXPECT_EQ(FramePreTranslation(), | 2594 EXPECT_EQ(FramePreTranslation(), |
| 2596 svg_with_view_box.LocalBorderBoxProperties()->Transform()); | 2595 svg_with_view_box.LocalBorderBoxProperties()->Transform()); |
| 2597 | 2596 |
| 2598 EXPECT_EQ(LayoutPoint(30, 20), svg_with_view_box.PaintOffset()); | 2597 EXPECT_EQ(LayoutPoint(30, 20), svg_with_view_box.PaintOffset()); |
| 2599 const auto& contents_properties = *svg_with_view_box.ContentsProperties(); | 2598 auto contents_properties = svg_with_view_box.ContentsProperties(); |
| 2600 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); | 2599 EXPECT_EQ(FramePreTranslation(), contents_properties.Transform()); |
| 2601 } | 2600 } |
| 2602 | 2601 |
| 2603 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { | 2602 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { |
| 2604 SetBodyInnerHTML( | 2603 SetBodyInnerHTML( |
| 2605 "<style>" | 2604 "<style>" |
| 2606 " body {" | 2605 " body {" |
| 2607 " margin: 0px;" | 2606 " margin: 0px;" |
| 2608 " }" | 2607 " }" |
| 2609 " #overflowHidden {" | 2608 " #overflowHidden {" |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 | 3460 |
| 3462 LayoutObject& svg_root = | 3461 LayoutObject& svg_root = |
| 3463 *GetDocument().GetElementById("svgroot")->GetLayoutObject(); | 3462 *GetDocument().GetElementById("svgroot")->GetLayoutObject(); |
| 3464 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); | 3463 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); |
| 3465 EXPECT_TRUE(svg_root_properties->Effect()); | 3464 EXPECT_TRUE(svg_root_properties->Effect()); |
| 3466 EXPECT_EQ(EffectPaintPropertyNode::Root(), | 3465 EXPECT_EQ(EffectPaintPropertyNode::Root(), |
| 3467 svg_root_properties->Effect()->Parent()); | 3466 svg_root_properties->Effect()->Parent()); |
| 3468 } | 3467 } |
| 3469 | 3468 |
| 3470 } // namespace blink | 3469 } // namespace blink |
| OLD | NEW |