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/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
9 #include "core/paint/PaintPropertyTreePrinter.h" | 9 #include "core/paint/PaintPropertyTreePrinter.h" |
10 #include "platform/graphics/paint/GeometryMapper.h" | 10 #include "platform/graphics/paint/GeometryMapper.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return frameView->contentClip(); | 64 return frameView->contentClip(); |
65 } | 65 } |
66 | 66 |
67 const ScrollPaintPropertyNode* frameScroll() { | 67 const ScrollPaintPropertyNode* frameScroll() { |
68 FrameView* frameView = document().view(); | 68 FrameView* frameView = document().view(); |
69 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 69 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
70 return frameView->layoutView()->objectPaintProperties()->scroll(); | 70 return frameView->layoutView()->objectPaintProperties()->scroll(); |
71 return frameView->scroll(); | 71 return frameView->scroll(); |
72 } | 72 } |
73 | 73 |
| 74 LayoutPoint paintOffset(const LayoutObject* object) { |
| 75 return object->objectPaintProperties() |
| 76 ->localBorderBoxProperties() |
| 77 ->paintOffset; |
| 78 } |
| 79 |
74 private: | 80 private: |
75 void SetUp() override { | 81 void SetUp() override { |
76 Settings::setMockScrollbarsEnabled(true); | 82 Settings::setMockScrollbarsEnabled(true); |
77 | 83 |
78 RenderingTest::SetUp(); | 84 RenderingTest::SetUp(); |
79 enableCompositing(); | 85 enableCompositing(); |
80 } | 86 } |
81 | 87 |
82 void TearDown() override { | 88 void TearDown() override { |
83 RenderingTest::TearDown(); | 89 RenderingTest::TearDown(); |
(...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2786 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
2781 EXPECT_FALSE( | 2787 EXPECT_FALSE( |
2782 overflowB->layoutObject() | 2788 overflowB->layoutObject() |
2783 ->objectPaintProperties() | 2789 ->objectPaintProperties() |
2784 ->scroll() | 2790 ->scroll() |
2785 ->parent() | 2791 ->parent() |
2786 ->hasMainThreadScrollingReasons( | 2792 ->hasMainThreadScrollingReasons( |
2787 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2793 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
2788 } | 2794 } |
2789 | 2795 |
| 2796 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumn) { |
| 2797 setBodyInnerHTML( |
| 2798 "<style>" |
| 2799 " body { margin: 0; }" |
| 2800 " .space { height: 30px; }" |
| 2801 " .abs { position: absolute; width: 20px; height: 20px; }" |
| 2802 "</style>" |
| 2803 "<div style='columns:2; width: 200px; column-gap: 0'>" |
| 2804 " <div style='position: relative'>" |
| 2805 " <div id=space1 class=space></div>" |
| 2806 " <div id=space2 class=space></div>" |
| 2807 " <div id=spanner style='column-span: all'>" |
| 2808 " <div id=normal style='height: 50px'></div>" |
| 2809 " <div id=top-left class=abs style='top: 0; left: 0'></div>" |
| 2810 " <div id=bottom-right class=abs style='bottom: 0; right: 0'></div>" |
| 2811 " </div>" |
| 2812 " <div id=space3 class=space></div>" |
| 2813 " <div id=space4 class=space></div>" |
| 2814 " </div>" |
| 2815 "</div>"); |
| 2816 |
| 2817 // Above the spanner. |
| 2818 // Column 1. |
| 2819 EXPECT_EQ(LayoutPoint(), paintOffset(getLayoutObjectByElementId("space1"))); |
| 2820 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 0). |
| 2821 EXPECT_EQ(LayoutPoint(0, 30), |
| 2822 paintOffset(getLayoutObjectByElementId("space2"))); |
| 2823 |
| 2824 // The spanner's normal flow. |
| 2825 EXPECT_EQ(LayoutPoint(0, 30), |
| 2826 paintOffset(getLayoutObjectByElementId("spanner"))); |
| 2827 EXPECT_EQ(LayoutPoint(0, 30), |
| 2828 paintOffset(getLayoutObjectByElementId("normal"))); |
| 2829 |
| 2830 // Below the spanner. |
| 2831 // Column 1. TODO(crbug.com/648274): This is incorrect. Should be (0, 80). |
| 2832 EXPECT_EQ(LayoutPoint(0, 60), |
| 2833 paintOffset(getLayoutObjectByElementId("space3"))); |
| 2834 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 80). |
| 2835 EXPECT_EQ(LayoutPoint(0, 90), |
| 2836 paintOffset(getLayoutObjectByElementId("space4"))); |
| 2837 |
| 2838 // Out-of-flow positioned descendants of the spanner. They are laid out in |
| 2839 // the relative-position container. |
| 2840 |
| 2841 // "top-left" should be aligned to the top-left corner of space1. |
| 2842 EXPECT_EQ(LayoutPoint(0, 0), |
| 2843 paintOffset(getLayoutObjectByElementId("top-left"))); |
| 2844 |
| 2845 // "bottom-right" should be aligned to the bottom-right corner of space4. |
| 2846 // TODO(crbug.com/648274): This is incorrect. Should be (180, 90). |
| 2847 EXPECT_EQ(LayoutPoint(80, 100), |
| 2848 paintOffset(getLayoutObjectByElementId("bottom-right"))); |
| 2849 } |
| 2850 |
| 2851 // Ensures no crash with multi-column containing relative-position inline with |
| 2852 // spanner with absolute-position children. |
| 2853 TEST_P(PaintPropertyTreeBuilderTest, |
| 2854 MultiColumnInlineRelativeAndSpannerAndAbsPos) { |
| 2855 setBodyInnerHTML( |
| 2856 "<div style='columns:2; width: 200px; column-gap: 0'>" |
| 2857 " <span style='position: relative'>" |
| 2858 " <span id=spanner style='column-span: all'>" |
| 2859 " <div id=absolute style='position: absolute'>absolute</div>" |
| 2860 " </span>" |
| 2861 " </span>" |
| 2862 "</div>"); |
| 2863 // The "spanner" isn't a real spanner because it's an inline. |
| 2864 EXPECT_FALSE(getLayoutObjectByElementId("spanner")->isColumnSpanAll()); |
| 2865 |
| 2866 setBodyInnerHTML( |
| 2867 "<div style='columns:2; width: 200px; column-gap: 0'>" |
| 2868 " <span style='position: relative'>" |
| 2869 " <div id=spanner style='column-span: all'>" |
| 2870 " <div id=absolute style='position: absolute'>absolute</div>" |
| 2871 " </div>" |
| 2872 " </span>" |
| 2873 "</div>"); |
| 2874 // There should be anonymous block created containing the inline "relative", |
| 2875 // serving as the container of "absolute". |
| 2876 EXPECT_TRUE( |
| 2877 getLayoutObjectByElementId("absolute")->container()->isLayoutBlock()); |
| 2878 } |
2790 } // namespace blink | 2879 } // namespace blink |
OLD | NEW |