Commit 87ae63d7 authored by psolanki@apple.com's avatar psolanki@apple.com

<https://webkit.org/b/119918> Frame::selection() should return a reference

Reviewed by Darin Adler.

m_selection is never NULL so return a reference from Frame::selection(). Also removed some
unnecessary null checks and assert diff ts exposed as a result.

Source/WebCore:

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::selection):
(WebCore::AccessibilityRenderObject::setSelectedTextRange):
(WebCore::AccessibilityRenderObject::isFocused):
(WebCore::AccessibilityRenderObject::setSelectedVisiblePositionRange):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityModifySelection:increase:]):
(-[WebAccessibilityObjectWrapper accessibilityMoveSelectionToMarker:]):
(-[WebAccessibilityObjectWrapper _convertToNSRange:]):
(-[WebAccessibilityObjectWrapper _convertToDOMRange:]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilitySetValue:forAttribute:]):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::isFrameFocused):
* dom/CharacterData.cpp:
(WebCore::CharacterData::setDataAndUpdate):
* dom/Document.cpp:
(WebCore::Document::nodeChildrenWillBeRemoved):
(WebCore::Document::nodeWillBeRemoved):
* dom/Element.cpp:
(WebCore::Element::updateFocusAppearance):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::stopPendingCorrection):
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
(WebCore::AlternativeTextController::applyAutocorrectionBeforeTypingIfAppropriate):
(WebCore::AlternativeTextController::respondToUnappliedSpellCorrection):
(WebCore::AlternativeTextController::timerFired):
(WebCore::AlternativeTextController::respondToChangedSelection):
* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::respondToChangedSelection):
(WebCore::DeleteButtonController::enable):
(WebCore::DeleteButtonController::deleteTarget):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
* editing/DictationCommand.cpp:
(WebCore::DictationCommand::insertText):
* editing/EditCommand.cpp:
(WebCore::EditCommand::EditCommand):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::mergeTypingStyle):
* editing/Editor.cpp:
(WebCore::Editor::selectionForCommand):
(WebCore::Editor::canEdit):
(WebCore::Editor::canEditRichly):
(WebCore::Editor::canDHTMLCut):
(WebCore::Editor::canDHTMLCopy):
(WebCore::Editor::canCopy):
(WebCore::Editor::canDelete):
(WebCore::Editor::canSmartCopyOrDelete):
(WebCore::Editor::deleteWithDirection):
(WebCore::Editor::deleteSelectionWithSmartDelete):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::selectedRange):
(WebCore::Editor::tryDHTMLCopy):
(WebCore::Editor::tryDHTMLCut):
(WebCore::Editor::hasBidiSelection):
(WebCore::Editor::selectionUnorderedListState):
(WebCore::Editor::selectionOrderedListState):
(WebCore::Editor::increaseSelectionListLevel):
(WebCore::Editor::increaseSelectionListLevelOrdered):
(WebCore::Editor::increaseSelectionListLevelUnordered):
(WebCore::Editor::decreaseSelectionListLevel):
(WebCore::Editor::findEventTargetFromSelection):
(WebCore::Editor::applyStyle):
(WebCore::Editor::applyParagraphStyle):
(WebCore::Editor::applyStyleToSelection):
(WebCore::Editor::applyParagraphStyleToSelection):
(WebCore::Editor::selectionStartHasStyle):
(WebCore::Editor::selectionHasStyle):
(WebCore::Editor::selectionStartCSSPropertyValue):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::insertLineBreak):
(WebCore::Editor::insertParagraphSeparator):
(WebCore::Editor::cut):
(WebCore::Editor::copy):
(WebCore::Editor::paste):
(WebCore::Editor::baseWritingDirectionForSelectionStart):
(WebCore::Editor::selectComposition):
(WebCore::Editor::setComposition):
(WebCore::Editor::ignoreSpelling):
(WebCore::Editor::learnSpelling):
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::misspelledWordAtCaretOrRange):
(WebCore::Editor::isSelectionUngrammatical):
(WebCore::Editor::guessesForMisspelledOrUngrammatical):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::isSpellCheckingEnabledInFocusedNode):
(WebCore::Editor::markAndReplaceFor):
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):
(WebCore::Editor::revealSelectionAfterEditingOperation):
(WebCore::Editor::getCompositionSelection):
(WebCore::Editor::transpose):
(WebCore::Editor::changeSelectionAfterCommand):
(WebCore::Editor::selectedText):
(WebCore::Editor::computeAndSetTypingStyle):
(WebCore::Editor::findString):
(WebCore::Editor::respondToChangedSelection):
(WebCore::Editor::selectionStartHasMarkerFor):
(WebCore::Editor::toggleOverwriteModeEnabled):
* editing/EditorCommand.cpp:
(WebCore::executeToggleStyleInList):
(WebCore::expandSelectionToGranularity):
(WebCore::stateTextWritingDirection):
(WebCore::executeDelete):
(WebCore::executeDeleteToMark):
(WebCore::executeMoveBackward):
(WebCore::executeMoveBackwardAndModifySelection):
(WebCore::executeMoveDown):
(WebCore::executeMoveDownAndModifySelection):
(WebCore::executeMoveForward):
(WebCore::executeMoveForwardAndModifySelection):
(WebCore::executeMoveLeft):
(WebCore::executeMoveLeftAndModifySelection):
(WebCore::executeMovePageDown):
(WebCore::executeMovePageDownAndModifySelection):
(WebCore::executeMovePageUp):
(WebCore::executeMovePageUpAndModifySelection):
(WebCore::executeMoveRight):
(WebCore::executeMoveRightAndModifySelection):
(WebCore::executeMoveToBeginningOfDocument):
(WebCore::executeMoveToBeginningOfDocumentAndModifySelection):
(WebCore::executeMoveToBeginningOfLine):
(WebCore::executeMoveToBeginningOfLineAndModifySelection):
(WebCore::executeMoveToBeginningOfParagraph):
(WebCore::executeMoveToBeginningOfParagraphAndModifySelection):
(WebCore::executeMoveToBeginningOfSentence):
(WebCore::executeMoveToBeginningOfSentenceAndModifySelection):
(WebCore::executeMoveToEndOfDocument):
(WebCore::executeMoveToEndOfDocumentAndModifySelection):
(WebCore::executeMoveToEndOfSentence):
(WebCore::executeMoveToEndOfSentenceAndModifySelection):
(WebCore::executeMoveToEndOfLine):
(WebCore::executeMoveToEndOfLineAndModifySelection):
(WebCore::executeMoveToEndOfParagraph):
(WebCore::executeMoveToEndOfParagraphAndModifySelection):
(WebCore::executeMoveParagraphBackwardAndModifySelection):
(WebCore::executeMoveParagraphForwardAndModifySelection):
(WebCore::executeMoveUp):
(WebCore::executeMoveUpAndModifySelection):
(WebCore::executeMoveWordBackward):
(WebCore::executeMoveWordBackwardAndModifySelection):
(WebCore::executeMoveWordForward):
(WebCore::executeMoveWordForwardAndModifySelection):
(WebCore::executeMoveWordLeft):
(WebCore::executeMoveWordLeftAndModifySelection):
(WebCore::executeMoveWordRight):
(WebCore::executeMoveWordRightAndModifySelection):
(WebCore::executeMoveToLeftEndOfLine):
(WebCore::executeMoveToLeftEndOfLineAndModifySelection):
(WebCore::executeMoveToRightEndOfLine):
(WebCore::executeMoveToRightEndOfLineAndModifySelection):
(WebCore::executeSelectAll):
(WebCore::executeSelectToMark):
(WebCore::executeSetMark):
(WebCore::executeSwapWithMark):
(WebCore::executeUnselect):
(WebCore::enabledInRichlyEditableText):
(WebCore::enabledRangeInEditableText):
(WebCore::enabledRangeInRichlyEditableText):
(WebCore::valueFormatBlock):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::setSelection):
(WebCore::FrameSelection::selectFrameElementInParentIfFullySelected):
* editing/InsertLineBreakCommand.cpp:
(WebCore::InsertLineBreakCommand::doApply):
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::doApply):
* editing/ModifySelectionListLevel.cpp:
(WebCore::IncreaseSelectionListLevelCommand::canIncreaseSelectionListLevel):
(WebCore::DecreaseSelectionListLevelCommand::canDecreaseSelectionListLevel):
* editing/RemoveFormatCommand.cpp:
(WebCore::RemoveFormatCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
* editing/SetSelectionCommand.cpp:
(WebCore::SetSelectionCommand::doApply):
(WebCore::SetSelectionCommand::doUnapply):
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::doApply):
* editing/TextInsertionBaseCommand.cpp:
(WebCore::TextInsertionBaseCommand::applyTextInsertionCommand):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::deleteSelection):
(WebCore::TypingCommand::updateSelectionIfDifferentFromCurrentSelection):
(WebCore::TypingCommand::insertText):
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection):
(WebCore::styleForSelectionStart):
(WebCore::Editor::fontForSelection):
* editing/mac/EditorMac.mm:
(WebCore::styleForSelectionStart):
(WebCore::Editor::fontForSelection):
(WebCore::Editor::canCopyExcludingStandaloneImages):
(WebCore::Editor::readSelectionFromPasteboard):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::defaultEventHandler):
(WebCore::HTMLAnchorElement::setActive):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateFocusAppearance):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updateFocusAppearance):
(WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setSelectionRange):
(WebCore::HTMLTextFormControlElement::computeSelectionStart):
(WebCore::HTMLTextFormControlElement::computeSelectionEnd):
(WebCore::HTMLTextFormControlElement::computeSelectionDirection):
(WebCore::HTMLTextFormControlElement::selectionChanged):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::clear):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createFromSelection):
* page/ContextMenuController.cpp:
(WebCore::insertUnicodeCharacter):
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::selectionContainsPossibleWord):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::checkOrEnableIfNeeded):
* page/DOMSelection.cpp:
(WebCore::selectionShadowAncestor):
(WebCore::DOMSelection::visibleSelection):
(WebCore::DOMSelection::isCollapsed):
(WebCore::DOMSelection::type):
(WebCore::DOMSelection::rangeCount):
(WebCore::DOMSelection::collapse):
(WebCore::DOMSelection::collapseToEnd):
(WebCore::DOMSelection::collapseToStart):
(WebCore::DOMSelection::empty):
(WebCore::DOMSelection::setBaseAndExtent):
(WebCore::DOMSelection::setPosition):
(WebCore::DOMSelection::modify):
(WebCore::DOMSelection::extend):
(WebCore::DOMSelection::getRangeAt):
(WebCore::DOMSelection::removeAllRanges):
(WebCore::DOMSelection::addRange):
(WebCore::DOMSelection::deleteFromDocument):
(WebCore::DOMSelection::containsNode):
(WebCore::DOMSelection::toString):
* page/DragController.cpp:
(WebCore::DragController::dragIsMove):
(WebCore::setSelectionToDragCaret):
(WebCore::DragController::concludeEditDrag):
(WebCore::DragController::draggableElement):
(WebCore::selectElement):
(WebCore::dragLocForSelectionDrag):
(WebCore::DragController::startDrag):
* page/DragController.h:
* page/EventHandler.cpp:
(WebCore::setSelectionIfNeeded):
(WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
(WebCore::EventHandler::handleMousePressEventDoubleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::lostMouseCapture):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::nodeIsNotBeingEdited):
(WebCore::EventHandler::selectCursor):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::dispatchMouseEvent):
(WebCore::EventHandler::sendContextMenuEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::handleKeyboardSelectionMovement):
(WebCore::EventHandler::handleDrag):
* page/FocusController.cpp:
(WebCore::FocusController::setFocusedFrame):
(WebCore::FocusController::setFocused):
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::clearSelectionIfNeeded):
(WebCore::FocusController::setActive):
* page/Frame.cpp:
(WebCore::Frame::dragImageForSelection):
* page/Frame.h:
(WebCore::Frame::selection):
* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks):
(WebCore::FrameView::paintContentsForSnapshot):
* page/Page.cpp:
(WebCore::Page::findString):
(WebCore::Page::findStringMatchingRanges):
(WebCore::Page::selection):
* page/mac/FrameMac.mm:
(WebCore::Frame::dragImageForSelection):
* page/mac/FrameSnapshottingMac.mm:
(WebCore::selectionImage):
* page/win/FrameWin.cpp:
(WebCore::imageFromSelection):
(WebCore::Frame::dragImageForSelection):
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::documentFragmentForPasteboardItemAtIndex):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::isSelected):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintAreaElementFocusRing):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::paintItemForeground):
(WebCore::RenderListBox::paintItemBackground):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionBackgroundColor):
(WebCore::RenderObject::selectionColor):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isFocused):
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::adjustSearchFieldStyle):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeSelection):
* rendering/RenderView.cpp:
(WebCore::RenderView::setSelection):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::deselectAll):
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::selectSubString):
* testing/Internals.cpp:
(WebCore::Internals::absoluteCaretBounds):
(WebCore::Internals::selectionBounds):

