Commit 5f8dfe18 authored by sunyunjia's avatar sunyunjia Committed by Commit bot

Check frame for nullptr in WebCore::AutoscrollController::animate

The previous solution at https://codereview.chromium.org/2316113003/ does not check
all the frames for nullptr. This patch solves the problem in a more clean and
thorough way.

BUG=361036

Review-Url: https://codereview.chromium.org/2322013002
Cr-Commit-Position: refs/heads/master@{#417399}
parent 7cdfec13
......@@ -235,26 +235,24 @@ bool AutoscrollController::panScrollInProgress() const
void AutoscrollController::animate(double)
{
if (!m_autoscrollLayoutObject) {
if (!m_autoscrollLayoutObject || !m_autoscrollLayoutObject->frame()) {
stopAutoscroll();
return;
}
EventHandler& eventHandler = m_autoscrollLayoutObject->frame()->eventHandler();
switch (m_autoscrollType) {
case AutoscrollForDragAndDrop:
if (WTF::monotonicallyIncreasingTime() - m_dragAndDropAutoscrollStartTime > autoscrollDelay)
m_autoscrollLayoutObject->autoscroll(m_dragAndDropAutoscrollReferencePosition);
break;
case AutoscrollForSelection:
if (LocalFrame* frame = m_autoscrollLayoutObject->frame()) {
EventHandler& eventHandler = frame->eventHandler();
if (!eventHandler.mousePressed()) {
stopAutoscroll();
return;
}
eventHandler.updateSelectionForMouseDrag();
m_autoscrollLayoutObject->autoscroll(eventHandler.lastKnownMousePosition());
if (!eventHandler.mousePressed()) {
stopAutoscroll();
return;
}
eventHandler.updateSelectionForMouseDrag();
m_autoscrollLayoutObject->autoscroll(eventHandler.lastKnownMousePosition());
break;
case NoAutoscroll:
break;
......@@ -265,12 +263,8 @@ void AutoscrollController::animate(double)
stopAutoscroll();
return;
}
if (LocalFrame* frame = m_autoscrollLayoutObject->frame()) {
if (FrameView* view = frame->view()) {
EventHandler& eventHandler = frame->eventHandler();
updatePanScrollState(view, eventHandler.lastKnownMousePosition());
}
}
if (FrameView* view = m_autoscrollLayoutObject->frame()->view())
updatePanScrollState(view, eventHandler.lastKnownMousePosition());
m_autoscrollLayoutObject->panScroll(m_panScrollStartPos);
break;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment