OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 4189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4200 virtual void setDeviceScaleFactor(float) override { } | 4200 virtual void setDeviceScaleFactor(float) override { } |
4201 virtual float deviceScaleFactor() const override { return 1.f; } | 4201 virtual float deviceScaleFactor() const override { return 1.f; } |
4202 virtual void setBackgroundColor(WebColor) override { } | 4202 virtual void setBackgroundColor(WebColor) override { } |
4203 virtual void setHasTransparentBackground(bool) override { } | 4203 virtual void setHasTransparentBackground(bool) override { } |
4204 virtual void setVisible(bool) override { } | 4204 virtual void setVisible(bool) override { } |
4205 virtual void setPageScaleFactorAndLimits(float pageScaleFactor, float minimu
m, float maximum) override { } | 4205 virtual void setPageScaleFactorAndLimits(float pageScaleFactor, float minimu
m, float maximum) override { } |
4206 virtual void startPageScaleAnimation(const WebPoint& destination, bool useAn
chor, float newPageScale, double durationSec) override { } | 4206 virtual void startPageScaleAnimation(const WebPoint& destination, bool useAn
chor, float newPageScale, double durationSec) override { } |
4207 virtual void setNeedsAnimate() override { } | 4207 virtual void setNeedsAnimate() override { } |
4208 virtual bool commitRequested() const override { return false; } | 4208 virtual bool commitRequested() const override { return false; } |
4209 virtual void finishAllRendering() override { } | 4209 virtual void finishAllRendering() override { } |
4210 virtual void registerSelection(const WebSelectionBound& start, const WebSele
ctionBound& end) override | 4210 virtual void registerSelection(const WebSelectionBounds& bounds) override |
4211 { | 4211 { |
4212 m_start = adoptPtr(new WebSelectionBound(start)); | 4212 m_bounds = adoptPtr(new WebSelectionBounds(bounds)); |
4213 m_end = adoptPtr(new WebSelectionBound(end)); | |
4214 } | 4213 } |
4215 virtual void clearSelection() override | 4214 virtual void clearSelection() override |
4216 { | 4215 { |
4217 m_selectionCleared = true; | 4216 m_selectionCleared = true; |
4218 m_start.clear(); | 4217 m_bounds.clear(); |
4219 m_end.clear(); | |
4220 } | 4218 } |
4221 | 4219 |
4222 bool getAndResetSelectionCleared() | 4220 bool getAndResetSelectionCleared() |
4223 { | 4221 { |
4224 bool selectionCleared = m_selectionCleared; | 4222 bool selectionCleared = m_selectionCleared; |
4225 m_selectionCleared = false; | 4223 m_selectionCleared = false; |
4226 return selectionCleared; | 4224 return selectionCleared; |
4227 } | 4225 } |
4228 | 4226 |
4229 const WebSelectionBound* start() const { return m_start.get(); } | 4227 const WebSelectionBounds* bounds() const { return m_bounds.get(); } |
4230 const WebSelectionBound* end() const { return m_end.get(); } | 4228 const WebSelectionBound* start() const { return m_bounds ? &m_bounds->start
: nullptr; } |
| 4229 const WebSelectionBound* end() const { return m_bounds ? &m_bounds->end: nul
lptr; } |
4231 | 4230 |
4232 private: | 4231 private: |
4233 bool m_selectionCleared; | 4232 bool m_selectionCleared; |
4234 OwnPtr<WebSelectionBound> m_start; | 4233 OwnPtr<WebSelectionBounds> m_bounds; |
4235 OwnPtr<WebSelectionBound> m_end; | |
4236 }; | 4234 }; |
4237 | 4235 |
4238 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { | 4236 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { |
4239 public: | 4237 public: |
4240 virtual ~CompositedSelectionBoundsTestWebViewClient() { } | 4238 virtual ~CompositedSelectionBoundsTestWebViewClient() { } |
4241 virtual WebLayerTreeView* layerTreeView() override { return &m_testLayerTree
View; } | 4239 virtual WebLayerTreeView* layerTreeView() override { return &m_testLayerTree
View; } |
4242 | 4240 |
4243 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } | 4241 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } |
4244 | 4242 |
4245 private: | 4243 private: |
(...skipping 29 matching lines...) Expand all Loading... |
4275 EXPECT_FALSE(selectStart); | 4273 EXPECT_FALSE(selectStart); |
4276 EXPECT_FALSE(selectEnd); | 4274 EXPECT_FALSE(selectEnd); |
4277 return; | 4275 return; |
4278 } | 4276 } |
4279 | 4277 |
4280 ASSERT_TRUE(selectStart); | 4278 ASSERT_TRUE(selectStart); |
4281 ASSERT_TRUE(selectEnd); | 4279 ASSERT_TRUE(selectEnd); |
4282 | 4280 |
4283 ASSERT_TRUE((*result)->IsArray()); | 4281 ASSERT_TRUE((*result)->IsArray()); |
4284 v8::Array& expectedResult = *v8::Array::Cast(*result); | 4282 v8::Array& expectedResult = *v8::Array::Cast(*result); |
4285 ASSERT_EQ(10u, expectedResult.Length()); | 4283 ASSERT_GE(expectedResult.Length(), 10u); |
4286 | 4284 |
4287 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(0)); | 4285 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
4288 ASSERT_TRUE(layerOwnerNodeForStart); | 4286 ASSERT_TRUE(layerOwnerNodeForStart); |
4289 EXPECT_EQ(layerOwnerNodeForStart->layoutObject()->enclosingLayer()->encl
osingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(),
selectStart->layerId); | 4287 EXPECT_EQ(layerOwnerNodeForStart->layoutObject()->enclosingLayer()->encl
osingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(),
selectStart->layerId); |
4290 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); | 4288 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); |
4291 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); | 4289 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); |
4292 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); | 4290 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); |
4293 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); | 4291 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); |
4294 | 4292 |
4295 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v
8::Isolate::GetCurrent(), expectedResult.Get(5)); | 4293 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v
8::Isolate::GetCurrent(), expectedResult.Get(5)); |
4296 ASSERT_TRUE(layerOwnerNodeForEnd); | 4294 ASSERT_TRUE(layerOwnerNodeForEnd); |
4297 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject()->enclosingLayer()->enclos
ingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), s
electEnd->layerId); | 4295 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject()->enclosingLayer()->enclos
ingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), s
electEnd->layerId); |
4298 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); | 4296 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); |
4299 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); | 4297 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); |
4300 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); | 4298 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); |
4301 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); | 4299 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); |
| 4300 |
| 4301 if (expectedResult.Length() == 12) { |
| 4302 EXPECT_EQ(expectedResult.Get(10)->BooleanValue(), m_fakeSelectionLay
erTreeView.bounds()->isEditable); |
| 4303 EXPECT_EQ(expectedResult.Get(11)->BooleanValue(), m_fakeSelectionLay
erTreeView.bounds()->isEditableRegionEmpty); |
| 4304 } |
4302 } | 4305 } |
4303 | 4306 |
4304 void runTestWithMultipleFiles(const char* testFile, ...) | 4307 void runTestWithMultipleFiles(const char* testFile, ...) |
4305 { | 4308 { |
4306 va_list auxFiles; | 4309 va_list auxFiles; |
4307 va_start(auxFiles, testFile); | 4310 va_start(auxFiles, testFile); |
4308 while (const char* auxFile = va_arg(auxFiles, const char*)) | 4311 while (const char* auxFile = va_arg(auxFiles, const char*)) |
4309 registerMockedHttpURLLoad(auxFile); | 4312 registerMockedHttpURLLoad(auxFile); |
4310 va_end(auxFiles); | 4313 va_end(auxFiles); |
4311 | 4314 |
4312 runTest(testFile); | 4315 runTest(testFile); |
4313 } | 4316 } |
4314 | 4317 |
4315 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; | 4318 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; |
4316 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; | 4319 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; |
4317 FrameTestHelpers::WebViewHelper m_webViewHelper; | 4320 FrameTestHelpers::WebViewHelper m_webViewHelper; |
4318 }; | 4321 }; |
4319 | 4322 |
4320 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } | 4323 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } |
4321 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } | 4324 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } |
4322 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } | 4325 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } |
4323 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio
n_bounds_split_layer.html"); } | 4326 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio
n_bounds_split_layer.html"); } |
4324 TEST_F(CompositedSelectionBoundsTest, EmptyLayer) { runTest("composited_selectio
n_bounds_empty_layer.html"); } | 4327 TEST_F(CompositedSelectionBoundsTest, EmptyLayer) { runTest("composited_selectio
n_bounds_empty_layer.html"); } |
4325 TEST_F(CompositedSelectionBoundsTest, Iframe) { runTestWithMultipleFiles("compos
ited_selection_bounds_iframe.html", "composited_selection_bounds_basic.html", nu
llptr); } | 4328 TEST_F(CompositedSelectionBoundsTest, Iframe) { runTestWithMultipleFiles("compos
ited_selection_bounds_iframe.html", "composited_selection_bounds_basic.html", nu
llptr); } |
4326 TEST_F(CompositedSelectionBoundsTest, DetachedFrame) { runTest("composited_selec
tion_bounds_detached_frame.html"); } | 4329 TEST_F(CompositedSelectionBoundsTest, DetachedFrame) { runTest("composited_selec
tion_bounds_detached_frame.html"); } |
| 4330 TEST_F(CompositedSelectionBoundsTest, Editable) { runTest("composited_selection_
bounds_editable.html"); } |
| 4331 TEST_F(CompositedSelectionBoundsTest, EmptyEditable) { runTest("composited_selec
tion_bounds_empty_editable.html"); } |
4327 | 4332 |
4328 | 4333 |
4329 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 4334 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
4330 { | 4335 { |
4331 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); | 4336 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); |
4332 | 4337 |
4333 registerMockedHttpURLLoad("select_range_basic.html"); | 4338 registerMockedHttpURLLoad("select_range_basic.html"); |
4334 registerMockedHttpURLLoad("select_range_scroll.html"); | 4339 registerMockedHttpURLLoad("select_range_scroll.html"); |
4335 | 4340 |
4336 int viewWidth = 500; | 4341 int viewWidth = 500; |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7053 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7058 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7054 WebView* view = WebView::create(&viewClient); | 7059 WebView* view = WebView::create(&viewClient); |
7055 view->setMainFrame(WebRemoteFrame::create(&remoteClient)); | 7060 view->setMainFrame(WebRemoteFrame::create(&remoteClient)); |
7056 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7061 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
7057 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", &childFrameClient); | 7062 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", &childFrameClient); |
7058 childFrame->detach(); | 7063 childFrame->detach(); |
7059 view->close(); | 7064 view->close(); |
7060 } | 7065 } |
7061 | 7066 |
7062 } // namespace blink | 7067 } // namespace blink |
OLD | NEW |