Source/WebKit/blackberry:

* Api/InRegionScroller.cpp:
(BlackBerry::WebKit::InRegionScrollerPrivate::setLayerScrollPosition):
* WebKitSupport/DatePickerClient.cpp:
(BlackBerry::WebKit::DatePickerClient::setValueAndClosePopup):
* WebKitSupport/InPageSearchManager.cpp:
(BlackBerry::WebKit::InPageSearchManager::findNextString):
(BlackBerry::WebKit::InPageSearchManager::clearTextMatches):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::focusedNodeChanged):
(BlackBerry::WebKit::InputHandler::requestSpellingCheckingOptions):
(BlackBerry::WebKit::InputHandler::setElementUnfocused):
(BlackBerry::WebKit::InputHandler::setInputModeEnabled):
(BlackBerry::WebKit::InputHandler::setElementFocused):
(BlackBerry::WebKit::InputHandler::openDatePopup):
(BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
(BlackBerry::WebKit::InputHandler::selectionPosition):
(BlackBerry::WebKit::InputHandler::setSelection):
(BlackBerry::WebKit::InputHandler::deleteSelection):
(BlackBerry::WebKit::InputHandler::setRelativeCursorPosition):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::cancelSelection):
(BlackBerry::WebKit::SelectionHandler::shouldUpdateSelectionOrCaretForPoint):
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):
(BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary):
(BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
(BlackBerry::WebKit::SelectionHandler::setSelection):
(BlackBerry::WebKit::SelectionHandler::startCaretViewportRect):
(BlackBerry::WebKit::SelectionHandler::selectNextParagraph):
(BlackBerry::WebKit::SelectionHandler::expandSelectionToGranularity):
(BlackBerry::WebKit::SelectionHandler::selectObject):
(BlackBerry::WebKit::directionOfEnclosingBlock):
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
(BlackBerry::WebKit::SelectionHandler::notifyCaretPositionChangedIfNeeded):
(BlackBerry::WebKit::SelectionHandler::caretPositionChanged):
(BlackBerry::WebKit::SelectionHandler::selectionContains):
* WebKitSupport/SpellingHandler.cpp:
(BlackBerry::WebKit::SpellingHandler::spellCheckTextBlock):

Source/WebKit/efl:

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::selectionRectangle):
(DumpRenderTreeSupportEfl::firstRectForCharacterRange):
(DumpRenderTreeSupportEfl::selectedRange):
* WebCoreSupport/EditorClientEfl.cpp:
(WebCore::EditorClientEfl::handleEditingKeyboardEvent):
* ewk/ewk_frame.cpp:
(ewk_frame_text_selection_type_get):

