<https://webkit.org/b/119918> Frame::selection() should return a reference
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Aug 2013 18:09:12 +0000 (18:09 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Aug 2013 18:09:12 +0000 (18:09 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@154286 268f45cc-cd09-0410-ab3c-d52691b4dbfc

103 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/dom/CharacterData.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/editing/AlternativeTextController.cpp
Source/WebCore/editing/DeleteButtonController.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/DictationCommand.cpp
Source/WebCore/editing/EditCommand.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/InsertLineBreakCommand.cpp
Source/WebCore/editing/InsertTextCommand.cpp
Source/WebCore/editing/ModifySelectionListLevel.cpp
Source/WebCore/editing/RemoveFormatCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/SetSelectionCommand.cpp
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/TextInsertionBaseCommand.cpp
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DOMSelection.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/mac/FrameMac.mm
Source/WebCore/page/mac/FrameSnapshottingMac.mm
Source/WebCore/page/win/FrameWin.cpp
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGTextContentElement.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/blackberry/Api/InRegionScroller.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/DatePickerClient.cpp
Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SpellingHandler.cpp
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp
Source/WebKit/efl/ewk/ewk_frame.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
Source/WebKit/gtk/webkit/webkitwebframe.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/WebPluginController.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebTextCompletionController.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebFrame.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

index d92da2507c956d01f58371cc69373511f72a3901..078b34930611044e317282a152f2798208f45924 100644 (file)
@@ -1,3 +1,340 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-19  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
 
         <https://webkit.org/b/119679> Remove the cast-align warnings for ARM
index 71cebae6622a891284fc8b621ceb7f5ab87ad7b2..4b67f022927c05107982aeb67980de52835356e4 100644 (file)
@@ -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());
     
index bc35baa201c7d3382c1ae548ea3aaf2d4c996e71..04367a72192fd791b0abad3157c2da9122d2faae 100644 (file)
@@ -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);
 }
index 2e282511a3e98a35c8fddefb14793d0369c4e914..2a79f6f5e85bb4d468ae7a9026e2e279873baefe 100644 (file)
@@ -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) {
index 243ed1029978e9b28f75c088dad1e2eab26d8b8d..7147fb428cf434dcd37ace926381622b442467ee 100644 (file)
@@ -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)
index e5c10f6f09b906b8c8eb2dd9e51fbddb8f12adb9..8ab42104082fc7677573df1ed890f27ba20bddfe 100644 (file)
@@ -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);
index 5e7f1efabc9e3b05ff76727a4b1c5a1708c54fb2..c084f8d532b4eb51c36f467ce61d4b31868187a1 100644 (file)
@@ -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);
     }
 }
index 8dc86bfbaa3c9943dffe132840c21f96855b93ca..1a0f1619d5e7d8b3a5c216830201e14ae51165f3 100644 (file)
@@ -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());
index 9eeee2d0587a554621ca40b50c3f0a344e0e8a61..04503f7b7b3e2e014cd9af3818a931830c2c008a 100644 (file)
@@ -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
index 133b7ee7aa2dadd0c68359524d1d33ad78fda0b7..8ff44ba75fa6ea706858f7e13c34e4b9c9045655 100644 (file)
@@ -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
 
index de108c79aa4cc7e951a2d41d35717eaf286d24cb..6110bd48f7077d01a078822a2c70e1438f76f943 100644 (file)
@@ -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()
index a15800e98ac512c67a494b3c9ce0c5d40743d487..609a48750885955f5de15dac5dd50aee6b834919 100644 (file)
@@ -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);
 
index eb52768df419de79022b72afee7d4a887a30ffc1..401d91e7f6c9bf1e8bcf14dab7e6a2c1651279e1 100644 (file)
@@ -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);
 }
 
index dcd202ad3db1657cbc3b714ebaec9f6897299989..89683ebffc0b1248a5aed728b64f82d84c9b1f30 100644 (file)
@@ -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;
 
index b71c759766242d550a1dab88dd090a8c5f9f8833..a55d1859410f6693dec6afa86ee595d3c7e404e0 100644 (file)
@@ -165,7 +165,7 @@ VisibleSelection Editor::avoidIntersectionWithDeleteButtonController(const Visib
 // we should use the target control's selection for this editing operation.
 VisibleSelection Editor::selectionForCommand(Event* event)
 {
-    VisibleSelection selection = m_frame.selection()->selection();
+    VisibleSelection selection = m_frame.selection().selection();
     if (!event)
         return selection;
     // If the target is a text control, and the current selection is outside of its shadow tree,
@@ -239,12 +239,12 @@ bool Editor::handleTextEvent(TextEvent* event)
 
 bool Editor::canEdit() const
 {
-    return m_frame.selection()->rootEditableElement();
+    return m_frame.selection().rootEditableElement();
 }
 
 bool Editor::canEditRichly() const
 {
-    return m_frame.selection()->isContentRichlyEditable();
+    return m_frame.selection().isContentRichlyEditable();
 }
 
 // WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu items.  They
@@ -254,12 +254,12 @@ bool Editor::canEditRichly() const
 
 bool Editor::canDHTMLCut()
 {
-    return !m_frame.selection()->isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb);
+    return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb);
 }
 
 bool Editor::canDHTMLCopy()
 {
-    return !m_frame.selection()->isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb);
+    return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb);
 }
 
 bool Editor::canDHTMLPaste()
@@ -295,8 +295,8 @@ bool Editor::canCopy() const
 {
     if (imageElementFromImageDocument(m_frame.document()))
         return true;
-    FrameSelection* selection = m_frame.selection();
-    return selection->isRange() && !selection->isInPasswordField();
+    FrameSelection& selection = m_frame.selection();
+    return selection.isRange() && !selection.isInPasswordField();
 }
 
 bool Editor::canPaste() const
@@ -306,8 +306,8 @@ bool Editor::canPaste() const
 
 bool Editor::canDelete() const
 {
-    FrameSelection* selection = m_frame.selection();
-    return selection->isRange() && selection->rootEditableElement();
+    FrameSelection& selection = m_frame.selection();
+    return selection.isRange() && selection.rootEditableElement();
 }
 
 bool Editor::canDeleteRange(Range* range) const
@@ -337,7 +337,7 @@ bool Editor::smartInsertDeleteEnabled()
     
 bool Editor::canSmartCopyOrDelete()
 {
-    return client() && client()->smartInsertDeleteEnabled() && m_frame.selection()->granularity() == WordGranularity;
+    return client() && client()->smartInsertDeleteEnabled() && m_frame.selection().granularity() == WordGranularity;
 }
 
 bool Editor::isSelectTrailingWhitespaceEnabled()
