OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/layout/LayoutGeometryMap.h" | 32 #include "core/layout/LayoutGeometryMap.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/layout/Layer.h" | 35 #include "core/layout/Layer.h" |
36 #include "core/rendering/RenderBox.h" | 36 #include "core/layout/LayoutBox.h" |
37 #include "core/testing/URLTestHelpers.h" | 37 #include "core/testing/URLTestHelpers.h" |
38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
39 #include "public/platform/WebUnitTestSupport.h" | 39 #include "public/platform/WebUnitTestSupport.h" |
40 #include "public/web/WebFrameClient.h" | 40 #include "public/web/WebFrameClient.h" |
41 #include "web/WebLocalFrameImpl.h" | 41 #include "web/WebLocalFrameImpl.h" |
42 #include "web/tests/FloatPointTestHelpers.h" | 42 #include "web/tests/FloatPointTestHelpers.h" |
43 #include "web/tests/FloatQuadTestHelpers.h" | 43 #include "web/tests/FloatQuadTestHelpers.h" |
44 #include "web/tests/FrameTestHelpers.h" | 44 #include "web/tests/FrameTestHelpers.h" |
45 #include <gtest/gtest.h> | 45 #include <gtest/gtest.h> |
46 | 46 |
(...skipping 10 matching lines...) Expand all Loading... |
57 : m_baseURL("http://www.test.com/") | 57 : m_baseURL("http://www.test.com/") |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
61 virtual void TearDown() | 61 virtual void TearDown() |
62 { | 62 { |
63 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 63 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
64 } | 64 } |
65 | 65 |
66 protected: | 66 protected: |
67 static RenderBox* getFrameElement(const char* iframeName, WebView* webView,
const WTF::AtomicString& elementId) | 67 static LayoutBox* getFrameElement(const char* iframeName, WebView* webView,
const WTF::AtomicString& elementId) |
68 { | 68 { |
69 WebLocalFrameImpl* iframe = toWebLocalFrameImpl(webView->findFrameByName
(WebString::fromUTF8(iframeName))); | 69 WebLocalFrameImpl* iframe = toWebLocalFrameImpl(webView->findFrameByName
(WebString::fromUTF8(iframeName))); |
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->renderBox(); | 77 return element->layoutBox(); |
78 } | 78 } |
79 | 79 |
80 static RenderBox* getRenderBox(WebView* webView, const WTF::AtomicString& el
ementId) | 80 static LayoutBox* getLayoutBox(WebView* webView, const WTF::AtomicString& el
ementId) |
81 { | 81 { |
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 Element* element = doc->getElementById(elementId); |
88 if (!element) | 88 if (!element) |
89 return nullptr; | 89 return nullptr; |
90 return element->renderBox(); | 90 return element->layoutBox(); |
91 } | 91 } |
92 | 92 |
93 static const LayoutBoxModelObject* getRenderContainer(WebView* webView, cons
t WTF::AtomicString &elementId) | 93 static const LayoutBoxModelObject* getRenderContainer(WebView* webView, cons
t WTF::AtomicString &elementId) |
94 { | 94 { |
95 RenderBox* rb = getRenderBox(webView, elementId); | 95 LayoutBox* rb = getLayoutBox(webView, elementId); |
96 if (!rb) | 96 if (!rb) |
97 return nullptr; | 97 return nullptr; |
98 Layer* compositingLayer = rb->enclosingLayer()->enclosingLayerForPaintIn
validation(); | 98 Layer* compositingLayer = rb->enclosingLayer()->enclosingLayerForPaintIn
validation(); |
99 if (!compositingLayer) | 99 if (!compositingLayer) |
100 return nullptr; | 100 return nullptr; |
101 return compositingLayer->renderer(); | 101 return compositingLayer->renderer(); |
102 } | 102 } |
103 | 103 |
104 static const LayoutBoxModelObject* getFrameRenderContainer(const char* frame
Id, WebView* webView, const WTF::AtomicString &elementId) | 104 static const LayoutBoxModelObject* getFrameRenderContainer(const char* frame
Id, WebView* webView, const WTF::AtomicString &elementId) |
105 { | 105 { |
106 RenderBox* rb = getFrameElement(frameId, webView, elementId); | 106 LayoutBox* rb = getFrameElement(frameId, webView, elementId); |
107 if (!rb) | 107 if (!rb) |
108 return nullptr; | 108 return nullptr; |
109 Layer* compositingLayer = rb->enclosingLayer()->enclosingLayerForPaintIn
validation(); | 109 Layer* compositingLayer = rb->enclosingLayer()->enclosingLayerForPaintIn
validation(); |
110 if (!compositingLayer) | 110 if (!compositingLayer) |
111 return nullptr; | 111 return nullptr; |
112 return compositingLayer->renderer(); | 112 return compositingLayer->renderer(); |
113 } | 113 } |
114 | 114 |
115 static const FloatRect rectFromQuad(const FloatQuad& quad) | 115 static const FloatRect rectFromQuad(const FloatQuad& quad) |
116 { | 116 { |
(...skipping 20 matching lines...) Expand all Loading... |
137 registerMockedHttpURLLoad("rgm_test.html"); | 137 registerMockedHttpURLLoad("rgm_test.html"); |
138 FrameTestHelpers::WebViewHelper webViewHelper; | 138 FrameTestHelpers::WebViewHelper webViewHelper; |
139 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_test.htm
l", true, 0, 0); | 139 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_test.htm
l", true, 0, 0); |
140 webView->resize(WebSize(1000, 1000)); | 140 webView->resize(WebSize(1000, 1000)); |
141 webView->layout(); | 141 webView->layout(); |
142 | 142 |
143 // We are going test everything twice. Once with FloatPoints and once with | 143 // We are going test everything twice. Once with FloatPoints and once with |
144 // FloatRects. This is because LayoutGeometryMap treats both slightly | 144 // FloatRects. This is because LayoutGeometryMap treats both slightly |
145 // differently | 145 // differently |
146 LayoutGeometryMap rgm; | 146 LayoutGeometryMap rgm; |
147 rgm.pushMappingsToAncestor(getRenderBox(webView, "InitialDiv"), 0); | 147 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InitialDiv"), 0); |
148 FloatPoint point; | 148 FloatPoint point; |
149 FloatRect rect(0.0f, 0.0f, 1.0f, 2.0f); | 149 FloatRect rect(0.0f, 0.0f, 1.0f, 2.0f); |
150 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); | 150 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); |
151 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, nullptr)); | 151 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, nullptr)); |
152 | 152 |
153 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 153 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
154 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); | 154 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); |
155 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, nullptr)); | 155 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, nullptr)); |
156 | 156 |
157 rgm.pushMappingsToAncestor(getRenderBox(webView, "InnerDiv"), 0); | 157 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InnerDiv"), 0); |
158 EXPECT_EQ(FloatPoint(21.0f, 6.0f), rgm.mapToContainer(point, getRenderBox(we
bView, "CenterDiv"))); | 158 EXPECT_EQ(FloatPoint(21.0f, 6.0f), rgm.mapToContainer(point, getLayoutBox(we
bView, "CenterDiv"))); |
159 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 6.0f, 1.0f, 2.0f)), rgm.mapToContainer(
rect, getRenderBox(webView, "CenterDiv"))); | 159 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 6.0f, 1.0f, 2.0f)), rgm.mapToContainer(
rect, getLayoutBox(webView, "CenterDiv"))); |
160 | 160 |
161 rgm.pushMappingsToAncestor(getRenderBox(webView, "OtherDiv"), getRenderBox(w
ebView, "InnerDiv")); | 161 rgm.pushMappingsToAncestor(getLayoutBox(webView, "OtherDiv"), getLayoutBox(w
ebView, "InnerDiv")); |
162 EXPECT_EQ(FloatPoint(22.0f, 12.0f), rgm.mapToContainer(point, getRenderBox(w
ebView, "CenterDiv"))); | 162 EXPECT_EQ(FloatPoint(22.0f, 12.0f), rgm.mapToContainer(point, getLayoutBox(w
ebView, "CenterDiv"))); |
163 EXPECT_EQ(FloatQuad(FloatRect(22.0f, 12.0f, 1.0f, 2.0f)), rgm.mapToContainer
(rect, getRenderBox(webView, "CenterDiv"))); | 163 EXPECT_EQ(FloatQuad(FloatRect(22.0f, 12.0f, 1.0f, 2.0f)), rgm.mapToContainer
(rect, getLayoutBox(webView, "CenterDiv"))); |
164 | 164 |
165 EXPECT_EQ(FloatPoint(1.0f, 6.0f), rgm.mapToContainer(point, getRenderBox(web
View, "InnerDiv"))); | 165 EXPECT_EQ(FloatPoint(1.0f, 6.0f), rgm.mapToContainer(point, getLayoutBox(web
View, "InnerDiv"))); |
166 EXPECT_EQ(FloatQuad(FloatRect(1.0f, 6.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, getRenderBox(webView, "InnerDiv"))); | 166 EXPECT_EQ(FloatQuad(FloatRect(1.0f, 6.0f, 1.0f, 2.0f)), rgm.mapToContainer(r
ect, getLayoutBox(webView, "InnerDiv"))); |
167 | 167 |
168 EXPECT_EQ(FloatPoint(50.0f, 44.0f), rgm.mapToContainer(point, nullptr)); | 168 EXPECT_EQ(FloatPoint(50.0f, 44.0f), rgm.mapToContainer(point, nullptr)); |
169 EXPECT_EQ(FloatQuad(FloatRect(50.0f, 44.0f, 1.0f, 2.0f)), rgm.mapToContainer
(rect, nullptr)); | 169 EXPECT_EQ(FloatQuad(FloatRect(50.0f, 44.0f, 1.0f, 2.0f)), rgm.mapToContainer
(rect, nullptr)); |
170 } | 170 } |
171 | 171 |
172 // Fails on Windows due to crbug.com/391457. When run through the transform the | 172 // Fails on Windows due to crbug.com/391457. When run through the transform the |
173 // position on windows differs by a pixel | 173 // position on windows differs by a pixel |
174 #if OS(WIN) | 174 #if OS(WIN) |
175 TEST_F(LayoutGeometryMapTest, DISABLED_TransformedGeometryTest) | 175 TEST_F(LayoutGeometryMapTest, DISABLED_TransformedGeometryTest) |
176 #else | 176 #else |
177 TEST_F(LayoutGeometryMapTest, TransformedGeometryTest) | 177 TEST_F(LayoutGeometryMapTest, TransformedGeometryTest) |
178 #endif | 178 #endif |
179 { | 179 { |
180 registerMockedHttpURLLoad("rgm_transformed_test.html"); | 180 registerMockedHttpURLLoad("rgm_transformed_test.html"); |
181 FrameTestHelpers::WebViewHelper webViewHelper; | 181 FrameTestHelpers::WebViewHelper webViewHelper; |
182 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_transfor
med_test.html", true, 0, 0); | 182 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_transfor
med_test.html", true, 0, 0); |
183 webView->resize(WebSize(1000, 1000)); | 183 webView->resize(WebSize(1000, 1000)); |
184 webView->layout(); | 184 webView->layout(); |
185 | 185 |
186 LayoutGeometryMap rgm; | 186 LayoutGeometryMap rgm; |
187 rgm.pushMappingsToAncestor(getRenderBox(webView, "InitialDiv"), 0); | 187 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InitialDiv"), 0); |
188 FloatPoint point; | 188 FloatPoint point; |
189 const float rectWidth = 15.0f; | 189 const float rectWidth = 15.0f; |
190 const float scaleWidth = 2.0f; | 190 const float scaleWidth = 2.0f; |
191 const float scaleHeight = 3.0f; | 191 const float scaleHeight = 3.0f; |
192 FloatRect rect(0.0f, 0.0f, 15.0f, 25.0f); | 192 FloatRect rect(0.0f, 0.0f, 15.0f, 25.0f); |
193 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); | 193 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); |
194 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); | 194 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); |
195 | 195 |
196 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 196 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
197 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); | 197 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); |
198 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 15.0f, 25.0f)).boundingBox(), rgm.
mapToContainer(rect, nullptr).boundingBox()); | 198 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 15.0f, 25.0f)).boundingBox(), rgm.
mapToContainer(rect, nullptr).boundingBox()); |
199 | 199 |
200 rgm.pushMappingsToAncestor(getRenderBox(webView, "InnerDiv"), 0); | 200 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InnerDiv"), 0); |
201 EXPECT_EQ(FloatPoint(523.0f, 6.0f), rgm.mapToContainer(point, getRenderBox(w
ebView, "CenterDiv"))); | 201 EXPECT_EQ(FloatPoint(523.0f, 6.0f), rgm.mapToContainer(point, getLayoutBox(w
ebView, "CenterDiv"))); |
202 EXPECT_EQ(FloatQuad(FloatRect(523.0f - rectWidth, 6.0f, 15.0f, 25.0f)).bound
ingBox(), rgm.mapToContainer(rect, getRenderBox(webView, "CenterDiv")).boundingB
ox()); | 202 EXPECT_EQ(FloatQuad(FloatRect(523.0f - rectWidth, 6.0f, 15.0f, 25.0f)).bound
ingBox(), rgm.mapToContainer(rect, getLayoutBox(webView, "CenterDiv")).boundingB
ox()); |
203 | 203 |
204 rgm.pushMappingsToAncestor(getRenderBox(webView, "OtherDiv"), getRenderBox(w
ebView, "InnerDiv")); | 204 rgm.pushMappingsToAncestor(getLayoutBox(webView, "OtherDiv"), getLayoutBox(w
ebView, "InnerDiv")); |
205 EXPECT_EQ(FloatPoint(522.0f, 12.0f), rgm.mapToContainer(point, getRenderBox(
webView, "CenterDiv"))); | 205 EXPECT_EQ(FloatPoint(522.0f, 12.0f), rgm.mapToContainer(point, getLayoutBox(
webView, "CenterDiv"))); |
206 EXPECT_EQ(FloatQuad(FloatRect(522.0f - rectWidth, 12.0f, 15.0f, 25.0f)).boun
dingBox(), rgm.mapToContainer(rect, getRenderBox(webView, "CenterDiv")).bounding
Box()); | 206 EXPECT_EQ(FloatQuad(FloatRect(522.0f - rectWidth, 12.0f, 15.0f, 25.0f)).boun
dingBox(), rgm.mapToContainer(rect, getLayoutBox(webView, "CenterDiv")).bounding
Box()); |
207 | 207 |
208 EXPECT_EQ(FloatPoint(1.0f, 6.0f), rgm.mapToContainer(point, getRenderBox(web
View, "InnerDiv"))); | 208 EXPECT_EQ(FloatPoint(1.0f, 6.0f), rgm.mapToContainer(point, getLayoutBox(web
View, "InnerDiv"))); |
209 EXPECT_EQ(FloatQuad(FloatRect(1.0f, 6.0f, 15.0f, 25.0f)).boundingBox(), rgm.
mapToContainer(rect, getRenderBox(webView, "InnerDiv")).boundingBox()); | 209 EXPECT_EQ(FloatQuad(FloatRect(1.0f, 6.0f, 15.0f, 25.0f)).boundingBox(), rgm.
mapToContainer(rect, getLayoutBox(webView, "InnerDiv")).boundingBox()); |
210 | 210 |
211 EXPECT_EQ(FloatPoint(821.0f, 31.0f), rgm.mapToContainer(point, nullptr)); | 211 EXPECT_EQ(FloatPoint(821.0f, 31.0f), rgm.mapToContainer(point, nullptr)); |
212 EXPECT_EQ(FloatQuad(FloatRect(821.0f - rectWidth * scaleWidth, 31.0f, 15.0f
* scaleWidth, 25.0f * scaleHeight)).boundingBox(), rgm.mapToContainer(rect, null
ptr).boundingBox()); | 212 EXPECT_EQ(FloatQuad(FloatRect(821.0f - rectWidth * scaleWidth, 31.0f, 15.0f
* scaleWidth, 25.0f * scaleHeight)).boundingBox(), rgm.mapToContainer(rect, null
ptr).boundingBox()); |
213 | 213 |
214 point = FloatPoint(10.0f, 25.0f); | 214 point = FloatPoint(10.0f, 25.0f); |
215 rect = FloatRect(10.0f, 25.0f, 15.0f, 25.0f); | 215 rect = FloatRect(10.0f, 25.0f, 15.0f, 25.0f); |
216 EXPECT_EQ(FloatPoint(512.0f, 37.0f), rgm.mapToContainer(point, getRenderBox(
webView, "CenterDiv"))); | 216 EXPECT_EQ(FloatPoint(512.0f, 37.0f), rgm.mapToContainer(point, getLayoutBox(
webView, "CenterDiv"))); |
217 EXPECT_EQ(FloatQuad(FloatRect(512.0f - rectWidth, 37.0f, 15.0f, 25.0f)).boun
dingBox(), rgm.mapToContainer(rect, getRenderBox(webView, "CenterDiv")).bounding
Box()); | 217 EXPECT_EQ(FloatQuad(FloatRect(512.0f - rectWidth, 37.0f, 15.0f, 25.0f)).boun
dingBox(), rgm.mapToContainer(rect, getLayoutBox(webView, "CenterDiv")).bounding
Box()); |
218 | 218 |
219 EXPECT_EQ(FloatPoint(11.0f, 31.0f), rgm.mapToContainer(point, getRenderBox(w
ebView, "InnerDiv"))); | 219 EXPECT_EQ(FloatPoint(11.0f, 31.0f), rgm.mapToContainer(point, getLayoutBox(w
ebView, "InnerDiv"))); |
220 EXPECT_EQ(FloatQuad(FloatRect(11.0f, 31.0f, 15.0f, 25.0f)).boundingBox(), rg
m.mapToContainer(rect, getRenderBox(webView, "InnerDiv")).boundingBox()); | 220 EXPECT_EQ(FloatQuad(FloatRect(11.0f, 31.0f, 15.0f, 25.0f)).boundingBox(), rg
m.mapToContainer(rect, getLayoutBox(webView, "InnerDiv")).boundingBox()); |
221 | 221 |
222 EXPECT_EQ(FloatPoint(801.0f, 106.0f), rgm.mapToContainer(point, nullptr)); | 222 EXPECT_EQ(FloatPoint(801.0f, 106.0f), rgm.mapToContainer(point, nullptr)); |
223 EXPECT_EQ(FloatQuad(FloatRect(801.0f - rectWidth * scaleWidth, 106.0f, 15.0f
* scaleWidth, 25.0f * scaleHeight)).boundingBox(), rgm.mapToContainer(rect, nul
lptr).boundingBox()); | 223 EXPECT_EQ(FloatQuad(FloatRect(801.0f - rectWidth * scaleWidth, 106.0f, 15.0f
* scaleWidth, 25.0f * scaleHeight)).boundingBox(), rgm.mapToContainer(rect, nul
lptr).boundingBox()); |
224 } | 224 } |
225 | 225 |
226 TEST_F(LayoutGeometryMapTest, FixedGeometryTest) | 226 TEST_F(LayoutGeometryMapTest, FixedGeometryTest) |
227 { | 227 { |
228 registerMockedHttpURLLoad("rgm_fixed_position_test.html"); | 228 registerMockedHttpURLLoad("rgm_fixed_position_test.html"); |
229 FrameTestHelpers::WebViewHelper webViewHelper; | 229 FrameTestHelpers::WebViewHelper webViewHelper; |
230 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_fixed_po
sition_test.html", true, 0, 0); | 230 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_fixed_po
sition_test.html", true, 0, 0); |
231 webView->resize(WebSize(1000, 1000)); | 231 webView->resize(WebSize(1000, 1000)); |
232 webView->layout(); | 232 webView->layout(); |
233 | 233 |
234 LayoutGeometryMap rgm; | 234 LayoutGeometryMap rgm; |
235 rgm.pushMappingsToAncestor(getRenderBox(webView, "InitialDiv"), 0); | 235 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InitialDiv"), 0); |
236 FloatPoint point; | 236 FloatPoint point; |
237 FloatRect rect(0.0f, 0.0f, 15.0f, 25.0f); | 237 FloatRect rect(0.0f, 0.0f, 15.0f, 25.0f); |
238 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); | 238 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); |
239 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); | 239 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); |
240 | 240 |
241 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 241 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
242 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); | 242 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); |
243 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); | 243 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 15.0f, 25.0f)), rgm.mapToContainer
(rect, nullptr)); |
244 | 244 |
245 rgm.pushMappingsToAncestor(getRenderBox(webView, "InnerDiv"), 0); | 245 rgm.pushMappingsToAncestor(getLayoutBox(webView, "InnerDiv"), 0); |
246 EXPECT_EQ(FloatPoint(20.0f, 14.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "CenterDiv"))); | 246 EXPECT_EQ(FloatPoint(20.0f, 14.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "CenterDiv"))); |
247 EXPECT_EQ(FloatQuad(FloatRect(20.0f, 14.0f, 15.0f, 25.0f)), rgm.mapToContain
er(rect, nullptr)); | 247 EXPECT_EQ(FloatQuad(FloatRect(20.0f, 14.0f, 15.0f, 25.0f)), rgm.mapToContain
er(rect, nullptr)); |
248 | 248 |
249 rgm.pushMappingsToAncestor(getRenderBox(webView, "OtherDiv"), getRenderBox(w
ebView, "InnerDiv")); | 249 rgm.pushMappingsToAncestor(getLayoutBox(webView, "OtherDiv"), getLayoutBox(w
ebView, "InnerDiv")); |
250 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "CenterDiv"))); | 250 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "CenterDiv"))); |
251 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 20.0f, 15.0f, 25.0f)), rgm.mapToContain
er(rect, getRenderContainer(webView, "CenterDiv"))); | 251 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 20.0f, 15.0f, 25.0f)), rgm.mapToContain
er(rect, getRenderContainer(webView, "CenterDiv"))); |
252 | 252 |
253 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "InnerDiv"))); | 253 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, getRenderConta
iner(webView, "InnerDiv"))); |
254 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, nullptr)); | 254 EXPECT_EQ(FloatPoint(21.0f, 20.0f), rgm.mapToContainer(point, nullptr)); |
255 | 255 |
256 point = FloatPoint(10.0f, 25.0f); | 256 point = FloatPoint(10.0f, 25.0f); |
257 rect = FloatRect(22.0f, 15.2f, 15.3f, 0.0f); | 257 rect = FloatRect(22.0f, 15.2f, 15.3f, 0.0f); |
258 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToContaine
r(rect, getRenderContainer(webView, "CenterDiv"))); | 258 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToContaine
r(rect, getRenderContainer(webView, "CenterDiv"))); |
259 | 259 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 // The document is 1000f wide (we resized to that size). | 354 // The document is 1000f wide (we resized to that size). |
355 // We have a 8px margin on either side of the document. | 355 // We have a 8px margin on either side of the document. |
356 // Between each column we have a 10px gap, and we have 3 columns. | 356 // Between each column we have a 10px gap, and we have 3 columns. |
357 // The width of a given column is (1000 - 16 - 20)/3. | 357 // The width of a given column is (1000 - 16 - 20)/3. |
358 // The total offset between any column and it's neighbour is width + 10px | 358 // The total offset between any column and it's neighbour is width + 10px |
359 // (for the gap). | 359 // (for the gap). |
360 float offset = (1000.0f - 16.0f - 20.0f) / 3.0f + 10.0f; | 360 float offset = (1000.0f - 16.0f - 20.0f) / 3.0f + 10.0f; |
361 | 361 |
362 LayoutGeometryMap rgm; | 362 LayoutGeometryMap rgm; |
363 rgm.pushMappingsToAncestor(getRenderBox(webView, "A"), 0); | 363 rgm.pushMappingsToAncestor(getLayoutBox(webView, "A"), 0); |
364 FloatPoint point; | 364 FloatPoint point; |
365 FloatRect rect(0.0f, 0.0f, 5.0f, 3.0f); | 365 FloatRect rect(0.0f, 0.0f, 5.0f, 3.0f); |
366 | 366 |
367 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); | 367 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); |
368 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); | 368 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); |
369 | 369 |
370 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 370 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
371 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); | 371 EXPECT_EQ(FloatPoint(0.0f, 0.0f), rgm.mapToContainer(point, nullptr)); |
372 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); | 372 EXPECT_EQ(FloatQuad(FloatRect(0.0f, 0.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); |
373 | 373 |
374 rgm.pushMappingsToAncestor(getRenderBox(webView, "Col1"), 0); | 374 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col1"), 0); |
375 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); | 375 EXPECT_EQ(FloatPoint(8.0f, 8.0f), rgm.mapToContainer(point, nullptr)); |
376 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); | 376 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 8.0f, 5.0f, 3.0f)), rgm.mapToContainer(r
ect, nullptr)); |
377 | 377 |
378 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 378 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
379 rgm.pushMappingsToAncestor(getRenderBox(webView, "Col2"), nullptr); | 379 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col2"), nullptr); |
380 EXPECT_NEAR(8.0f + offset, rgm.mapToContainer(point, nullptr).x(), 0.1f); | 380 EXPECT_NEAR(8.0f + offset, rgm.mapToContainer(point, nullptr).x(), 0.1f); |
381 EXPECT_NEAR(8.0f, rgm.mapToContainer(point, nullptr).y(), 0.1f); | 381 EXPECT_NEAR(8.0f, rgm.mapToContainer(point, nullptr).y(), 0.1f); |
382 EXPECT_NEAR(8.0f + offset, rectFromQuad(rgm.mapToContainer(rect, nullptr)).x
(), 0.1f); | 382 EXPECT_NEAR(8.0f + offset, rectFromQuad(rgm.mapToContainer(rect, nullptr)).x
(), 0.1f); |
383 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).y(), 0.1f)
; | 383 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).y(), 0.1f)
; |
384 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).width()); | 384 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).width()); |
385 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).height()); | 385 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).height()); |
386 | 386 |
387 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); | 387 rgm.popMappingsToAncestor(static_cast<Layer*>(nullptr)); |
388 rgm.pushMappingsToAncestor(getRenderBox(webView, "Col3"), nullptr); | 388 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col3"), nullptr); |
389 EXPECT_NEAR(8.0f + offset * 2.0f, rgm.mapToContainer(point, nullptr).x(), 0.
1f); | 389 EXPECT_NEAR(8.0f + offset * 2.0f, rgm.mapToContainer(point, nullptr).x(), 0.
1f); |
390 EXPECT_NEAR(8.0f, rgm.mapToContainer(point, nullptr).y(), 0.1f); | 390 EXPECT_NEAR(8.0f, rgm.mapToContainer(point, nullptr).y(), 0.1f); |
391 EXPECT_NEAR(8.0f + offset * 2.0f, rectFromQuad(rgm.mapToContainer(rect, null
ptr)).x(), 0.1f); | 391 EXPECT_NEAR(8.0f + offset * 2.0f, rectFromQuad(rgm.mapToContainer(rect, null
ptr)).x(), 0.1f); |
392 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).y(), 0.1f)
; | 392 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).y(), 0.1f)
; |
393 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).width()); | 393 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).width()); |
394 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).height()); | 394 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToContainer(rect, nullptr)).height()); |
395 | 395 |
396 } | 396 } |
397 } // namespace :: | 397 } // namespace :: |
OLD | NEW |