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 16 matching lines...) Expand all Loading... |
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 | 32 |
33 #include "public/web/WebFrame.h" | 33 #include "public/web/WebFrame.h" |
34 | 34 |
35 #include "SkBitmap.h" | 35 #include "SkBitmap.h" |
36 #include "SkCanvas.h" | 36 #include "SkCanvas.h" |
| 37 #include "bindings/core/v8/V8Node.h" |
37 #include "core/UserAgentStyleSheets.h" | 38 #include "core/UserAgentStyleSheets.h" |
38 #include "core/clipboard/DataTransfer.h" | 39 #include "core/clipboard/DataTransfer.h" |
39 #include "core/css/StyleSheetContents.h" | 40 #include "core/css/StyleSheetContents.h" |
40 #include "core/css/resolver/StyleResolver.h" | 41 #include "core/css/resolver/StyleResolver.h" |
41 #include "core/css/resolver/ViewportStyleResolver.h" | 42 #include "core/css/resolver/ViewportStyleResolver.h" |
42 #include "core/dom/DocumentMarkerController.h" | 43 #include "core/dom/DocumentMarkerController.h" |
43 #include "core/dom/Fullscreen.h" | 44 #include "core/dom/Fullscreen.h" |
44 #include "core/dom/NodeRenderStyle.h" | 45 #include "core/dom/NodeRenderStyle.h" |
45 #include "core/dom/Range.h" | 46 #include "core/dom/Range.h" |
46 #include "core/editing/Editor.h" | 47 #include "core/editing/Editor.h" |
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4044 } | 4045 } |
4045 | 4046 |
4046 bool getAndResetSelectionCleared() | 4047 bool getAndResetSelectionCleared() |
4047 { | 4048 { |
4048 bool selectionCleared = m_selectionCleared; | 4049 bool selectionCleared = m_selectionCleared; |
4049 m_selectionCleared = false; | 4050 m_selectionCleared = false; |
4050 return selectionCleared; | 4051 return selectionCleared; |
4051 } | 4052 } |
4052 | 4053 |
4053 const WebSelectionBound* start() const { return m_start.get(); } | 4054 const WebSelectionBound* start() const { return m_start.get(); } |
4054 const WebSelectionBound* end() const { return m_start.get(); } | 4055 const WebSelectionBound* end() const { return m_end.get(); } |
4055 | 4056 |
4056 private: | 4057 private: |
4057 bool m_selectionCleared; | 4058 bool m_selectionCleared; |
4058 OwnPtr<WebSelectionBound> m_start; | 4059 OwnPtr<WebSelectionBound> m_start; |
4059 OwnPtr<WebSelectionBound> m_end; | 4060 OwnPtr<WebSelectionBound> m_end; |
4060 }; | 4061 }; |
4061 | 4062 |
4062 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { | 4063 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { |
4063 public: | 4064 public: |
4064 virtual ~CompositedSelectionBoundsTestWebViewClient() { } | 4065 virtual ~CompositedSelectionBoundsTestWebViewClient() { } |
4065 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } | 4066 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } |
4066 | 4067 |
4067 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } | 4068 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } |
4068 | 4069 |
4069 private: | 4070 private: |
4070 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; | 4071 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; |
4071 }; | 4072 }; |
4072 | 4073 |
| 4074 class CompositedSelectionBoundsTest : public WebFrameTest { |
| 4075 protected: |
| 4076 CompositedSelectionBoundsTest() |
| 4077 : m_fakeSelectionLayerTreeView(m_fakeSelectionWebViewClient.selectionLay
erTreeView()) |
| 4078 { |
| 4079 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true)
; |
| 4080 registerMockedHttpURLLoad("Ahem.ttf"); |
| 4081 |
| 4082 m_webViewHelper.initialize(true, 0, &m_fakeSelectionWebViewClient); |
| 4083 m_webViewHelper.webView()->settings()->setDefaultFontSize(12); |
| 4084 m_webViewHelper.webView()->setPageScaleFactorLimits(1, 1); |
| 4085 m_webViewHelper.webView()->resize(WebSize(640, 480)); |
| 4086 } |
| 4087 |
| 4088 void runTest(const char* testFile) |
| 4089 { |
| 4090 registerMockedHttpURLLoad(testFile); |
| 4091 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); |
| 4092 m_webViewHelper.webView()->layout(); |
| 4093 |
| 4094 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); |
| 4095 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| 4096 |
| 4097 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 4098 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->e
xecuteScriptAndReturnValueForTests(WebScriptSource("expectedResult")); |
| 4099 if (result.IsEmpty() || (*result)->IsUndefined()) { |
| 4100 EXPECT_FALSE(selectStart); |
| 4101 EXPECT_FALSE(selectEnd); |
| 4102 return; |
| 4103 } |
| 4104 |
| 4105 ASSERT_TRUE(selectStart); |
| 4106 ASSERT_TRUE(selectEnd); |
| 4107 |
| 4108 ASSERT_TRUE((*result)->IsArray()); |
| 4109 v8::Array& expectedResult = *v8::Array::Cast(*result); |
| 4110 ASSERT_EQ(10u, expectedResult.Length()); |
| 4111 |
| 4112 blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
| 4113 ASSERT_TRUE(layerOwnerNodeForStart); |
| 4114 EXPECT_EQ(layerOwnerNodeForStart->renderer()->enclosingLayer()->enclosin
gLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), sel
ectStart->layerId); |
| 4115 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); |
| 4116 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); |
| 4117 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); |
| 4118 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); |
| 4119 |
| 4120 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v
8::Isolate::GetCurrent(), expectedResult.Get(5)); |
| 4121 ASSERT_TRUE(layerOwnerNodeForEnd); |
| 4122 EXPECT_EQ(layerOwnerNodeForEnd->renderer()->enclosingLayer()->enclosingL
ayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), selec
tEnd->layerId); |
| 4123 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); |
| 4124 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); |
| 4125 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); |
| 4126 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); |
| 4127 } |
| 4128 |
| 4129 void runTestWithMultipleFiles(const char* testFile, ...) |
| 4130 { |
| 4131 va_list auxFiles; |
| 4132 va_start(auxFiles, testFile); |
| 4133 while (const char* auxFile = va_arg(auxFiles, const char*)) |
| 4134 registerMockedHttpURLLoad(auxFile); |
| 4135 va_end(auxFiles); |
| 4136 |
| 4137 runTest(testFile); |
| 4138 } |
| 4139 |
| 4140 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; |
| 4141 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; |
| 4142 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 4143 }; |
| 4144 |
| 4145 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } |
| 4146 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } |
| 4147 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } |
| 4148 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio
n_bounds_split_layer.html"); } |
| 4149 TEST_F(CompositedSelectionBoundsTest, Iframe) { runTestWithMultipleFiles("compos
ited_selection_bounds_iframe.html", "composited_selection_bounds_basic.html", nu
llptr); } |
| 4150 |
4073 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 4151 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
4074 { | 4152 { |
4075 RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); | 4153 RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true); |
4076 | 4154 |
4077 registerMockedHttpURLLoad("select_range_basic.html"); | 4155 registerMockedHttpURLLoad("select_range_basic.html"); |
4078 registerMockedHttpURLLoad("select_range_scroll.html"); | 4156 registerMockedHttpURLLoad("select_range_scroll.html"); |
4079 | 4157 |
4080 int viewWidth = 500; | 4158 int viewWidth = 500; |
4081 int viewHeight = 500; | 4159 int viewHeight = 500; |
4082 | 4160 |
4083 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; | 4161 CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient; |
4084 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); | 4162 CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView = fak
eSelectionWebViewClient.selectionLayerTreeView(); |
4085 | 4163 |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6268 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6346 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6269 | 6347 |
6270 // Neither should a page reload. | 6348 // Neither should a page reload. |
6271 localFrame->reload(); | 6349 localFrame->reload(); |
6272 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6350 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6273 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6351 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6274 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6352 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6275 } | 6353 } |
6276 | 6354 |
6277 } // namespace | 6355 } // namespace |
OLD | NEW |