@@ -350,7 +350,7 @@ bool Editor::deleteWithDirection(SelectionDirection direction, TextGranularity g
     if (!canEdit())
         return false;
 
-    if (m_frame.selection()->isRange()) {
+    if (m_frame.selection().isRange()) {
         if (isTypingAction) {
             TypingCommand::deleteKeyPressed(m_frame.document(), canSmartCopyOrDelete() ? TypingCommand::SmartDelete : 0, granularity);
             revealSelectionAfterEditingOperation();
@@ -390,7 +390,7 @@ bool Editor::deleteWithDirection(SelectionDirection direction, TextGranularity g
 
 void Editor::deleteSelectionWithSmartDelete(bool smartDelete)
 {
-    if (m_frame.selection()->isNone())
+    if (m_frame.selection().isNone())
         return;
     
     applyCommand(DeleteSelectionCommand::create(m_frame.document(), smartDelete));
@@ -456,7 +456,7 @@ bool Editor::shouldInsertFragment(PassRefPtr<DocumentFragment> fragment, PassRef
 
 void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
 {
-    if (m_frame.selection()->isNone() || !m_frame.selection()->isContentEditable() || !fragment)
+    if (m_frame.selection().isNone() || !m_frame.selection().isContentEditable() || !fragment)
         return;
 
     ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment;
@@ -469,9 +469,9 @@ void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment,
     applyCommand(ReplaceSelectionCommand::create(m_frame.document(), fragment, options, EditActionPaste));
     revealSelectionAfterEditingOperation();
 
-    if (m_frame.selection()->isInPasswordField() || !isContinuousSpellCheckingEnabled())
+    if (m_frame.selection().isInPasswordField() || !isContinuousSpellCheckingEnabled())
         return;
-    Node* nodeToCheck = m_frame.selection()->rootEditableElement();
+    Node* nodeToCheck = m_frame.selection().rootEditableElement();
     if (!nodeToCheck)
         return;
 
@@ -486,7 +486,7 @@ void Editor::replaceSelectionWithText(const String& text, bool selectReplacement
 
 PassRefPtr<Range> Editor::selectedRange()
 {
-    return m_frame.selection()->toNormalizedRange();
+    return m_frame.selection().toNormalizedRange();
 }
 
 bool Editor::shouldDeleteRange(Range* range) const
@@ -502,7 +502,7 @@ bool Editor::shouldDeleteRange(Range* range) const
 
 bool Editor::tryDHTMLCopy()
 {   
-    if (m_frame.selection()->isInPasswordField())
+    if (m_frame.selection().isInPasswordField())
         return false;
 
     return !dispatchCPPEvent(eventNames().copyEvent, ClipboardWritable);
@@ -510,7 +510,7 @@ bool Editor::tryDHTMLCopy()
 
 bool Editor::tryDHTMLCut()
 {
-    if (m_frame.selection()->isInPasswordField())
+    if (m_frame.selection().isInPasswordField())
         return false;
     
     return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable);
@@ -553,17 +553,17 @@ void Editor::respondToChangedContents(const VisibleSelection& endingSelection)
 
 bool Editor::hasBidiSelection() const
 {
-    if (m_frame.selection()->isNone())
+    if (m_frame.selection().isNone())
         return false;
 
     Node* startNode;
-    if (m_frame.selection()->isRange()) {
-        startNode = m_frame.selection()->selection().start().downstream().deprecatedNode();
-        Node* endNode = m_frame.selection()->selection().end().upstream().deprecatedNode();
+    if (m_frame.selection().isRange()) {
+        startNode = m_frame.selection().selection().start().downstream().deprecatedNode();
+        Node* endNode = m_frame.selection().selection().end().upstream().deprecatedNode();
         if (enclosingBlock(startNode) != enclosingBlock(endNode))
             return false;
     } else
-        startNode = m_frame.selection()->selection().visibleStart().deepEquivalent().deprecatedNode();
+        startNode = m_frame.selection().selection().visibleStart().deepEquivalent().deprecatedNode();
 
     RenderObject* renderer = startNode->renderer();
     while (renderer && !renderer->isRenderBlock())
@@ -581,12 +581,12 @@ bool Editor::hasBidiSelection() const
 
 TriState Editor::selectionUnorderedListState() const
 {
-    if (m_frame.selection()->isCaret()) {
-        if (enclosingNodeWithTag(m_frame.selection()->selection().start(), ulTag))
+    if (m_frame.selection().isCaret()) {
+        if (enclosingNodeWithTag(m_frame.selection().selection().start(), ulTag))
             return TrueTriState;
-    } else if (m_frame.selection()->isRange()) {
-        Node* startNode = enclosingNodeWithTag(m_frame.selection()->selection().start(), ulTag);
-        Node* endNode = enclosingNodeWithTag(m_frame.selection()->selection().end(), ulTag);
+    } else if (m_frame.selection().isRange()) {
+        Node* startNode = enclosingNodeWithTag(m_frame.selection().selection().start(), ulTag);
+        Node* endNode = enclosingNodeWithTag(m_frame.selection().selection().end(), ulTag);
         if (startNode && endNode && startNode == endNode)
             return TrueTriState;
     }
@@ -596,12 +596,12 @@ TriState Editor::selectionUnorderedListState() const
 
 TriState Editor::selectionOrderedListState() const
 {
-    if (m_frame.selection()->isCaret()) {
-        if (enclosingNodeWithTag(m_frame.selection()->selection().start(), olTag))
+    if (m_frame.selection().isCaret()) {
+        if (enclosingNodeWithTag(m_frame.selection().selection().start(), olTag))
             return TrueTriState;
-    } else if (m_frame.selection()->isRange()) {
-        Node* startNode = enclosingNodeWithTag(m_frame.selection()->selection().start(), olTag);
-        Node* endNode = enclosingNodeWithTag(m_frame.selection()->selection().end(), olTag);
+    } else if (m_frame.selection().isRange()) {
+        Node* startNode = enclosingNodeWithTag(m_frame.selection().selection().start(), olTag);
+        Node* endNode = enclosingNodeWithTag(m_frame.selection().selection().end(), olTag);
         if (startNode && endNode && startNode == endNode)
             return TrueTriState;
     }
@@ -641,7 +641,7 @@ bool Editor::canDecreaseSelectionListLevel()
 
 PassRefPtr<Node> Editor::increaseSelectionListLevel()
 {
-    if (!canEditRichly() || m_frame.selection()->isNone())
+    if (!canEditRichly() || m_frame.selection().isNone())
         return 0;
     
     RefPtr<Node> newList = IncreaseSelectionListLevelCommand::increaseSelectionListLevel(m_frame.document());
@@ -651,7 +651,7 @@ PassRefPtr<Node> Editor::increaseSelectionListLevel()
 
 PassRefPtr<Node> Editor::increaseSelectionListLevelOrdered()
 {
-    if (!canEditRichly() || m_frame.selection()->isNone())
+    if (!canEditRichly() || m_frame.selection().isNone())
         return 0;
     
     RefPtr<Node> newList = IncreaseSelectionListLevelCommand::increaseSelectionListLevelOrdered(m_frame.document());
@@ -661,7 +661,7 @@ PassRefPtr<Node> Editor::increaseSelectionListLevelOrdered()
 
 PassRefPtr<Node> Editor::increaseSelectionListLevelUnordered()
 {
-    if (!canEditRichly() || m_frame.selection()->isNone())
+    if (!canEditRichly() || m_frame.selection().isNone())
         return 0;
     
     RefPtr<Node> newList = IncreaseSelectionListLevelCommand::increaseSelectionListLevelUnordered(m_frame.document());
@@ -671,7 +671,7 @@ PassRefPtr<Node> Editor::increaseSelectionListLevelUnordered()
 
 void Editor::decreaseSelectionListLevel()
 {
-    if (!canEditRichly() || m_frame.selection()->isNone())
+    if (!canEditRichly() || m_frame.selection().isNone())
         return;
     
     DecreaseSelectionListLevelCommand::decreaseSelectionListLevel(m_frame.document());
@@ -730,12 +730,12 @@ Node* Editor::findEventTargetFrom(const VisibleSelection& selection) const
 
 Node* Editor::findEventTargetFromSelection() const
 {
-    return findEventTargetFrom(m_frame.selection()->selection());
+    return findEventTargetFrom(m_frame.selection().selection());
 }
 
 void Editor::applyStyle(StylePropertySet* style, EditAction editingAction)
 {
-    switch (m_frame.selection()->selectionType()) {
+    switch (m_frame.selection().selectionType()) {
     case VisibleSelection::NoSelection:
         // do nothing
         break;
@@ -756,7 +756,7 @@ bool Editor::shouldApplyStyle(StylePropertySet* style, Range* range)
     
 void Editor::applyParagraphStyle(StylePropertySet* style, EditAction editingAction)
 {
-    switch (m_frame.selection()->selectionType()) {
+    switch (m_frame.selection().selectionType()) {
     case VisibleSelection::NoSelection:
         // do nothing
         break;
@@ -773,7 +773,7 @@ void Editor::applyStyleToSelection(StylePropertySet* style, EditAction editingAc
     if (!style || style->isEmpty() || !canEditRichly())
         return;
 
-    if (client() && client()->shouldApplyStyle(style, m_frame.selection()->toNormalizedRange().get()))
+    if (client() && client()->shouldApplyStyle(style, m_frame.selection().toNormalizedRange().get()))
         applyStyle(style, editingAction);
 }
 
@@ -782,24 +782,24 @@ void Editor::applyParagraphStyleToSelection(StylePropertySet* style, EditAction
     if (!style || style->isEmpty() || !canEditRichly())
         return;
     
-    if (client() && client()->shouldApplyStyle(style, m_frame.selection()->toNormalizedRange().get()))
+    if (client() && client()->shouldApplyStyle(style, m_frame.selection().toNormalizedRange().get()))
         applyParagraphStyle(style, editingAction);
 }
 
 bool Editor::selectionStartHasStyle(CSSPropertyID propertyID, const String& value) const
 {
     return EditingStyle::create(propertyID, value)->triStateOfStyle(
-        EditingStyle::styleAtSelectionStart(m_frame.selection()->selection(), propertyID == CSSPropertyBackgroundColor).get());
+        EditingStyle::styleAtSelectionStart(m_frame.selection().selection(), propertyID == CSSPropertyBackgroundColor).get());
 }
 
 TriState Editor::selectionHasStyle(CSSPropertyID propertyID, const String& value) const
 {
-    return EditingStyle::create(propertyID, value)->triStateOfStyle(m_frame.selection()->selection());
+    return EditingStyle::create(propertyID, value)->triStateOfStyle(m_frame.selection().selection());
 }
 
 String Editor::selectionStartCSSPropertyValue(CSSPropertyID propertyID)
 {
-    RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(m_frame.selection()->selection(),
+    RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(m_frame.selection().selection(),
         propertyID == CSSPropertyBackgroundColor);
     if (!selectionStyle || !selectionStyle->style())
         return String();
@@ -845,7 +845,7 @@ void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
     dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement());
 
     if (!cmd->preservesTypingStyle())
-        m_frame.selection()->clearTypingStyle();
+        m_frame.selection().clearTypingStyle();
 
     // Command will be equal to last edit command only in the case of typing
     if (m_lastEditCommand.get() == cmd)
@@ -984,7 +984,7 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
             // Reveal the current selection
             if (Frame* editedFrame = document->frame())
                 if (Page* page = editedFrame->page())
-                    page->focusController().focusedOrMainFrame()->selection()->revealSelection(ScrollAlignment::alignCenterIfNeeded);
+                    page->focusController().focusedOrMainFrame()->selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
         }
     }
 
@@ -996,10 +996,10 @@ bool Editor::insertLineBreak()
     if (!canEdit())
         return false;
 
-    if (!shouldInsertText("\n", m_frame.selection()->toNormalizedRange().get(), EditorInsertActionTyped))
+    if (!shouldInsertText("\n", m_frame.selection().toNormalizedRange().get(), EditorInsertActionTyped))
         return true;
 
-    VisiblePosition caret = m_frame.selection()->selection().visibleStart();
+    VisiblePosition caret = m_frame.selection().selection().visibleStart();
     bool alignToEdge = isEndOfEditableOrNonEditableContent(caret);
     bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate();
     TypingCommand::insertLineBreak(m_frame.document(), autocorrectionIsApplied ? TypingCommand::RetainAutocorrectionIndicator : 0);
@@ -1016,10 +1016,10 @@ bool Editor::insertParagraphSeparator()
     if (!canEditRichly())
         return insertLineBreak();
 
-    if (!shouldInsertText("\n", m_frame.selection()->toNormalizedRange().get(), EditorInsertActionTyped))
+    if (!shouldInsertText("\n", m_frame.selection().toNormalizedRange().get(), EditorInsertActionTyped))
         return true;
 
-    VisiblePosition caret = m_frame.selection()->selection().visibleStart();
+    VisiblePosition caret = m_frame.selection().selection().visibleStart();
     bool alignToEdge = isEndOfEditableOrNonEditableContent(caret);
     bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate();
     TypingCommand::insertParagraphSeparator(m_frame.document(), autocorrectionIsApplied ? TypingCommand::RetainAutocorrectionIndicator : 0);
@@ -1040,7 +1040,7 @@ void Editor::cut()
     willWriteSelectionToPasteboard(selection);
     if (shouldDeleteRange(selection.get())) {
         updateMarkersForWordsAffectedByEditing(true);
-        if (enclosingTextFormControl(m_frame.selection()->start())) {
+        if (enclosingTextFormControl(m_frame.selection().start())) {
             Pasteboard::generalPasteboard()->writePlainText(selectedTextForClipboard(),
                 canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
         } else
@@ -1060,7 +1060,7 @@ void Editor::copy()
     }
 
     willWriteSelectionToPasteboard(selectedRange());
-    if (enclosingTextFormControl(m_frame.selection()->start())) {
+    if (enclosingTextFormControl(m_frame.selection().start())) {
         Pasteboard::generalPasteboard()->writePlainText(selectedTextForClipboard(),
             canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
     } else {
@@ -1084,7 +1084,7 @@ void Editor::paste()
     updateMarkersForWordsAffectedByEditing(false);
     CachedResourceLoader* loader = m_frame.document()->cachedResourceLoader();
     ResourceCacheValidationSuppressor validationSuppressor(loader);
-    if (m_frame.selection()->isContentRichlyEditable())
+    if (m_frame.selection().isContentRichlyEditable())
         pasteWithPasteboard(Pasteboard::generalPasteboard(), true);
     else
         pasteAsPlainTextWithPasteboard(Pasteboard::generalPasteboard());
@@ -1375,7 +1375,7 @@ WritingDirection Editor::baseWritingDirectionForSelectionStart() const
 {
     WritingDirection result = LeftToRightWritingDirection;
 
-    Position pos = m_frame.selection()->selection().visibleStart().deepEquivalent();
+    Position pos = m_frame.selection().selection().visibleStart().deepEquivalent();
     Node* node = pos.deprecatedNode();
     if (!node)
         return result;
@@ -1414,7 +1414,7 @@ void Editor::selectComposition()
     // See <http://bugs.webkit.org/show_bug.cgi?id=15781>
     VisibleSelection selection;
     selection.setWithoutValidation(range->startPosition(), range->endPosition());
-    m_frame.selection()->setSelection(selection, 0);
+    m_frame.selection().setSelection(selection, 0);
 }
 
 void Editor::confirmComposition()
@@ -1459,7 +1459,7 @@ void Editor::setComposition(const String& text, SetCompositionMode mode)
     else
         selectComposition();
 
-    if (m_frame.selection()->isNone()) {
+    if (m_frame.selection().isNone()) {
         setIgnoreCompositionSelectionChange(false);
         return;
     }
@@ -1503,7 +1503,7 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
 
     selectComposition();
 
-    if (m_frame.selection()->isNone()) {
+    if (m_frame.selection().isNone()) {
         setIgnoreCompositionSelectionChange(false);
         return;
     }
@@ -1555,8 +1555,8 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
         TypingCommand::insertText(m_frame.document(), text, TypingCommand::SelectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompositionUpdate);
 
         // Find out what node has the composition now.
-        Position base = m_frame.selection()->base().downstream();
-        Position extent = m_frame.selection()->extent();
+        Position base = m_frame.selection().base().downstream();
+        Position extent = m_frame.selection().extent();
         Node* baseNode = base.deprecatedNode();
         unsigned baseOffset = base.deprecatedEditingOffset();
         Node* extentNode = extent.deprecatedNode();
@@ -1578,7 +1578,7 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
             unsigned start = min(baseOffset + selectionStart, extentOffset);
             unsigned end = min(max(start, baseOffset + selectionEnd), extentOffset);
             RefPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end);                
-            m_frame.selection()->setSelectedRange(selectedRange.get(), DOWNSTREAM, false);
+            m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM, false);
         }
     }
 
@@ -1590,7 +1590,7 @@ void Editor::ignoreSpelling()
     if (!client())
         return;
         
-    RefPtr<Range> selectedRange = m_frame.selection()->toNormalizedRange();
+    RefPtr<Range> selectedRange = m_frame.selection().toNormalizedRange();
     if (selectedRange)
         m_frame.document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling);
 
@@ -1606,7 +1606,7 @@ void Editor::learnSpelling()
         
     // FIXME: On Mac OS X, when use "learn" button on "Spelling and Grammar" panel, we don't call this function. It should remove misspelling markers around the learned word, see <rdar://problem/5396072>.
 
-    RefPtr<Range> selectedRange = m_frame.selection()->toNormalizedRange();
+    RefPtr<Range> selectedRange = m_frame.selection().toNormalizedRange();
     if (selectedRange)
         m_frame.document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling);
 
@@ -1622,7 +1622,7 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection)
     
     // Start at the end of the selection, search to edge of document.  Starting at the selection end makes
     // repeated "check spelling" commands work.
-    VisibleSelection selection(m_frame.selection()->selection());
+    VisibleSelection selection(m_frame.selection().selection());
     RefPtr<Range> spellingSearchRange(rangeOfContents(m_frame.document()));
 
     bool startedWithSelection = false;
@@ -1768,8 +1768,8 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection)
         
         // FIXME 4859190: This gets confused with doubled punctuation at the end of a paragraph
         RefPtr<Range> badGrammarRange = TextIterator::subrange(grammarSearchRange.get(), grammarPhraseOffset + grammarDetail.location, grammarDetail.length);
-        m_frame.selection()->setSelection(VisibleSelection(badGrammarRange.get(), SEL_DEFAULT_AFFINITY));
-        m_frame.selection()->revealSelection();
+        m_frame.selection().setSelection(VisibleSelection(badGrammarRange.get(), SEL_DEFAULT_AFFINITY));
+        m_frame.selection().revealSelection();
         
         client()->updateSpellingUIWithGrammarString(badGrammarPhrase, grammarDetail);
         m_frame.document()->markers()->addMarker(badGrammarRange.get(), DocumentMarker::Grammar, grammarDetail.userDescription);
@@ -1780,8 +1780,8 @@ void Editor::advanceToNextMisspelling(bool startBeforeSelection)
         // a marker so we draw the red squiggle later.
         
         RefPtr<Range> misspellingRange = TextIterator::subrange(spellingSearchRange.get(), misspellingOffset, misspelledWord.length());
-        m_frame.selection()->setSelection(VisibleSelection(misspellingRange.get(), DOWNSTREAM));
-        m_frame.selection()->revealSelection();
+        m_frame.selection().setSelection(VisibleSelection(misspellingRange.get(), DOWNSTREAM));
+        m_frame.selection().revealSelection();
         
         client()->updateSpellingUIWithMisspelledWord(misspelledWord);
         m_frame.document()->markers()->addMarker(misspellingRange.get(), DocumentMarker::Spelling);
@@ -1793,7 +1793,7 @@ String Editor::misspelledWordAtCaretOrRange(Node* clickedNode) const
     if (!isContinuousSpellCheckingEnabled() || !clickedNode || !isSpellCheckingEnabledFor(clickedNode))
         return String();
 
-    VisibleSelection selection = m_frame.selection()->selection();
+    VisibleSelection selection = m_frame.selection().selection();
     if (!selection.isContentEditable() || selection.isNone())
         return String();
 
@@ -1845,7 +1845,7 @@ String Editor::misspelledSelectionString() const
 bool Editor::isSelectionUngrammatical()
 {
 #if USE(GRAMMAR_CHECKING)
-    RefPtr<Range> range = m_frame.selection()->toNormalizedRange();
+    RefPtr<Range> range = m_frame.selection().toNormalizedRange();
     if (!range)
         return false;
     return TextCheckingHelper(client(), range).isUngrammatical();
@@ -1868,13 +1868,13 @@ Vector<String> Editor::guessesForMisspelledOrUngrammatical(bool& misspelled, boo
 {
     if (unifiedTextCheckerEnabled()) {
         RefPtr<Range> range;
-        FrameSelection* frameSelection = m_frame.selection();
-        if (frameSelection->isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
-            VisibleSelection wordSelection = VisibleSelection(frameSelection->base());
+        FrameSelection& frameSelection = m_frame.selection();
+        if (frameSelection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
+            VisibleSelection wordSelection = VisibleSelection(frameSelection.base());
             wordSelection.expandUsingGranularity(WordGranularity);
             range = wordSelection.toNormalizedRange();
         } else
-            range = frameSelection->toNormalizedRange();
+            range = frameSelection.toNormalizedRange();
         if (!range)
             return Vector<String>();
         return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical);
@@ -1983,10 +1983,10 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
     // If autocorrected word is non empty, replace the misspelled word by this word.
     if (!autocorrectedString.isEmpty()) {
         VisibleSelection newSelection(misspellingRange.get(), DOWNSTREAM);
-        if (newSelection != m_frame.selection()->selection()) {
-            if (!m_frame.selection()->shouldChangeSelection(newSelection))
+        if (newSelection != m_frame.selection().selection()) {
+            if (!m_frame.selection().shouldChangeSelection(newSelection))
                 return;
-            m_frame.selection()->setSelection(newSelection);
+            m_frame.selection().setSelection(newSelection);
         }
 
         if (!m_frame.editor().shouldInsertText(autocorrectedString, misspellingRange.get(), EditorInsertActionTyped))
@@ -1994,8 +1994,8 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
         m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false);
 
         // Reset the charet one character further.
-        m_frame.selection()->moveTo(m_frame.selection()->end());
-        m_frame.selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+        m_frame.selection().moveTo(m_frame.selection().end());
+        m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
     }
 
     if (!isGrammarCheckingEnabled())
@@ -2056,7 +2056,7 @@ bool Editor::isSpellCheckingEnabledFor(Node* node) const
 
 bool Editor::isSpellCheckingEnabledInFocusedNode() const
 {
-    return isSpellCheckingEnabledFor(m_frame.selection()->start().deprecatedNode());
+    return isSpellCheckingEnabledFor(m_frame.selection().start().deprecatedNode());
 }
 
 void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange)
@@ -2180,9 +2180,9 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
     bool adjustSelectionForParagraphBoundaries = false;
 
     if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) {
-        if (m_frame.selection()->selectionType() == VisibleSelection::CaretSelection) {
+        if (m_frame.selection().selectionType() == VisibleSelection::CaretSelection) {
             // Attempt to save the caret position so we can restore it later if needed
-            Position caretPosition = m_frame.selection()->end();
+            Position caretPosition = m_frame.selection().end();
             selectionOffset = paragraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION);
             restoreSelectionAfterChange = true;
             if (selectionOffset > 0 && (selectionOffset > paragraph.textLength() || paragraph.textCharAt(selectionOffset - 1) == newlineCharacter))
@@ -2265,13 +2265,13 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
             }
 
             VisibleSelection selectionToReplace(rangeToReplace.get(), DOWNSTREAM);
-            if (selectionToReplace != m_frame.selection()->selection()) {
-                if (!m_frame.selection()->shouldChangeSelection(selectionToReplace))
+            if (selectionToReplace != m_frame.selection().selection()) {
+                if (!m_frame.selection().shouldChangeSelection(selectionToReplace))
                     continue;
             }
 
             if (resultType == TextCheckingTypeLink) {
-                m_frame.selection()->setSelection(selectionToReplace);
+                m_frame.selection().setSelection(selectionToReplace);
                 selectionChanged = true;
                 restoreSelectionAfterChange = false;
                 if (canEditRichly())
@@ -2280,7 +2280,7 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
                 correctSpellcheckingPreservingTextCheckingParagraph(paragraph, rangeToReplace, replacement, resultLocation, resultLength);
 
                 if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache()) {
-                    if (Element* root = m_frame.selection()->selection().rootEditableElement())
+                    if (Element* root = m_frame.selection().selection().rootEditableElement())
                         cache->postNotification(root, AXObjectCache::AXAutocorrectionOccured, true);
                 }
 
@@ -2306,13 +2306,13 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
         extendedParagraph.expandRangeToNextEnd();
         if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffset <= extendedParagraph.rangeLength()) {
             RefPtr<Range> selectionRange = extendedParagraph.subrange(0, selectionOffset);
-            m_frame.selection()->moveTo(selectionRange->endPosition(), DOWNSTREAM);
+            m_frame.selection().moveTo(selectionRange->endPosition(), DOWNSTREAM);
             if (adjustSelectionForParagraphBoundaries)
-                m_frame.selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+                m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
         } else {
             // If this fails for any reason, the fallback is to go one position beyond the last replacement
-            m_frame.selection()->moveTo(m_frame.selection()->end());
-            m_frame.selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
+            m_frame.selection().moveTo(m_frame.selection().end());
+            m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
         }
     }
 }
@@ -2381,8 +2381,8 @@ void Editor::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSelectionA
     // Of course, if current selection is a range, we potentially will edit two words that fall on the boundaries of
     // selection, and remove words between the selection boundaries.
     //
-    VisiblePosition startOfSelection = m_frame.selection()->selection().start();
-    VisiblePosition endOfSelection = m_frame.selection()->selection().end();
+    VisiblePosition startOfSelection = m_frame.selection().selection().start();
+    VisiblePosition endOfSelection = m_frame.selection().selection().end();
     if (startOfSelection.isNull())
         return;
     // First word is the word that ends after or on the start of selection.
@@ -2466,7 +2466,7 @@ void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignme
     if (m_ignoreCompositionSelectionChange)
         return;
 
-    m_frame.selection()->revealSelection(alignment, revealExtentOption);
+    m_frame.selection().revealSelection(alignment, revealExtentOption);
 }
 
 void Editor::setIgnoreCompositionSelectionChange(bool ignore)
@@ -2495,10 +2495,10 @@ bool Editor::getCompositionSelection(unsigned& selectionStart, unsigned& selecti
 {
     if (!m_compositionNode)
         return false;
-    Position start = m_frame.selection()->start();
+    Position start = m_frame.selection().start();
     if (start.deprecatedNode() != m_compositionNode)
         return false;
-    Position end = m_frame.selection()->end();
+    Position end = m_frame.selection().end();
     if (end.deprecatedNode() != m_compositionNode)
         return false;
 
@@ -2517,7 +2517,7 @@ void Editor::transpose()
     if (!canEdit())
         return;
 
-    VisibleSelection selection = m_frame.selection()->selection();
+    VisibleSelection selection = m_frame.selection().selection();
     if (!selection.isCaret())
         return;
 
@@ -2542,10 +2542,10 @@ void Editor::transpose()
     String transposed = text.right(1) + text.left(1);
 
     // Select the two characters.
-    if (newSelection != m_frame.selection()->selection()) {
-        if (!m_frame.selection()->shouldChangeSelection(newSelection))
+    if (newSelection != m_frame.selection().selection()) {
+        if (!m_frame.selection().shouldChangeSelection(newSelection))
             return;
-        m_frame.selection()->setSelection(newSelection);
+        m_frame.selection().setSelection(newSelection);
     }
 
     // Insert the transposed characters.
@@ -2593,9 +2593,9 @@ void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection,
     // because there is work that it must do in this situation.
     // The old selection can be invalid here and calling shouldChangeSelection can produce some strange calls.
     // See <rdar://problem/5729315> Some shouldChangeSelectedDOMRange contain Ranges for selections that are no longer valid
-    bool selectionDidNotChangeDOMPosition = newSelection == m_frame.selection()->selection();
-    if (selectionDidNotChangeDOMPosition || m_frame.selection()->shouldChangeSelection(newSelection))
-        m_frame.selection()->setSelection(newSelection, options);
+    bool selectionDidNotChangeDOMPosition = newSelection == m_frame.selection().selection();
+    if (selectionDidNotChangeDOMPosition || m_frame.selection().shouldChangeSelection(newSelection))
+        m_frame.selection().setSelection(newSelection, options);
 
     // Some editing operations change the selection visually without affecting its position within the DOM.
     // For example when you press return in the following (the caret is marked by ^):
@@ -2623,7 +2623,7 @@ String Editor::selectedTextForClipboard() const
 String Editor::selectedText(TextIteratorBehavior behavior) const
 {
     // We remove '\0' characters because they are not visibly rendered to the user.
-    return plainText(m_frame.selection()->toNormalizedRange().get(), behavior).replaceWithLiteral('\0', "");
+    return plainText(m_frame.selection().toNormalizedRange().get(), behavior).replaceWithLiteral('\0', "");
 }
 
 static inline void collapseCaretWidth(IntRect& rect)
@@ -2681,19 +2681,19 @@ bool Editor::shouldChangeSelection(const VisibleSelection& oldSelection, const V
 void Editor::computeAndSetTypingStyle(StylePropertySet* style, EditAction editingAction)
 {
     if (!style || style->isEmpty()) {
-        m_frame.selection()->clearTypingStyle();
+        m_frame.selection().clearTypingStyle();
         return;
     }
 
     // Calculate the current typing style.
     RefPtr<EditingStyle> typingStyle;
-    if (m_frame.selection()->typingStyle()) {
-        typingStyle = m_frame.selection()->typingStyle()->copy();
+    if (m_frame.selection().typingStyle()) {
+        typingStyle = m_frame.selection().typingStyle()->copy();
         typingStyle->overrideWithStyle(style);
     } else
         typingStyle = EditingStyle::create(style);
 
-    typingStyle->prepareToApplyAt(m_frame.selection()->selection().visibleStart().deepEquivalent(), EditingStyle::PreserveWritingDirection);
+    typingStyle->prepareToApplyAt(m_frame.selection().selection().visibleStart().deepEquivalent(), EditingStyle::PreserveWritingDirection);
 
     // Handle block styles, substracting these from the typing style.
     RefPtr<EditingStyle> blockStyle = typingStyle->extractAndRemoveBlockProperties();
@@ -2701,7 +2701,7 @@ void Editor::computeAndSetTypingStyle(StylePropertySet* style, EditAction editin
         applyCommand(ApplyStyleCommand::create(m_frame.document(), blockStyle.get(), editingAction));
 
     // Set the remaining style as the typing style.
-    m_frame.selection()->setTypingStyle(typingStyle);
+    m_frame.selection().setTypingStyle(typingStyle);
 }
 
 void Editor::textFieldDidBeginEditing(Element* e)
@@ -2775,15 +2775,15 @@ bool Editor::findString(const String& target, bool forward, bool caseFlag, bool
 
 bool Editor::findString(const String& target, FindOptions options)
 {
-    VisibleSelection selection = m_frame.selection()->selection();
+    VisibleSelection selection = m_frame.selection().selection();
 
     RefPtr<Range> resultRange = rangeOfString(target, selection.firstRange().get(), options);
 
     if (!resultRange)
         return false;
 
-    m_frame.selection()->setSelection(VisibleSelection(resultRange.get(), DOWNSTREAM));
-    m_frame.selection()->revealSelection();
+    m_frame.selection().setSelection(VisibleSelection(resultRange.get(), DOWNSTREAM));
+    m_frame.selection().revealSelection();
     return true;
 }
 
@@ -2974,8 +2974,8 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra
         VisibleSelection newAdjacentWords;
         VisibleSelection newSelectedSentence;
         bool caretBrowsing = m_frame.settings().caretBrowsingEnabled();
-        if (m_frame.selection()->selection().isContentEditable() || caretBrowsing) {
-            VisiblePosition newStart(m_frame.selection()->selection().visibleStart());
+        if (m_frame.selection().selection().isContentEditable() || caretBrowsing) {
+            VisiblePosition newStart(m_frame.selection().selection().visibleStart());
             newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary));
             if (isContinuousGrammarCheckingEnabled)
                 newSelectedSentence = VisibleSelection(startOfSentence(newStart), endOfSentence(newStart));
@@ -3038,7 +3038,7 @@ static Node* findFirstMarkable(Node* node)
 
 bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const
 {
-    Node* node = findFirstMarkable(m_frame.selection()->start().deprecatedNode());
+    Node* node = findFirstMarkable(m_frame.selection().start().deprecatedNode());
     if (!node)
         return false;
 
@@ -3115,7 +3115,7 @@ void Editor::applyDictationAlternativelternative(const String& alternativeString
 void Editor::toggleOverwriteModeEnabled()
 {
     m_overwriteModeEnabled = !m_overwriteModeEnabled;
-    m_frame.selection()->setShouldShowBlockCursor(m_overwriteModeEnabled);
+    m_frame.selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
 };
 
 } // namespace WebCore
index 3e9b8824656110e33d4b34da7d564c0844fd04ad..a949fbe0fc4ce5bd3f99ed164caa08a751c1dca7 100644 (file)
@@ -135,7 +135,7 @@ static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditActi
 //        until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved.
 static bool executeToggleStyleInList(Frame* frame, EditorCommandSource source, EditAction action, CSSPropertyID propertyID, CSSValue* value)
 {
-    RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(frame->selection()->selection());
+    RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(frame->selection().selection());
     if (!selectionStyle || !selectionStyle->style())
         return false;
 
@@ -209,18 +209,18 @@ static bool executeInsertNode(Frame* frame, PassRefPtr<Node> content)
 
 static bool expandSelectionToGranularity(Frame* frame, TextGranularity granularity)
 {
-    VisibleSelection selection = frame->selection()->selection();
+    VisibleSelection selection = frame->selection().selection();
     selection.expandUsingGranularity(granularity);
     RefPtr<Range> newRange = selection.toNormalizedRange();
     if (!newRange)
         return false;
     if (newRange->collapsed(IGNORE_EXCEPTION))
         return false;
-    RefPtr<Range> oldRange = frame->selection()->selection().toNormalizedRange();
-    EAffinity affinity = frame->selection()->affinity();
+    RefPtr<Range> oldRange = frame->selection().selection().toNormalizedRange();
+    EAffinity affinity = frame->selection().affinity();
     if (!frame->editor().client()->shouldChangeSelectedRange(oldRange.get(), newRange.get(), affinity, false))
         return false;
-    frame->selection()->setSelectedRange(newRange.get(), affinity, true);
+    frame->selection().setSelectedRange(newRange.get(), affinity, true);
     return true;
 }
 
@@ -241,8 +241,8 @@ static String valueStyle(Frame* frame, CSSPropertyID propertyID)
 static TriState stateTextWritingDirection(Frame* frame, WritingDirection direction)
 {
     bool hasNestedOrMultipleEmbeddings;
-    WritingDirection selectionDirection = EditingStyle::textDirectionForSelection(frame->selection()->selection(),
-        frame->selection()->typingStyle(), hasNestedOrMultipleEmbeddings);
+    WritingDirection selectionDirection = EditingStyle::textDirectionForSelection(frame->selection().selection(),
+        frame->selection().typingStyle(), hasNestedOrMultipleEmbeddings);
     // FXIME: We should be returning MixedTriState when selectionDirection == direction && hasNestedOrMultipleEmbeddings
     return (selectionDirection == direction && !hasNestedOrMultipleEmbeddings) ? TrueTriState : FalseTriState;
 }
@@ -327,7 +327,7 @@ static bool executeDelete(Frame* frame, Event*, EditorCommandSource source, cons
     case CommandFromDOMWithUserInterface:
         // If the current selection is a caret, delete the preceding character. IE performs forwardDelete, but we currently side with Firefox.
         // Doesn't scroll to make the selection visible, or modify the kill ring (this time, siding with IE, not Firefox).
-        TypingCommand::deleteKeyPressed(frame->document(), frame->selection()->granularity() == WordGranularity ? TypingCommand::SmartDelete : 0);
+        TypingCommand::deleteKeyPressed(frame->document(), frame->selection().granularity() == WordGranularity ? TypingCommand::SmartDelete : 0);
         return true;
     }
     ASSERT_NOT_REACHED();
@@ -384,15 +384,15 @@ static bool executeDeleteToEndOfParagraph(Frame* frame, Event*, EditorCommandSou
 static bool executeDeleteToMark(Frame* frame, Event*, EditorCommandSource, const String&)
 {
     RefPtr<Range> mark = frame->editor().mark().toNormalizedRange();
+    FrameSelection& selection = frame->selection();
     if (mark) {
-        FrameSelection* selection = frame->selection();
-        bool selected = selection->setSelectedRange(unionDOMRanges(mark.get(), frame->editor().selectedRange().get()).get(), DOWNSTREAM, true);
+        bool selected = selection.setSelectedRange(unionDOMRanges(mark.get(), frame->editor().selectedRange().get()).get(), DOWNSTREAM, true);
         ASSERT(selected);
         if (!selected)
             return false;
     }
     frame->editor().performDelete();
-    frame->editor().setMark(frame->selection()->selection());
+    frame->editor().setMark(selection.selection());
     return true;
 }
 
@@ -614,47 +614,47 @@ static bool executeMakeTextWritingDirectionRightToLeft(Frame* frame, Event*, Edi
 
 static bool executeMoveBackward(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveBackwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveDown(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    return frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
+    return frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
 }
 
 static bool executeMoveDownAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, LineGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, LineGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveForward(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveForwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveLeft(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    return frame->selection()->modify(FrameSelection::AlterationMove, DirectionLeft, CharacterGranularity, UserTriggered);
+    return frame->selection().modify(FrameSelection::AlterationMove, DirectionLeft, CharacterGranularity, UserTriggered);
 }
 
 static bool executeMoveLeftAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionLeft, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionLeft, CharacterGranularity, UserTriggered);
     return true;
 }
 
@@ -663,7 +663,7 @@ static bool executeMovePageDown(Frame* frame, Event*, EditorCommandSource, const
     unsigned distance = verticalScrollDistance(frame);
     if (!distance)
         return false;
-    return frame->selection()->modify(FrameSelection::AlterationMove, distance, FrameSelection::DirectionDown,
+    return frame->selection().modify(FrameSelection::AlterationMove, distance, FrameSelection::DirectionDown,
         UserTriggered, FrameSelection::AlignCursorOnScrollAlways);
 }
 
@@ -672,7 +672,7 @@ static bool executeMovePageDownAndModifySelection(Frame* frame, Event*, EditorCo
     unsigned distance = verticalScrollDistance(frame);
     if (!distance)
         return false;
-    return frame->selection()->modify(FrameSelection::AlterationExtend, distance, FrameSelection::DirectionDown,
+    return frame->selection().modify(FrameSelection::AlterationExtend, distance, FrameSelection::DirectionDown,
         UserTriggered, FrameSelection::AlignCursorOnScrollAlways);
 }
 
@@ -681,7 +681,7 @@ static bool executeMovePageUp(Frame* frame, Event*, EditorCommandSource, const S
     unsigned distance = verticalScrollDistance(frame);
     if (!distance)
         return false;
-    return frame->selection()->modify(FrameSelection::AlterationMove, distance, FrameSelection::DirectionUp,
+    return frame->selection().modify(FrameSelection::AlterationMove, distance, FrameSelection::DirectionUp,
         UserTriggered, FrameSelection::AlignCursorOnScrollAlways);
 }
 
@@ -690,209 +690,209 @@ static bool executeMovePageUpAndModifySelection(Frame* frame, Event*, EditorComm
     unsigned distance = verticalScrollDistance(frame);
     if (!distance)
         return false;
-    return frame->selection()->modify(FrameSelection::AlterationExtend, distance, FrameSelection::DirectionUp,
+    return frame->selection().modify(FrameSelection::AlterationExtend, distance, FrameSelection::DirectionUp,
         UserTriggered, FrameSelection::AlignCursorOnScrollAlways);
 }
 
 static bool executeMoveRight(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    return frame->selection()->modify(FrameSelection::AlterationMove, DirectionRight, CharacterGranularity, UserTriggered);
+    return frame->selection().modify(FrameSelection::AlterationMove, DirectionRight, CharacterGranularity, UserTriggered);
 }
 
 static bool executeMoveRightAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionRight, CharacterGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionRight, CharacterGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfDocument(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, DocumentBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfDocumentAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, DocumentBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfLineAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, ParagraphBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfParagraphAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfSentence(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, SentenceBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToBeginningOfSentenceAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, SentenceBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfDocument(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, DocumentBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfDocumentAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, DocumentBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, DocumentBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfSentence(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, SentenceBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfSentenceAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, SentenceBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, SentenceBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfLineAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, ParagraphBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToEndOfParagraphAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveParagraphBackwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, ParagraphGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveParagraphForwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, ParagraphGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveUp(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    return frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, LineGranularity, UserTriggered);
+    return frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, LineGranularity, UserTriggered);
 }
 
 static bool executeMoveUpAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, LineGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, LineGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordBackward(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionBackward, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordBackwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordForward(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionForward, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordForwardAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionForward, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionForward, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordLeft(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionLeft, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionLeft, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordLeftAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionLeft, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionLeft, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordRight(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionRight, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionRight, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveWordRightAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionRight, WordGranularity, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionRight, WordGranularity, UserTriggered);
     return true;
 }
 
 static bool executeMoveToLeftEndOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionLeft, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionLeft, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToLeftEndOfLineAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionLeft, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionLeft, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToRightEndOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationMove, DirectionRight, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationMove, DirectionRight, LineBoundary, UserTriggered);
     return true;
 }
 
 static bool executeMoveToRightEndOfLineAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->modify(FrameSelection::AlterationExtend, DirectionRight, LineBoundary, UserTriggered);
+    frame->selection().modify(FrameSelection::AlterationExtend, DirectionRight, LineBoundary, UserTriggered);
     return true;
 }
 
@@ -1005,7 +1005,7 @@ static bool executeScrollToEndOfDocument(Frame* frame, Event*, EditorCommandSour
 
 static bool executeSelectAll(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->selectAll();
+    frame->selection().selectAll();
     return true;
 }
 
@@ -1032,7 +1032,7 @@ static bool executeSelectToMark(Frame* frame, Event*, EditorCommandSource, const
         systemBeep();
         return false;
     }
-    frame->selection()->setSelectedRange(unionDOMRanges(mark.get(), selection.get()).get(), DOWNSTREAM, true);
+    frame->selection().setSelectedRange(unionDOMRanges(mark.get(), selection.get()).get(), DOWNSTREAM, true);
     return true;
 }
 
@@ -1043,7 +1043,7 @@ static bool executeSelectWord(Frame* frame, Event*, EditorCommandSource, const S
 
 static bool executeSetMark(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->editor().setMark(frame->selection()->selection());
+    frame->editor().setMark(frame->selection().selection());
     return true;
 }
 
@@ -1078,12 +1078,12 @@ static bool executeSuperscript(Frame* frame, Event*, EditorCommandSource source,
 static bool executeSwapWithMark(Frame* frame, Event*, EditorCommandSource, const String&)
 {
     const VisibleSelection& mark = frame->editor().mark();
-    const VisibleSelection& selection = frame->selection()->selection();
+    const VisibleSelection& selection = frame->selection().selection();
     if (mark.isNone() || selection.isNone()) {
         systemBeep();
         return false;
     }
-    frame->selection()->setSelection(mark);
+    frame->selection().setSelection(mark);
     frame->editor().setMark(selection);
     return true;
 }
@@ -1137,7 +1137,7 @@ static bool executeUnscript(Frame* frame, Event*, EditorCommandSource source, co
 
 static bool executeUnselect(Frame* frame, Event*, EditorCommandSource, const String&)
 {
-    frame->selection()->clear();
+    frame->selection().clear();
     return true;
 }
 
@@ -1267,7 +1267,7 @@ static bool enabledInEditableTextOrCaretBrowsing(Frame* frame, Event* event, Edi
 
 static bool enabledInRichlyEditableText(Frame* frame, Event*, EditorCommandSource)
 {
-    return frame->selection()->isCaretOrRange() && frame->selection()->isContentRichlyEditable() && frame->selection()->rootEditableElement();
+    return frame->selection().isCaretOrRange() && frame->selection().isContentRichlyEditable() && frame->selection().rootEditableElement();
 }
 
 static bool enabledPaste(Frame* frame, Event*, EditorCommandSource)
@@ -1277,12 +1277,12 @@ static bool enabledPaste(Frame* frame, Event*, EditorCommandSource)
 
 static bool enabledRangeInEditableText(Frame* frame, Event*, EditorCommandSource)
 {
-    return frame->selection()->isRange() && frame->selection()->isContentEditable();
+    return frame->selection().isRange() && frame->selection().isContentEditable();
 }
 
 static bool enabledRangeInRichlyEditableText(Frame* frame, Event*, EditorCommandSource)
 {
-    return frame->selection()->isRange() && frame->selection()->isContentRichlyEditable();
+    return frame->selection().isRange() && frame->selection().isContentRichlyEditable();
 }
 
 static bool enabledRedo(Frame* frame, Event*, EditorCommandSource)
@@ -1436,7 +1436,7 @@ static String valueForeColor(Frame* frame, Event*)
 
 static String valueFormatBlock(Frame* frame, Event*)
 {
-    const VisibleSelection& selection = frame->selection()->selection();
+    const VisibleSelection& selection = frame->selection().selection();
     if (!selection.isNonOrphanedCaretOrRange() || !selection.isContentEditable())
         return "";
     Element* formatBlockElement = FormatBlockCommand::elementForFormatBlockCommand(selection.firstRange().get());
index 61c54a43e48a556195c7b0a56234bc2472b31c83..291c4398adfe6b105416a2ce7e6d3ad8b929c56d 100644 (file)
@@ -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);
     }
 }
 
index 34b462207b852102eae8b28c71ac10114ef04ffc..1cccb34557fae3277614b97895af74c3b8043708 100644 (file)
@@ -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
index bb087d5acfca0b2af45de7cd0d0d82b64412bfb0..93a4107ef24723be74f444f30f7966925438bff4 100644 (file)
@@ -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());
index be6181ca227e662d07bfb83cdf29910d2cdb9f46..b19b1f2b7acd136dd852562aec613ef70594fae6 100644 (file)
@@ -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)
index 3c417cd05eaf64804c5b13272eae871b501c928c..6134d67232f8de461bb1e01c9eb0c0cc3e2be521 100644 (file)
@@ -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.
index 3912590bcedfe4d2af359d3607fc205e10a36ec3..7192bd3106312621e0ac33718df7807f5590e93a 100644 (file)
@@ -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);
 
index 51ffaf689e009bed4a3117bdebb696d5d991431e..275160974d9190e8cfa40843af4ce615971d3562 100644 (file)
@@ -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
index b741bce2ae1184037b6d0dcd51b90b8c963b6220..a1135e40fcf5daca3fefbec58ddd7b3ef81e5f78 100644 (file)
@@ -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);
index 674fb5c0c83819339af2e97f0c37bf9f237368e6..8234f0a7a992699cf0069b5ed71dcab9bd979593 100644 (file)
@@ -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);
     }
 }
 
index 02f061fc952f51ac18a4339d355632d70a42e0d0..b9598994fb816fb580a3a9e4604a25baa9ce8f0b 100644 (file)
@@ -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)
index b97ae223cbf48489bcc8d8a51305eaf93331de6c..627a0c8fae34f7230a19cc392f5826bcdc42fe8f 100644 (file)
@@ -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.
index 84dc0f27bff30f1dbfaf4cfc945ae4691ad9c238..a1e197044d743716783c79ffe4bb88d63bf44a6b 100644 (file)
@@ -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);
     else
         pasteAsPlainTextWithPasteboard(&pasteboard);   
index 904da27e58fc4216523f2ccbb2b6f27b82b4b93d..373670ecf2ecd23eaa6e7ce20d9d3a8970356009 100644 (file)
@@ -195,8 +195,8 @@ void HTMLAnchorElement::defaultEventHandler(Event* event)
         if (rendererIsEditable()) {
             // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
             // for the LiveWhenNotFocused editable link behavior
-            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
-                setRootEditableElementForSelectionOnMouseDown(document()->frame()->selection()->rootEditableElement());
+            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()->frame()) {
+                setRootEditableElementForSelectionOnMouseDown(document()->frame()->selection().rootEditableElement());
                 m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
             } else if (event->type() == eventNames().mouseoverEvent) {
                 // These are cleared on mouseover and not mouseout because their values are needed for drag events,
@@ -229,7 +229,7 @@ void HTMLAnchorElement::setActive(bool down, bool pause)
             // Don't set the link to be active if the current selection is in the same editable block as
             // this link
             case EditableLinkLiveWhenNotFocused:
-                if (down && document()->frame() && document()->frame()->selection()->rootEditableElement() == rootEditableElement())
+                if (down && document()->frame() && document()->frame()->selection().rootEditableElement() == rootEditableElement())
                     return;
                 break;
             
index 576ca7d014c2a0fc0cf4dfc24aaf8fa395582a01..a43886b8b4aea50499dc2a3f3c1c5b1bcebb2d34 100644 (file)
@@ -413,7 +413,7 @@ void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
         else
             restoreCachedSelection();
         if (document()->frame())
-            document()->frame()->selection()->revealSelection();
+            document()->frame()->selection().revealSelection();
     } else
         HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelection);
 }
index 34f7dffd477774b24c88c716cb02d957c5fc47a3..6658f1a88f276807597a0a2d77abb5515faa5266 100644 (file)
@@ -261,7 +261,7 @@ void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection)
         restoreCachedSelection();
 
     if (document()->frame())
-        document()->frame()->selection()->revealSelection();
+        document()->frame()->selection().revealSelection();
 }
 
 void HTMLTextAreaElement::defaultEventHandler(Event* event)
@@ -310,7 +310,7 @@ void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*
     // If the text field has no focus, we don't need to take account of the
     // selection length. The selection is the source of text drag-and-drop in
     // that case, and nothing in the text field will be removed.
-    unsigned selectionLength = focused() ? computeLengthForSubmission(plainText(document()->frame()->selection()->selection().toNormalizedRange().get())) : 0;
+    unsigned selectionLength = focused() ? computeLengthForSubmission(plainText(document()->frame()->selection().selection().toNormalizedRange().get())) : 0;
     ASSERT(currentLength >= selectionLength);
     unsigned baseLength = currentLength - selectionLength;
     unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0;
index 1452de6ae39d4e017801571b70c068deb3f64b6e..3c96078ae86760a07585955de3955bd2143ccdd6 100644 (file)
@@ -336,7 +336,7 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
     newSelection.setIsDirectional(direction != SelectionHasNoDirection);
 
     if (Frame* frame = document()->frame())
-        frame->selection()->setSelection(newSelection);
+        frame->selection().setSelection(newSelection);
 }
 
 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const
@@ -367,7 +367,7 @@ int HTMLTextFormControlElement::computeSelectionStart() const
     if (!frame)
         return 0;
 
-    return indexForVisiblePosition(frame->selection()->start());
+    return indexForVisiblePosition(frame->selection().start());
 }
 
 int HTMLTextFormControlElement::selectionEnd() const
@@ -386,7 +386,7 @@ int HTMLTextFormControlElement::computeSelectionEnd() const
     if (!frame)
         return 0;
 
-    return indexForVisiblePosition(frame->selection()->end());
+    return indexForVisiblePosition(frame->selection().end());
 }
 
 static const AtomicString& directionString(TextFieldSelectionDirection direction)
@@ -425,7 +425,7 @@ TextFieldSelectionDirection HTMLTextFormControlElement::computeSelectionDirectio
     if (!frame)
         return SelectionHasNoDirection;
 
-    const VisibleSelection& selection = frame->selection()->selection();
+    const VisibleSelection& selection = frame->selection().selection();
     return selection.isDirectional() ? (selection.isBaseFirst() ? SelectionHasForwardDirection : SelectionHasBackwardDirection) : SelectionHasNoDirection;
 }
 
@@ -495,7 +495,7 @@ void HTMLTextFormControlElement::selectionChanged(bool userTriggered)
     cacheSelection(computeSelectionStart(), computeSelectionEnd(), computeSelectionDirection());
 
     if (Frame* frame = document()->frame()) {
-        if (frame->selection()->isRange() && userTriggered)
+        if (frame->selection().isRange() && userTriggered)
             dispatchEvent(Event::create(eventNames().selectEvent, true, false));
     }
 }
index ecc1845baa612b6e9e8cbf1ee18a3a78d37cd8e6..410b104ebc536f2fa422f2ef30ffaa259f1a8153 100644 (file)
@@ -377,7 +377,7 @@ void TextFieldInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*
     // If the text field has no focus, we don't need to take account of the
     // selection length. The selection is the source of text drag-and-drop in
     // that case, and nothing in the text field will be removed.
-    unsigned selectionLength = element()->focused() ? numGraphemeClusters(plainText(element()->document()->frame()->selection()->selection().toNormalizedRange().get())) : 0;
+    unsigned selectionLength = element()->focused() ? numGraphemeClusters(plainText(element()->document()->frame()->selection().selection().toNormalizedRange().get())) : 0;
     ASSERT(oldLength >= selectionLength);
 
     // Selected characters will be removed by the next text event.
index 8728dd60a5c8e4dea463f1d2d456aaf50f010f70..fb4f33ae4d5a9c32487d6575a45f4b8555e39e56 100644 (file)
@@ -590,7 +590,7 @@ void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool
         m_frame->script().clearWindowShell(newDocument->domWindow(), m_frame->document()->inPageCache());
     }
 
-    m_frame->selection()->prepareForDestruction();
+    m_frame->selection().prepareForDestruction();
     m_frame->eventHandler().clear();
     if (clearFrameView && m_frame->view())
         m_frame->view()->clear();
index 295c5dcdc9a8215150f95d2a6933448be99845c8..0c4195534b4f8e0fb93e22fb18181621ee6058a9 100644 (file)
@@ -590,7 +590,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame)
     if (!frame)
         return 0;
     
-    RefPtr<Range> selectionRange = frame->selection()->toNormalizedRange();
+    RefPtr<Range> selectionRange = frame->selection().toNormalizedRange();
     Vector<Node*> nodeList;
     String markupString = frame->documentTypeString() + createMarkup(selectionRange.get(), &nodeList, AnnotateForInterchange);
     
index 9b3ae290c74af16b7cc53e8316d960548ad4eb31..b9dd3174554810a82327ba3120ae2f5549de2064 100644 (file)
@@ -197,7 +197,7 @@ static void openNewWindow(const KURL& urlToLoad, Frame* frame)
 static void insertUnicodeCharacter(UChar character, Frame* frame)
 {
     String text(&character, 1);
-    if (!frame->editor().shouldInsertText(text, frame->selection()->toNormalizedRange().get(), EditorInsertActionTyped))
+    if (!frame->editor().shouldInsertText(text, frame->selection().toNormalizedRange().get(), EditorInsertActionTyped))
         return;
 
     TypingCommand::insertText(frame->document(), text, 0, TypingCommand::TextCompositionNone);
@@ -351,16 +351,16 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
         break;
 #endif
     case ContextMenuItemTagSpellingGuess: {
-        FrameSelection* frameSelection = frame->selection();
-        if (frame->editor().shouldInsertText(item->title(), frameSelection->toNormalizedRange().get(), EditorInsertActionPasted)) {
+        FrameSelection& frameSelection = frame->selection();
+        if (frame->editor().shouldInsertText(item->title(), frameSelection.toNormalizedRange().get(), EditorInsertActionPasted)) {
             Document* document = frame->document();
             ReplaceSelectionCommand::CommandOptions replaceOptions = ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting;
 
             if (frame->editor().behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
-                ASSERT(frameSelection->isCaretOrRange());
-                VisibleSelection wordSelection(frameSelection->base());
+                ASSERT(frameSelection.isCaretOrRange());
+                VisibleSelection wordSelection(frameSelection.base());
                 wordSelection.expandUsingGranularity(WordGranularity);
-                frameSelection->setSelection(wordSelection);
+                frameSelection.setSelection(wordSelection);
             } else {
                 ASSERT(frame->editor().selectedText().length());
                 replaceOptions |= ReplaceSelectionCommand::SelectReplacement;
@@ -368,7 +368,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
 
             RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), replaceOptions);
             applyCommand(command);
-            frameSelection->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
+            frameSelection.revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
         }
         break;
     }
@@ -408,7 +408,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
         // which may make this difficult to implement. Maybe a special case of text-shadow?
         break;
     case ContextMenuItemTagStartSpeaking: {
-        RefPtr<Range> selectedRange = frame->selection()->toNormalizedRange();
+        RefPtr<Range> selectedRange = frame->selection().toNormalizedRange();
         if (!selectedRange || selectedRange->collapsed(IGNORE_EXCEPTION)) {
             Document* document = m_hitTestResult.innerNonSharedNode()->document();
             selectedRange = document->createRange();
@@ -722,7 +722,7 @@ void ContextMenuController::createAndAppendTransformationsSubMenu(ContextMenuIte
 static bool selectionContainsPossibleWord(Frame* frame)
 {
     // Current algorithm: look for a character that's not just a separator.
-    for (TextIterator it(frame->selection()->toNormalizedRange().get()); !it.atEnd(); it.advance()) {
+    for (TextIterator it(frame->selection().toNormalizedRange().get()); !it.atEnd(); it.advance()) {
         int length = it.length();
         for (int i = 0; i < length; ++i)
             if (!(category(it.characterAt(i)) & (Separator_Space | Separator_Line | Separator_Paragraph)))
@@ -950,8 +950,7 @@ void ContextMenuController::populate()
             }
         }
     } else { // Make an editing context menu
-        FrameSelection* selection = frame->selection();
-        bool inPasswordField = selection->isInPasswordField();
+        bool inPasswordField = frame->selection().isInPasswordField();
         if (!inPasswordField) {
             bool haveContextMenuItemsForMisspellingOrGrammer = false;
             bool spellCheckingEnabled = frame->editor().isSpellCheckingEnabledFor(node);
@@ -1207,7 +1206,7 @@ void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const
             break;
         case ContextMenuItemTagIgnoreSpelling:
         case ContextMenuItemTagLearnSpelling:
-            shouldEnable = frame->selection()->isRange();
+            shouldEnable = frame->selection().isRange();
             break;
         case ContextMenuItemTagPaste:
             shouldEnable = frame->editor().canDHTMLPaste() || frame->editor().canPaste();
@@ -1242,7 +1241,7 @@ void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const
             break;
         }
         case ContextMenuItemTagLookUpInDictionary:
-            shouldEnable = frame->selection()->isRange();
+            shouldEnable = frame->selection().isRange();
             break;
         case ContextMenuItemTagCheckGrammarWithSpelling:
             if (frame->editor().isGrammarCheckingEnabled())
index 79c8a1fd0d9e983a92b363642533fc548ae0dd48..db5715a7cb9b195f4dda7366fe42abd92c244afc 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 
 static Node* selectionShadowAncestor(Frame* frame)
 {
-    Node* node = frame->selection()->selection().base().anchorNode();
+    Node* node = frame->selection().selection().base().anchorNode();
     if (!node)
         return 0;
 
@@ -70,7 +70,7 @@ void DOMSelection::clearTreeScope()
 const VisibleSelection& DOMSelection::visibleSelection() const
 {
     ASSERT(m_frame);
-    return m_frame->selection()->selection();
+    return m_frame->selection().selection();
 }
 
 static Position anchorPosition(const VisibleSelection& selection)
@@ -163,7 +163,7 @@ bool DOMSelection::isCollapsed() const
 {
     if (!m_frame || selectionShadowAncestor(m_frame))
         return true;
-    return !m_frame->selection()->isRange();
+    return !m_frame->selection().isRange();
 }
 
 String DOMSelection::type() const
@@ -171,14 +171,14 @@ String DOMSelection::type() const
     if (!m_frame)
         return String();
 
-    FrameSelection* selection = m_frame->selection();
+    FrameSelection& selection = m_frame->selection();
 
     // This is a WebKit DOM extension, incompatible with an IE extension
     // IE has this same attribute, but returns "none", "text" and "control"
     // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx
-    if (selection->isNone())
+    if (selection.isNone())
         return "None";
-    if (selection->isCaret())
+    if (selection.isCaret())
         return "Caret";
     return "Range";
 }
@@ -187,7 +187,7 @@ int DOMSelection::rangeCount() const
 {
     if (!m_frame)
         return 0;
-    return m_frame->selection()->isNone() ? 0 : 1;
+    return m_frame->selection().isNone() ? 0 : 1;
 }
 
 void DOMSelection::collapse(Node* node, int offset, ExceptionCode& ec)
@@ -204,7 +204,7 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionCode& ec)
         return;
 
     // FIXME: Eliminate legacy editing positions
-    m_frame->selection()->moveTo(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
+    m_frame->selection().moveTo(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
 }
 
 void DOMSelection::collapseToEnd(ExceptionCode& ec)
@@ -212,14 +212,14 @@ void DOMSelection::collapseToEnd(ExceptionCode& ec)
     if (!m_frame)
         return;
 
-    const VisibleSelection& selection = m_frame->selection()->selection();
+    const VisibleSelection& selection = m_frame->selection().selection();
 
     if (selection.isNone()) {
         ec = INVALID_STATE_ERR;
         return;
     }
 
-    m_frame->selection()->moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
+    m_frame->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
 }
 
 void DOMSelection::collapseToStart(ExceptionCode& ec)
@@ -227,21 +227,21 @@ void DOMSelection::collapseToStart(ExceptionCode& ec)
     if (!m_frame)
         return;
 
-    const VisibleSelection& selection = m_frame->selection()->selection();
+    const VisibleSelection& selection = m_frame->selection().selection();
 
     if (selection.isNone()) {
         ec = INVALID_STATE_ERR;
         return;
     }
 
-    m_frame->selection()->moveTo(VisiblePosition(selection.start(), DOWNSTREAM));
+    m_frame->selection().moveTo(VisiblePosition(selection.start(), DOWNSTREAM));
 }
 
 void DOMSelection::empty()
 {
     if (!m_frame)
         return;
-    m_frame->selection()->clear();
+    m_frame->selection().clear();
 }
 
 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionCode& ec)
@@ -261,7 +261,7 @@ void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
     VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(baseNode, baseOffset), DOWNSTREAM);
     VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(extentNode, extentOffset), DOWNSTREAM);
 
-    m_frame->selection()->moveTo(visibleBase, visibleExtent);
+    m_frame->selection().moveTo(visibleBase, visibleExtent);
 }
 
 void DOMSelection::setPosition(Node* node, int offset, ExceptionCode& ec)
@@ -277,7 +277,7 @@ void DOMSelection::setPosition(Node* node, int offset, ExceptionCode& ec)
         return;
 
     // FIXME: Eliminate legacy editing positions
-    m_frame->selection()->moveTo(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
+    m_frame->selection().moveTo(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
 }
 
 void DOMSelection::modify(const String& alterString, const String& directionString, const String& granularityString)
@@ -327,7 +327,7 @@ void DOMSelection::modify(const String& alterString, const String& directionStri
     else
         return;
 
-    m_frame->selection()->modify(alter, direction, granularity);
+    m_frame->selection().modify(alter, direction, granularity);
 }
 
 void DOMSelection::extend(Node* node, int offset, ExceptionCode& ec)
@@ -349,7 +349,7 @@ void DOMSelection::extend(Node* node, int offset, ExceptionCode& ec)
         return;
 
     // FIXME: Eliminate legacy editing positions
-    m_frame->selection()->setExtent(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
+    m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
 }
 
 PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec)
@@ -371,7 +371,7 @@ PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec)
         return Range::create(shadowAncestor->document(), container, offset, container, offset);
     }
 
-    const VisibleSelection& selection = m_frame->selection()->selection();
+    const VisibleSelection& selection = m_frame->selection().selection();
     return selection.firstRange();
 }
 
@@ -379,7 +379,7 @@ void DOMSelection::removeAllRanges()
 {
     if (!m_frame)
         return;
-    m_frame->selection()->clear();
+    m_frame->selection().clear();
 }
 
 void DOMSelection::addRange(Range* r)
@@ -389,23 +389,23 @@ void DOMSelection::addRange(Range* r)
     if (!r)
         return;
 
-    FrameSelection* selection = m_frame->selection();
+    FrameSelection& selection = m_frame->selection();
 
-    if (selection->isNone()) {
-        selection->setSelection(VisibleSelection(r));
+    if (selection.isNone()) {
+        selection.setSelection(VisibleSelection(r));
         return;
     }
 
-    RefPtr<Range> range = selection->selection().toNormalizedRange();
+    RefPtr<Range> range = selection.selection().toNormalizedRange();
     if (r->compareBoundaryPoints(Range::START_TO_START, range.get(), IGNORE_EXCEPTION) == -1) {
         // We don't support discontiguous selection. We don't do anything if r and range don't intersect.
         if (r->compareBoundaryPoints(Range::START_TO_END, range.get(), IGNORE_EXCEPTION) > -1) {
             if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_EXCEPTION) == -1)
                 // The original range and r intersect.
-                selection->setSelection(VisibleSelection(r->startPosition(), range->endPosition(), DOWNSTREAM));
+                selection.setSelection(VisibleSelection(r->startPosition(), range->endPosition(), DOWNSTREAM));
             else
                 // r contains the original range.
-                selection->setSelection(VisibleSelection(r));
+                selection.setSelection(VisibleSelection(r));
         }
     } else {
         // We don't support discontiguous selection. We don't do anything if r and range don't intersect.
@@ -413,10 +413,10 @@ void DOMSelection::addRange(Range* r)
         if (r->compareBoundaryPoints(Range::END_TO_START, range.get(), ec) < 1 && !ec) {
             if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_EXCEPTION) == -1)
                 // The original range contains r.
-                selection->setSelection(VisibleSelection(range.get()));
+                selection.setSelection(VisibleSelection(range.get()));
             else
                 // The original range and r intersect.
-                selection->setSelection(VisibleSelection(range->startPosition(), r->endPosition(), DOWNSTREAM));
+                selection.setSelection(VisibleSelection(range->startPosition(), r->endPosition(), DOWNSTREAM));
         }
     }
 }
@@ -426,15 +426,15 @@ void DOMSelection::deleteFromDocument()
     if (!m_frame)
         return;
 
-    FrameSelection* selection = m_frame->selection();
+    FrameSelection& selection = m_frame->selection();
 
-    if (selection->isNone())
+    if (selection.isNone())
         return;
 
     if (isCollapsed())
-        selection->modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity);
+        selection.modify(FrameSelection::AlterationExtend, DirectionBackward, CharacterGranularity);
 
-    RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
+    RefPtr<Range> selectedRange = selection.selection().toNormalizedRange();
     if (!selectedRange)
         return;
 
@@ -448,13 +448,13 @@ bool DOMSelection::containsNode(Node* n, bool allowPartial) const
     if (!m_frame)
         return false;
 
-    FrameSelection* selection = m_frame->selection();
+    FrameSelection& selection = m_frame->selection();
 
-    if (!n || m_frame->document() != n->document() || selection->isNone())
+    if (!n || m_frame->document() != n->document() || selection.isNone())
         return false;
 
     RefPtr<Node> node = n;
-    RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
+    RefPtr<Range> selectedRange = selection.selection().toNormalizedRange();
 
     ContainerNode* parentNode = node->parentNode();
     if (!parentNode || !parentNode->inDocument())
@@ -491,7 +491,7 @@ String DOMSelection::toString()
     if (!m_frame)
         return String();
 
-    return plainText(m_frame->selection()->selection().toNormalizedRange().get());
+    return plainText(m_frame->selection().selection().toNormalizedRange().get());
 }
 
 Node* DOMSelection::shadowAdjustedNode(const Position& position) const
index d3d6898350cc2e7857aa3666922a3d0963a53519..3ee3e135e860a01d27988c316f3a18496df3a1f1 100644 (file)
@@ -164,9 +164,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
     return 0;
 }
 
-bool DragController::dragIsMove(FrameSelection* selection, DragData* dragData)
+bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData)
 {
-    return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && selection->isRange() && !isCopyKeyDown(dragData);
+    return m_documentUnderMouse == m_dragInitiator && selection.isContentEditable() && selection.isRange() && !isCopyKeyDown(dragData);
 }
 
 // FIXME: This method is poorly named.  We're just clearing the selection from the document this drag is exiting.
@@ -429,13 +429,13 @@ DragOperation DragController::operationForLoad(DragData* dragData)
 
 static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, RefPtr<Range>& range, const IntPoint& point)
 {
-    frame->selection()->setSelection(dragCaret);
-    if (frame->selection()->isNone()) {
+    frame->selection().setSelection(dragCaret);
+    if (frame->selection().isNone()) {
         dragCaret = frame->visiblePositionForPoint(point);
-        frame->selection()->setSelection(dragCaret);
+        frame->selection().setSelection(dragCaret);
         range = dragCaret.toNormalizedRange();
     }
-    return !frame->selection()->isNone() && frame->selection()->isContentEditable();
+    return !frame->selection().isNone() && frame->selection().isContentEditable();
 }
 
 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData)
@@ -473,7 +473,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
         Color color = dragData->asColor();
         if (!color.isValid())
             return false;
-        RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange();
+        RefPtr<Range> innerRange = innerFrame->selection().toNormalizedRange();
         RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create();
         style->setProperty(CSSPropertyColor, color.serialized(), false);
         if (!innerFrame->editor().shouldApplyStyle(style.get(), innerRange.get()))
@@ -501,7 +501,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
     VisibleSelection dragCaret = m_page->dragCaretController().caretPosition();
     m_page->dragCaretController().clear();
     RefPtr<Range> range = dragCaret.toNormalizedRange();
-    RefPtr<Element> rootEditableElement = innerFrame->selection()->rootEditableElement();
+    RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableElement();
 
     // For range to be null a WebKit client must have done something bad while
     // manually controlling drag behaviour
@@ -521,7 +521,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
             // NSTextView behavior is to always smart delete on moving a selection,
             // but only to smart insert if the selection granularity is word granularity.
             bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
-            bool smartInsert = smartDelete && innerFrame->selection()->granularity() == WordGranularity && dragData->canSmartReplace();
+            bool smartInsert = smartDelete && innerFrame->selection().granularity() == WordGranularity && dragData->canSmartReplace();
             applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete));
         } else {
             if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) {
@@ -638,7 +638,7 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
 
 Element* DragController::draggableElement(const Frame* sourceFrame, Element* startElement, const IntPoint& dragOrigin, DragState& state) const
 {
-    state.type = (sourceFrame->selection()->contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
+    state.type = (sourceFrame->selection().contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
     if (!startElement)
         return 0;
 
@@ -705,7 +705,7 @@ static void selectElement(Element* element)
 {
     RefPtr<Range> range = element->document()->createRange();
     range->selectNode(element);
-    element->document()->frame()->selection()->setSelection(VisibleSelection(range.get(), DOWNSTREAM));
+    element->document()->frame()->selection().setSelection(VisibleSelection(range.get(), DOWNSTREAM));
 }
 
 static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const IntPoint& dragOrigin, const IntPoint& dragImageOffset, bool isLinkImage)
@@ -726,7 +726,7 @@ static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const Int
 
 static IntPoint dragLocForSelectionDrag(Frame* src)
 {
-    IntRect draggingRect = enclosingIntRect(src->selection()->bounds());
+    IntRect draggingRect = enclosingIntRect(src->selection().bounds());
     int xpos = draggingRect.maxX();
     xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos;
     int ypos = draggingRect.maxY();
@@ -787,16 +787,16 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
     Image* image = getImage(element);
     if (state.type == DragSourceActionSelection) {
         if (!clipboard->hasData()) {
-            RefPtr<Range> selectionRange = src->selection()->toNormalizedRange();
+            RefPtr<Range> selectionRange = src->selection().toNormalizedRange();
             ASSERT(selectionRange);
 
             src->editor().willWriteSelectionToPasteboard(selectionRange.get());
 
-            if (enclosingTextFormControl(src->selection()->start()))
+            if (enclosingTextFormControl(src->selection().start()))
                 clipboard->pasteboard().writePlainText(src->editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);
             else {
                 // FIXME: Could this instead be a helper function in Editor?
-                clipboard->pasteboard().writeSelection(selectionRange.get(), src->editor().smartInsertDeleteEnabled() && src->selection()->granularity() == WordGranularity, src, IncludeImageAltTextForClipboard);
+                clipboard->pasteboard().writeSelection(selectionRange.get(), src->editor().smartInsertDeleteEnabled() && src->selection().granularity() == WordGranularity, src, IncludeImageAltTextForClipboard);
             }
 
             src->editor().didWriteSelectionToPasteboard();
@@ -835,14 +835,14 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
             // on the web page. This includes replacing newlines with spaces.
             clipboard->pasteboard().writeURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), src);
 
-        if (src->selection()->isCaret() && src->selection()->isContentEditable()) {
+        if (src->selection().isCaret() && src->selection().isContentEditable()) {
             // a user can initiate a drag on a link without having any text
             // selected.  In this case, we should expand the selection to
             // the enclosing anchor element
-            Position pos = src->selection()->base();
+            Position pos = src->selection().base();
             Node* node = enclosingAnchorElement(pos);
             if (node)
-                src->selection()->setSelection(VisibleSelection::selectionFromContentsOfNode(node));
+                src->selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
         }
 
         m_client->willPerformDragSourceAction(DragSourceActionLink, dragOrigin, clipboard);
index aeeba187305a0e006fe42af2c32efa80ae072166..c0bdb5d89a125fc111eee64ca426405a462b4793 100644 (file)
@@ -102,7 +102,7 @@ namespace WebCore {
         bool tryDHTMLDrag(DragData*, DragOperation&);
         DragOperation dragOperation(DragData*);
         void cancelDrag();
-        bool dragIsMove(FrameSelection*, DragData*);
+        bool dragIsMove(FrameSelection&, DragData*);
         bool isCopyKeyDown(DragData*);
 
         void mouseMovedIntoDocument(Document*);
index 03e5cd97169b0ecf173eff55f6acb843e555213f..74bf865642f9a0a590700f417e76bffd3a51c3d5 100644 (file)
@@ -429,11 +429,10 @@ void EventHandler::nodeWillBeRemoved(Node* nodeToBeRemoved)
         m_clickNode = 0;
 }
 
-static void setSelectionIfNeeded(FrameSelection* selection, const VisibleSelection& newSelection)
+static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelection& newSelection)
 {
-    ASSERT(selection);
-    if (selection->selection() != newSelection && selection->shouldChangeSelection(newSelection))
-        selection->setSelection(newSelection);
+    if (selection.selection() != newSelection && selection.shouldChangeSelection(newSelection))
+        selection.setSelection(newSelection);
 }
 
 static inline bool dispatchSelectStart(Node* node)
@@ -477,7 +476,7 @@ bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targe
         m_selectionInitiationState = PlacedCaret;
     }
 
-    m_frame->selection()->setNonDirectionalSelectionIfNeeded(selection, granularity);
+    m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granularity);
 
     return true;
 }
@@ -532,7 +531,7 @@ bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR
     if (event.event().button() != LeftButton)
         return false;
 
-    if (m_frame->selection()->isRange())
+    if (m_frame->selection().isRange())
         // A double-click when range is already selected
         // should not change the selection.  So, do not call
         // selectClosestWordFromMouseEvent, but do set
@@ -584,7 +583,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
     // existing selection so we can allow for text dragging.
     if (FrameView* view = m_frame->view()) {
         LayoutPoint vPoint = view->windowToContents(event.event().position());
-        if (!extendSelection && m_frame->selection()->contains(vPoint)) {
+        if (!extendSelection && m_frame->selection().contains(vPoint)) {
             m_mouseDownWasSingleClickInSelection = true;
             return false;
         }
@@ -595,7 +594,7 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
         visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOWNSTREAM);
     Position pos = visiblePos.deepEquivalent();
 
-    VisibleSelection newSelection = m_frame->selection()->selection();
+    VisibleSelection newSelection = m_frame->selection().selection();
     TextGranularity granularity = CharacterGranularity;
 
     if (extendSelection && newSelection.isCaretOrRange()) {
@@ -621,9 +620,9 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
         } else
             newSelection.setExtent(pos);
 
-        if (m_frame->selection()->granularity() != CharacterGranularity) {
-            granularity = m_frame->selection()->granularity();
-            newSelection.expandUsingGranularity(m_frame->selection()->granularity());
+        if (m_frame->selection().granularity() != CharacterGranularity) {
+            granularity = m_frame->selection().granularity();
+            newSelection.expandUsingGranularity(m_frame->selection().granularity());
         }
     } else
         newSelection = expandSelectionToRespectUserSelectAll(innerNode, visiblePos);
@@ -837,7 +836,7 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
     if (!target)
         return;
 
-    VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_frame->selection()->selection(), hitTestResult.localPoint(), target);
+    VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_frame->selection().selection(), hitTestResult.localPoint(), target);
 
     // Don't modify the selection if we're not on a node.
     if (targetPosition.isNull())
@@ -845,7 +844,7 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
 
     // Restart the selection if this is the first mouse move. This work is usually
     // done in handleMousePressEvent, but not if the mouse press was on an existing selection.
-    VisibleSelection newSelection = m_frame->selection()->selection();
+    VisibleSelection newSelection = m_frame->selection().selection();
 
 #if ENABLE(SVG)
     // Special case to limit selection to the containing block for SVG text.
@@ -888,17 +887,17 @@ void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul
     newSelection.setExtent(targetPosition);
 #endif
 
-    if (m_frame->selection()->granularity() != CharacterGranularity)
-        newSelection.expandUsingGranularity(m_frame->selection()->granularity());
+    if (m_frame->selection().granularity() != CharacterGranularity)
+        newSelection.expandUsingGranularity(m_frame->selection().granularity());
 
-    m_frame->selection()->setNonDirectionalSelectionIfNeeded(newSelection, m_frame->selection()->granularity(),
+    m_frame->selection().setNonDirectionalSelectionIfNeeded(newSelection, m_frame->selection().granularity(),
         FrameSelection::AdjustEndpointsAtBidiBoundary);
 }
 #endif // ENABLE(DRAG_SUPPORT)
 
 void EventHandler::lostMouseCapture()
 {
-    m_frame->selection()->setCaretBlinkingSuspended(false);
+    m_frame->selection().setCaretBlinkingSuspended(false);
 }
 
 bool EventHandler::handleMouseUp(const MouseEventWithHitTestResults& event)
@@ -943,7 +942,7 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
 #if ENABLE(DRAG_SUPPORT)
             && m_dragStartPos == event.event().position()
 #endif
-            && m_frame->selection()->isRange()
+            && m_frame->selection().isRange()
             && event.event().button() != RightButton) {
         VisibleSelection newSelection;
         Node* node = event.targetNode();
@@ -958,9 +957,9 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
         handled = true;
     }
 
-    m_frame->selection()->notifyRendererOfSelectionChange(UserTriggered);
+    m_frame->selection().notifyRendererOfSelectionChange(UserTriggered);
 
-    m_frame->selection()->selectFrameElementInParentIfFullySelected();
+    m_frame->selection().selectFrameElementInParentIfFullySelected();
 
     if (event.event().button() == MiddleButton) {
         // Ignore handled, since we want to paste to where the caret was placed anyway.
@@ -1202,7 +1201,7 @@ static bool isSubmitImage(Node* node)
 // Returns true if the node's editable block is not current focused for editing
 static bool nodeIsNotBeingEdited(Node* node, Frame* frame)
 {
-    return frame->selection()->rootEditableElement() != node->rootEditableElement();
+    return frame->selection().rootEditableElement() != node->rootEditableElement();
 }
 
 bool EventHandler::useHandCursor(Node* node, bool isOverLink, bool shiftKey)
@@ -1318,7 +1317,7 @@ OptionalCursor EventHandler::selectCursor(const HitTestResult& result, bool shif
 #if ENABLE(DRAG_SUPPORT)
         && !m_mouseDownMayStartDrag
 #endif
-        && m_frame->selection()->isCaretOrRange() && !m_capturingMouseEventsNode)
+        && m_frame->selection().isCaretOrRange() && !m_capturingMouseEventsNode)
         return iBeam;
 
     if (renderer) {
@@ -1591,7 +1590,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
         }
     }
 
-    m_frame->selection()->setCaretBlinkingSuspended(true);
+    m_frame->selection().setCaretBlinkingSuspended(true);
 
     bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
     m_capturesDragging = !swallowEvent || mev.scrollbar();
@@ -1645,7 +1644,7 @@ bool EventHandler::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEv
 {
     RefPtr<FrameView> protector(m_frame->view());
 
-    m_frame->selection()->setCaretBlinkingSuspended(false);
+    m_frame->selection().setCaretBlinkingSuspended(false);
 
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
 
@@ -1872,7 +1871,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
 {
     RefPtr<FrameView> protector(m_frame->view());
 
-    m_frame->selection()->setCaretBlinkingSuspended(false);
+    m_frame->selection().setCaretBlinkingSuspended(false);
 
 #if ENABLE(TOUCH_EVENTS)
     bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent);
@@ -2387,8 +2386,8 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
                 // node on mouse down if it's selected and inside a focused node. It will be
                 // focused if the user does a mouseup over it, however, because the mouseup
                 // will set a selection inside it, which will call setFocuseNodeIfNeeded.
-                if (m_frame->selection()->isRange()
-                    && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
+                if (m_frame->selection().isRange()
+                    && m_frame->selection().toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
                     && element->isDescendantOf(m_frame->document()->focusedElement()))
                     return true;
                     
@@ -2948,12 +2947,12 @@ bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
     MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportPos, event);
 
     if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick()
-        && !m_frame->selection()->contains(viewportPos)
+        && !m_frame->selection().contains(viewportPos)
         && !mev.scrollbar()
         // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
         // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
         // available for text selections.  But only if we're above text.
-        && (m_frame->selection()->isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) {
+        && (m_frame->selection().isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) {
         m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
         selectClosestWordOrLinkFromMouseEvent(mev);
     }
@@ -2986,11 +2985,11 @@ bool EventHandler::sendContextMenuEventForKey()
     IntPoint location;
 
     Element* focusedElement = doc->focusedElement();
-    FrameSelection* selection = m_frame->selection();
-    Position start = selection->selection().start();
+    FrameSelection& selection = m_frame->selection();
+    Position start = selection.selection().start();
 
-    if (start.deprecatedNode() && (selection->rootEditableElement() || selection->isRange())) {
-        RefPtr<Range> selectionRange = selection->toNormalizedRange();
+    if (start.deprecatedNode() && (selection.rootEditableElement() || selection.isRange())) {
+        RefPtr<Range> selectionRange = selection.toNormalizedRange();
         IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.get());
 
         int x = rightAligned ? firstRect.maxX() : firstRect.x();
@@ -3351,7 +3350,7 @@ static FocusDirection focusDirectionForKey(const AtomicString& keyIdentifier)
     return retVal;
 }
 
-static void handleKeyboardSelectionMovement(FrameSelection* selection, KeyboardEvent* event)
+static void handleKeyboardSelectionMovement(FrameSelection& selection, KeyboardEvent* event)
 {
     if (!event)
         return;
@@ -3388,7 +3387,7 @@ static void handleKeyboardSelectionMovement(FrameSelection* selection, KeyboardE
     }
 
     FrameSelection::EAlteration alternation = event->getModifierState("Shift") ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove;
-    selection->modify(alternation, direction, granularity, UserTriggered);
+    selection.modify(alternation, direction, granularity, UserTriggered);
     event->setDefaultHandled();
 }
 
@@ -3610,7 +3609,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr
         } 
         
         m_mouseDownMayStartDrag = dispatchDragSrcEvent(eventNames().dragstartEvent, m_mouseDown)
-            && !m_frame->selection()->isInPasswordField();
+            && !m_frame->selection().isInPasswordField();
         
         // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
         // image can still be changed as we drag, but not the pasteboard data.
index 8fbdce6a217889df6da4711214a8d0b6b5355cfd..6f60d6b979699f28ff3e2de2e057a5f5c6c434f6 100644 (file)
@@ -190,12 +190,12 @@ void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
 
     // Now that the frame is updated, fire events and update the selection focused states of both frames.
     if (oldFrame && oldFrame->view()) {
-        oldFrame->selection()->setFocused(false);
+        oldFrame->selection().setFocused(false);
         oldFrame->document()->dispatchWindowEvent(Event::create(eventNames().blurEvent, false, false));
     }
 
     if (newFrame && newFrame->view() && isFocused()) {
-        newFrame->selection()->setFocused(true);
+        newFrame->selection().setFocused(true);
         newFrame->document()->dispatchWindowEvent(Event::create(eventNames().focusEvent, false, false));
     }
 
@@ -225,7 +225,7 @@ void FocusController::setFocused(bool focused)
         setFocusedFrame(m_page->mainFrame());
 
     if (m_focusedFrame->view()) {
-        m_focusedFrame->selection()->setFocused(focused);
+        m_focusedFrame->selection().setFocused(focused);
         dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), focused);
     }
 }
@@ -290,7 +290,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
     bool caretBrowsing = frame->settings().caretBrowsingEnabled();
 
     if (caretBrowsing && !currentNode)
-        currentNode = frame->selection()->start().deprecatedNode();
+        currentNode = frame->selection().start().deprecatedNode();
 
     document->updateLayoutIgnorePendingStylesheets();
 
@@ -349,8 +349,8 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
     if (caretBrowsing) {
         Position position = firstPositionInOrBeforeNode(element.get());
         VisibleSelection newSelection(position, position, DOWNSTREAM);
-        if (frame->selection()->shouldChangeSelection(newSelection))
-            frame->selection()->setSelection(newSelection);
+        if (frame->selection().shouldChangeSelection(newSelection))
+            frame->selection().setSelection(newSelection);
     }
 
     element->focus(false, direction);
@@ -564,22 +564,22 @@ static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFram
     if (oldFocusedFrame->document() != newFocusedFrame->document())
         return;
     
-    FrameSelection* s = oldFocusedFrame->selection();
-    if (s->isNone())
+    FrameSelection& selection = oldFocusedFrame->selection();
+    if (selection.isNone())
         return;
 
     bool caretBrowsing = oldFocusedFrame->settings().caretBrowsingEnabled();
     if (caretBrowsing)
         return;
 
-    Node* selectionStartNode = s->selection().start().deprecatedNode();
+    Node* selectionStartNode = selection.selection().start().deprecatedNode();
     if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newFocusedNode)
         return;
         
     if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) {
         if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
             // Don't clear the selection for contentEditable elements, but do clear it for input and textarea. See bug 38696.
-            Node * root = s->rootEditableElement();
+            Node * root = selection.rootEditableElement();
             if (!root)
                 return;
 
@@ -590,7 +590,7 @@ static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFram
         }
     }
     
