| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/LayoutTreeAsText.h" | 8 #include "core/layout/LayoutTreeAsText.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 loadTestData("position-and-scroll.html"); | 88 loadTestData("position-and-scroll.html"); |
| 89 | 89 |
| 90 Element* scroller = document().getElementById("scroller"); | 90 Element* scroller = document().getElementById("scroller"); |
| 91 scroller->scrollTo(0, 100); | 91 scroller->scrollTo(0, 100); |
| 92 FrameView* frameView = document().view(); | 92 FrameView* frameView = document().view(); |
| 93 frameView->updateAllLifecyclePhases(); | 93 frameView->updateAllLifecyclePhases(); |
| 94 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); | 94 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object
PaintProperties(); |
| 95 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 95 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
| 96 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); | 96 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); |
| 97 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); | 97 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); |
| 98 EXPECT_EQ(FloatRoundedRect(120, 340, 385, 285), scrollerProperties->overflow
Clip()->clipRect()); | 98 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
| 99 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); | 99 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); |
| 100 | 100 |
| 101 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 101 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
| 102 // and should be affected by ancestor scroll transforms. | 102 // and should be affected by ancestor scroll transforms. |
| 103 Element* relPos = document().getElementById("rel-pos"); | 103 Element* relPos = document().getElementById("rel-pos"); |
| 104 ObjectPaintProperties* relPosProperties = relPos->layoutObject()->objectPain
tProperties(); | 104 ObjectPaintProperties* relPosProperties = relPos->layoutObject()->objectPain
tProperties(); |
| 105 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 105 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
| 106 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 106 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
| 107 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 107 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 108 EXPECT_EQ(FloatRoundedRect(0, 0, 385, 0), relPosProperties->overflowClip()->
clipRect()); | 108 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); |
| 109 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 109 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
| 110 | 110 |
| 111 // The absolute-positioned element should not be affected by non-positioned
scroller at all. | 111 // The absolute-positioned element should not be affected by non-positioned
scroller at all. |
| 112 Element* absPos = document().getElementById("abs-pos"); | 112 Element* absPos = document().getElementById("abs-pos"); |
| 113 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain
tProperties(); | 113 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain
tProperties(); |
| 114 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 114 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
| 115 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); | 115 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); |
| 116 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 116 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 117 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); | 117 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); |
| 118 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); | 118 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 121 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
| 122 { | 122 { |
| 123 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 123 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 124 | 124 |
| 125 document().domWindow()->scrollTo(0, 100); | 125 document().domWindow()->scrollTo(0, 100); |
| 126 | 126 |
| 127 FrameView* frameView = document().view(); | 127 FrameView* frameView = document().view(); |
| 128 frameView->updateAllLifecyclePhases(); | 128 frameView->updateAllLifecyclePhases(); |
| 129 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 129 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
| 130 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); | 130 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); |
| 131 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); | 131 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); |
| 132 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 132 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
| 133 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); | 133 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); |
| 134 EXPECT_EQ(FloatRoundedRect(0, 0, 785, 600), frameView->contentClip()->clipRe
ct()); | 134 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); |
| 135 EXPECT_EQ(nullptr, frameView->contentClip()->parent()); | 135 EXPECT_EQ(nullptr, frameView->contentClip()->parent()); |
| 136 | 136 |
| 137 LayoutView* layoutView = document().layoutView(); | 137 LayoutView* layoutView = document().layoutView(); |
| 138 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert
ies(); | 138 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert
ies(); |
| 139 EXPECT_EQ(nullptr, layoutViewProperties); | 139 EXPECT_EQ(nullptr, layoutViewProperties); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. | 142 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. |
| 143 // Need to set it during test setup. Besides that, the test still won't work bec
ause | 143 // Need to set it during test setup. Besides that, the test still won't work bec
ause |
| 144 // root layer scrolling mode is not compatible with SPv2 at this moment. | 144 // root layer scrolling mode is not compatible with SPv2 at this moment. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 " }" | 531 " }" |
| 532 "</style>" | 532 "</style>" |
| 533 "<div id='div'></div>"); | 533 "<div id='div'></div>"); |
| 534 | 534 |
| 535 FrameView* frameView = document().view(); | 535 FrameView* frameView = document().view(); |
| 536 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 536 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
| 537 ObjectPaintProperties* divProperties = div.objectPaintProperties(); | 537 ObjectPaintProperties* divProperties = div.objectPaintProperties(); |
| 538 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); | 538 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); |
| 539 // The overflow clip rect includes only the padding box. | 539 // The overflow clip rect includes only the padding box. |
| 540 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) | 540 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) |
| 541 EXPECT_EQ(FloatRoundedRect(60, 45, 485, 385), divProperties->overflowClip()-
>clipRect()); | 541 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); |
| 542 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); | 542 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); |
| 543 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); | 543 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); |
| 544 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. | 544 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. |
| 545 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: | 545 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: |
| 546 // inner radius = max(outer radius - border width, 0) | 546 // inner radius = max(outer radius - border width, 0) |
| 547 // In the case that two adjacent borders have different width, the inner rad
ius of the corner | 547 // In the case that two adjacent borders have different width, the inner rad
ius of the corner |
| 548 // may transition from one value to the other. i.e. being an ellipse. | 548 // may transition from one value to the other. i.e. being an ellipse. |
| 549 EXPECT_EQ( | 549 EXPECT_EQ( |
| 550 FloatRoundedRect( | 550 FloatRoundedRect( |
| 551 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) | 551 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) |
| 552 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) | 552 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) |
| 553 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) | 553 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) |
| 554 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) | 554 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) |
| 555 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) | 555 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) |
| 556 borderRadiusClip->clipRect()); | 556 borderRadiusClip->clipRect()); |
| 557 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); | 557 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace blink | 560 } // namespace blink |
| OLD | NEW |