Source/WebKit/gtk:

* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::ChromeClient::paint):
* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::firstRectForCharacterRange):
(DumpRenderTreeSupportGtk::selectedRange):
(DumpRenderTreeSupportGtk::rectangleForSelection):
* WebCoreSupport/EditorClientGtk.cpp:
(WebKit::collapseSelection):
(WebKit::setSelectionPrimaryClipboardIfNeeded):
* webkit/webkitwebframe.cpp:
(webkit_web_frame_get_range_for_word_around_caret):
* webkit/webkitwebview.cpp:
(getLocationForKeyboardGeneratedContextMenu):

Source/WebKit/mac:

* Plugins/WebPluginController.mm:
* WebView/WebFrame.mm:
(-[WebFrame _hasSelection]):
(-[WebFrame _rangeByAlteringCurrentSelection:FrameSelection::direction:granularity:]):
(-[WebFrame _selectionGranularity]):
(-[WebFrame _convertToNSRange:]):
(-[WebFrame _convertToDOMRange:]):
(-[WebFrame _insertParagraphSeparatorInQuotedContent]):
(-[WebFrame _typingStyle]):
(-[WebFrame _selectedNSRange]):
(-[WebFrame _selectNSRange:]):
(-[WebFrame _replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
(-[WebFrame _replaceSelectionWithText:selectReplacement:smartReplace:]):
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation currentForm]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView readSelectionFromPasteboard:]):
(-[WebHTMLView _selectedRange]):
(-[WebHTMLView _hasSelection]):
(-[WebHTMLView _hasSelectionOrInsertionPoint]):
(-[WebHTMLView _hasInsertionPoint]):
(-[WebHTMLView _isEditable]):
(-[WebHTMLView jumpToSelection:]):
(-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]):
(-[WebHTMLView maintainsInactiveSelection]):
(isTextInput):
(isInPasswordField):
(-[WebHTMLView centerSelectionInVisibleArea:]):
(-[WebHTMLView _canSmartCopyOrDelete]):
(-[WebHTMLView _lookUpInDictionaryFromMenu:]):
(-[WebHTMLView _updateSelectionForInputManager]):
(-[WebHTMLView selectionRect]):
(-[WebHTMLView selectionTextRects]):
(-[WebHTMLView selectionImageRect]):
(-[WebHTMLView selectAll]):
(-[WebHTMLView deselectAll]):
(-[WebHTMLView selectedAttributedString]):
* WebView/WebTextCompletionController.mm:
(-[WebTextCompletionController doCompletion]):
* WebView/WebView.mm:
(-[WebView setSelectedDOMRange:affinity:]):
(-[WebView selectedDOMRange]):
(-[WebView selectionAffinity]):
(-[WebView setEditable:]):
(-[WebView _selectionIsCaret]):
(-[WebView _selectionIsAll]):