-    s->clear();
+    selection.clear();
 }
 
 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newFocusedFrame, FocusDirection direction)
@@ -660,7 +660,7 @@ void FocusController::setActive(bool active)
         }
     }
 
-    focusedOrMainFrame()->selection()->pageActivationChanged();
+    focusedOrMainFrame()->selection().pageActivationChanged();
     
     if (m_focusedFrame && isFocused())
         dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), active);
index 414402e3afe7e889d919449fe7ff27b307d8601c..9019a4007f0d9e1eb34143802278075ef82ea39d 100644 (file)
@@ -1097,14 +1097,14 @@ DragImageRef Frame::nodeImage(Node* node)
 
 DragImageRef Frame::dragImageForSelection()
 {
-    if (!selection()->isRange())
+    if (!selection().isRange())
         return 0;
 
     const ScopedFramePaintingState state(this, 0);
     m_view->setPaintBehavior(PaintBehaviorSelectionOnly);
     m_doc->updateLayout();
 
-    IntRect paintingRect = enclosingIntRect(selection()->bounds());
+    IntRect paintingRect = enclosingIntRect(selection().bounds());
 
     float deviceScaleFactor = 1;
     if (m_page)
index 3ab79fe7cf69f7522ab4e4f15e6cde886b8478a3..d67f715dfdeed2b0ae0077a2b80ffc41c64973bb 100644 (file)
@@ -118,7 +118,7 @@ namespace WebCore {
         EventHandler& eventHandler() const;
         FrameLoader& loader() const;
         NavigationScheduler* navigationScheduler() const;
-        FrameSelection* selection() const;
+        FrameSelection& selection() const;
         FrameTree* tree() const;
         AnimationController* animation() const;
         ScriptController& script();
@@ -286,9 +286,9 @@ namespace WebCore {
         return m_doc.get();
     }
 
-    inline FrameSelection* Frame::selection() const
+    inline FrameSelection& Frame::selection() const
     {
-        return m_selection.get();
+        return *m_selection;
     }
 
     inline Editor& Frame::editor() const
index 2ae1aa29ce0783c3cde4df4879b5dbee0f6b433c..302db5994aa61cd75dc1a611af02e3fa39abbbd6 100644 (file)
@@ -2716,8 +2716,8 @@ void FrameView::performPostLayoutTasks()
 {
     m_postLayoutTasksTimer.stop();
 
-    frame().selection()->setCaretRectNeedsUpdate();
-    frame().selection()->updateAppearance();
+    frame().selection().setCaretRectNeedsUpdate();
+    frame().selection().updateAppearance();
 
     LayoutMilestones requestedMilestones = 0;
     LayoutMilestones milestonesAchieved = 0;
@@ -3642,7 +3642,7 @@ void FrameView::paintContentsForSnapshot(GraphicsContext* context, const IntRect
     // Restore selection.
     if (shouldPaintSelection == ExcludeSelection) {
         for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get()))
-            frame->selection()->updateAppearance();
+            frame->selection().updateAppearance();
     }
 
     // Restore cached paint behavior.
index 56be22353c696cf4222ec7fee43618555205f61a..0946da3d227a91d2f163b26a458a2a377edd8b1d 100644 (file)
@@ -573,7 +573,7 @@ bool Page::findString(const String& target, FindOptions options)
     do {
         if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) {
             if (frame != startFrame)
-                startFrame->selection()->clear();
+                startFrame->selection().clear();
             focusController().setFocusedFrame(frame);
             return true;
         }
@@ -582,7 +582,7 @@ bool Page::findString(const String& target, FindOptions options)
 
     // Search contents of startFrame, on the other side of the selection that we did earlier.
     // We cheat a bit and just research with wrap on
-    if (shouldWrap && !startFrame->selection()->isNone()) {
+    if (shouldWrap && !startFrame->selection().isNone()) {
         bool found = startFrame->editor().findString(target, options | WrapAround | StartInSelection);
         focusController().setFocusedFrame(frame);
         return found;
@@ -601,7 +601,7 @@ void Page::findStringMatchingRanges(const String& target, FindOptions options, i
     Frame* frameWithSelection = 0;
     do {
         frame->editor().countMatchesForText(target, 0, options, limit ? (limit - matchRanges->size()) : 0, true, matchRanges);
-        if (frame->selection()->isRange())
+        if (frame->selection().isRange())
             frameWithSelection = frame;
         frame = incrementFrame(frame, true, false);
     } while (frame);
@@ -611,7 +611,7 @@ void Page::findStringMatchingRanges(const String& target, FindOptions options, i
 
     if (frameWithSelection) {
         indexForSelection = NoMatchAfterUserSelection;
-        RefPtr<Range> selectedRange = frameWithSelection->selection()->selection().firstRange();
+        RefPtr<Range> selectedRange = frameWithSelection->selection().selection().firstRange();
         if (options & Backwards) {
             for (size_t i = matchRanges->size(); i > 0; --i) {
                 if (selectedRange->compareBoundaryPoints(Range::END_TO_START, matchRanges->at(i - 1).get(), IGNORE_EXCEPTION) > 0) {
@@ -705,7 +705,7 @@ void Page::unmarkAllTextMatches()
 
 const VisibleSelection& Page::selection() const
 {
-    return focusController().focusedOrMainFrame()->selection()->selection();
+    return focusController().focusedOrMainFrame()->selection().selection();
 }
 
 void Page::setDefersLoading(bool defers)
index ebd586fb5fe198a44a8ddb0a6dce59e4c3e94a4b..dafb1f91bcbd6f0627a61d1e94de9b714a8b5434 100644 (file)
@@ -56,7 +56,7 @@ DragImageRef Frame::nodeImage(Node* node)
 
 DragImageRef Frame::dragImageForSelection()
 {
-    if (!selection()->isRange())
+    if (!selection().isRange())
         return nil;
     return selectionImage(this);
 }
index 70b9c19419aa7da7e44144e633387cd746bb8b48..4c886ebd4643dbe534167d06d931ecc15b02f9aa 100644 (file)
@@ -75,7 +75,7 @@ NSImage* selectionImage(Frame* frame, bool forceBlackText)
 {
     frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
     frame->document()->updateLayout();
-    NSImage* result = imageFromRect(frame, frame->selection()->bounds());
+    NSImage* result = imageFromRect(frame, frame->selection().bounds());
     frame->view()->setPaintBehavior(PaintBehaviorNormal);
     return result;
 }
index aafee76017edff7a253f04a50c49dd652c2355b8..732ca0eb18382ebdc039649a8f3a1220a887723d 100644 (file)
@@ -50,7 +50,7 @@ PassOwnPtr<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
     frame->document()->updateLayout();
 
     frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
-    FloatRect fr = frame->selection()->bounds();
+    FloatRect fr = frame->selection().bounds();
     IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()), static_cast<int>(fr.width()), static_cast<int>(fr.height()));
     OwnPtr<HBITMAP> image = imageFromRect(frame, ir);
     frame->view()->setPaintBehavior(PaintBehaviorNormal);
@@ -59,7 +59,7 @@ PassOwnPtr<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
 
 DragImageRef Frame::dragImageForSelection()
 {
-    if (selection()->isRange())
+    if (selection().isRange())
         return imageFromSelection(this, false).leakPtr();
 
     return 0;
index d93a8aed622421e6d5aff36be2da864935fa5808..b557c887aebf2defef841069ff87fd6b9cbb9cf4 100644 (file)
@@ -384,7 +384,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragmentForPasteboardItemAtInde
             NSURL *url = (NSURL *)value;
 
             if (!frame->editor().client()->hasRichlyEditableSelection()) {
-                fragment = createFragmentFromText(frame->selection()->toNormalizedRange().get(), [url absoluteString]);
+                fragment = createFragmentFromText(frame->selection().toNormalizedRange().get(), [url absoluteString]);
                 if (fragment)
                     return fragment.release();
             }
@@ -414,7 +414,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragmentForPasteboardItemAtInde
             }
 
             chosePlainText = true;
-            fragment = createFragmentFromText(frame->selection()->toNormalizedRange().get(), (NSString*)value);
+            fragment = createFragmentFromText(frame->selection().toNormalizedRange().get(), (NSString*)value);
             if (fragment)
                 return fragment.release();
         }
index c5fadbb95b16b84c03a4f75221c2066a858719e8..051df0092d9c86a87630302a561852ca32653e9f 100644 (file)
@@ -185,7 +185,7 @@ bool HitTestResult::isSelected() const
     if (!frame)
         return false;
 
-    return frame->selection()->contains(m_hitTestLocation.point());
+    return frame->selection().contains(m_hitTestLocation.point());
 }
 
 String HitTestResult::spellingToolTip(TextDirection& dir) const
index 1ab6bc661d0f138c3720acc69359ed8322c76225..feac67fead2d0039a64377b481a9ef156d3642a0 100644 (file)
@@ -3278,8 +3278,8 @@ void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse
     RenderObject* caretPainter;
     bool isContentEditable;
     if (type == CursorCaret) {
-        caretPainter = frame()->selection()->caretRenderer();
-        isContentEditable = frame()->selection()->rendererIsEditable();
+        caretPainter = frame()->selection().caretRenderer();
+        isContentEditable = frame()->selection().rendererIsEditable();
     } else {
         caretPainter = frame()->page()->dragCaretController().caretRenderer();
         isContentEditable = frame()->page()->dragCaretController().isContentEditable();
@@ -3287,7 +3287,7 @@ void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse
 
     if (caretPainter == this && (isContentEditable || caretBrowsing)) {
         if (type == CursorCaret)
-            frame()->selection()->paintCaret(paintInfo.context, paintOffset, paintInfo.rect);
+            frame()->selection().paintCaret(paintInfo.context, paintOffset, paintInfo.rect);
         else
             frame()->page()->dragCaretController().paintDragCaret(frame(), paintInfo.context, paintOffset, paintInfo.rect);
     }
index 5fa2c7fd495e973a74c357ae51c5beebb74b7667..ea19cc2f6daa77e6aeaed1146de6567ca75b8204 100644 (file)
@@ -418,7 +418,7 @@ void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo)
 {
     Document* document = this->document();
     
-    if (document->printing() || !document->frame()->selection()->isFocusedAndActive())
+    if (document->printing() || !document->frame()->selection().isFocusedAndActive())
         return;
     
     if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
index c39c4dc059630163ef1c09c7e56d9bb17131d020..0a1b3b22e2365f2ccc168f8e132f775ed5f06308 100644 (file)
@@ -2236,7 +2236,7 @@ void RenderLayer::scrollTo(int x, int y)
     RenderLayerModelObject* repaintContainer = renderer()->containerForRepaint();
     if (frame) {
         // The caret rect needs to be invalidated after scrolling
-        frame->selection()->setCaretRectNeedsUpdate();
+        frame->selection().setCaretRectNeedsUpdate();
 
         FloatQuad quadForFakeMouseMoveEvent = FloatQuad(m_repaintRect);
         if (repaintContainer)
index 9ab2f075c0f3b7738709e2f310a4fd05eee3b267..9606a1ecae28fcfbf6997158cc55396ae3de30e0 100644 (file)
@@ -413,7 +413,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint&
 
     Color textColor = element->renderStyle() ? element->renderStyle()->visitedDependentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor);
     if (isOptionElement && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
+        if (frame()->selection().isFocusedAndActive() && document()->focusedElement() == node())
             textColor = theme()->activeListBoxSelectionForegroundColor();
         // Honor the foreground color for disabled items
         else if (!element->isDisabledFormControl() && !select->isDisabledFormControl())
@@ -446,7 +446,7 @@ void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint&
 
     Color backColor;
     if (isHTMLOptionElement(element) && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
+        if (frame()->selection().isFocusedAndActive() && document()->focusedElement() == node())
             backColor = theme()->activeListBoxSelectionBackgroundColor();
         else
             backColor = theme()->inactiveListBoxSelectionBackgroundColor();
index 5d170bc526e4506675c5b888b1692261847a6cd9..65e689e4a2f71dab639951e0f086207594ef17ff 100644 (file)
@@ -1632,14 +1632,14 @@ Color RenderObject::selectionBackgroundColor() const
 {
     Color color;
     if (style()->userSelect() != SELECT_NONE) {
-        if (frame()->selection()->shouldShowBlockCursor() && frame()->selection()->isCaret())
+        if (frame()->selection().shouldShowBlockCursor() && frame()->selection().isCaret())
             color = style()->visitedDependentColor(CSSPropertyColor).blendWithWhite();
         else {
             RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
             if (pseudoStyle && pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).isValid())
                 color = pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).blendWithWhite();
             else
-                color = frame()->selection()->isFocusedAndActive() ? theme()->activeSelectionBackgroundColor() : theme()->inactiveSelectionBackgroundColor();
+                color = frame()->selection().isFocusedAndActive() ? theme()->activeSelectionBackgroundColor() : theme()->inactiveSelectionBackgroundColor();
         }
     }
 
@@ -1660,7 +1660,7 @@ Color RenderObject::selectionColor(int colorProperty) const
         if (!color.isValid())
             color = pseudoStyle->visitedDependentColor(CSSPropertyColor);
     } else
-        color = frame()->selection()->isFocusedAndActive() ?
+        color = frame()->selection().isFocusedAndActive() ?
                 theme()->activeSelectionForegroundColor() :
                 theme()->inactiveSelectionForegroundColor();
 
index af5bc1d7263953556528ef36d6ce1887c14b315f..67b4645459238a11fb464b59b8925f50f3ada3c2 100644 (file)
@@ -284,9 +284,9 @@ void RenderTextControlSingleLine::capsLockStateMayHaveChanged()
 
     if (Frame* frame = document()->frame())
         shouldDrawCapsLockIndicator = inputElement()->isPasswordField()
-                                      && frame->selection()->isFocusedAndActive()
-                                      && document()->focusedElement() == node()
-                                      && PlatformKeyboardEvent::currentCapsLockState();
+            && frame->selection().isFocusedAndActive()
+            && document()->focusedElement() == node()
+            && PlatformKeyboardEvent::currentCapsLockState();
 
     if (shouldDrawCapsLockIndicator != m_shouldDrawCapsLockIndicator) {
         m_shouldDrawCapsLockIndicator = shouldDrawCapsLockIndicator;
index 8644de517da48952c232474001501db714690dd1..1a0a9a233ce69351554b4d10dbb4f6de06e7c678 100644 (file)
@@ -799,7 +799,7 @@ bool RenderTheme::isFocused(const RenderObject* o) const
     Element* focusDelegate = toElement(node)->focusDelegate();
     Document* document = focusDelegate->document();
     Frame* frame = document->frame();
-    return focusDelegate == document->focusedElement() && frame && frame->selection()->isFocusedAndActive();
+    return focusDelegate == document->focusedElement() && frame && frame->selection().isFocusedAndActive();
 }
 
 bool RenderTheme::isPressed(const RenderObject* o) const
index 0ae4e4d973fc8c7e63474c864f351d95cc89c9f2..9cec469b3a4b6d11a97cd51433f7d40cbf9affa1 100644 (file)
@@ -919,7 +919,7 @@ void RenderThemeWin::adjustSearchFieldStyle(StyleResolver* styleResolver, Render
     style->setPaddingRight(Length(padding, Fixed));
     style->setPaddingTop(Length(padding, Fixed));
     style->setPaddingBottom(Length(padding, Fixed));
-    if (e && e->focused() && e->document()->frame()->selection()->isFocusedAndActive())
+    if (e && e->focused() && e->document()->frame()->selection().isFocusedAndActive())
         style->setOutlineOffset(-2);
 }
 
index 0f353ec2bd1b72fb3ac6731652522c6e8f01db39..af217b23b25e179a87dd4eb2c1560af0103e16b7 100644 (file)
@@ -849,7 +849,7 @@ static void writeSelection(TextStream& ts, const RenderObject* o)
     if (!frame)
         return;
 
-    VisibleSelection selection = frame->selection()->selection();
+    VisibleSelection selection = frame->selection().selection();
     if (selection.isCaret()) {
         ts << "caret: position " << selection.start().deprecatedEditingOffset() << " of " << nodePosition(selection.start().deprecatedNode());
         if (selection.affinity() == UPSTREAM)
index 0ac0ece6a318ae2fa5259c1eb047afc40c671211..2d8024a9fcaf1c56061cf458df81e3fb759e5b4a 100644 (file)
@@ -752,8 +752,8 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
     if ((start && !end) || (end && !start))
         return;
 
-    bool caretChanged = m_selectionWasCaret != view()->frame()->selection()->isCaret();
-    m_selectionWasCaret = view()->frame()->selection()->isCaret();
+    bool caretChanged = m_selectionWasCaret != view()->frame()->selection().isCaret();
+    m_selectionWasCaret = view()->frame()->selection().isCaret();
     // Just return if the selection hasn't changed.
     if (m_selectionStart == start && m_selectionStartPos == startPos &&
         m_selectionEnd == end && m_selectionEndPos == endPos && !caretChanged)
index e185453d76247ee2b2a0d4d1cbe2a4f2784becf0..f290e8d3f0acb2c602e24fa2184930a1cc5dc66b 100644 (file)
@@ -387,7 +387,7 @@ bool SVGSVGElement::checkEnclosure(SVGElement* element, const FloatRect& rect) c
 void SVGSVGElement::deselectAll()
 {
     if (Frame* frame = document()->frame())
-        frame->selection()->clear();
+        frame->selection().clear();
 }
 
 float SVGSVGElement::createSVGNumber()
index b6aebc6135b64c297d4a337024c864f15c9b8e25..5cccf6a50fddfae195a118969f91457d246519c3 100644 (file)
@@ -195,9 +195,7 @@ void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E
     ASSERT(document());
     ASSERT(document()->frame());
 
-    FrameSelection* selection = document()->frame()->selection();
-    if (!selection)
-        return;
+    FrameSelection& selection = document()->frame()->selection();
 
     // Find selection start
     VisiblePosition start(firstPositionInNode(const_cast<SVGTextContentElement*>(this)));
@@ -209,7 +207,7 @@ void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E
     for (unsigned i = 0; i < nchars; ++i)
         end = end.next();
 
-    selection->setSelection(VisibleSelection(start, end));
+    selection.setSelection(VisibleSelection(start, end));
 }
 
 bool SVGTextContentElement::isSupportedAttribute(const QualifiedName& attrName)
index 80a15a0dbebe1a3ce9fc426e0c9122540f13318c..49033cac0b9dc99abf842d74299f73916f006333 100644 (file)
@@ -768,12 +768,12 @@ void Internals::enableMockSpeechSynthesizer()
 PassRefPtr<ClientRect> Internals::absoluteCaretBounds(ExceptionCode& ec)
 {
     Document* document = contextDocument();
-    if (!document || !document->frame() || !document->frame()->selection()) {
+    if (!document || !document->frame()) {
         ec = INVALID_ACCESS_ERR;
         return ClientRect::create();
     }
 
-    return ClientRect::create(document->frame()->selection()->absoluteCaretBounds());
+    return ClientRect::create(document->frame()->selection().absoluteCaretBounds());
 }
 
 PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionCode& ec)
@@ -2165,12 +2165,12 @@ double Internals::closestTimeToTimeRanges(double time, TimeRanges* ranges)
 PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionCode& ec)
 {
     Document* document = contextDocument();
-    if (!document || !document->frame() || !document->frame()->selection()) {
+    if (!document || !document->frame()) {
         ec = INVALID_ACCESS_ERR;
         return ClientRect::create();
     }
 
-    return ClientRect::create(document->frame()->selection()->bounds());
+    return ClientRect::create(document->frame()->selection().bounds());
 }
 
 #if ENABLE(VIBRATION)
index 7aacdebdf9ecfae5fb220fb8609746bc0591f043..08bee13ce02fb25a5a28765a90e635781d559350 100644 (file)
@@ -397,7 +397,7 @@ bool InRegionScrollerPrivate::setLayerScrollPosition(RenderLayer* layer, const I
         layer->scrollToOffset(toIntSize(scrollPosition));
     }
 
-    layer->renderer()->frame()->selection()->updateAppearance();
+    layer->renderer()->frame()->selection().updateAppearance();
     // FIXME: We have code in place to handle scrolling and clipping tap highlight
     // on in-region scrolling. As soon as it is fast enough (i.e. we have it backed by
     // a backing store), we can reliably make use of it in the real world.
index 91da59886e165d475da84b7740e819ec16af03f8..eb4baac9f1a7a5f8c6160f85e9f974d2d4335f8c 100644 (file)
@@ -1,3 +1,50 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-16  Pratik Solanki  <psolanki@apple.com>
 
         <https://webkit.org/b/119852> Frame::scriptController() should return a reference
index f357d20da437ec0ff2889412821ac2803fdc9235..ff3960b452ca271d0f352e5eeb61ca677120e69f 100644 (file)
@@ -137,7 +137,7 @@ void DatePickerClient::setValueAndClosePopup(const String& value)
         return;
 
     // We hide caret when we select date input field, restore it when we close date picker.
-    m_element->document()->frame()->selection()->setCaretVisible(true);
+    m_element->document()->frame()->selection().setCaretVisible(true);
 
     // Return -1 if user cancel the selection.
     if (value != "-1")
index ed70fac09bdb7b79c634d8e34254014173118bad..daff2cb9d19b3ef263e2e84bff55ba39883894f3 100644 (file)
@@ -128,10 +128,10 @@ bool InPageSearchManager::findNextString(const String& text, FindOptions findOpt
 
     // If there is any active selection, new search should start from the beginning of it.
     bool startFromSelection = false;
-    VisibleSelection selection = m_webPage->focusedOrMainFrame()->selection()->selection();
+    VisibleSelection selection = m_webPage->focusedOrMainFrame()->selection().selection();
     if (!selection.isNone()) {
         searchStartingPoint = selection.firstRange().get();
-        m_webPage->focusedOrMainFrame()->selection()->clear();
+        m_webPage->focusedOrMainFrame()->selection().clear();
         startFromSelection = true;
     }
 
@@ -235,7 +235,7 @@ void InPageSearchManager::clearTextMatches(bool selectActiveMatchOnClear)
 {
     if (selectActiveMatchOnClear && m_activeMatch.get()) {
         VisibleSelection selection(m_activeMatch.get());
-        m_activeMatch->ownerDocument()->frame()->selection()->setSelection(selection);
+        m_activeMatch->ownerDocument()->frame()->selection().setSelection(selection);
     }
     m_webPage->m_page->unmarkAllTextMatches();
     m_activeMatch = 0;
index 784c4d4a5ee52508c8170d9f18dec03f06bbc1bc..d9562524f8b1e93b39a2ea9e04422b03b424a8d9 100644 (file)
@@ -472,8 +472,8 @@ void InputHandler::focusedNodeChanged()
         // this particular object.
         // Example site: html5demos.com/contentEditable - blur event triggers focus change.
         if (frame == m_webPage->focusedOrMainFrame()
-            && frame->selection()->start().anchorNode()
-            && frame->selection()->start().anchorNode()->isContentEditable()
+            && frame->selection().start().anchorNode()
+            && frame->selection().start().anchorNode()->isContentEditable()
             && !m_elementTouchedIsCrossFrame)
                 return;
     }
@@ -790,7 +790,7 @@ bool InputHandler::shouldRequestSpellCheckingOptionsForPoint(const Platform::Int
 void InputHandler::requestSpellingCheckingOptions(imf_sp_text_t& spellCheckingOptionRequest, WebCore::IntSize& screenOffset, bool shouldMoveDialog)
 {
     // If the caret is no longer active, no message should be sent.
-    if (m_webPage->focusedOrMainFrame()->selection()->selectionType() != VisibleSelection::CaretSelection)
+    if (m_webPage->focusedOrMainFrame()->selection().selectionType() != VisibleSelection::CaretSelection)
         return;
 
     if (!m_currentFocusElement || !m_currentFocusElement->document() || !m_currentFocusElement->document()->frame())
@@ -814,7 +814,7 @@ void InputHandler::requestSpellingCheckingOptions(imf_sp_text_t& spellCheckingOp
 
     // imf_sp_text_t should be generated in pixel viewport coordinates.
     // Caret is in document coordinates.
-    WebCore::IntRect caretRect = m_webPage->focusedOrMainFrame()->selection()->selection().visibleStart().absoluteCaretBounds();
+    WebCore::IntRect caretRect = m_webPage->focusedOrMainFrame()->selection().selection().visibleStart().absoluteCaretBounds();
 
     // Shift from posible iFrame to root view/main frame.
     caretRect = m_webPage->focusedOrMainFrame()->view()->contentsToRootView(caretRect);
@@ -827,7 +827,7 @@ void InputHandler::requestSpellingCheckingOptions(imf_sp_text_t& spellCheckingOp
     if (!shouldMoveDialog) {
         // Calculate the offset for contentEditable since the marker offsets are relative to the node.
         // Get caret selection. Though the spelling markers might no longer exist, if this method is called we can assume the caret was placed on top of a marker earlier.
-        VisibleSelection caretSelection = m_currentFocusElement->document()->frame()->selection()->selection();
+        VisibleSelection caretSelection = m_currentFocusElement->document()->frame()->selection().selection();
         caretSelection = DOMSupport::visibleSelectionForClosestActualWordStart(caretSelection);
         VisiblePosition wordStart = caretSelection.visibleStart();
         VisiblePosition wordEnd = endOfWord(caretSelection.visibleStart());
@@ -888,9 +888,9 @@ void InputHandler::setElementUnfocused(bool refocusOccuring)
             m_currentFocusElement->renderer()->repaint();
 
         // If the frame selection isn't focused, focus it.
-        FrameSelection* frameSelection = m_currentFocusElement->document()->frame()->selection();
-        if (frameSelection && !frameSelection->isFocused())
-            frameSelection->setFocused(true);
+        FrameSelection& frameSelection = m_currentFocusElement->document()->frame()->selection();
+        if (!frameSelection.isFocused())
+            frameSelection.setFocused(true);
     }
 
     // Cancel any preexisting spellcheck requests.
@@ -927,8 +927,8 @@ void InputHandler::setInputModeEnabled(bool active)
     if (isInputModeEnabled()
         && isActiveTextEdit()
         && DOMSupport::isElementAndDocumentAttached(m_currentFocusElement.get())
-        && !m_currentFocusElement->document()->frame()->selection()->isFocused())
-        m_currentFocusElement->document()->frame()->selection()->setFocused(true);
+        && !m_currentFocusElement->document()->frame()->selection().isFocused())
+        m_currentFocusElement->document()->frame()->selection().setFocused(true);
 }
 
 void InputHandler::updateFormState()
@@ -1133,8 +1133,8 @@ void InputHandler::setElementFocused(Element* element)
     if (!frame)
         return;
 
-    if (frame->selection()->isFocused() != isInputModeEnabled())
-        frame->selection()->setFocused(isInputModeEnabled());
+    if (frame->selection().isFocused() != isInputModeEnabled())
+        frame->selection().setFocused(isInputModeEnabled());
 
     // Ensure visible when refocusing.
     // If device does not have physical keyboard, wait to ensure visible until VKB resizes viewport so that both animations are combined into one.
@@ -1284,7 +1284,7 @@ bool InputHandler::openDatePopup(HTMLInputElement* element, BlackBerryInputType
     case BlackBerry::Platform::InputTypeDateTimeLocal:
     case BlackBerry::Platform::InputTypeMonth: {
         // Date input have button appearance, we hide caret when they get clicked.
-        element->document()->frame()->selection()->setCaretVisible(false);
+        element->document()->frame()->selection().setCaretVisible(false);
 
         WTF::String value = element->value();
         WTF::String min = element->getAttribute(HTMLNames::minAttr).string();
@@ -1385,16 +1385,16 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
         return;
 
     WebCore::IntRect selectionFocusRect;
-    switch (elementFrame->selection()->selectionType()) {
+    switch (elementFrame->selection().selectionType()) {
     case VisibleSelection::CaretSelection:
-        selectionFocusRect = elementFrame->selection()->absoluteCaretBounds();
+        selectionFocusRect = elementFrame->selection().absoluteCaretBounds();
         break;
     case VisibleSelection::RangeSelection: {
         Position selectionPosition;
         if (m_webPage->m_selectionHandler->lastUpdatedEndPointIsValid())
-            selectionPosition = elementFrame->selection()->end();
+            selectionPosition = elementFrame->selection().end();
         else
-            selectionPosition = elementFrame->selection()->start();
+            selectionPosition = elementFrame->selection().start();
         selectionFocusRect = VisiblePosition(selectionPosition).absoluteCaretBounds();
         break;
     }
@@ -1446,7 +1446,7 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
     }
 
     bool shouldConstrainScrollingToContentEdge = true;
-    Position start = elementFrame->selection()->start();
+    Position start = elementFrame->selection().start();
     if (start.anchorNode() && start.anchorNode()->renderer()) {
         if (RenderLayer* layer = start.anchorNode()->renderer()->enclosingLayer()) {
             // Screen rect after the required zoom.
@@ -1678,7 +1678,7 @@ int InputHandler::selectionPosition(bool start) const
         return start ? controlElement->selectionStart() : controlElement->selectionEnd();
 
     FrameSelection caretSelection;
-    caretSelection.setSelection(m_currentFocusElement->document()->frame()->selection()->selection());
+    caretSelection.setSelection(m_currentFocusElement->document()->frame()->selection().selection());
     RefPtr<Range> rangeSelection = caretSelection.selection().toNormalizedRange();
     if (!rangeSelection)
         return 0;
@@ -1752,7 +1752,7 @@ bool InputHandler::setSelection(int start, int end, bool changeIsPartOfCompositi
     ProcessingChangeGuard guard(this);
 
     VisibleSelection newSelection = DOMSupport::visibleSelectionForRangeInputElement(m_currentFocusElement.get(), start, end);
-    m_currentFocusElement->document()->frame()->selection()->setSelection(newSelection, changeIsPartOfComposition ? 0 : FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
+    m_currentFocusElement->document()->frame()->selection().setSelection(newSelection, changeIsPartOfComposition ? 0 : FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
 
     InputLog(Platform::LogLevelInfo,
         "InputHandler::setSelection selectionStart=%u, selectionEnd=%u",
@@ -1889,7 +1889,7 @@ bool InputHandler::deleteSelection()
     ASSERT(m_currentFocusElement->document() && m_currentFocusElement->document()->frame());
     Frame* frame = m_currentFocusElement->document()->frame();
 
-    if (frame->selection()->selectionType() != VisibleSelection::RangeSelection)
+    if (frame->selection().selectionType() != VisibleSelection::RangeSelection)
         return false;
 
     ASSERT(frame->editor());
@@ -2602,7 +2602,7 @@ bool InputHandler::setRelativeCursorPosition(int insertionPoint, int relativeCur
 
     // 1 place cursor at end of insertion text.
     if (relativeCursorPosition == 1) {
-        m_currentFocusElement->document()->frame()->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
+        m_currentFocusElement->document()->frame()->selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
         return true;
     }
 
index aaa5e1ec5462f1f5c0ab6fecfb88b01ecb758395..6b3e7e85857f7e37f8f3dba830dc76574afe1a46 100644 (file)
@@ -100,7 +100,7 @@ void SelectionHandler::cancelSelection()
     if (m_webPage->m_inputHandler->isInputMode())
         m_webPage->m_inputHandler->cancelSelection();
     else
-        m_webPage->focusedOrMainFrame()->selection()->clear();
+        m_webPage->focusedOrMainFrame()->selection().clear();
 }
 
 BlackBerry::Platform::String SelectionHandler::selectedText() const
@@ -218,7 +218,7 @@ bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPo
     if (point == DOMSupport::InvalidPoint)
         return true;
 
-    VisibleSelection currentSelection = m_webPage->focusedOrMainFrame()->selection()->selection();
+    VisibleSelection currentSelection = m_webPage->focusedOrMainFrame()->selection().selection();
 
     // If the input field is single line or we are on the first or last
     // line of a multiline input field only horizontal movement is supported.
@@ -256,9 +256,9 @@ void SelectionHandler::setCaretPosition(const WebCore::IntPoint& position)
         Platform::IntPoint(position).toString().c_str());
 
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
-    FrameSelection* controller = focusedFrame->selection();
+    FrameSelection& controller = focusedFrame->selection();
     WebCore::IntPoint relativePoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, position);
-    WebCore::IntRect currentCaretRect = controller->selection().visibleStart().absoluteCaretBounds();
+    WebCore::IntRect currentCaretRect = controller.selection().visibleStart().absoluteCaretBounds();
 
     if (relativePoint == DOMSupport::InvalidPoint || !shouldUpdateSelectionOrCaretForPoint(relativePoint, currentCaretRect)) {
         selectionPositionChanged(true /* forceUpdateWithoutChange */);
@@ -277,12 +277,12 @@ void SelectionHandler::setCaretPosition(const WebCore::IntPoint& position)
     }
 
     VisibleSelection newSelection(focusedFrame->visiblePositionForPoint(relativePoint));
-    if (controller->selection() == newSelection) {
+    if (controller.selection() == newSelection) {
         selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
 
-    controller->setSelection(newSelection);
+    controller.setSelection(newSelection);
 
     SelectionLog(Platform::LogLevelInfo, "SelectionHandler::setCaretPosition point valid, cursor updated");
 }
@@ -372,7 +372,7 @@ unsigned SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, co
     if (!focusedFrame->document()->focusedElement() || !focusedFrame->document()->focusedElement()->renderer())
         return 0;
 
-    VisibleSelection activeSelection = focusedFrame->selection()->selection();
+    VisibleSelection activeSelection = focusedFrame->selection().selection();
 
     WebCore::IntRect caretRect = isStartHandle ? activeSelection.visibleStart().absoluteCaretBounds() : activeSelection.visibleEnd().absoluteCaretBounds();
 
@@ -418,10 +418,10 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
     if (!focusedNode || !focusedNode->renderer())
         return false;
 
-    FrameSelection* controller = focusedFrame->selection();
+    FrameSelection& controller = focusedFrame->selection();
 
-    WebCore::IntRect currentStartCaretRect = controller->selection().visibleStart().absoluteCaretBounds();
-    WebCore::IntRect currentEndCaretRect = controller->selection().visibleEnd().absoluteCaretBounds();
+    WebCore::IntRect currentStartCaretRect = controller.selection().visibleStart().absoluteCaretBounds();
+    WebCore::IntRect currentEndCaretRect = controller.selection().visibleEnd().absoluteCaretBounds();
 
     // Check if the handle movement is valid.
     if (!shouldUpdateSelectionOrCaretForPoint(relativeStart, currentStartCaretRect, true /* startCaret */)
@@ -442,16 +442,16 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
     bool needToInvertDirection = false;
     if (startIsOutsideOfField) {
         character = extendSelectionToFieldBoundary(true /* isStartHandle */, relativeStart, newSelection);
-        if (character && controller->selection().isBaseFirst()) {
+        if (character && controller.selection().isBaseFirst()) {
             // Invert the selection so that the cursor point is at the beginning.
-            controller->setSelection(VisibleSelection(controller->selection().end(), controller->selection().start(), true /* isDirectional */));
+            controller.setSelection(VisibleSelection(controller.selection().end(), controller.selection().start(), true /* isDirectional */));
             needToInvertDirection = true;
         }
     } else if (endIsOutsideOfField) {
         character = extendSelectionToFieldBoundary(false /* isStartHandle */, relativeEnd, newSelection);
-        if (character && !controller->selection().isBaseFirst()) {
+        if (character && !controller.selection().isBaseFirst()) {
             // Reset the selection so that the end is the edit point.
-            controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */));
+            controller.setSelection(VisibleSelection(controller.selection().start(), controller.selection().end(), true /* isDirectional */));
         }
     }
 
@@ -462,11 +462,11 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
         "SelectionHandler::updateOrHandleInputSelection making selection change attempt using key event %d",
         character);
 
-    if (shouldExtendSelectionInDirection(controller->selection(), character))
+    if (shouldExtendSelectionInDirection(controller.selection(), character))
         m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character, Platform::KeyboardEvent::KeyDown, KEYMOD_SHIFT));
 
     if (needToInvertDirection)
-        controller->setSelection(VisibleSelection(controller->selection().extent(), controller->selection().base(), true /* isDirectional */));
+        controller.setSelection(VisibleSelection(controller.selection().extent(), controller.selection().base(), true /* isDirectional */));
 
     // Send the selection changed in case this does not trigger a selection change to
     // ensure the caret position is accurate. This may be a duplicate event.
@@ -480,10 +480,9 @@ void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint e
 
     ASSERT(m_webPage);
     ASSERT(m_webPage->focusedOrMainFrame());
-    ASSERT(m_webPage->focusedOrMainFrame()->selection());
 
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
-    FrameSelection* controller = focusedFrame->selection();
+    FrameSelection& controller = focusedFrame->selection();
 
 #if SHOWDEBUG_SELECTIONHANDLER_TIMING
     m_timer.start();
@@ -517,8 +516,8 @@ void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint e
     WebCore::IntPoint relativeEnd = end;
 
     // Initialize the new start and end of our selection at the current positions.
-    VisiblePosition newStart = controller->selection().visibleStart();
-    VisiblePosition newEnd = controller->selection().visibleEnd();
+    VisiblePosition newStart = controller.selection().visibleStart();
+    VisiblePosition newEnd = controller.selection().visibleEnd();
 
     // We don't return early in the following, so that we can do input field scrolling if the
     // handle is outside the bounds of the field. This can be extended to handle sub-region
@@ -539,7 +538,7 @@ void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint e
 
     VisibleSelection newSelection(newStart, newEnd, true /* isDirectional */);
 
-    if (!controller->selection().isRange())
+    if (!controller.selection().isRange())
         m_webPage->updateSelectionScrollView(newSelection.visibleEnd().deepEquivalent().anchorNode());
 
     if (m_webPage->m_inputHandler->isInputMode()) {
@@ -547,7 +546,7 @@ void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint e
             return;
     }
 
-    if (controller->selection() == newSelection) {
+    if (controller.selection() == newSelection) {
         selectionPositionChanged(true /* forceUpdateWithoutChange */);
         return;
     }
@@ -575,7 +574,7 @@ void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint e
         newSelection = VisibleSelection(newSelection.extent(), newSelection.base());
     }
 
-    controller->setSelection(newSelection);
+    controller.setSelection(newSelection);
     SelectionLog(Platform::LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated.");
 }
 
@@ -639,8 +638,8 @@ WebCore::IntRect SelectionHandler::startCaretViewportRect(const WebCore::IntPoin
     if (!frame)
         return caretRect;
 
-    if (frame->selection()->selectionType() != VisibleSelection::NoSelection) {
-        caretRect = frame->selection()->selection().visibleStart().absoluteCaretBounds();
+    if (frame->selection().selectionType() != VisibleSelection::NoSelection) {
+        caretRect = frame->selection().selection().visibleStart().absoluteCaretBounds();
         caretRect.moveBy(frameOffset);
     }
 
@@ -696,14 +695,14 @@ static bool isInvalidParagraph(const VisiblePosition& pos)
 
 void SelectionHandler::selectNextParagraph()
 {
-    FrameSelection* controller = m_webPage->focusedOrMainFrame()->selection();
+    FrameSelection& controller = m_webPage->focusedOrMainFrame()->selection();
 
-    VisiblePosition startPos = VisiblePosition(controller->start(), controller->affinity());
+    VisiblePosition startPos = VisiblePosition(controller.start(), controller.affinity());
     if (isStartOfLine(startPos) && isEndOfDocument(startPos))
         startPos = startPos.previous(CannotCrossEditingBoundary);
 
     // Find next paragraph end position.
-    VisiblePosition endPos(controller->end(), controller->affinity()); // endPos here indicates the end of current paragraph
+    VisiblePosition endPos(controller.end(), controller.affinity()); // endPos here indicates the end of current paragraph
     endPos = endPos.next(CannotCrossEditingBoundary); // find the start of next paragraph
     while (!isEndOfDocument(endPos) && endPos.isNotNull() && isInvalidParagraph(endPos))
         endPos = endPos.next(CannotCrossEditingBoundary); // go to next position
@@ -712,8 +711,8 @@ void SelectionHandler::selectNextParagraph()
     // Set selection if the paragraph is covered by overlay and endPos is not null.
     if (m_currentAnimationOverlayRegion.extents().bottom() >= endPos.absoluteCaretBounds().maxY() && endPos.isNotNull()) {
         VisibleSelection selection = VisibleSelection(startPos, endPos);
-        selection.setAffinity(controller->affinity());
-        controller->setSelection(selection);
+        selection.setAffinity(controller.affinity());
+        controller.setSelection(selection);
 
         // Stop expansion if reaching the end of page.
         if (isEndOfDocument(endPos))
@@ -844,7 +843,6 @@ void SelectionHandler::setParagraphExpansionScrollMargin(const WebCore::IntSize&
 bool SelectionHandler::expandSelectionToGranularity(Frame* frame, VisibleSelection selection, TextGranularity granularity, bool isInputMode)
 {
     ASSERT(frame);
-    ASSERT(frame->selection());
 
     if (!(selection.start().anchorNode() && selection.start().anchorNode()->isTextNode()))
         return false;
@@ -853,9 +851,9 @@ bool SelectionHandler::expandSelectionToGranularity(Frame* frame, VisibleSelecti
         selection = DOMSupport::visibleSelectionForClosestActualWordStart(selection);
 
     selection.expandUsingGranularity(granularity);
-    selection.setAffinity(frame->selection()->affinity());
+    selection.setAffinity(frame->selection().affinity());
 
-    if (isInputMode && !frame->selection()->shouldChangeSelection(selection))
+    if (isInputMode && !frame->selection().shouldChangeSelection(selection))
         return false;
 
     m_animationOverlayStartPos = selection.visibleStart();
@@ -872,7 +870,7 @@ bool SelectionHandler::expandSelectionToGranularity(Frame* frame, VisibleSelecti
 
     ensureSelectedTextVisible(WebCore::IntPoint(), true /* scroll if needed */);
     drawAnimationOverlay(regionForSelectionQuads(selection), false /* isExpandingOverlayAtConstantRate */, granularity == WordGranularity /* isStartOfSelection */);
-    frame->selection()->setSelection(selection);
+    frame->selection().setSelection(selection);
     if (granularity == ParagraphGranularity)
         findNextAnimationOverlayRegion();
     return true;
@@ -881,7 +879,7 @@ bool SelectionHandler::expandSelectionToGranularity(Frame* frame, VisibleSelecti
 void SelectionHandler::selectObject(const WebCore::IntPoint& location, TextGranularity granularity)
 {
     ASSERT(location.x() >= 0 && location.y() >= 0);
-    ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
+    ASSERT(m_webPage && m_webPage->focusedOrMainFrame());
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
 
     SelectionLog(Platform::LogLevelInfo,
@@ -910,15 +908,15 @@ void SelectionHandler::selectObject(TextGranularity granularity)
     if (!m_webPage->m_inputHandler->isInputMode())
         return;
 
-    ASSERT(m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
+    ASSERT(m_webPage->focusedOrMainFrame());
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
 
     SelectionLog(Platform::LogLevelInfo, "SelectionHandler::selectObject using current selection");
 
-    ASSERT(focusedFrame->selection()->selectionType() != VisibleSelection::NoSelection);
+    ASSERT(focusedFrame->selection().selectionType() != VisibleSelection::NoSelection);
 
     // Use the current selection as the selection point.
-    VisibleSelection selectionOrigin = focusedFrame->selection()->selection();
+    VisibleSelection selectionOrigin = focusedFrame->selection().selection();
 
     // If this is the end of the input field, make sure we select the last word.
     if (m_webPage->m_inputHandler->isCaretAtEndOfText())
@@ -938,20 +936,20 @@ void SelectionHandler::selectObject(Node* node)
 
     m_selectionActive = true;
 
-    ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
+    ASSERT(m_webPage && m_webPage->focusedOrMainFrame());
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
 
     SelectionLog(Platform::LogLevelInfo, "SelectionHandler::selectNode");
 
     VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(node);
     drawAnimationOverlay(regionForSelectionQuads(selection), false /* isExpandingOverlayAtConstantRate */, true /* isStartOfSelection */);
-    focusedFrame->selection()->setSelection(selection);
+    focusedFrame->selection().setSelection(selection);
     m_webPage->updateSelectionScrollView(node);
 }
 
-static TextDirection directionOfEnclosingBlock(FrameSelection* selection)
+static TextDirection directionOfEnclosingBlock(FrameSelection& selection)
 {
-    Node* enclosingBlockNode = enclosingBlock(selection->selection().extent().deprecatedNode());
+    Node* enclosingBlockNode = enclosingBlock(selection.selection().extent().deprecatedNode());
     if (!enclosingBlockNode)
         return LTR;
 
@@ -1162,9 +1160,9 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
         return;
 
     WebCore::IntPoint framePos = m_webPage->frameOffset(frame);
-    if (m_selectionActive && (m_caretActive || frame->selection()->isNone()))
+    if (m_selectionActive && (m_caretActive || frame->selection().isNone()))
         m_selectionActive = false;
-    else if (frame->selection()->isRange())
+    else if (frame->selection().isRange())
         m_selectionActive = true;
     else if (!m_selectionActive)
         return;
@@ -1185,7 +1183,7 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
 
     // Get the text rects from the selections range.
     Vector<FloatQuad> quads;
-    DOMSupport::visibleTextQuads(frame->selection()->selection(), quads);
+    DOMSupport::visibleTextQuads(frame->selection().selection(), quads);
 
     IntRectRegion unclippedRegion;
     regionForTextQuads(quads, unclippedRegion, false /* shouldClipToVisibleContent */);
@@ -1203,8 +1201,8 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
         WebCore::IntRect unclippedStartCaret;
         WebCore::IntRect unclippedEndCaret;
 
-        WebCore::IntPoint startCaretReferencePoint = referencePoint(frame->selection()->selection().visibleStart(), unclippedRegion.extents(), framePos, true /* isStartCaret */, isRTL);
-        WebCore::IntPoint endCaretReferencePoint = referencePoint(frame->selection()->selection().visibleEnd(), unclippedRegion.extents(), framePos, false /* isStartCaret */, isRTL);
+        WebCore::IntPoint startCaretReferencePoint = referencePoint(frame->selection().selection().visibleStart(), unclippedRegion.extents(), framePos, true /* isStartCaret */, isRTL);
+        WebCore::IntPoint endCaretReferencePoint = referencePoint(frame->selection().selection().visibleEnd(), unclippedRegion.extents(), framePos, false /* isStartCaret */, isRTL);
 
         adjustCaretRects(unclippedStartCaret, false /* unclipped */, unclippedEndCaret, false /* unclipped */, unclippedRegion.rects(), startCaretReferencePoint, endCaretReferencePoint, isRTL);
 
@@ -1248,9 +1246,9 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
     if (m_webPage->m_selectionOverlay)
         m_webPage->m_selectionOverlay->draw(visibleSelectionRegion);
 
-    VisibleSelection currentSelection = frame->selection()->selection();
+    VisibleSelection currentSelection = frame->selection().selection();
     SelectionDetails details(startCaret, endCaret, visibleSelectionRegion, inputNodeOverridesTouch(),
-        m_lastSelection != currentSelection, requestedSelectionHandlePosition(frame->selection()->selection()), isRTL);
+        m_lastSelection != currentSelection, requestedSelectionHandlePosition(frame->selection().selection()), isRTL);
 
     m_webPage->m_client->notifySelectionDetailsChanged(details);
     m_lastSelection = currentSelection;
@@ -1264,7 +1262,7 @@ void SelectionHandler::notifyCaretPositionChangedIfNeeded(bool userTouchTriggere
 {
     m_didSuppressCaretPositionChangedNotification = false;
 
-    if (m_caretActive || (m_webPage->m_inputHandler->isInputMode() && m_webPage->focusedOrMainFrame()->selection()->isCaret())) {
+    if (m_caretActive || (m_webPage->m_inputHandler->isInputMode() && m_webPage->focusedOrMainFrame()->selection().isCaret())) {
         // This may update the caret to no longer be active.
         caretPositionChanged(userTouchTriggeredOnTextField);
     }
@@ -1283,14 +1281,14 @@ void SelectionHandler::caretPositionChanged(bool userTouchTriggeredOnTextField)
         return;
     }
 
-    ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
+    ASSERT(m_webPage && m_webPage->focusedOrMainFrame());
 
     // This function should only reach this point if input mode is active.
     ASSERT(m_webPage->m_inputHandler->isInputMode());
 
     WebCore::IntRect clippingRectForContent(clippingRectForVisibleContent());
     WebCore::IntPoint frameOffset(m_webPage->frameOffset(m_webPage->focusedOrMainFrame()));
-    if (m_webPage->focusedOrMainFrame()->selection()->selectionType() == VisibleSelection::CaretSelection) {
+    if (m_webPage->focusedOrMainFrame()->selection().selectionType() == VisibleSelection::CaretSelection) {
         caretLocation = startCaretViewportRect(frameOffset);
         if (!caretLocation.isEmpty())
             caretLocation.intersect(clippingRectForContent); // Clip against the containing frame and node boundaries.
@@ -1323,8 +1321,8 @@ void SelectionHandler::caretPositionChanged(bool userTouchTriggeredOnTextField)
 
 bool SelectionHandler::selectionContains(const WebCore::IntPoint& point)
 {
-    ASSERT(m_webPage && m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->selection());
-    return m_webPage->focusedOrMainFrame()->selection()->contains(point);
+    ASSERT(m_webPage && m_webPage->focusedOrMainFrame());
+    return m_webPage->focusedOrMainFrame()->selection().contains(point);
 }
 
 }
index d1f59c08ea851d928c52148859501d3b5f314490..a7a600be60d8b65c5ebaed33dfae48fab243e9cf 100644 (file)
@@ -51,7 +51,7 @@ void SpellingHandler::spellCheckTextBlock(const WebCore::Element* element, WebCo
     if (!(element->document() && element->document()->frame() && element->document()->frame()->selection()))
         return;
 
-    VisiblePosition caretPosition = element->document()->frame()->selection()->start();
+    VisiblePosition caretPosition = element->document()->frame()->selection().start();
     // Expand the range to include the previous line. This should handle cases when the user hits enter to finish composing a word and create a new line.
     // Account for word wrapping by jumping to the start of the previous line, then moving to the start of any word which might be there.
     VisibleSelection visibleSelection = VisibleSelection(
index 9d3cda7c95ab4c6a9c3143b290dc5fc64e0b98a9..13640db7c9af735eadcfaacedc0902508ac8afa9 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-16  Jaehun Lim  <ljaehun.lim@samsung.com>
 
         [EFL] Unreviewed build fix after r154192
index bf504323e78057526530a6219c39e8d787ce7803..c90ce5c31e80227da6d8245296ea7b4228c46c6a 100644 (file)
@@ -200,7 +200,7 @@ WebCore::IntRect DumpRenderTreeSupportEfl::selectionRectangle(const Evas_Object*
 {
     DRT_SUPPORT_FRAME_GET_OR_RETURN(ewkFrame, frame, WebCore::IntRect());
 
-    return enclosingIntRect(frame->selection()->bounds());
+    return enclosingIntRect(frame->selection().bounds());
 }
 
 // Compare with "WebKit/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
@@ -642,7 +642,7 @@ WebCore::IntRect DumpRenderTreeSupportEfl::firstRectForCharacterRange(Evas_Objec
 
     WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
 
-    RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
+    RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     if (!range)
         return WebCore::IntRect();
 
@@ -660,11 +660,11 @@ bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, i
         return false;
 
     WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
-    RefPtr<WebCore::Range> range = frame->selection()->toNormalizedRange().get();
+    RefPtr<WebCore::Range> range = frame->selection().toNormalizedRange().get();
     if (!range)
         return false;
 
-    WebCore::Element* selectionRoot = frame->selection()->rootEditableElement();
+    WebCore::Element* selectionRoot = frame->selection().rootEditableElement();
     WebCore::Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
 
     RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
index a9e7866cc8c86181359c75767f1180a05fb1131e..9653a5d6fda1937f03702878bfa2e0477f44e550 100644 (file)
@@ -295,25 +295,25 @@ bool EditorClientEfl::handleEditingKeyboardEvent(KeyboardEvent* event)
     if (caretBrowsing) {
         switch (keyEvent->windowsVirtualKeyCode()) {
         case VK_LEFT:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                                        DirectionLeft,
                                        keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
                                        UserTriggered);
             return true;
         case VK_RIGHT:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                                        DirectionRight,
                                        keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
                                        UserTriggered);
             return true;
         case VK_UP:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                                        DirectionBackward,
                                        keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
                                        UserTriggered);
             return true;
         case VK_DOWN:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                                        DirectionForward,
                                        keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
                                        UserTriggered);
index b918e28b4002c81878e743a6f6eb2c86437c9e5b..a1fab1a08a745e44e5362b4276c21d2da874ed3e 100644 (file)
@@ -1073,11 +1073,9 @@ Ewk_Text_Selection_Type ewk_frame_text_selection_type_get(const Evas_Object* ewk
     EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, EWK_TEXT_SELECTION_NONE);
     EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, EWK_TEXT_SELECTION_NONE);
 
-    WebCore::FrameSelection* controller = smartData->frame->selection();
-    if (!controller)
-        return EWK_TEXT_SELECTION_NONE;
+    WebCore::FrameSelection& controller = smartData->frame->selection();
 
-    return static_cast<Ewk_Text_Selection_Type>(controller->selectionType());
+    return static_cast<Ewk_Text_Selection_Type>(controller.selectionType());
 }
 
 /* internal methods ****************************************************/
index f4b0a8706057668fc7c3d7d9297ecb06fec51a6e..05f0c6411b9b104f6182d1fb7fcd2edc9112618a 100644 (file)
@@ -1,3 +1,26 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-17  Darin Adler  <darin@apple.com>
 
         <https://webkit.org/b/119941> Make Page::dragController return a reference
index 3c67f8baeeebdaea83699a43f8a7f378d915672e..0bc807a75dc8d43e99a9786a1f3ca305fe78f1e6 100644 (file)
@@ -625,7 +625,7 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*)
     // the selection changing.
     Frame* focusedFrame = core(m_webView)->focusController().focusedOrMainFrame();
     if (focusedFrame && focusedFrame->editor().canEdit())
-        m_webView->priv->imFilter.setCursorRect(frame->selection()->absoluteCaretBounds());
+        m_webView->priv->imFilter.setCursorRect(frame->selection().absoluteCaretBounds());
 }
 
 void ChromeClient::forcePaint()
index 354af6783dc1a35ee722bfee715a81fd9696787e..8b06921f999ffa6d7c560e0b3206bdd315091ae1 100644 (file)
@@ -393,7 +393,7 @@ bool DumpRenderTreeSupportGtk::firstRectForCharacterRange(WebKitWebView* webView
 
     Editor& editor = frame->editor();
 
-    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
+    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
     if (!range)
         return false;
 
@@ -410,11 +410,11 @@ bool DumpRenderTreeSupportGtk::selectedRange(WebKitWebView* webView, int* start,
     if (!frame)
         return false;
 
-    RefPtr<Range> range = frame->selection()->toNormalizedRange().get();
+    RefPtr<Range> range = frame->selection().toNormalizedRange().get();
     if (!range)
         return false;
 
-    Element* selectionRoot = frame->selection()->rootEditableElement();
+    Element* selectionRoot = frame->selection().rootEditableElement();
     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
 
     RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
@@ -531,7 +531,7 @@ void DumpRenderTreeSupportGtk::rectangleForSelection(WebKitWebFrame* frame, cair
     if (!coreFrame)
         return;
 
-    IntRect bounds = enclosingIntRect(coreFrame->selection()->bounds());
+    IntRect bounds = enclosingIntRect(coreFrame->selection().bounds());
     rectangle->x = bounds.x();
     rectangle->y = bounds.y();
     rectangle->width = bounds.width();
index 497278d3fe810d2a3a16887222d0ef2fb302752c..5bc03f5b62bec661b3d4b74aa8dbb38049040ccf 100644 (file)
@@ -216,7 +216,7 @@ static void collapseSelection(GtkClipboard* clipboard, WebKitWebView* webView)
 
     // Collapse the selection without clearing it
     ASSERT(frame);
-    frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity());
+    frame->selection().setBase(frame->selection().extent(), frame->selection().affinity());
 }
 
 #if PLATFORM(X11)
@@ -230,11 +230,11 @@ static void setSelectionPrimaryClipboardIfNeeded(WebKitWebView* webView)
     WebCore::Page* corePage = core(webView);
     Frame* targetFrame = corePage->focusController().focusedOrMainFrame();
 
-    if (!targetFrame->selection()->isRange())
+    if (!targetFrame->selection().isRange())
         return;
 
     dataObject->clearAll();
-    dataObject->setRange(targetFrame->selection()->toNormalizedRange());
+    dataObject->setRange(targetFrame->selection().toNormalizedRange());
 
     viewSettingClipboard = webView;
     GClosure* callback = g_cclosure_new_object(G_CALLBACK(collapseSelection), G_OBJECT(webView));
index 06b2ea8f494b56d2d8bdf6294ba34160e189a1ae..261c636155424e36766c76e24b370b68833d91ab 100644 (file)
@@ -1155,10 +1155,10 @@ WebKitDOMRange* webkit_web_frame_get_range_for_word_around_caret(WebKitWebFrame*
     g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0);
 
     Frame* coreFrame = core(frame);
-    FrameSelection* selection = coreFrame->selection();
-    if (selection->isNone() || selection->isRange())
+    FrameSelection& selection = coreFrame->selection();
+    if (selection.isNone() || selection.isRange())
         return 0;
-    VisibleSelection visibleSelection(selection->selection().visibleStart());
+    VisibleSelection visibleSelection(selection.selection().visibleStart());
     visibleSelection.expandUsingGranularity(WordGranularity);
 
     return kit(visibleSelection.firstRange().get());
index 7c4137c08a32ae3e5ddb6c5070a99ba8bbbfdb2e..db4439f2cb2b43e842292faa1ad4637d5e6e7bff 100644 (file)
@@ -427,9 +427,9 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
 static const int gContextMenuMargin = 1;
 static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame)
 {
-    FrameSelection* selection = frame->selection();
-    if (!selection->selection().isNonOrphanedCaretOrRange()
-         || (selection->selection().isCaret() && !selection->selection().isContentEditable())) {
+    FrameSelection& selection = frame->selection();
+    if (!selection.selection().isNonOrphanedCaretOrRange()
+        || (selection.selection().isCaret() && !selection.selection().isContentEditable())) {
         if (Node* focusedNode = getFocusedNode(frame))
             return focusedNode->pixelSnappedBoundingBox().location();
 
@@ -441,7 +441,7 @@ static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame)
     // selection->selection().firstRange can return 0 here, but if that was the case
     // selection->selection().isNonOrphanedCaretOrRange() would have returned false
     // above, so we do not have to check it.
-    IntRect firstRect = frame->editor().firstRectForRange(selection->selection().firstRange().get());
+    IntRect firstRect = frame->editor().firstRectForRange(selection.selection().firstRange().get());
     return IntPoint(firstRect.x(), firstRect.maxY());
 }
 
index fc83a0f1ee0db9507ef6b28fc60c8f72ed49b10f..d1d0c834b906104e2fb4898c1cfae8a939cdc791 100644 (file)
@@ -1,3 +1,59 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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]):
+
 2013-08-17  Darin Adler  <darin@apple.com>
 
         <https://webkit.org/b/119941> Make Page::dragController return a reference
index dded2d92d7baac6c5410919d9925de29dc3819f7..f0e4e7fea1ceb5049ca1388808790dff389cd0c5 100644 (file)
@@ -428,7 +428,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
 {
     bool primary = true;
     if (Frame* frame = core([self webFrame]))
-        primary = frame->selection()->isFocusedAndActive();
+        primary = frame->selection().isFocusedAndActive();
     return primary ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
 }
 
index 1fc6c7e004610403bde8ccbf2c3a186c346c2838..2f6ba07d6224a35d812a0d8fcfc57894db781895 100644 (file)
@@ -413,7 +413,7 @@ WebView *getWebView(WebFrame *webFrame)
     // optimization for common case to avoid creating potentially large selection string
     if ([documentView isKindOfClass:[WebHTMLView class]])
         if (Frame* coreFrame = _private->coreFrame)
-            return coreFrame->selection()->isRange();
+            return coreFrame->selection().isRange();
 
     if ([documentView conformsToProtocol:@protocol(WebDocumentText)])
         return [[documentView selectedString] length] > 0;
@@ -633,18 +633,18 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (DOMRange *)_rangeByAlteringCurrentSelection:(FrameSelection::EAlteration)alteration direction:(SelectionDirection)direction granularity:(TextGranularity)granularity
 {
-    if (_private->coreFrame->selection()->isNone())
+    if (_private->coreFrame->selection().isNone())
         return nil;
 
     FrameSelection selection;
-    selection.setSelection(_private->coreFrame->selection()->selection());
+    selection.setSelection(_private->coreFrame->selection().selection());
     selection.modify(alteration, direction, granularity);
     return kit(selection.toNormalizedRange().get());
 }
 
 - (TextGranularity)_selectionGranularity
 {
-    return _private->coreFrame->selection()->granularity();
+    return _private->coreFrame->selection().granularity();
 }
 
 - (NSRange)_convertToNSRange:(Range *)range
@@ -654,7 +654,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
     size_t location;
     size_t length;
-    if (!TextIterator::getLocationAndLengthFromRange(_private->coreFrame->selection()->rootEditableElementOrDocumentElement(), range, location, length))
+    if (!TextIterator::getLocationAndLengthFromRange(_private->coreFrame->selection().rootEditableElementOrDocumentElement(), range, location, length))
         return NSMakeRange(NSNotFound, 0);
 
     return NSMakeRange(location, length);
@@ -673,7 +673,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     // directly in the document DOM, so serialization is problematic. Our solution is
     // to use the root editable element of the selection start as the positional base.
     // That fits with AppKit's idea of an input context.
-    return TextIterator::rangeFromLocationAndLength(_private->coreFrame->selection()->rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);
+    return TextIterator::rangeFromLocationAndLength(_private->coreFrame->selection().rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);
 }
 
 - (DOMRange *)_convertNSRangeToDOMRange:(NSRange)nsrange
@@ -755,7 +755,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (void)_insertParagraphSeparatorInQuotedContent
 {
-    if (_private->coreFrame->selection()->isNone())
+    if (_private->coreFrame->selection().isNone())
         return;
 
     _private->coreFrame->editor().insertParagraphSeparatorInQuotedContent();
@@ -776,7 +776,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 {
     if (!_private->coreFrame)
         return nil;
-    RefPtr<MutableStylePropertySet> typingStyle = _private->coreFrame->selection()->copyTypingStyle();
+    RefPtr<MutableStylePropertySet> typingStyle = _private->coreFrame->selection().copyTypingStyle();
     if (!typingStyle)
         return nil;
     return kit(typingStyle->ensureCSSStyleDeclaration());
@@ -894,14 +894,14 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (NSRange)_selectedNSRange
 {
-    return [self _convertToNSRange:_private->coreFrame->selection()->toNormalizedRange().get()];
+    return [self _convertToNSRange:_private->coreFrame->selection().toNormalizedRange().get()];
 }
 
 - (void)_selectNSRange:(NSRange)range
 {
     RefPtr<Range> domRange = [self _convertToDOMRange:range];
     if (domRange)
-        _private->coreFrame->selection()->setSelection(VisibleSelection(domRange.get(), SEL_DEFAULT_AFFINITY));
+        _private->coreFrame->selection().setSelection(VisibleSelection(domRange.get(), SEL_DEFAULT_AFFINITY));
 }
 
 - (BOOL)_isDisplayingStandaloneImage
@@ -939,14 +939,14 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
 
 - (void)_replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle
 {
-    if (_private->coreFrame->selection()->isNone() || !fragment)
+    if (_private->coreFrame->selection().isNone() || !fragment)
         return;
     _private->coreFrame->editor().replaceSelectionWithFragment(core(fragment), selectReplacement, smartReplace, matchStyle);
 }
 
 - (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace
 {   
-    DOMDocumentFragment* fragment = kit(createFragmentFromText(_private->coreFrame->selection()->toNormalizedRange().get(), text).get());
+    DOMDocumentFragment* fragment = kit(createFragmentFromText(_private->coreFrame->selection().toNormalizedRange().get(), text).get());
     [self _replaceSelectionWithFragment:fragment selectReplacement:selectReplacement smartReplace:smartReplace matchStyle:YES];
 }
 
index 482b0b3d46b17352da48aba25e2821eae30485d7..f5534fc55b73650d33c4db2f8d516a328283fd51 100644 (file)
@@ -329,7 +329,7 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
 
 - (DOMElement *)currentForm
 {
-    return kit(core([_private->dataSource webFrame])->selection()->currentForm());
+    return kit(core([_private->dataSource webFrame])->selection().currentForm());
 }
 
 - (NSArray *)controlsInForm:(DOMElement *)form
index 1337d3b0dbf58bd00e9f822ebf3a5fe0a62f6428..2ab9b5eac1292128262f8df25e15b1da0b13d803 100644 (file)
@@ -903,7 +903,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
     Frame* coreFrame = core([self _frame]); 
     if (!coreFrame) 
         return NO; 
-    if (coreFrame->selection()->isContentRichlyEditable()) 
+    if (coreFrame->selection().isContentRichlyEditable())
         [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; 
     else 
         [self _pasteAsPlainTextWithPasteboard:pasteboard]; 
@@ -977,7 +977,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
 - (DOMRange *)_selectedRange
 {
     Frame* coreFrame = core([self _frame]);
-    return coreFrame ? kit(coreFrame->selection()->toNormalizedRange().get()) : nil;
+    return coreFrame ? kit(coreFrame->selection().toNormalizedRange().get()) : nil;
 }
 
 - (BOOL)_shouldDeleteRange:(DOMRange *)range
@@ -1790,25 +1790,25 @@ static bool mouseEventIsPartOfClickOrDrag(NSEvent *event)
 - (BOOL)_hasSelection
 {
     Frame* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection()->isRange();
+    return coreFrame && coreFrame->selection().isRange();
 }
 
 - (BOOL)_hasSelectionOrInsertionPoint
 {
     Frame* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection()->isCaretOrRange();
+    return coreFrame && coreFrame->selection().isCaretOrRange();
 }
 
 - (BOOL)_hasInsertionPoint
 {
     Frame* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection()->isCaret();
+    return coreFrame && coreFrame->selection().isCaret();
 }
 
 - (BOOL)_isEditable
 {
     Frame* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection()->isContentEditable();
+    return coreFrame && coreFrame->selection().isContentEditable();
 }
 
 - (BOOL)_transparentBackground
@@ -2551,7 +2551,7 @@ WEBCORE_COMMAND(yankAndSelect)
     COMMAND_PROLOGUE
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+        coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
 }
 
 - (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item
@@ -2660,7 +2660,7 @@ WEBCORE_COMMAND(yankAndSelect)
     
     if (action == @selector(pasteAsRichText:))
         return frame && (frame->editor().canDHTMLPaste()
-            || (frame->editor().canPaste() && frame->selection()->isContentRichlyEditable()));
+            || (frame->editor().canPaste() && frame->selection().isContentRichlyEditable()));
     
     if (action == @selector(performFindPanelAction:))
         return NO;
@@ -2798,7 +2798,7 @@ WEBCORE_COMMAND(yankAndSelect)
         return YES;
 
     Frame* coreFrame = core([self _frame]);
-    bool selectionIsEditable = coreFrame && coreFrame->selection()->isContentEditable();
+    bool selectionIsEditable = coreFrame && coreFrame->selection().isContentEditable();
     bool nextResponderIsInWebView = [nextResponder isKindOfClass:[NSView class]]
         && [nextResponder isDescendantOf:[[[self _webView] mainFrame] frameView]];
 
@@ -3761,12 +3761,12 @@ static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension
 // API when an editable region is not currently focused.
 static BOOL isTextInput(Frame* coreFrame)
 {
-    return coreFrame && !coreFrame->selection()->isNone() && coreFrame->selection()->isContentEditable();
+    return coreFrame && !coreFrame->selection().isNone() && coreFrame->selection().isContentEditable();
 }
 
 static BOOL isInPasswordField(Frame* coreFrame)
 {
-    return coreFrame && coreFrame->selection()->isInPasswordField();
+    return coreFrame && coreFrame->selection().isInPasswordField();
 }
 
 static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
@@ -4232,7 +4232,7 @@ static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
     COMMAND_PROLOGUE
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+        coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
 }
 
 - (NSData *)_selectionStartFontAttributesAsRTF
@@ -5058,7 +5058,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
     if (![[self _webView] smartInsertDeleteEnabled])
         return NO;
     Frame* coreFrame = core([self _frame]);
-    return coreFrame && coreFrame->selection()->granularity() == WordGranularity;
+    return coreFrame && coreFrame->selection().granularity() == WordGranularity;
 }
 
 - (NSEvent *)_mouseDownEvent
@@ -5233,7 +5233,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
     if (!coreFrame)
         return;
 
-    NSRect rect = coreFrame->selection()->bounds();
+    NSRect rect = coreFrame->selection().bounds();
 
     NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
     NSFont *font = [attributes objectForKey:NSFontAttributeName];
@@ -5895,7 +5895,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
         _private->exposeInputContext = exposeInputContext;
         // Let AppKit cache a potentially changed input context.
         // WebCore routinely sets the selection to None when editing, and IMs become unhappy when an input context suddenly turns nil, see bug 26009.
-        if (!coreFrame->selection()->isNone())
+        if (!coreFrame->selection().isNone())
             [NSApp updateWindows];
     }
 
@@ -5922,7 +5922,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 {
     if (![self _hasSelection])
         return NSZeroRect;
-    return core([self _frame])->selection()->bounds();
+    return core([self _frame])->selection().bounds();
 }
 
 - (NSArray *)selectionTextRects
@@ -5932,7 +5932,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 
     Vector<FloatRect> list;
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->selection()->getClippedVisibleTextRectangles(list);
+        coreFrame->selection().getClippedVisibleTextRectangles(list);
 
     size_t size = list.size();
 
@@ -5960,7 +5960,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 {
     if (![self _hasSelection])
         return NSZeroRect;
-    return core([self _frame])->selection()->bounds();
+    return core([self _frame])->selection().bounds();
 }
 
 - (NSArray *)pasteboardTypesForSelection
@@ -5983,7 +5983,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
 {
     Frame* coreFrame = core([self _frame]);
     if (coreFrame)
-        coreFrame->selection()->selectAll();
+        coreFrame->selection().selectAll();
 }
 
 - (void)deselectAll
@@ -5991,7 +5991,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     Frame* coreFrame = core([self _frame]);
     if (!coreFrame)
         return;
-    coreFrame->selection()->clear();
+    coreFrame->selection().clear();
 }
 
 - (NSString *)string
@@ -6035,7 +6035,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     if (!attributedString) {
         Frame* coreFrame = core([self _frame]);
         if (coreFrame) {
-            RefPtr<Range> range = coreFrame->selection()->selection().toNormalizedRange();
+            RefPtr<Range> range = coreFrame->selection().selection().toNormalizedRange();
             attributedString = [WebHTMLConverter editingAttributedStringFromRange:range.get()];
         }
     }
index 4d76dbdbfe774fe9fdb8dba1139992baf66d621c..53ea018c815c9581562558e733f8ebb5a821a05a 100644 (file)
@@ -171,7 +171,7 @@ using namespace WebCore;
 
         // Get preceeding word stem
         WebFrame *frame = [_htmlView _frame];
-        DOMRange *selection = kit(core(frame)->selection()->toNormalizedRange().get());
+        DOMRange *selection = kit(core(frame)->selection().toNormalizedRange().get());
         DOMRange *wholeWord = [frame _rangeByAlteringCurrentSelection:FrameSelection::AlterationExtend
             direction:DirectionBackward granularity:WordGranularity];
         DOMRange *prefix = [wholeWord cloneRange];
index a23568d0de30e6d36b34c9f8ffb6c374796f9dbf..0e429da41f28c5d4d3e6ee39d9dffad8d260b95f 100644 (file)
@@ -5446,7 +5446,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
         return;
 
     if (range == nil)
-        coreFrame->selection()->clear();
+        coreFrame->selection().clear();
     else {
         // Derive the frame to use from the range passed in.
         // Using _selectedOrMainFrame could give us a different document than
@@ -5455,7 +5455,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
         if (!coreFrame)
             return;
 
-        coreFrame->selection()->setSelectedRange(core(range), core(selectionAffinity), true);
+        coreFrame->selection().setSelectedRange(core(range), core(selectionAffinity), true);
     }
 }
 
@@ -5464,7 +5464,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
     Frame* coreFrame = core([self _selectedOrMainFrame]);
     if (!coreFrame)
         return nil;
-    return kit(coreFrame->selection()->toNormalizedRange().get());
+    return kit(coreFrame->selection().toNormalizedRange().get());
 }
 
 - (NSSelectionAffinity)selectionAffinity
@@ -5472,7 +5472,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
     Frame* coreFrame = core([self _selectedOrMainFrame]);
     if (!coreFrame)
         return NSSelectionAffinityDownstream;
-    return kit(coreFrame->selection()->affinity());
+    return kit(coreFrame->selection().affinity());
 }
 
 - (void)setEditable:(BOOL)flag
@@ -5487,7 +5487,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
                 mainFrame->editor().applyEditingStyleToBodyElement();
                 // If the WebView is made editable and the selection is empty, set it to something.
                 if (![self selectedDOMRange])
-                    mainFrame->selection()->setSelectionFromNone();
+                    mainFrame->selection().setSelectionFromNone();
             }
         }
     }
@@ -5854,7 +5854,7 @@ FOR_EACH_RESPONDER_SELECTOR(FORWARD)
     Frame* coreFrame = core([self _selectedOrMainFrame]);
     if (!coreFrame)
         return NO;
-    return coreFrame->selection()->isCaret();
+    return coreFrame->selection().isCaret();
 }
 
 - (BOOL)_selectionIsAll
@@ -5862,7 +5862,7 @@ FOR_EACH_RESPONDER_SELECTOR(FORWARD)
     Frame* coreFrame = core([self _selectedOrMainFrame]);
     if (!coreFrame)
         return NO;
-    return coreFrame->selection()->isAll(CanCrossEditingBoundary);
+    return coreFrame->selection().isAll(CanCrossEditingBoundary);
 }
 
 - (void)_simplifyMarkup:(DOMNode *)startNode endNode:(DOMNode *)endNode
index 51827dd768deaa7d73b7ae6fe6c1d6d5f6990651..8b4d4a7f88b27ddb673abb3fd9d4dcce5df44edb 100644 (file)
@@ -1,3 +1,25 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-19  Arunprasad Rajkumar  <arurajku@cisco.com>
 
         <https://webkit.org/b/119933> [Qt] Fix tst_QObjectBridge::connectAndDisconnect() fail
index 98f226d50bea5abc3126c33bcadab0b054bd810e..a39b03995cfbb9d044acc6bcf4cf4b0eade0f95d 100644 (file)
@@ -341,9 +341,9 @@ QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter)
 {
     WebCore::Frame* frame = adapter->page->focusController().focusedOrMainFrame();
     QVariantList selectedRange;
-    RefPtr<Range> range = frame->selection()->toNormalizedRange().get();
+    RefPtr<Range> range = frame->selection().toNormalizedRange().get();
 
-    Element* selectionRoot = frame->selection()->rootEditableElement();
+    Element* selectionRoot = frame->selection().rootEditableElement();
     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
 
     RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
@@ -369,7 +369,7 @@ QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter
     if ((location + length < location) && (location + length))
         length = 0;
 
-    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
+    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
 
     if (!range)
         return QVariantList();
index 1c30162d282b9881670bd5a525782db02bc03340..17e6e7d353806882bfedddf3eb3dc21b8c289244 100644 (file)
@@ -203,10 +203,10 @@ void EditorClientQt::respondToChangedSelection(Frame* frame)
 //     selection.formatForDebugger(buffer, sizeof(buffer));
 //     printf("%s\n", buffer);
 
-    if (supportsGlobalSelection() && frame->selection()->isRange()) {
+    if (supportsGlobalSelection() && frame->selection().isRange()) {
         bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
         Pasteboard::generalPasteboard()->setSelectionMode(true);
-        Pasteboard::generalPasteboard()->writeSelection(frame->selection()->toNormalizedRange().get(), frame->editor().canSmartCopyOrDelete(), frame);
+        Pasteboard::generalPasteboard()->writeSelection(frame->selection().toNormalizedRange().get(), frame->editor().canSmartCopyOrDelete(), frame);
         Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
     }
 
@@ -430,7 +430,7 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
     if (!kevent || kevent->type() == PlatformEvent::KeyUp)
         return;
 
-    Node* start = frame->selection()->start().containerNode();
+    Node* start = frame->selection().start().containerNode();
     if (!start)
         return;
 
index 04cf6654e6b9acd660e02b3275ecb981b85410f8..09d992724b8908a589a37220c6999fcc0b97481e 100644 (file)
@@ -354,14 +354,14 @@ bool QWebPageAdapter::hasSelection() const
 {
     Frame* frame = page->focusController().focusedOrMainFrame();
     if (frame)
-        return (frame->selection()->selection().selectionType() != VisibleSelection::NoSelection);
+        return (frame->selection().selection().selectionType() != VisibleSelection::NoSelection);
     return false;
 }
 
 QString QWebPageAdapter::selectedText() const
 {
     Frame* frame = page->focusController().focusedOrMainFrame();
-    if (frame->selection()->selection().selectionType() == VisibleSelection::NoSelection)
+    if (frame->selection().selection().selectionType() == VisibleSelection::NoSelection)
         return QString();
     return frame->editor().selectedText();
 }
@@ -421,10 +421,10 @@ bool QWebPageAdapter::findText(const QString& subString, FindFlag options)
     }
 
     if (subString.isEmpty()) {
-        page->mainFrame()->selection()->clear();
+        page->mainFrame()->selection().clear();
         Frame* frame = page->mainFrame()->tree()->firstChild();
         while (frame) {
-            frame->selection()->clear();
+            frame->selection().clear();
             frame = frame->tree()->traverseNextWithWrap(false);
         }
     }
@@ -626,8 +626,8 @@ void QWebPageAdapter::inputMethodEvent(QInputMethodEvent *ev)
     }
 
     Node* node = 0;
-    if (frame->selection()->rootEditableElement())
-        node = frame->selection()->rootEditableElement()->deprecatedShadowAncestorNode();
+    if (frame->selection().rootEditableElement())
+        node = frame->selection().rootEditableElement()->deprecatedShadowAncestorNode();
 
     Vector<CompositionUnderline> underlines;
     bool hasSelection = false;
@@ -642,9 +642,9 @@ void QWebPageAdapter::inputMethodEvent(QInputMethodEvent *ev)
             break;
         }
         case QInputMethodEvent::Cursor: {
-            frame->selection()->setCaretVisible(a.length); // if length is 0 cursor is invisible
+            frame->selection().setCaretVisible(a.length); // if length is 0 cursor is invisible
             if (a.length > 0) {
-                RenderObject* caretRenderer = frame->selection()->caretRenderer();
+                RenderObject* caretRenderer = frame->selection().caretRenderer();
                 if (caretRenderer) {
                     QColor qcolor = a.value.value<QColor>();
                     caretRenderer->style()->setColor(Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())));
@@ -676,7 +676,7 @@ void QWebPageAdapter::inputMethodEvent(QInputMethodEvent *ev)
     }
 
     if (node && ev->replacementLength() > 0) {
-        int cursorPos = frame->selection()->extent().offsetInContainerNode();
+        int cursorPos = frame->selection().extent().offsetInContainerNode();
         int start = cursorPos + ev->replacementStart();
         if (isHTMLTextFormControlElement(node))
             toHTMLTextFormControlElement(node)->setSelectionRange(start, start + ev->replacementLength());
@@ -706,8 +706,8 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
     RenderObject* renderer = 0;
     RenderTextControl* renderTextControl = 0;
 
-    if (frame->selection()->rootEditableElement())
-        renderer = frame->selection()->rootEditableElement()->deprecatedShadowAncestorNode()->renderer();
+    if (frame->selection().rootEditableElement())
+        renderer = frame->selection().rootEditableElement()->deprecatedShadowAncestorNode()->renderer();
 
     if (renderer && renderer->isTextControl())
         renderTextControl = toRenderTextControl(renderer);
@@ -719,7 +719,7 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
             // We can't access absoluteCaretBounds() while the view needs to layout.
             return QVariant();
         }
-        return QVariant(view->contentsToWindow(frame->selection()->absoluteCaretBounds()));
+        return QVariant(view->contentsToWindow(frame->selection().absoluteCaretBounds()));
     }
     case Qt::ImFont: {
         if (renderTextControl) {
@@ -730,8 +730,8 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
     }
     case Qt::ImCursorPosition: {
         if (editor.hasComposition())
-            return QVariant(frame->selection()->end().offsetInContainerNode());
-        return QVariant(frame->selection()->extent().offsetInContainerNode());
+            return QVariant(frame->selection().end().offsetInContainerNode());
+        return QVariant(frame->selection().extent().offsetInContainerNode());
     }
     case Qt::ImSurroundingText: {
         if (renderTextControl && renderTextControl->textFormControlElement()) {
@@ -745,8 +745,8 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
     }
     case Qt::ImCurrentSelection: {
         if (!editor.hasComposition() && renderTextControl && renderTextControl->textFormControlElement()) {
-            int start = frame->selection()->start().offsetInContainerNode();
-            int end = frame->selection()->end().offsetInContainerNode();
+            int start = frame->selection().start().offsetInContainerNode();
+            int end = frame->selection().end().offsetInContainerNode();
             if (end > start)
                 return QVariant(QString(renderTextControl->textFormControlElement()->value()).mid(start, end - start));
         }
@@ -755,11 +755,11 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
     }
     case Qt::ImAnchorPosition: {
         if (editor.hasComposition())
-            return QVariant(frame->selection()->start().offsetInContainerNode());
-        return QVariant(frame->selection()->base().offsetInContainerNode());
+            return QVariant(frame->selection().start().offsetInContainerNode());
+        return QVariant(frame->selection().base().offsetInContainerNode());
     }
     case Qt::ImMaximumTextLength: {
-        if (frame->selection()->isContentEditable()) {
+        if (frame->selection().isContentEditable()) {
             if (frame->document() && frame->document()->focusedElement()) {
                 if (isHTMLInputElement(frame->document()->focusedElement())) {
                     HTMLInputElement* inputElement = toHTMLInputElement(frame->document()->focusedElement());
index 5142db5e5ae98e572f4da3cae72a946f1d6d5b17..38fd0e18a694fb295b6b6d2b5ec9262d01573efc 100644 (file)
@@ -1,3 +1,27 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-17  Andreas Kling  <akling@apple.com>
 
         Windows build fix after r154219.
index 82f6624094cc9b6a99126ff1c32246724e853d72..90458e422d8bc60ed3bc06e465c6b0549389ebca 100644 (file)
@@ -518,7 +518,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::currentForm(
     *currentForm = 0;
 
     if (Frame* coreFrame = core(this)) {
-        if (HTMLFormElement* formElement = coreFrame->selection()->currentForm())
+        if (HTMLFormElement* formElement = coreFrame->selection().currentForm())
             *currentForm = DOMElement::createInstance(formElement);
     }
 
index 165192f39c7cc2116f3a43512858511a337a0c3d..bf12f72d27e9ab1f4655ee7fe2995fa2cd755022 100644 (file)
@@ -3486,7 +3486,7 @@ HRESULT STDMETHODCALLTYPE WebView::updateFocusedAndActiveState()
     bool active = m_page->focusController().isActive();
     Frame* mainFrame = m_page->mainFrame();
     Frame* focusedFrame = m_page->focusController().focusedOrMainFrame();
-    mainFrame->selection()->setFocused(active && mainFrame == focusedFrame);
+    mainFrame->selection().setFocused(active && mainFrame == focusedFrame);
 
     return S_OK;
 }
@@ -3574,7 +3574,7 @@ HRESULT STDMETHODCALLTYPE WebView::selectionRect(RECT* rc)
     WebCore::Frame* frame = m_page->focusController().focusedOrMainFrame();
 
     if (frame) {
-        IntRect ir = enclosingIntRect(frame->selection()->bounds());
+        IntRect ir = enclosingIntRect(frame->selection().bounds());
         ir = frame->view()->convertToContainingWindow(ir);
         ir.move(-frame->view()->scrollOffset().width(), -frame->view()->scrollOffset().height());
         rc->left = ir.x();
@@ -3734,7 +3734,7 @@ HRESULT STDMETHODCALLTYPE WebView::centerSelectionInVisibleArea(
     if (!coreFrame)
         return E_FAIL;
 
-    coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+    coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
     return S_OK;
 }
 
@@ -4298,7 +4298,7 @@ HRESULT STDMETHODCALLTYPE WebView::styleDeclarationWithText(
 HRESULT STDMETHODCALLTYPE WebView::hasSelectedRange( 
         /* [retval][out] */ BOOL* hasSelectedRange)
 {
-    *hasSelectedRange = m_page->mainFrame()->selection()->isRange();
+    *hasSelectedRange = m_page->mainFrame()->selection().isRange();
     return S_OK;
 }
     
@@ -4387,9 +4387,9 @@ HRESULT STDMETHODCALLTYPE WebView::replaceSelectionWithNode(
 HRESULT STDMETHODCALLTYPE WebView::replaceSelectionWithText( 
         /* [in] */ BSTR text)
 {
-    Position start = m_page->mainFrame()->selection()->selection().start();
+    Position start = m_page->mainFrame()->selection().selection().start();
     m_page->focusController().focusedOrMainFrame()->editor().insertText(toString(text), 0);
-    m_page->mainFrame()->selection()->setBase(start);
+    m_page->mainFrame()->selection().setBase(start);
     return S_OK;
 }
     
@@ -4416,7 +4416,7 @@ HRESULT STDMETHODCALLTYPE WebView::deleteSelection( void)
 
 HRESULT STDMETHODCALLTYPE WebView::clearSelection( void)
 {
-    m_page->focusController().focusedOrMainFrame()->selection()->clear();
+    m_page->focusController().focusedOrMainFrame()->selection().clear();
     return S_OK;
 }
     
@@ -5510,7 +5510,7 @@ void WebView::releaseIMMContext(HIMC hIMC)
 void WebView::prepareCandidateWindow(Frame* targetFrame, HIMC hInputContext) 
 {
     IntRect caret;
-    if (RefPtr<Range> range = targetFrame->selection()->selection().toNormalizedRange()) {
+    if (RefPtr<Range> range = targetFrame->selection().selection().toNormalizedRange()) {
         ExceptionCode ec = 0;
         RefPtr<Range> tempRange = range->cloneRange(ec);
         caret = targetFrame->editor().firstRectForRange(tempRange.get());
@@ -5774,7 +5774,7 @@ LRESULT WebView::onIMERequestCharPosition(Frame* targetFrame, IMECHARPOSITION* c
     if (charPos->dwCharPos && !targetFrame->editor().hasComposition())
         return 0;
     IntRect caret;
-    if (RefPtr<Range> range = targetFrame->editor().hasComposition() ? targetFrame->editor().compositionRange() : targetFrame->selection()->selection().toNormalizedRange()) {
+    if (RefPtr<Range> range = targetFrame->editor().hasComposition() ? targetFrame->editor().compositionRange() : targetFrame->selection().selection().toNormalizedRange()) {
         ExceptionCode ec = 0;
         RefPtr<Range> tempRange = range->cloneRange(ec);
         tempRange->setStart(tempRange->startContainer(ec), tempRange->startOffset(ec) + charPos->dwCharPos, ec);
@@ -5791,7 +5791,7 @@ LRESULT WebView::onIMERequestCharPosition(Frame* targetFrame, IMECHARPOSITION* c
 
 LRESULT WebView::onIMERequestReconvertString(Frame* targetFrame, RECONVERTSTRING* reconvertString)
 {
-    RefPtr<Range> selectedRange = targetFrame->selection()->toNormalizedRange();
+    RefPtr<Range> selectedRange = targetFrame->selection().toNormalizedRange();
     String text = selectedRange->text();
     if (!reconvertString)
         return sizeof(RECONVERTSTRING) + text.length() * sizeof(UChar);
@@ -7045,7 +7045,7 @@ HRESULT STDMETHODCALLTYPE WebView::firstRectForCharacterRangeForTesting(
     if (length > INT_MAX || location + length > INT_MAX)
         length = INT_MAX - location;
         
-    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
+    RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);
 
     if (!range)
         return E_FAIL;
@@ -7077,7 +7077,7 @@ HRESULT STDMETHODCALLTYPE WebView::selectedRangeForTesting(/* [out] */ UINT* loc
 
     size_t locationSize;
     size_t lengthSize;
-    if (range && TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
+    if (range && TextIterator::getLocationAndLengthFromRange(frame->selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
         *location = static_cast<UINT>(locationSize);
         *length = static_cast<UINT>(lengthSize);
     }
index a8df28fa2eb85bdd16fc96765d9bb75152c6d4da..3a1d58c7e7bca8929392e0e5d6c851011f1df8de 100644 (file)
@@ -1,3 +1,15 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * WebCoreSupport/EditorClientWinCE.cpp:
+        (WebKit::EditorClientWinCE::handleEditingKeyboardEvent):
+
 2013-08-15  Anders Carlsson  <andersca@apple.com>
 
         <https://webkit.org/b/119859> Frame::loader() should return a reference
index 3078bd1056883c707a0ed8efc8fd7b5f750267b0..b740a0b83915faf59ef6d6bb6578bc4b7e90e3f1 100644 (file)
@@ -369,25 +369,25 @@ bool EditorClientWinCE::handleEditingKeyboardEvent(KeyboardEvent* event)
     if (caretBrowsing) {
         switch (keyEvent->windowsVirtualKeyCode()) {
         case VK_LEFT:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                     DirectionLeft,
                     keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
                     UserTriggered);
             return true;
         case VK_RIGHT:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                     DirectionRight,
                     keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
                     UserTriggered);
             return true;
         case VK_UP:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                     DirectionBackward,
                     keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
                     UserTriggered);
             return true;
         case VK_DOWN:
-            frame->selection()->modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
+            frame->selection().modify(keyEvent->shiftKey() ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove,
                     DirectionForward,
                     keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
                     UserTriggered);
index 1bae7910778eea56ba07285c898ad1209965af71..eb4bfbbc5f8b94b17d4ff3b8609b8c8b8c5ed424 100644 (file)
@@ -1,3 +1,51 @@
+2013-08-19  Pratik Solanki  <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.
+
+        * 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):
+
 2013-08-18  Darin Adler  <darin@apple.com>
 
         <https://webkit.org/b/119989> Make use of Node::ownerDocument a compile time error
index 9466be6efe407e11dbd61002a509961ab962282e..b19b537799750fa9585ea427c5664a89a817e361 100644 (file)
@@ -206,10 +206,10 @@ void WebEditorClient::respondToChangedSelection(Frame* frame)
 // FIXME: Use this function for other X11-based platforms that need to manually update the global selection.
 void WebEditorClient::updateGlobalSelection(Frame* frame)
 {
-    if (supportsGlobalSelection() && frame->selection()->isRange()) {
+    if (supportsGlobalSelection() && frame->selection().isRange()) {
         bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
         Pasteboard::generalPasteboard()->setSelectionMode(true);
-        Pasteboard::generalPasteboard()->writeSelection(frame->selection()->toNormalizedRange().get(), frame->editor().canSmartCopyOrDelete(), frame);
+        Pasteboard::generalPasteboard()->writeSelection(frame->selection().toNormalizedRange().get(), frame->editor().canSmartCopyOrDelete(), frame);
         Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
     }
 }
index f47545aad5efd0cb36a06443865b43d60ba87911..b0404a5fd72cc1cc16857339132f46f64dfaff5e 100644 (file)
@@ -166,7 +166,7 @@ static void collapseSelection(GtkClipboard* clipboard, Frame* frame)
 
     // Collapse the selection without clearing it.
     ASSERT(frame);
-    frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity());
+    frame->selection().setBase(frame->selection().extent(), frame->selection().affinity());
 }
 #endif
 
@@ -176,11 +176,11 @@ void WebEditorClient::updateGlobalSelection(Frame* frame)
     GtkClipboard* clipboard = PasteboardHelper::defaultPasteboardHelper()->getPrimarySelectionClipboard(frame);
     DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
 
-    if (!frame->selection()->isRange())
+    if (!frame->selection().isRange())
         return;
 
     dataObject->clearAll();
-    dataObject->setRange(frame->selection()->toNormalizedRange());
+    dataObject->setRange(frame->selection().toNormalizedRange());
 
     frameSettingClipboard = frame;
     GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
index 3c230ebe44ac4e73326b4c6bd95848193cf3b08a..948517939e6a388f74ae688c81500db5bcb79031 100644 (file)
@@ -43,7 +43,7 @@ namespace WebKit {
 
 void WebContextMenuClient::lookUpInDictionary(Frame* frame)
 {
-    m_page->performDictionaryLookupForSelection(frame, frame->selection()->selection());
+    m_page->performDictionaryLookupForSelection(frame, frame->selection().selection());
 }
 
 bool WebContextMenuClient::isSpeaking()
@@ -79,7 +79,7 @@ void WebContextMenuClient::searchWithSpotlight()
     
     Frame* selectionFrame = mainFrame;
     for (; selectionFrame; selectionFrame = selectionFrame->tree()->traverseNext(mainFrame)) {
-        if (selectionFrame->selection()->isRange())
+        if (selectionFrame->selection().isRange())
             break;
     }
     if (!selectionFrame)
index 7dbfc975e9d467a64114d1d74f77aa3ea2420b98..12d17d1263f3808d072322d6b081591acaa4175a 100644 (file)
@@ -99,7 +99,7 @@ void FindController::countStringMatches(const String& string, FindOptions option
 static Frame* frameWithSelection(Page* page)
 {
     for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-        if (frame->selection()->isRange())
+        if (frame->selection().isRange())
             return frame;
     }
 
@@ -119,7 +119,7 @@ void FindController::updateFindUIAfterPageScroll(bool found, const String& strin
             m_webPage->corePage()->unmarkAllTextMatches();
 
         if (selectedFrame)
-            selectedFrame->selection()->clear();
+            selectedFrame->selection().clear();
 
         hideFindIndicator();
 
@@ -201,7 +201,7 @@ void FindController::findStringMatches(const String& string, FindOptions options
 
 bool FindController::getFindIndicatorBitmapAndRect(Frame* frame, ShareableBitmap::Handle& handle, IntRect& selectionRect)
 {
-    selectionRect = enclosingIntRect(frame->selection()->bounds());
+    selectionRect = enclosingIntRect(frame->selection().bounds());
 
     // Selection rect can be empty for matches that are currently obscured from view.
     if (selectionRect.isEmpty())
@@ -242,14 +242,14 @@ void FindController::getImageForFindMatch(uint32_t matchIndex)
     if (!frame)
         return;
 
-    VisibleSelection oldSelection = frame->selection()->selection();
-    frame->selection()->setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
+    VisibleSelection oldSelection = frame->selection().selection();
+    frame->selection().setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
 
     IntRect selectionRect;
     ShareableBitmap::Handle handle;
     getFindIndicatorBitmapAndRect(frame, handle, selectionRect);
 
-    frame->selection()->setSelection(oldSelection);
+    frame->selection().setSelection(oldSelection);
 
     if (handle.isNull())
         return;
@@ -264,7 +264,7 @@ void FindController::selectFindMatch(uint32_t matchIndex)
     Frame* frame = m_findMatches[matchIndex]->startContainer()->document()->frame();
     if (!frame)
         return;
-    frame->selection()->setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
+    frame->selection().setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
 }
 
 void FindController::hideFindUI()
@@ -297,7 +297,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
     IntRect selectionRectInWindowCoordinates = selectedFrame->view()->contentsToWindow(selectionRect);
 
     Vector<FloatRect> textRects;
-    selectedFrame->selection()->getClippedVisibleTextRectangles(textRects);
+    selectedFrame->selection().getClippedVisibleTextRectangles(textRects);
 
     // We want the text rects in selection rect coordinates.
     Vector<FloatRect> textRectsInSelectionRectCoordinates;
@@ -431,7 +431,7 @@ void FindController::drawRect(PageOverlay* pageOverlay, GraphicsContext& graphic
         return;
 
     if (Frame* selectedFrame = frameWithSelection(m_webPage->corePage())) {
-        IntRect findIndicatorRect = selectedFrame->view()->contentsToWindow(enclosingIntRect(selectedFrame->selection()->bounds()));
+        IntRect findIndicatorRect = selectedFrame->view()->contentsToWindow(enclosingIntRect(selectedFrame->selection().bounds()));
 
         if (findIndicatorRect != m_findIndicatorRect)
             hideFindIndicator();
index fbd50d455d1e3c2f36fc9407d8657ecdf2071ac5..ecdf8b653978a29006b27b27649f87163e978cd0 100644 (file)
@@ -599,11 +599,11 @@ EditorState WebPage::editorState() const
         }
     }
 
-    result.selectionIsNone = frame->selection()->isNone();
-    result.selectionIsRange = frame->selection()->isRange();
-    result.isContentEditable = frame->selection()->isContentEditable();
-    result.isContentRichlyEditable = frame->selection()->isContentRichlyEditable();
-    result.isInPasswordField = frame->selection()->isInPasswordField();
+    result.selectionIsNone = frame->selection().isNone();
+    result.selectionIsRange = frame->selection().isRange();
+    result.isContentEditable = frame->selection().isContentEditable();
+    result.isContentRichlyEditable = frame->selection().isContentRichlyEditable();
+    result.isInPasswordField = frame->selection().isInPasswordField();
     result.hasComposition = frame->editor().hasComposition();
     result.shouldIgnoreCompositionSelectionChange = frame->editor().ignoreCompositionSelectionChange();
 
@@ -611,7 +611,7 @@ EditorState WebPage::editorState() const
     size_t location = 0;
     size_t length = 0;
 
-    Element* selectionRoot = frame->selection()->rootEditableElementRespectingShadowTree();
+    Element* selectionRoot = frame->selection().rootEditableElementRespectingShadowTree();
     Element* scope = selectionRoot ?&nbs