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

Side by Side Diff: third_party/WebKit/Source/web/tests/LayoutGeometryMapTest.cpp

Issue 2575423003: Fix geometry mapping issues for float under inline (Closed)
Patch Set: SVG floating Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (!iframe) 70 if (!iframe)
71 return nullptr; 71 return nullptr;
72 LocalFrame* frame = iframe->frame(); 72 LocalFrame* frame = iframe->frame();
73 Document* doc = frame->document(); 73 Document* doc = frame->document();
74 Element* element = doc->getElementById(elementId); 74 Element* element = doc->getElementById(elementId);
75 if (!element) 75 if (!element)
76 return nullptr; 76 return nullptr;
77 return element->layoutBox(); 77 return element->layoutBox();
78 } 78 }
79 79
80 static LayoutBox* getLayoutBox(WebView* webView, 80 static Element* getElement(WebView* webView,
81 const WTF::AtomicString& elementId) { 81 const WTF::AtomicString& elementId) {
82 WebViewImpl* webViewImpl = toWebViewImpl(webView); 82 WebViewImpl* webViewImpl = toWebViewImpl(webView);
83 if (!webViewImpl) 83 if (!webViewImpl)
84 return nullptr; 84 return nullptr;
85 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); 85 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame();
86 Document* doc = frame->document(); 86 Document* doc = frame->document();
87 Element* element = doc->getElementById(elementId); 87 return doc->getElementById(elementId);
88 }
89
90 static LayoutBox* getLayoutBox(WebView* webView,
91 const WTF::AtomicString& elementId) {
92 Element* element = getElement(webView, elementId);
88 if (!element) 93 if (!element)
89 return nullptr; 94 return nullptr;
90 return element->layoutBox(); 95 return element->layoutBox();
91 } 96 }
92 97
93 static const LayoutBoxModelObject* getLayoutContainer( 98 static const LayoutBoxModelObject* getLayoutContainer(
94 WebView* webView, 99 WebView* webView,
95 const WTF::AtomicString& elementId) { 100 const WTF::AtomicString& elementId) {
96 LayoutBox* rb = getLayoutBox(webView, elementId); 101 LayoutBox* rb = getLayoutBox(webView, elementId);
97 if (!rb) 102 if (!rb)
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 492
488 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr)); 493 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr));
489 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col3"), nullptr); 494 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col3"), nullptr);
490 EXPECT_NEAR(8.0f + offset * 2.0f, 495 EXPECT_NEAR(8.0f + offset * 2.0f,
491 rectFromQuad(rgm.mapToAncestor(rect, nullptr)).x(), 0.1f); 496 rectFromQuad(rgm.mapToAncestor(rect, nullptr)).x(), 0.1f);
492 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).y(), 0.1f); 497 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).y(), 0.1f);
493 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).width()); 498 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).width());
494 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).height()); 499 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).height());
495 } 500 }
496 501
502 TEST_P(LayoutGeometryMapTest, FloatUnderInlineLayer) {
503 registerMockedHttpURLLoad("rgm_float_under_inline.html");
504 FrameTestHelpers::WebViewHelper webViewHelper;
505 WebView* webView = webViewHelper.initializeAndLoad(
506 m_baseURL + "rgm_float_under_inline.html", true, 0, 0);
507 webView->resize(WebSize(1000, 1000));
508 webView->updateAllLifecyclePhases();
509
510 LayoutGeometryMap rgm;
511 auto* layerUnderFloat = getLayoutBox(webView, "layer-under-float");
512 auto* span = getElement(webView, "span")->layoutBoxModelObject();
513 auto* floating = getLayoutBox(webView, "float");
514 auto* container = getLayoutBox(webView, "container");
515 FloatRect rect(3.0f, 4.0f, 10.0f, 8.0f);
516
517 rgm.pushMappingsToAncestor(container->layer(), nullptr);
518 rgm.pushMappingsToAncestor(span->layer(), container->layer());
519 rgm.pushMappingsToAncestor(layerUnderFloat->layer(), span->layer());
520 EXPECT_EQ(rect, rectFromQuad(rgm.mapToAncestor(rect, container)));
521 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f),
522 rectFromQuad(rgm.mapToAncestor(rect, nullptr)));
523
524 rgm.popMappingsToAncestor(span->layer());
525 EXPECT_EQ(FloatRect(203.0f, 104.0f, 10.0f, 8.0f),
526 rectFromQuad(rgm.mapToAncestor(rect, container)));
527 EXPECT_EQ(FloatRect(263.0f, 154.0f, 10.0f, 8.0f),
528 rectFromQuad(rgm.mapToAncestor(rect, nullptr)));
529
530 rgm.pushMappingsToAncestor(floating, span);
531 EXPECT_EQ(rect, rectFromQuad(rgm.mapToAncestor(rect, container)));
532 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f),
533 rectFromQuad(rgm.mapToAncestor(rect, nullptr)));
534 }
535
497 } // namespace blink 536 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698