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 ...@@ -235,26 +235,24 @@ bool AutoscrollController::panScrollInProgress() const
void AutoscrollController::animate(double) void AutoscrollController::animate(double)
{ {
if (!m_autoscrollLayoutObject) { if (!m_autoscrollLayoutObject || !m_autoscrollLayoutObject->frame()) {
stopAutoscroll(); stopAutoscroll();
return; return;
} }
EventHandler& eventHandler = m_autoscrollLayoutObject->frame()->eventHandler();
switch (m_autoscrollType) { switch (m_autoscrollType) {
case AutoscrollForDragAndDrop: case AutoscrollForDragAndDrop:
if (WTF::monotonicallyIncreasingTime() - m_dragAndDropAutoscrollStartTime > autoscrollDelay) if (WTF::monotonicallyIncreasingTime() - m_dragAndDropAutoscrollStartTime > autoscrollDelay)
m_autoscrollLayoutObject->autoscroll(m_dragAndDropAutoscrollReferencePosition); m_autoscrollLayoutObject->autoscroll(m_dragAndDropAutoscrollReferencePosition);
break; break;
case AutoscrollForSelection: case AutoscrollForSelection:
if (LocalFrame* frame = m_autoscrollLayoutObject->frame()) {
EventHandler& eventHandler = frame->eventHandler();
if (!eventHandler.mousePressed()) { if (!eventHandler.mousePressed()) {
stopAutoscroll(); stopAutoscroll();
return; return;
} }
eventHandler.updateSelectionForMouseDrag(); eventHandler.updateSelectionForMouseDrag();
m_autoscrollLayoutObject->autoscroll(eventHandler.lastKnownMousePosition()); m_autoscrollLayoutObject->autoscroll(eventHandler.lastKnownMousePosition());
}
break; break;
case NoAutoscroll: case NoAutoscroll:
break; break;
...@@ -265,12 +263,8 @@ void AutoscrollController::animate(double) ...@@ -265,12 +263,8 @@ void AutoscrollController::animate(double)
stopAutoscroll(); stopAutoscroll();
return; return;
} }
if (LocalFrame* frame = m_autoscrollLayoutObject->frame()) { if (FrameView* view = m_autoscrollLayoutObject->frame()->view())
if (FrameView* view = frame->view()) {
EventHandler& eventHandler = frame->eventHandler();
updatePanScrollState(view, eventHandler.lastKnownMousePosition()); updatePanScrollState(view, eventHandler.lastKnownMousePosition());
}
}
m_autoscrollLayoutObject->panScroll(m_panScrollStartPos); m_autoscrollLayoutObject->panScroll(m_panScrollStartPos);
break; break;
#endif #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