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 3951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 } | 3999 } |
3999 | 4000 |
4000 bool getAndResetSelectionCleared() | 4001 bool getAndResetSelectionCleared() |
4001 { | 4002 { |
4002 bool selectionCleared = m_selectionCleared; | 4003 bool selectionCleared = m_selectionCleared; |
4003 m_selectionCleared = false; | 4004 m_selectionCleared = false; |
4004 return selectionCleared; | 4005 return selectionCleared; |
4005 } | 4006 } |
4006 | 4007 |
4007 const WebSelectionBound* start() const { return m_start.get(); } | 4008 const WebSelectionBound* start() const { return m_start.get(); } |
4008 const WebSelectionBound* end() const { return m_start.get(); } | 4009 const WebSelectionBound* end() const { return m_end.get(); } |
4009 | 4010 |
4010 private: | 4011 private: |
4011 bool m_selectionCleared; | 4012 bool m_selectionCleared; |
4012 OwnPtr<WebSelectionBound> m_start; | 4013 OwnPtr<WebSelectionBound> m_start; |
4013 OwnPtr<WebSelectionBound> m_end; | 4014 OwnPtr<WebSelectionBound> m_end; |
4014 }; | 4015 }; |
4015 | 4016 |
4016 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { | 4017 class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::Test
WebViewClient { |
4017 public: | 4018 public: |
4018 virtual ~CompositedSelectionBoundsTestWebViewClient() { } | 4019 virtual ~CompositedSelectionBoundsTestWebViewClient() { } |
4019 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } | 4020 virtual WebLayerTreeView* layerTreeView() OVERRIDE { return &m_testLayerTree
View; } |
4020 | 4021 |
4021 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } | 4022 CompositedSelectionBoundsTestLayerTreeView& selectionLayerTreeView() { retur
n m_testLayerTreeView; } |
4022 | 4023 |
4023 private: | 4024 private: |
4024 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; | 4025 CompositedSelectionBoundsTestLayerTreeView m_testLayerTreeView; |
4025 }; | 4026 }; |
4026 | 4027 |
| 4028 class CompositedSelectionBoundsTest : public WebFrameTest { |
| 4029 protected: |
| 4030 CompositedSelectionBoundsTest() |
| 4031 : m_fakeSelectionLayerTreeView(m_fakeSelectionWebViewClient.selectionLay
erTreeView()) |
| 4032 { |
| 4033 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true
); |
| 4034 registerMockedHttpURLLoad("Ahem.ttf"); |
| 4035 |
| 4036 m_webViewHelper.initialize(true, 0, &m_fakeSelectionWebViewClient); |
| 4037 m_webViewHelper.webView()->settings()->setDefaultFontSize(12); |
| 4038 m_webViewHelper.webView()->setPageScaleFactorLimits(1, 1); |
| 4039 m_webViewHelper.webView()->resize(WebSize(640, 480)); |
| 4040 } |
| 4041 |
| 4042 void runTest(const char* testFile) |
| 4043 { |
| 4044 registerMockedHttpURLLoad(testFile); |
| 4045 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); |
| 4046 m_webViewHelper.webView()->layout(); |
| 4047 |
| 4048 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); |
| 4049 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| 4050 |
| 4051 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| 4052 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->e
xecuteScriptAndReturnValueForTests(WebScriptSource("expectedResult")); |
| 4053 if (result.IsEmpty() || (*result)->IsUndefined()) { |
| 4054 EXPECT_FALSE(selectStart); |
| 4055 EXPECT_FALSE(selectEnd); |
| 4056 return; |
| 4057 } |
| 4058 |
| 4059 ASSERT_TRUE(selectStart); |
| 4060 ASSERT_TRUE(selectEnd); |
| 4061 |
| 4062 ASSERT_TRUE((*result)->IsArray()); |
| 4063 v8::Array& expectedResult = *v8::Array::Cast(*result); |
| 4064 ASSERT_EQ(10u, expectedResult.Length()); |
| 4065 |
| 4066 blink::Node* layerOwnerNodeForStart = blink::V8Node::toNativeWithTypeChe
ck(v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
| 4067 ASSERT_TRUE(layerOwnerNodeForStart); |
| 4068 EXPECT_EQ(layerOwnerNodeForStart->renderer()->enclosingLayer()->enclosin
gLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), sel
ectStart->layerId); |
| 4069 EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLay
er.x); |
| 4070 EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLay
er.y); |
| 4071 EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomIn
Layer.x); |
| 4072 EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomIn
Layer.y); |
| 4073 |
| 4074 blink::Node* layerOwnerNodeForEnd = blink::V8Node::toNativeWithTypeCheck
(v8::Isolate::GetCurrent(), expectedResult.Get(5)); |
| 4075 ASSERT_TRUE(layerOwnerNodeForEnd); |
| 4076 EXPECT_EQ(layerOwnerNodeForEnd->renderer()->enclosingLayer()->enclosingL
ayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), selec
tEnd->layerId); |
| 4077 EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer
.x); |
| 4078 EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer
.y); |
| 4079 EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLa
yer.x); |
| 4080 EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLa
yer.y); |
| 4081 } |
| 4082 |
| 4083 void runTestWithMultipleFiles(const char* testFile, ...) |
| 4084 { |
| 4085 va_list auxFiles; |
| 4086 va_start(auxFiles, testFile); |
| 4087 while (const char* auxFile = va_arg(auxFiles, const char*)) |
| 4088 registerMockedHttpURLLoad(auxFile); |
| 4089 va_end(auxFiles); |
| 4090 |
| 4091 runTest(testFile); |
| 4092 } |
| 4093 |
| 4094 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 4095 CompositedSelectionBoundsTestWebViewClient m_fakeSelectionWebViewClient; |
| 4096 CompositedSelectionBoundsTestLayerTreeView& m_fakeSelectionLayerTreeView; |
| 4097 }; |
| 4098 |
| 4099 TEST_F(CompositedSelectionBoundsTest, None) { runTest("composited_selection_boun
ds_none.html"); } |
| 4100 TEST_F(CompositedSelectionBoundsTest, Basic) { runTest("composited_selection_bou
nds_basic.html"); } |
| 4101 TEST_F(CompositedSelectionBoundsTest, Transformed) { runTest("composited_selecti
on_bounds_transformed.html"); } |
| 4102 TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio
n_bounds_split_layer.html"); } |
| 4103 TEST_F(CompositedSelectionBoundsTest, Iframe) { runTestWithMultipleFiles("compos
ited_selection_bounds_iframe.html", "composited_selection_bounds_basic.html", nu
llptr); } |
| 4104 |
4027 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) | 4105 TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
4028 { | 4106 { |
4029 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); | 4107 blink::RuntimeEnabledFeatures::setCompositedSelectionUpdatesEnabled(true); |
4030 | 4108 |
4031 registerMockedHttpURLLoad("select_range_basic.html"); | 4109 registerMockedHttpURLLoad("select_range_basic.html"); |
4032 registerMockedHttpURLLoad("select_range_scroll.html"); | 4110 registerMockedHttpURLLoad("select_range_scroll.html"); |
4033 | 4111 |
4034 int viewWidth = 500; | 4112 int viewWidth = 500; |
4035 int viewHeight = 500; | 4113 int viewHeight = 500; |
4036 | 4114 |
(...skipping 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6179 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6257 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6180 | 6258 |
6181 // Neither should a page reload. | 6259 // Neither should a page reload. |
6182 localFrame->reload(); | 6260 localFrame->reload(); |
6183 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6261 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6184 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6262 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6185 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6263 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6186 } | 6264 } |
6187 | 6265 |
6188 } // namespace | 6266 } // namespace |
OLD | NEW |