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

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

Issue 1907443003: Translate flow thread coords to the nearest enclosing coord space when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a unit test too. Created 4 years, 8 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
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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 mappedPoint = mapLocalToAncestor(flowThread, container, mappedPoint); 553 mappedPoint = mapLocalToAncestor(flowThread, container, mappedPoint);
554 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); 554 EXPECT_EQ(FloatPoint(125, 35), mappedPoint);
555 555
556 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint); 556 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint);
557 EXPECT_EQ(FloatPoint(110, 20), mappedPoint); 557 EXPECT_EQ(FloatPoint(110, 20), mappedPoint);
558 558
559 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); 559 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint);
560 EXPECT_EQ(FloatPoint(), mappedPoint); 560 EXPECT_EQ(FloatPoint(), mappedPoint);
561 } 561 }
562 562
563 TEST_F(MapCoordinatesTest, NestedMulticolWithBlock)
564 {
565 setBodyInnerHTML(
566 "<div id='outerMulticol' style='columns:2; column-gap:0; column-fill:aut o; width:560px; height:215px; border:8px solid; padding:7px;'>"
567 " <div style='height:10px;'></div>"
568 " <div id='innerMulticol' style='columns:2; column-gap:0; border:8px solid; padding:7px;'>"
569 " <div style='height:630px;'></div>"
570 " <div id='target' style='width:50px; height:50px;'></div>"
571 " </div>"
572 "</div>");
573
574 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
575 LayoutBox* outerMulticol = toLayoutBox(getLayoutObjectByElementId("outerMult icol"));
576 LayoutBox* innerMulticol = toLayoutBox(getLayoutObjectByElementId("innerMult icol"));
577 LayoutBox* innerFlowThread = target->parentBox();
578 ASSERT_TRUE(innerFlowThread->isLayoutFlowThread());
579 LayoutBox* outerFlowThread = innerMulticol->parentBox();
580 ASSERT_TRUE(outerFlowThread->isLayoutFlowThread());
581
582 FloatPoint mappedPoint = mapLocalToAncestor(target, outerMulticol, FloatPoin t());
583 EXPECT_EQ(FloatPoint(435, 115), mappedPoint);
584
585 // TODO(mstensho): Add mapAncestorToLocal() tests when it starts working in nested multicol.
586
587 // Walk each ancestor in the chain separately, to verify each step on the wa y.
588 mappedPoint = mapLocalToAncestor(target, innerFlowThread, FloatPoint());
589 EXPECT_EQ(FloatPoint(0, 630), mappedPoint);
590
591 mappedPoint = mapLocalToAncestor(innerFlowThread, innerMulticol, mappedPoint );
592 EXPECT_EQ(FloatPoint(140, 305), mappedPoint);
593
594 mappedPoint = mapLocalToAncestor(innerMulticol, outerFlowThread, mappedPoint );
595 EXPECT_EQ(FloatPoint(140, 315), mappedPoint);
596
597 mappedPoint = mapLocalToAncestor(outerFlowThread, outerMulticol, mappedPoint );
598 EXPECT_EQ(FloatPoint(435, 115), mappedPoint);
599 }
600
563 TEST_F(MapCoordinatesTest, MulticolWithAbsPosInRelPos) 601 TEST_F(MapCoordinatesTest, MulticolWithAbsPosInRelPos)
564 { 602 {
565 setBodyInnerHTML( 603 setBodyInnerHTML(
566 "<div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0; colu mn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" 604 "<div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0; colu mn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>"
567 " <div style='height:110px;'></div>" 605 " <div style='height:110px;'></div>"
568 " <div id='relpos' style='position:relative; left:4px; top:4px;'>" 606 " <div id='relpos' style='position:relative; left:4px; top:4px;'>"
569 " <div id='target' style='position:absolute; left:15px; top:15px; margin:10px; border:13px; padding:13px;'></div>" 607 " <div id='target' style='position:absolute; left:15px; top:15px; margin:10px; border:13px; padding:13px;'></div>"
570 " </div>" 608 " </div>"
571 "</div>"); 609 "</div>");
572 610
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1169
1132 // With child2, each rotation gets flattened and the end result is approxima tely a 90-degree rotation. 1170 // With child2, each rotation gets flattened and the end result is approxima tely a 90-degree rotation.
1133 matrix = child2->localToAbsoluteTransform(); 1171 matrix = child2->localToAbsoluteTransform();
1134 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn it::epsilon()); 1172 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn it::epsilon());
1135 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn it::epsilon()); 1173 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn it::epsilon());
1136 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn it::epsilon()); 1174 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn it::epsilon());
1137 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU nit::epsilon()); 1175 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU nit::epsilon());
1138 } 1176 }
1139 1177
1140 } // namespace blink 1178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698