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

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

Issue 1834263002: Round visual rects when crossing frame boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/LayoutObject.h" 5 #include "core/layout/LayoutObject.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 frameDocument.view()->setScrollPosition(DoublePoint(0, 47), ProgrammaticScro ll); 174 frameDocument.view()->setScrollPosition(DoublePoint(0, 47), ProgrammaticScro ll);
175 LayoutRect rect(4, 60, 20, 80); 175 LayoutRect rect(4, 60, 20, 80);
176 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect) ); 176 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect) );
177 EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); 177 EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));
178 178
179 rect = LayoutRect(4, 60, 0, 80); 179 rect = LayoutRect(4, 60, 0, 80);
180 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect, EdgeInclusive)); 180 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect, EdgeInclusive));
181 EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37)); 181 EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37));
182 } 182 }
183 183
184 TEST_F(LayoutObjectTest, LayoutViewMapToVisibleRectInAncestorSpaceSubpixelRoundi ng)
185 {
186 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
187 setBodyInnerHTML(
188 "<style>body { margin: 0; }</style>"
189 "<div id=frameContainer style='position: relative; left: 0.5px'>"
190 " <iframe id=frame style='position: relative; left: 0.5px' src='http:// test.com' width='200' height='200' frameBorder='0'></iframe>"
191 "</div>");
192
193 Document& frameDocument = setupChildIframe(
194 "frame", "<style>body { margin: 0; }</style><div id='target' style='posi tion: relative; width: 100px; height: 100px; left: 0.5px'>");
195 frameDocument.updateLayout();
196
197 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer"));
198 LayoutObject* target = frameDocument.getElementById("target")->layoutObject( );
199 LayoutRect rect(0, 0, 100, 100);
200 EXPECT_TRUE(target->mapToVisibleRectInAncestorSpace(frameContainer, rect));
201 // When passing from the iframe to the parent frame, the rect of (0.5, 0, 10 0, 100) is expanded to (0, 0, 100, 100), and then offset by
202 // the 0.5 offset of frameContainer.
203 EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)) , rect);
204 }
205
184 } // namespace blink 206 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698