| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "platform/PlatformResourceLoader.h" | 79 #include "platform/PlatformResourceLoader.h" |
| 80 #include "platform/RuntimeEnabledFeatures.h" | 80 #include "platform/RuntimeEnabledFeatures.h" |
| 81 #include "platform/UserGestureIndicator.h" | 81 #include "platform/UserGestureIndicator.h" |
| 82 #include "platform/geometry/FloatRect.h" | 82 #include "platform/geometry/FloatRect.h" |
| 83 #include "platform/network/ResourceError.h" | 83 #include "platform/network/ResourceError.h" |
| 84 #include "platform/scroll/ScrollbarTheme.h" | 84 #include "platform/scroll/ScrollbarTheme.h" |
| 85 #include "platform/weborigin/SchemeRegistry.h" | 85 #include "platform/weborigin/SchemeRegistry.h" |
| 86 #include "platform/weborigin/SecurityOrigin.h" | 86 #include "platform/weborigin/SecurityOrigin.h" |
| 87 #include "public/platform/Platform.h" | 87 #include "public/platform/Platform.h" |
| 88 #include "public/platform/WebFloatRect.h" | 88 #include "public/platform/WebFloatRect.h" |
| 89 #include "public/platform/WebSelectionBound.h" | |
| 90 #include "public/platform/WebThread.h" | 89 #include "public/platform/WebThread.h" |
| 91 #include "public/platform/WebURL.h" | 90 #include "public/platform/WebURL.h" |
| 92 #include "public/platform/WebURLResponse.h" | 91 #include "public/platform/WebURLResponse.h" |
| 93 #include "public/platform/WebUnitTestSupport.h" | 92 #include "public/platform/WebUnitTestSupport.h" |
| 94 #include "public/web/WebCache.h" | 93 #include "public/web/WebCache.h" |
| 95 #include "public/web/WebDataSource.h" | 94 #include "public/web/WebDataSource.h" |
| 96 #include "public/web/WebDocument.h" | 95 #include "public/web/WebDocument.h" |
| 97 #include "public/web/WebFindOptions.h" | 96 #include "public/web/WebFindOptions.h" |
| 98 #include "public/web/WebFormElement.h" | 97 #include "public/web/WebFormElement.h" |
| 99 #include "public/web/WebFrameClient.h" | 98 #include "public/web/WebFrameClient.h" |
| 100 #include "public/web/WebHistoryItem.h" | 99 #include "public/web/WebHistoryItem.h" |
| 101 #include "public/web/WebPrintParams.h" | 100 #include "public/web/WebPrintParams.h" |
| 102 #include "public/web/WebRange.h" | 101 #include "public/web/WebRange.h" |
| 103 #include "public/web/WebRemoteFrame.h" | 102 #include "public/web/WebRemoteFrame.h" |
| 104 #include "public/web/WebScriptSource.h" | 103 #include "public/web/WebScriptSource.h" |
| 105 #include "public/web/WebSearchableFormData.h" | 104 #include "public/web/WebSearchableFormData.h" |
| 106 #include "public/web/WebSecurityOrigin.h" | 105 #include "public/web/WebSecurityOrigin.h" |
| 107 #include "public/web/WebSecurityPolicy.h" | 106 #include "public/web/WebSecurityPolicy.h" |
| 107 #include "public/web/WebSelection.h" |
| 108 #include "public/web/WebSettings.h" | 108 #include "public/web/WebSettings.h" |
| 109 #include "public/web/WebSpellCheckClient.h" | 109 #include "public/web/WebSpellCheckClient.h" |
| 110 #include "public/web/WebTextCheckingCompletion.h" | 110 #include "public/web/WebTextCheckingCompletion.h" |
| 111 #include "public/web/WebTextCheckingResult.h" | 111 #include "public/web/WebTextCheckingResult.h" |
| 112 #include "public/web/WebViewClient.h" | 112 #include "public/web/WebViewClient.h" |
| 113 #include "web/WebLocalFrameImpl.h" | 113 #include "web/WebLocalFrameImpl.h" |
| 114 #include "web/WebRemoteFrameImpl.h" | 114 #include "web/WebRemoteFrameImpl.h" |
| 115 #include "web/WebViewImpl.h" | 115 #include "web/WebViewImpl.h" |
| 116 #include "web/tests/FrameTestHelpers.h" | 116 #include "web/tests/FrameTestHelpers.h" |
| 117 #include "wtf/Forward.h" | 117 #include "wtf/Forward.h" |
| (...skipping 4082 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 WebSelection& selection) override |
| 4211 { | 4211 { |
| 4212 m_start = adoptPtr(new WebSelectionBound(start)); | 4212 m_selection = adoptPtr(new WebSelection(selection)); |
| 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_selection.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 WebSelection* selection() const { return m_selection.get(); } |
| 4230 const WebSelectionBound* end() const { return m_end.get(); } | 4228 const WebSelectionBound* start() const { return m_selection ? &m_selection->
start() : nullptr; } |
| 4229 const WebSelectionBound* end() const { return m_selection ? &m_selection->en
d() : nullptr; } |
| 4231 | 4230 |
| 4232 private: | 4231 private: |
| 4233 bool m_selectionCleared; | 4232 bool m_selectionCleared; |
| 4234 OwnPtr<WebSelectionBound> m_start; | 4233 OwnPtr<WebSelection> m_selection; |
| 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 13 matching lines...) Expand all Loading... |
| 4259 m_webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); | 4257 m_webViewHelper.webView()->setDefaultPageScaleLimits(1, 1); |
| 4260 m_webViewHelper.webView()->resize(WebSize(640, 480)); | 4258 m_webViewHelper.webView()->resize(WebSize(640, 480)); |
| 4261 } | 4259 } |
| 4262 | 4260 |
| 4263 void runTest(const char* testFile) | 4261 void runTest(const char* testFile) |
| 4264 { | 4262 { |
| 4265 registerMockedHttpURLLoad(testFile); | 4263 registerMockedHttpURLLoad(testFile); |
| 4266 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); | 4264 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); |
| 4267 m_webViewHelper.webView()->layout(); | 4265 m_webViewHelper.webView()->layout(); |
| 4268 | 4266 |
| 4267 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection()
; |
| 4269 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); | 4268 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); |
| 4270 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); | 4269 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| 4271 | 4270 |
| 4272 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 4271 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 4273 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->t
oWebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult"))
; | 4272 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->t
oWebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult"))
; |
| 4274 if (result.IsEmpty() || (*result)->IsUndefined()) { | 4273 if (result.IsEmpty() || (*result)->IsUndefined()) { |
| 4274 EXPECT_FALSE(selection); |
| 4275 EXPECT_FALSE(selectStart); | 4275 EXPECT_FALSE(selectStart); |
| 4276 EXPECT_FALSE(selectEnd); | 4276 EXPECT_FALSE(selectEnd); |
| 4277 return; | 4277 return; |
| 4278 } | 4278 } |
| 4279 | 4279 |
| 4280 ASSERT_TRUE(selection); |
| 4280 ASSERT_TRUE(selectStart); | 4281 ASSERT_TRUE(selectStart); |
| 4281 ASSERT_TRUE(selectEnd); | 4282 ASSERT_TRUE(selectEnd); |
| 4282 | 4283 |
| 4284 EXPECT_FALSE(selection->isNone()); |
| 4285 |
| 4283 ASSERT_TRUE((*result)->IsArray()); | 4286 ASSERT_TRUE((*result)->IsArray()); |
| 4284 v8::Array& expectedResult = *v8::Array::Cast(*result); | 4287 v8::Array& expectedResult = *v8::Array::Cast(*result); |
| 4285 ASSERT_EQ(10u, expectedResult.Length()); | 4288 ASSERT_GE(expectedResult.Length(), 10u); |
| 4286 | 4289 |
| 4287 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(0)); | 4290 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
| 4288 ASSERT_TRUE(layerOwnerNodeForStart); | 4291 ASSERT_TRUE(layerOwnerNodeForStart); |
| 4289 EXPECT_EQ(layerOwnerNodeForStart->layoutObject()->enclosingLayer()->encl
osingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(),
selectStart->layerId); | 4292 EXPECT_EQ(layerOwnerNodeForStart->layoutObject()->enclosingLayer()->encl
osingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(),
selectStart->layerId); |
| 4290 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); | 4293 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); |
| 4291 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); | 4294 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); |
| 4292 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); | 4295 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); |
| 4293 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); | 4296 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); |
| 4294 | 4297 |
| 4295 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v
8::Isolate::GetCurrent(), expectedResult.Get(5)); | 4298 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v
8::Isolate::GetCurrent(), expectedResult.Get(5)); |
| 4296 ASSERT_TRUE(layerOwnerNodeForEnd); | 4299 ASSERT_TRUE(layerOwnerNodeForEnd); |
| 4297 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject()->enclosingLayer()->enclos
ingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), s
electEnd->layerId); | 4300 EXPECT_EQ(layerOwnerNodeForEnd->layoutObject()->enclosingLayer()->enclos
ingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), s
electEnd->layerId); |
| 4298 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); | 4301 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); |
| 4299 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); | 4302 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); |
| 4300 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); | 4303 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); |
| 4301 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); | 4304 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); |
| 4305 |
| 4306 if (expectedResult.Length() >= 12) { |
| 4307 EXPECT_EQ(expectedResult.Get(10)->BooleanValue(), m_fakeSelectionLay
erTreeView.selection()->isEditable()); |
| 4308 EXPECT_EQ(expectedResult.Get(11)->BooleanValue(), m_fakeSelectionLay
erTreeView.selection()->isEditableRegionEmpty()); |
| 4309 } |
| 4302 } | 4310 } |
| 4303 | 4311 |
| 4304 void runTestWithMultipleFiles(const char* testFile, ...) | 4312 void runTestWithMultipleFiles(const char* testFile, ...) |
| 4305 { | 4313 { |
| 4306 va_list auxFiles; | 4314 va_list auxFiles; |
| 4307 va_start(auxFiles, testFile); | 4315 va_start(auxFiles, testFile); |
| 4308 while (const char* auxFile = va_arg(auxFiles, const char*)) | 4316 while (const char* auxFile = va_arg(auxFiles, const char*)) |
| 4309 registerMockedHttpURLLoad(auxFile); | 4317 registerMockedHttpURLLoad(auxFile); |
| 4310 va_end(auxFiles); | 4318 va_end(auxFiles); |
| 4311 | 4319 |
| 4312 runTest(testFile); | 4320 runTest(testFile); |
| 4313 } | 4321 } |
| 4314 | 4322 |
| 4315 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; | 4323 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; |
| 4316 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; | 4324 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; |
| 4317 FrameTestHelpers::WebViewHelper m_webViewHelper; | 4325 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 4318 }; | 4326 }; |
| 4319 | 4327 |
| 4320 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } | 4328 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } |
| 4321 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } | 4329 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } |
| 4322 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } | 4330 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } |
| 4323 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio
n_bounds_split_layer.html"); } | 4331 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"); } | 4332 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); } | 4333 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"); } | 4334 TEST_F(CompositedSelectionBoundsTest, DetachedFrame) { runTest("composited_selec
tion_bounds_detached_frame.html"); } |
| 4327 | 4335 TEST_F(CompositedSelectionBoundsTest, Editable) { runTest("composited_selection_
bounds_editable.html"); } |
| 4336 TEST_F(CompositedSelectionBoundsTest, EditableDiv) { runTest("composited_selecti
on_bounds_editable_div.html"); } |
| 4337 TEST_F(CompositedSelectionBoundsTest, EmptyEditableInput) { runTest("composited_
selection_bounds_empty_editable_input.html"); } |
| 4338 TEST_F(CompositedSelectionBoundsTest, EmptyEditableArea) { runTest("composited_s
election_bounds_empty_editable_area.html"); } |
| 4328 | 4339 |
| 4329 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 4340 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
| 4330 { | 4341 { |
| 4331 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); | 4342 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); |
| 4332 | 4343 |
| 4333 registerMockedHttpURLLoad("select_range_basic.html"); | 4344 registerMockedHttpURLLoad("select_range_basic.html"); |
| 4334 registerMockedHttpURLLoad("select_range_scroll.html"); | 4345 registerMockedHttpURLLoad("select_range_scroll.html"); |
| 4335 | 4346 |
| 4336 int viewWidth = 500; | 4347 int viewWidth = 500; |
| 4337 int viewHeight = 500; | 4348 int viewHeight = 500; |
| (...skipping 2741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7079 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7090 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| 7080 WebView* view = WebView::create(&viewClient); | 7091 WebView* view = WebView::create(&viewClient); |
| 7081 view->setMainFrame(WebRemoteFrame::create(&remoteClient)); | 7092 view->setMainFrame(WebRemoteFrame::create(&remoteClient)); |
| 7082 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7093 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
| 7083 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); | 7094 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); |
| 7084 childFrame->detach(); | 7095 childFrame->detach(); |
| 7085 view->close(); | 7096 view->close(); |
| 7086 } | 7097 } |
| 7087 | 7098 |
| 7088 } // namespace blink | 7099 } // namespace blink |
| OLD | NEW |