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

Side by Side Diff: third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp

Issue 2436283002: Fix LayoutObject::mapLocalToAncestor() for fixed under absolute (Closed)
Patch Set: Rebaseline after rebase Created 4 years, 1 month 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 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/layout/LayoutInline.h" 5 #include "core/layout/LayoutInline.h"
6 #include "core/layout/LayoutTestHelper.h" 6 #include "core/layout/LayoutTestHelper.h"
7 #include "core/layout/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "platform/geometry/TransformState.h" 8 #include "platform/geometry/TransformState.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 mappedPoint = mapAncestorToLocal(staticChild, container, mappedPoint); 498 mappedPoint = mapAncestorToLocal(staticChild, container, mappedPoint);
499 EXPECT_EQ(FloatPoint(-15, -15), mappedPoint); 499 EXPECT_EQ(FloatPoint(-15, -15), mappedPoint);
500 500
501 mappedPoint = mapAncestorToLocal(outerFixed, staticChild, mappedPoint); 501 mappedPoint = mapAncestorToLocal(outerFixed, staticChild, mappedPoint);
502 EXPECT_EQ(FloatPoint(-101, -101), mappedPoint); 502 EXPECT_EQ(FloatPoint(-101, -101), mappedPoint);
503 503
504 mappedPoint = mapAncestorToLocal(target, outerFixed, mappedPoint); 504 mappedPoint = mapAncestorToLocal(target, outerFixed, mappedPoint);
505 EXPECT_EQ(FloatPoint(), mappedPoint); 505 EXPECT_EQ(FloatPoint(), mappedPoint);
506 } 506 }
507 507
508 TEST_F(MapCoordinatesTest, FixedPosInFixedPosScrollView) {
509 setBodyInnerHTML(
510 "<div style='height: 4000px'></div>"
511 "<div id='container' style='position:fixed; top: 100px; left: 100px'>"
512 " <div id='target' style='position:fixed; top: 200px; left: 200px'>"
513 " </div>"
514 "</div>");
515
516 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
517 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
518 LayoutBox* body = container->parentBox();
519 LayoutBox* html = body->parentBox();
520 LayoutBox* view = html->parentBox();
521 ASSERT_TRUE(view->isLayoutView());
522
523 document().view()->setScrollOffset(ScrollOffset(0.0, 50), ProgrammaticScroll);
524 document().view()->updateAllLifecyclePhases();
525 EXPECT_EQ(50, document().view()->scrollOffsetInt().height());
526
527 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
528 EXPECT_EQ(FloatPoint(200, 250), mappedPoint);
529 mappedPoint = mapAncestorToLocal(target, view, FloatPoint(200, 250));
530 EXPECT_EQ(FloatPoint(), mappedPoint);
531
532 mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
533 EXPECT_EQ(FloatPoint(100, 100), mappedPoint);
534 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 100));
535 EXPECT_EQ(FloatPoint(), mappedPoint);
536 }
537
538 TEST_F(MapCoordinatesTest, FixedPosInAbsolutePosScrollView) {
539 setBodyInnerHTML(
540 "<div style='height: 4000px'></div>"
541 "<div id='container' style='position:absolute; top: 100px; left: 100px'>"
542 " <div id='target' style='position:fixed; top: 200px; left: 200px'>"
543 " </div>"
544 "</div>");
545
546 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
547 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
548 LayoutBox* body = container->parentBox();
549 LayoutBox* html = body->parentBox();
550 LayoutBox* view = html->parentBox();
551 ASSERT_TRUE(view->isLayoutView());
552
553 document().view()->setScrollOffset(ScrollOffset(0.0, 50), ProgrammaticScroll);
554 document().view()->updateAllLifecyclePhases();
555 EXPECT_EQ(50, document().view()->scrollOffsetInt().height());
556
557 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
558 EXPECT_EQ(FloatPoint(200, 250), mappedPoint);
559 mappedPoint = mapAncestorToLocal(target, view, FloatPoint(200, 250));
560 EXPECT_EQ(FloatPoint(), mappedPoint);
561
562 mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
563 EXPECT_EQ(FloatPoint(100, 150), mappedPoint);
564 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 150));
565 EXPECT_EQ(FloatPoint(), mappedPoint);
566 }
567
508 TEST_F(MapCoordinatesTest, FixedPosInTransform) { 568 TEST_F(MapCoordinatesTest, FixedPosInTransform) {
509 setBodyInnerHTML( 569 setBodyInnerHTML(
510 "<style>#container { transform: translateY(100px); position: absolute; " 570 "<style>#container { transform: translateY(100px); position: absolute; "
511 "left: 0; top: 100px; }" 571 "left: 0; top: 100px; }"
512 ".fixed { position: fixed; top: 0; }" 572 ".fixed { position: fixed; top: 0; }"
513 ".spacer { height: 2000px; } </style>" 573 ".spacer { height: 2000px; } </style>"
514 "<div id='container'><div class='fixed' id='target'></div></div>" 574 "<div id='container'><div class='fixed' id='target'></div></div>"
515 "<div class='spacer'></div>"); 575 "<div class='spacer'></div>");
516 576
517 document().view()->setScrollOffset(ScrollOffset(0.0, 50), ProgrammaticScroll); 577 document().view()->setScrollOffset(ScrollOffset(0.0, 50), ProgrammaticScroll);
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 LayoutUnit::epsilon()); 1513 LayoutUnit::epsilon());
1454 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), 1514 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(),
1455 LayoutUnit::epsilon()); 1515 LayoutUnit::epsilon());
1456 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), 1516 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(),
1457 LayoutUnit::epsilon()); 1517 LayoutUnit::epsilon());
1458 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), 1518 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(),
1459 LayoutUnit::epsilon()); 1519 LayoutUnit::epsilon());
1460 } 1520 }
1461 1521
1462 } // namespace blink 1522 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698