Source/WebKit/qt:

* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::selectedRange):
(DumpRenderTreeSupportQt::firstRectForCharacterRange):
* WebCoreSupport/EditorClientQt.cpp:
(WebCore::EditorClientQt::respondToChangedSelection):
(WebCore::EditorClientQt::handleKeyboardEvent):
* WebCoreSupport/QWebPageAdapter.cpp:
(QWebPageAdapter::hasSelection):
(QWebPageAdapter::selectedText):
(QWebPageAdapter::findText):
(QWebPageAdapter::inputMethodEvent):
(QWebPageAdapter::inputMethodQuery):

Source/WebKit/win:

* WebFrame.cpp:
(WebFrame::currentForm):
* WebView.cpp:
(WebView::updateFocusedAndActiveState):
(WebView::selectionRect):
(WebView::centerSelectionInVisibleArea):
(WebView::hasSelectedRange):
(WebView::replaceSelectionWithText):
(WebView::clearSelection):
(WebView::prepareCandidateWindow):
(WebView::onIMERequestCharPosition):
(WebView::onIMERequestReconvertString):
(WebView::firstRectForCharacterRangeForTesting):
(WebView::selectedRangeForTesting):

Source/WebKit/wince:

* WebCoreSupport/EditorClientWinCE.cpp:
(WebKit::EditorClientWinCE::handleEditingKeyboardEvent):

