| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ScrollIntoViewOptionsOrBoolean.h" | 5 #include "bindings/core/v8/ScrollIntoViewOptionsOrBoolean.h" |
| 6 #include "core/dom/Range.h" |
| 7 #include "core/editing/Editor.h" |
| 8 #include "core/editing/TextFinder.h" |
| 6 #include "core/frame/ScrollIntoViewOptions.h" | 9 #include "core/frame/ScrollIntoViewOptions.h" |
| 7 #include "core/frame/ScrollToOptions.h" | 10 #include "core/frame/ScrollToOptions.h" |
| 8 #include "public/web/WebScriptSource.h" | 11 #include "public/web/WebScriptSource.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "web/WebLocalFrameImpl.h" | 13 #include "web/WebLocalFrameImpl.h" |
| 11 #include "web/tests/sim/SimCompositor.h" | 14 #include "web/tests/sim/SimCompositor.h" |
| 12 #include "web/tests/sim/SimDisplayItemList.h" | 15 #include "web/tests/sim/SimDisplayItemList.h" |
| 13 #include "web/tests/sim/SimRequest.h" | 16 #include "web/tests/sim/SimRequest.h" |
| 14 #include "web/tests/sim/SimTest.h" | 17 #include "web/tests/sim/SimTest.h" |
| 15 | 18 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 options.setBlock("end"); | 279 options.setBlock("end"); |
| 277 options.setInlinePosition("end"); | 280 options.setInlinePosition("end"); |
| 278 arg4.setScrollIntoViewOptions(options); | 281 arg4.setScrollIntoViewOptions(options); |
| 279 content->scrollIntoView(arg4); | 282 content->scrollIntoView(arg4); |
| 280 ASSERT_EQ(Window().scrollX(), | 283 ASSERT_EQ(Window().scrollX(), |
| 281 content->OffsetLeft() + content_width - window_width); | 284 content->OffsetLeft() + content_width - window_width); |
| 282 ASSERT_EQ(Window().scrollY(), | 285 ASSERT_EQ(Window().scrollY(), |
| 283 content->OffsetTop() + content_height - window_height); | 286 content->OffsetTop() + content_height - window_height); |
| 284 } | 287 } |
| 285 | 288 |
| 289 TEST_F(SmoothScrollTest, FindTriggersSmoothScroll) { |
| 290 v8::HandleScope HandleScope(v8::Isolate::GetCurrent()); |
| 291 WebView().Resize(WebSize(800, 600)); |
| 292 SimRequest request("https://example.com/test.html", "text/html"); |
| 293 LoadURL("https://example.com/test.html"); |
| 294 request.Complete( |
| 295 "<div id='space' style='height: 2000px'></div>" |
| 296 "<div id='content' style='height: 2000px'>text</div>"); |
| 297 |
| 298 Range* range = GetDocument().createRange(); |
| 299 MainFrame().GetFrame()->GetEditor().FindStringAndScrollToVisible( |
| 300 "text", range, kCaseInsensitive); |
| 301 |
| 302 // Scrolling the container |
| 303 Compositor().BeginFrame(); // update run_state_. |
| 304 Compositor().BeginFrame(); // Set start_time = now. |
| 305 Compositor().BeginFrame(0.2); |
| 306 ASSERT_EQ(Window().scrollY(), 299); |
| 307 |
| 308 // Finish scrolling the container |
| 309 Compositor().BeginFrame(1); |
| 310 ASSERT_EQ(Window().scrollY(), 1708); |
| 311 } |
| 312 |
| 286 } // namespace | 313 } // namespace |
| 287 | 314 |
| 288 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |