diff options
Diffstat (limited to 'Source/WebKit/chromium/src/WebFrameImpl.cpp')
-rw-r--r-- | Source/WebKit/chromium/src/WebFrameImpl.cpp | 66 |
1 files changed, 5 insertions, 61 deletions
diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index 7bb0efeea..6d68a6f23 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -1029,7 +1029,7 @@ void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item) m_frame->loader()->prepareForHistoryNavigation(); RefPtr<HistoryItem> currentItem = m_frame->loader()->history()->currentItem(); - m_inSameDocumentHistoryLoad = currentItem->shouldDoSameDocumentNavigationTo(historyItem.get()); + m_inSameDocumentHistoryLoad = currentItem && currentItem->shouldDoSameDocumentNavigationTo(historyItem.get()); m_frame->page()->goToItem(historyItem.get(), FrameLoadTypeIndexedBackForward); m_inSameDocumentHistoryLoad = false; @@ -1466,71 +1466,15 @@ bool WebFrameImpl::selectWordAroundCaret() return true; } -void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end) +void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) { - if (start == end && moveCaret(start)) - return; - - if (moveSelectionStart(start, true) && moveSelectionEnd(end, true)) - return; - - // Failed to move endpoints, probably because there's no current selection. - // Just set the selection explicitly (but this won't handle editable boundaries correctly). - VisibleSelection newSelection(visiblePositionForWindowPoint(start), visiblePositionForWindowPoint(end)); + VisiblePosition basePos = visiblePositionForWindowPoint(base); + VisiblePosition extentPos = visiblePositionForWindowPoint(extent); + VisibleSelection newSelection = VisibleSelection(basePos, extentPos); if (frame()->selection()->shouldChangeSelection(newSelection)) frame()->selection()->setSelection(newSelection, CharacterGranularity); } -bool WebFrameImpl::moveSelectionStart(const WebPoint& point, bool allowCollapsedSelection) -{ - const VisibleSelection& selection = frame()->selection()->selection(); - if (selection.isNone()) - return false; - - VisiblePosition start = visiblePositionForWindowPoint(point); - if (!allowCollapsedSelection) { - VisiblePosition maxStart = selection.visibleEnd().previous(); - if (comparePositions(start, maxStart) > 0) - start = maxStart; - } - - // start is moving, so base=end, extent=start - VisibleSelection newSelection = VisibleSelection(selection.visibleEnd(), start); - frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity); - return true; -} - -bool WebFrameImpl::moveSelectionEnd(const WebPoint& point, bool allowCollapsedSelection) -{ - const VisibleSelection& selection = frame()->selection()->selection(); - if (selection.isNone()) - return false; - - VisiblePosition end = visiblePositionForWindowPoint(point); - if (!allowCollapsedSelection) { - VisiblePosition minEnd = selection.visibleStart().next(); - if (comparePositions(end, minEnd) < 0) - end = minEnd; - } - - // end is moving, so base=start, extent=end - VisibleSelection newSelection = VisibleSelection(selection.visibleStart(), end); - frame()->selection()->setNonDirectionalSelectionIfNeeded(newSelection, CharacterGranularity); - return true; -} - -bool WebFrameImpl::moveCaret(const WebPoint& point) -{ - FrameSelection* frameSelection = frame()->selection(); - if (frameSelection->isNone() || !frameSelection->isContentEditable()) - return false; - - VisiblePosition pos = visiblePositionForWindowPoint(point); - frameSelection->setExtent(pos, UserTriggered); - frameSelection->setBase(frameSelection->extent(), UserTriggered); - return true; -} - void WebFrameImpl::selectRange(const WebRange& webRange) { RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange); |