forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check auto scroll not canceled before schedule animation
This issue is caused by AutoscrollForSelection call UpdateSelectionForMouseDrag may cancel auto scroll by layout. In this patch we check auto scroll state before schedule animation. Bug: 781455 Change-Id: I904ae86aaaa4694a5ce56f9daca7daf778d8a6c8 Reviewed-on: https://chromium-review.googlesource.com/776622 Commit-Queue: Jianpeng Chao <chaopeng@chromium.org> Reviewed-by: David Bokan <bokan@chromium.org> Cr-Commit-Position: refs/heads/master@{#517711}
- Loading branch information
Showing
4 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
third_party/WebKit/Source/core/page/AutoscrollControllerTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "core/dom/Element.h" | ||
#include "core/input/EventHandler.h" | ||
#include "core/page/AutoscrollController.h" | ||
#include "core/page/Page.h" | ||
#include "core/testing/sim/SimDisplayItemList.h" | ||
#include "core/testing/sim/SimRequest.h" | ||
#include "core/testing/sim/SimTest.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace blink { | ||
|
||
class AutoscrollControllerTest : public SimTest { | ||
public: | ||
AutoscrollController& GetAutoscrollController() { | ||
return WebView().GetPage()->GetAutoscrollController(); | ||
} | ||
}; | ||
|
||
// Ensure Autoscroll not crash by layout called in UpdateSelectionForMouseDrag. | ||
TEST_F(AutoscrollControllerTest, | ||
CrashWhenLayoutStopAnimationBeforeScheduleAnimation) { | ||
WebView().Resize(WebSize(800, 600)); | ||
WebView().SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); | ||
SimRequest request("https://example.com/test.html", "text/html"); | ||
LoadURL("https://example.com/test.html"); | ||
request.Complete(R"HTML( | ||
<!DOCTYPE html> | ||
<style> | ||
#scrollable { | ||
overflow: auto; | ||
width: 10px; | ||
height: 10px; | ||
} | ||
</style> | ||
<div id='scrollable'> | ||
<p id='p'>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
<p>Some text here for selection autoscroll.</p> | ||
</div> | ||
)HTML"); | ||
|
||
Compositor().BeginFrame(); | ||
|
||
AutoscrollController& controller = GetAutoscrollController(); | ||
Document& document = GetDocument(); | ||
|
||
Element* scrollable = document.getElementById("scrollable"); | ||
DCHECK(scrollable); | ||
DCHECK(scrollable->GetLayoutObject()); | ||
|
||
WebMouseEvent event(WebInputEvent::kMouseDown, WebFloatPoint(5, 5), | ||
WebFloatPoint(5, 5), WebPointerProperties::Button::kLeft, | ||
0, WebInputEvent::Modifiers::kLeftButtonDown, | ||
TimeTicks::Now().InSeconds()); | ||
event.SetFrameScale(1); | ||
|
||
GetDocument().GetFrame()->GetEventHandler().HandleMousePressEvent(event); | ||
|
||
controller.StartAutoscrollForSelection(scrollable->GetLayoutObject()); | ||
|
||
DCHECK(controller.IsAutoscrolling()); | ||
|
||
// Hide scrollable here will cause UpdateSelectionForMouseDrag stop animation. | ||
scrollable->SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | ||
|
||
// BeginFrame will call AutoscrollController::Animate. | ||
Compositor().BeginFrame(); | ||
|
||
EXPECT_FALSE(controller.IsAutoscrolling()); | ||
} | ||
|
||
} // namespace blink |