Source/WebKit2:

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::updateGlobalSelection):
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::collapseSelection):
(WebKit::WebEditorClient::updateGlobalSelection):
* WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
(WebKit::WebContextMenuClient::lookUpInDictionary):
(WebKit::WebContextMenuClient::searchWithSpotlight):
* WebProcess/WebPage/FindController.cpp:
(WebKit::frameWithSelection):
(WebKit::FindController::updateFindUIAfterPageScroll):
(WebKit::FindController::getFindIndicatorBitmapAndRect):
(WebKit::FindController::getImageForFindMatch):
(WebKit::FindController::selectFindMatch):
(WebKit::FindController::updateFindIndicator):
(WebKit::FindController::drawRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
(WebKit::WebPage::scaledSnapshotWithOptions):
(WebKit::WebPage::centerSelectionInVisibleArea):
(WebKit::frameWithSelection):
(WebKit::WebPage::clearSelection):
(WebKit::WebPage::confirmComposition):
(WebKit::WebPage::setComposition):
(WebKit::WebPage::currentSelectionAsRange):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setComposition):
(WebKit::WebPage::insertText):
(WebKit::WebPage::insertDictatedText):
(WebKit::WebPage::getMarkedRange):
(WebKit::WebPage::getSelectedRange):
(WebKit::WebPage::getAttributedSubstringFromRange):
(WebKit::WebPage::characterIndexForPoint):
(WebKit::convertToRange):
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::readSelectionFromPasteboard):
(WebKit::WebPage::getStringSelectionForPasteboard):
(WebKit::WebPage::getDataSelectionForPasteboard):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154286 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4094d11c
This diff is collapsed.
......@@ -1417,7 +1417,7 @@ const AtomicString& AccessibilityRenderObject::accessKey() const
VisibleSelection AccessibilityRenderObject::selection() const
{
return m_renderer->frame()->selection()->selection();
return m_renderer->frame()->selection().selection();
}
PlainTextRange AccessibilityRenderObject::selectedTextRange() const
......@@ -1454,7 +1454,7 @@ void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range
if (!frame)
return;
Node* node = m_renderer->node();
frame->selection()->setSelection(VisibleSelection(Position(node, range.start, Position::PositionIsOffsetInAnchor),
frame->selection().setSelection(VisibleSelection(Position(node, range.start, Position::PositionIsOffsetInAnchor),
Position(node, range.start + range.length, Position::PositionIsOffsetInAnchor), DOWNSTREAM));
}
......@@ -1585,7 +1585,7 @@ bool AccessibilityRenderObject::isFocused() const
// A web area is represented by the Document node in the DOM tree, which isn't focusable.
// Check instead if the frame's selection controller is focused
if (focusedElement == m_renderer->node()
|| (roleValue() == WebAreaRole && document->frame()->selection()->isFocusedAndActive()))
|| (roleValue() == WebAreaRole && document->frame()->selection().isFocusedAndActive()))
return true;
return false;
......@@ -1966,10 +1966,10 @@ void AccessibilityRenderObject::setSelectedVisiblePositionRange(const VisiblePos
// make selection and tell the document to use it. if it's zero length, then move to that position
if (range.start == range.end)
m_renderer->frame()->selection()->moveTo(range.start, UserTriggered);
m_renderer->frame()->selection().moveTo(range.start, UserTriggered);
else {
VisibleSelection newSelection = VisibleSelection(range.start, range.end);
m_renderer->frame()->selection()->setSelection(newSelection);
m_renderer->frame()->selection().setSelection(newSelection);
}
}
......@@ -2335,7 +2335,7 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
if (!element)
return;
Document* doc = renderer()->document();
if (!doc->frame()->selection()->isFocusedAndActive() || doc->focusedElement() != element)
if (!doc->frame()->selection().isFocusedAndActive() || doc->focusedElement() != element)
return;
AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
......
......@@ -1337,17 +1337,17 @@ static RenderObject* rendererForView(WAKView* view)
if (![self _prepareAccessibilityCall])
return;
FrameSelection* frameSelection = m_object->document()->frame()->selection();
FrameSelection& frameSelection = m_object->document()->frame()->selection();
VisibleSelection selection = m_object->selection();
VisiblePositionRange range = m_object->visiblePositionRange();
// Before a selection with length exists, the cursor position needs to move to the right starting place.
// That should be the beginning of this element (range.start). However, if the cursor is already within the
// range of this element (the cursor is represented by selection), then the cursor does not need to move.
if (frameSelection->isNone() && (selection.visibleStart() < range.start || selection.visibleEnd() > range.end))
frameSelection->moveTo(range.start, UserTriggered);
if (frameSelection.isNone() && (selection.visibleStart() < range.start || selection.visibleEnd() > range.end))
frameSelection.moveTo(range.start, UserTriggered);
frameSelection->modify(FrameSelection::AlterationExtend, (increase) ? DirectionRight : DirectionLeft, granularity, UserTriggered);
frameSelection.modify(FrameSelection::AlterationExtend, (increase) ? DirectionRight : DirectionLeft, granularity, UserTriggered);
}
- (void)accessibilityIncreaseSelection:(TextGranularity)granularity
......@@ -1369,8 +1369,8 @@ static RenderObject* rendererForView(WAKView* view)
if (visiblePosition.isNull())
return;
FrameSelection* frameSelection = m_object->document()->frame()->selection();
frameSelection->moveTo(visiblePosition, UserTriggered);
FrameSelection& frameSelection = m_object->document()->frame()->selection();
frameSelection.moveTo(visiblePosition, UserTriggered);
}
- (void)accessibilityIncrement
......@@ -1634,9 +1634,9 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
return NSMakeRange(NSNotFound, 0);
Document* document = m_object->document();
FrameSelection* frameSelection = document->frame()->selection();
FrameSelection& frameSelection = document->frame()->selection();
Element* selectionRoot = frameSelection->rootEditableElement();
Element* selectionRoot = frameSelection.rootEditableElement();
Element* scope = selectionRoot ? selectionRoot : document->documentElement();
// Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
......@@ -1672,8 +1672,8 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
// to use the root editable element of the selection start as the positional base.
// That fits with AppKit's idea of an input context.
Document* document = m_object->document();
FrameSelection* frameSelection = document->frame()->selection();
Element* selectionRoot = frameSelection->rootEditableElement();
FrameSelection& frameSelection = document->frame()->selection();
Element* selectionRoot = frameSelection.rootEditableElement();
Element* scope = selectionRoot ? selectionRoot : document->documentElement();
return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
}
......
......@@ -3086,7 +3086,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
bool focus = [number boolValue];
// If focus is just set without making the view the first responder, then keyboard focus won't move to the right place.
if (focus && m_object->isWebArea() && !m_object->document()->frame()->selection()->isFocusedAndActive()) {
if (focus && m_object->isWebArea() && !m_object->document()->frame()->selection().isFocusedAndActive()) {
FrameView* frameView = m_object->documentFrameView();
Page* page = m_object->page();
if (page && frameView) {
......
......@@ -934,7 +934,7 @@ unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector)
bool SelectorChecker::isFrameFocused(const Element* element)
{
return element->document()->frame() && element->document()->frame()->selection()->isFocusedAndActive();
return element->document()->frame() && element->document()->frame()->selection().isFocusedAndActive();
}
bool SelectorChecker::matchesFocusPseudoClass(const Element* element)
......
......@@ -195,7 +195,7 @@ void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfRep
toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength);
if (document()->frame())
document()->frame()->selection()->textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);
document()->frame()->selection().textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);
document()->incDOMTreeVersion();
dispatchModifiedEvent(oldData);
......
......@@ -3463,7 +3463,7 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode* container)
if (Frame* frame = this->frame()) {
for (Node* n = container->firstChild(); n; n = n->nextSibling()) {
frame->eventHandler().nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->selection().nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}
......@@ -3483,7 +3483,7 @@ void Document::nodeWillBeRemoved(Node* n)
if (Frame* frame = this->frame()) {
frame->eventHandler().nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->selection().nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}
......
......@@ -1970,15 +1970,15 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
return;
// When focusing an editable element in an iframe, don't reset the selection if it already contains a selection.
if (this == frame->selection()->rootEditableElement())
if (this == frame->selection().rootEditableElement())
return;
// FIXME: We should restore the previous selection if there is one.
VisibleSelection newSelection = VisibleSelection(firstPositionInOrBeforeNode(this), DOWNSTREAM);
if (frame->selection()->shouldChangeSelection(newSelection)) {
frame->selection()->setSelection(newSelection);
frame->selection()->revealSelection();
if (frame->selection().shouldChangeSelection(newSelection)) {
frame->selection().setSelection(newSelection);
frame->selection().revealSelection();
}
} else if (renderer() && !renderer()->isWidget())
renderer()->scrollRectToVisible(boundingBox());
......
......@@ -165,7 +165,7 @@ void AlternativeTextController::stopAlternativeTextUITimer()
void AlternativeTextController::stopPendingCorrection(const VisibleSelection& oldSelection)
{
// Make sure there's no pending autocorrection before we call markMisspellingsAndBadGrammar() below.
VisibleSelection currentSelection(m_frame->selection()->selection());
VisibleSelection currentSelection(m_frame->selection().selection());
if (currentSelection == oldSelection)
return;
......@@ -281,7 +281,7 @@ void AlternativeTextController::applyAlternativeTextToRange(const Range* range,
// Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
paragraphRangeContainingCorrection = TextIterator::rangeFromLocationAndLength(m_frame->document(), paragraphStartIndex, correctionStartOffsetInParagraph + alternative.length());
setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection()->selection().start());
setEnd(paragraphRangeContainingCorrection.get(), m_frame->selection().selection().start());
RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, alternative.length());
String newText = plainText(replacementRange.get());
......@@ -303,7 +303,7 @@ bool AlternativeTextController::applyAutocorrectionBeforeTypingIfAppropriate()
if (m_alternativeTextInfo.type != AlternativeTextTypeCorrection)
return false;
Position caretPosition = m_frame->selection()->selection().start();
Position caretPosition = m_frame->selection().selection().start();
if (m_alternativeTextInfo.rangeWithAlternative->endPosition() == caretPosition) {
handleAlternativeTextUIResult(dismissSoon(ReasonForDismissingAlternativeTextAccepted));
......@@ -321,8 +321,8 @@ void AlternativeTextController::respondToUnappliedSpellCorrection(const VisibleS
if (AlternativeTextClient* client = alternativeTextClient())
client->recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction);
m_frame->document()->updateLayout();
m_frame->selection()->setSelection(selectionOfCorrected, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::SpellCorrectionTriggered);
RefPtr<Range> range = Range::create(m_frame->document(), m_frame->selection()->selection().start(), m_frame->selection()->selection().end());
m_frame->selection().setSelection(selectionOfCorrected, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::SpellCorrectionTriggered);
RefPtr<Range> range = Range::create(m_frame->document(), m_frame->selection().selection().start(), m_frame->selection().selection().end());
DocumentMarkerController* markers = m_frame->document()->markers();
markers->removeMarkers(range.get(), DocumentMarker::Spelling | DocumentMarker::Autocorrected, DocumentMarkerController::RemovePartiallyOverlappingMarker);
......@@ -335,7 +335,7 @@ void AlternativeTextController::timerFired(Timer<AlternativeTextController>*)
m_isDismissedByEditing = false;
switch (m_alternativeTextInfo.type) {
case AlternativeTextTypeCorrection: {
VisibleSelection selection(m_frame->selection()->selection());
VisibleSelection selection(m_frame->selection().selection());
VisiblePosition start(selection.start(), selection.affinity());
VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary);
VisibleSelection adjacentWords = VisibleSelection(p, start);
......@@ -449,7 +449,7 @@ FloatRect AlternativeTextController::rootViewRectForRange(const Range* range) co
void AlternativeTextController::respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions options)
{
VisibleSelection currentSelection(m_frame->selection()->selection());
VisibleSelection currentSelection(m_frame->selection().selection());
// When user moves caret to the end of autocorrected word and pauses, we show the panel
// containing the original pre-correction word so that user can quickly revert the
// undesired autocorrection. Here, we start correction panel timer once we confirm that
......
......@@ -176,7 +176,7 @@ void DeleteButtonController::respondToChangedSelection(const VisibleSelection& o
return;
HTMLElement* oldElement = enclosingDeletableElement(oldSelection);
HTMLElement* newElement = enclosingDeletableElement(m_frame->selection()->selection());
HTMLElement* newElement = enclosingDeletableElement(m_frame->selection().selection());
if (oldElement == newElement)
return;
......@@ -350,7 +350,7 @@ void DeleteButtonController::enable()
// because whether something is editable depends on style, so we need
// to recalculate style before calling enclosingDeletableElement.
m_frame->document()->updateStyleIfNeeded();
show(enclosingDeletableElement(m_frame->selection()->selection()));
show(enclosingDeletableElement(m_frame->selection().selection()));
}
}
......@@ -395,7 +395,7 @@ void DeleteButtonController::deleteTarget()
// a caret where the target had been.
Position pos = positionInParentBeforeNode(m_target.get());
applyCommand(RemoveTargetCommand::create(m_frame->document(), m_target));
m_frame->selection()->setSelection(VisiblePosition(pos));
m_frame->selection().setSelection(VisiblePosition(pos));
}
#endif
......
......@@ -726,7 +726,7 @@ void DeleteSelectionCommand::calculateTypingStyleAfterDelete()
// In this case if we start typing, the new characters should have the same style as the just deleted ones,
// but, if we change the selection, come back and start typing that style should be lost. Also see
// preserveTypingStyle() below.
document()->frame()->selection()->setTypingStyle(m_typingStyle);
document()->frame()->selection().setTypingStyle(m_typingStyle);
}
void DeleteSelectionCommand::clearTransientState()
......
......@@ -93,7 +93,7 @@ void DictationCommand::insertText(Document* document, const String& text, const
RefPtr<Frame> frame = document->frame();
ASSERT(frame);
VisibleSelection currentSelection = frame->selection()->selection();
VisibleSelection currentSelection = frame->selection().selection();
String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, false);
......
......@@ -45,7 +45,7 @@ EditCommand::EditCommand(Document* document)
{
ASSERT(m_document);
ASSERT(m_document->frame());
setStartingSelection(m_document->frame()->editor().avoidIntersectionWithDeleteButtonController(m_document->frame()->selection()->selection()));
setStartingSelection(m_document->frame()->editor().avoidIntersectionWithDeleteButtonController(m_document->frame()->selection().selection()));
setEndingSelection(m_startingSelection);
}
......
......@@ -956,7 +956,7 @@ void EditingStyle::mergeTypingStyle(Document* document)
{
ASSERT(document);
RefPtr<EditingStyle> typingStyle = document->frame()->selection()->typingStyle();
RefPtr<EditingStyle> typingStyle = document->frame()->selection().typingStyle();
if (!typingStyle || typingStyle == this)
return;
......
This diff is collapsed.
This diff is collapsed.
......@@ -280,7 +280,7 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
Document* document = s.base().anchorNode()->document();
if (document && document->frame() && document->frame() != m_frame && document != m_frame->document()) {
RefPtr<Frame> guard = document->frame();
document->frame()->selection()->setSelection(s, options, align, granularity);
document->frame()->selection().setSelection(s, options, align, granularity);
// It's possible that during the above set selection, this FrameSelection has been modified by
// selectFrameElementInParentIfFullySelected, but that the selection is no longer valid since
// the frame is about to be destroyed. If this is the case, clear our selection.
......@@ -1625,9 +1625,9 @@ void FrameSelection::selectFrameElementInParentIfFullySelected()
// Focus on the parent frame, and then select from before this element to after.
VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement);
if (parent->selection()->shouldChangeSelection(newSelection)) {
if (parent->selection().shouldChangeSelection(newSelection)) {
page->focusController().setFocusedFrame(parent);
parent->selection()->setSelection(newSelection);
parent->selection().setSelection(newSelection);
}
}
......
......@@ -167,7 +167,7 @@ void InsertLineBreakCommand::doApply()
// Handle the case where there is a typing style.
RefPtr<EditingStyle> typingStyle = document()->frame()->selection()->typingStyle();
RefPtr<EditingStyle> typingStyle = document()->frame()->selection().typingStyle();
if (typingStyle && !typingStyle->isEmpty()) {
// Apply the typing style to the inserted line break, so that if the selection
......
......@@ -222,7 +222,7 @@ void InsertTextCommand::doApply()
setEndingSelectionWithoutValidation(startPosition, endPosition);
// Handle the case where there is a typing style.
if (RefPtr<EditingStyle> typingStyle = document()->frame()->selection()->typingStyle()) {
if (RefPtr<EditingStyle> typingStyle = document()->frame()->selection().typingStyle()) {
typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWritingDirection);
if (!typingStyle->isEmpty())
applyStyle(typingStyle.get());
......
......@@ -206,7 +206,7 @@ bool IncreaseSelectionListLevelCommand::canIncreaseSelectionListLevel(Document*
{
Node* startListChild;
Node* endListChild;
return canIncreaseListLevel(document->frame()->selection()->selection(), startListChild, endListChild);
return canIncreaseListLevel(document->frame()->selection().selection(), startListChild, endListChild);
}
PassRefPtr<Node> IncreaseSelectionListLevelCommand::increaseSelectionListLevel(Document* document, Type type)
......@@ -282,7 +282,7 @@ bool DecreaseSelectionListLevelCommand::canDecreaseSelectionListLevel(Document*
{
Node* startListChild;
Node* endListChild;
return canDecreaseListLevel(document->frame()->selection()->selection(), startListChild, endListChild);
return canDecreaseListLevel(document->frame()->selection().selection(), startListChild, endListChild);
}
void DecreaseSelectionListLevelCommand::decreaseSelectionListLevel(Document* document)
......
......@@ -81,12 +81,12 @@ void RemoveFormatCommand::doApply()
{
Frame* frame = document()->frame();
if (!frame->selection()->selection().isNonOrphanedCaretOrRange())
if (!frame->selection().selection().isNonOrphanedCaretOrRange())
return;
// Get the default style for this editable root, it's the style that we'll give the
// content that we're operating on.
Node* root = frame->selection()->rootEditableElement();
Node* root = frame->selection().rootEditableElement();
RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root);
// We want to remove everything but transparent background.
......
......@@ -1013,7 +1013,7 @@ void ReplaceSelectionCommand::doApply()
// FIXME: Can this wait until after the operation has been performed? There doesn't seem to be
// any work performed after this that queries or uses the typing style.
if (Frame* frame = document()->frame())
frame->selection()->clearTypingStyle();
frame->selection().clearTypingStyle();
removeHeadContents(fragment);
......
......@@ -40,22 +40,20 @@ SetSelectionCommand::SetSelectionCommand(const VisibleSelection& selection, Fram
void SetSelectionCommand::doApply()
{
FrameSelection* selection = document()->frame()->selection();
ASSERT(selection);
FrameSelection& selection = document()->frame()->selection();
if (selection->shouldChangeSelection(m_selectionToSet) && m_selectionToSet.isNonOrphanedCaretOrRange()) {
selection->setSelection(m_selectionToSet, m_options);
if (selection.shouldChangeSelection(m_selectionToSet) && m_selectionToSet.isNonOrphanedCaretOrRange()) {
selection.setSelection(m_selectionToSet, m_options);
setEndingSelection(m_selectionToSet);
}
}
void SetSelectionCommand::doUnapply()
{
FrameSelection* selection = document()->frame()->selection();
ASSERT(selection);
FrameSelection& selection = document()->frame()->selection();
if (selection->shouldChangeSelection(startingSelection()) && startingSelection().isNonOrphanedCaretOrRange())
selection->setSelection(startingSelection(), m_options);
if (selection.shouldChangeSelection(startingSelection()) && startingSelection().isNonOrphanedCaretOrRange())
selection.setSelection(startingSelection(), m_options);
}
} // namespace WebCore
......@@ -95,7 +95,7 @@ void SpellingCorrectionCommand::doApply()
if (!m_corrected.length())
return;
if (!document()->frame()->selection()->shouldChangeSelection(m_selectionToBeCorrected))
if (!document()->frame()->selection().shouldChangeSelection(m_selectionToBeCorrected))
return;
RefPtr<DocumentFragment> fragment = createFragmentFromText(m_rangeToBeCorrected.get(), m_correction);
......
......@@ -50,7 +50,7 @@ void TextInsertionBaseCommand::applyTextInsertionCommand(Frame* frame, PassRefPt
applyCommand(command);
if (changeSelection) {
command->setEndingSelection(endingSelection);
frame->selection()->setSelection(endingSelection);
frame->selection().setSelection(endingSelection);
}
}
......
......@@ -98,7 +98,7 @@ void TypingCommand::deleteSelection(Document* document, Options options)
Frame* frame = document->frame();
ASSERT(frame);
if (!frame->selection()->isRange())
if (!frame->selection().isRange())
return;
if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame)) {
......@@ -145,7 +145,7 @@ void TypingCommand::forwardDeleteKeyPressed(Document *document, Options options,
void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Frame* frame)
{
ASSERT(frame);
VisibleSelection currentSelection = frame->selection()->selection();
VisibleSelection currentSelection = frame->selection().selection();
if (currentSelection == typingCommand->endingSelection())
return;
......@@ -163,7 +163,7 @@ void TypingCommand::insertText(Document* document, const String& text, Options o
if (!text.isEmpty())
document->frame()->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.characters()[0]));
insertText(document, text, frame->selection()->selection(), options, composition);
insertText(document, text, frame->selection().selection(), options, composition);
}
// FIXME: We shouldn't need to take selectionForInsertion. It should be identical to FrameSelection's current selection.
......@@ -174,7 +174,7 @@ void TypingCommand::insertText(Document* document, const String& text, const Vis
RefPtr<Frame> frame = document->frame();
ASSERT(frame);
VisibleSelection currentSelection = frame->selection()->selection();
VisibleSelection currentSelection = frame->selection().selection();
String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionUpdate);
......@@ -510,7 +510,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
if (selectionToDelete.isNone())
return;
if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
if (selectionToDelete.isCaret() || !frame->selection().shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
......@@ -603,7 +603,7 @@ void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool ki
if (selectionToDelete.isNone())
return;
if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
if (selectionToDelete.isCaret() || !frame->selection().shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
......
......@@ -72,7 +72,7 @@ void Editor::setTextAlignmentForChangedBaseWritingDirection(WritingDirection dir
// If the text has left or right alignment, flip left->right and right->left.
// Otherwise, do nothing.
RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(frame()->selection()->selection());
RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(frame()->selection().selection());
if (!selectionStyle || !selectionStyle->style())
return;
......@@ -147,14 +147,14 @@ static RenderStyle* styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
{
nodeToRemove = 0;
if (frame->selection()->isNone())
if (frame->selection().isNone())
return 0;
Position position = frame->selection()->selection().visibleStart().deepEquivalent();
Position position = frame->selection().selection().visibleStart().deepEquivalent();
if (!position.isCandidate() || position.isNull())
return 0;
RefPtr<EditingStyle> typingStyle = frame->selection()->typingStyle();
RefPtr<EditingStyle> typingStyle = frame->selection().typingStyle();
if (!typingStyle || !typingStyle->style())
return position.deprecatedNode()->renderer()->style();
......@@ -178,7 +178,7 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
{
hasMultipleFonts = false;
if (!m_frame.selection()->isRange()) {
if (!m_frame.selection().isRange()) {
Node* nodeToRemove;
RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
......@@ -196,8 +196,8 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
}
const SimpleFontData* font = 0;
RefPtr<Range> range = m_frame.selection()->toNormalizedRange();
if (Node* startNode = adjustedSelectionStartForStyleComputation(m_frame.selection()->selection()).deprecatedNode()) {
RefPtr<Range> range = m_frame.selection().toNormalizedRange();
if (Node* startNode = adjustedSelectionStartForStyleComputation(m_frame.selection().selection()).deprecatedNode()) {
Node* pastEnd = range->pastLastNode();
// In the loop below, n should eventually match pastEnd and not become nil, but we've seen at least one
// unreproducible case where this didn't happen, so check for null also.
......
......@@ -112,14 +112,14 @@ static RenderStyle* styleForSelectionStart(Frame* frame, Node *&nodeToRemove)
{
nodeToRemove = 0;
if (frame->selection()->isNone())
if (frame->selection().isNone())
return 0;
Position position = frame->selection()->selection().visibleStart().deepEquivalent();
Position position = frame->selection().selection().visibleStart().deepEquivalent();
if (!position.isCandidate() || position.isNull())
return 0;
RefPtr<EditingStyle> typingStyle = frame->selection()->typingStyle();
RefPtr<EditingStyle> typingStyle = frame->selection().typingStyle();
if (!typingStyle || !typingStyle->style())
return position.deprecatedNode()->renderer()->style();
......@@ -140,7 +140,7 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
{
hasMultipleFonts = false;
if (!m_frame.selection()->isRange()) {
if (!m_frame.selection().isRange()) {
Node* nodeToRemove;
RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
......@@ -155,8 +155,8 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
}
const SimpleFontData* font = 0;
RefPtr<Range> range = m_frame.selection()->toNormalizedRange();
Node* startNode = adjustedSelectionStartForStyleComputation(m_frame.selection()->selection()).deprecatedNode();
RefPtr<Range> range = m_frame.selection().toNormalizedRange();
Node* startNode = adjustedSelectionStartForStyleComputation(m_frame.selection().selection()).deprecatedNode();
if (range && startNode) {
Node* pastEnd = range->pastLastNode();
// In the loop below, n should eventually match pastEnd and not become nil, but we've seen at least one
......@@ -242,8 +242,8 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
bool Editor::canCopyExcludingStandaloneImages()
{
FrameSelection* selection = m_frame.selection();
return selection->isRange() && !selection->isInPasswordField();
FrameSelection& selection = m_frame.selection();
return selection.isRange() && !selection.isInPasswordField();
}
void Editor::takeFindStringFromSelection()
......@@ -268,7 +268,7 @@ void Editor::writeSelectionToPasteboard(const String& pasteboardName, const Vect
void Editor::readSelectionFromPasteboard(const String& pasteboardName)
{
Pasteboard pasteboard(pasteboardName);
if (m_frame.selection()->isContentRichlyEditable())
if (m_frame.selection().isContentRichlyEditable())
pasteWithPasteboard(&pasteboard, true);