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
+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
VisibleSelection AccessibilityRenderObject::selection() const
{
- return m_renderer->frame()->selection()->selection();
+ return m_renderer->frame()->selection().selection();
}
PlainTextRange AccessibilityRenderObject::selectedTextRange() const
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));
}
// 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;
// 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);
}
}
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());
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
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
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
// 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);
}
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) {
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)
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);
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);
}
}
if (Frame* frame = this->frame()) {
frame->eventHandler().nodeWillBeRemoved(n);
- frame->selection()->nodeWillBeRemoved(n);
+ frame->selection().nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}
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());
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;
// 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());
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));
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);
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);
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
return;
HTMLElement* oldElement = enclosingDeletableElement(oldSelection);
- HTMLElement* newElement = enclosingDeletableElement(m_frame->selection()->selection());
+ HTMLElement* newElement = enclosingDeletableElement(m_frame->selection().selection());
if (oldElement == newElement)
return;
// 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()));
}
}
// 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
// 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()
RefPtr<Frame> frame = document->frame();
ASSERT(frame);
- VisibleSelection currentSelection = frame->selection()->selection();
+ VisibleSelection currentSelection = frame->selection().selection();
String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, false);
{
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);
}
{
ASSERT(document);
- RefPtr<EditingStyle> typingStyle = document->frame()->selection()->typingStyle();
+ RefPtr<EditingStyle> typingStyle = document->frame()->selection().typingStyle();
if (!typingStyle || typingStyle == this)
return;
// 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,
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
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()
{
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
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
bool Editor::canSmartCopyOrDelete()
{
- return client() && client()->smartInsertDeleteEnabled() && m_frame.selection()->granularity() == WordGranularity;
+ return client() && client()->smartInsertDeleteEnabled() && m_frame.selection().granularity() == WordGranularity;
}
bool Editor::isSelectTrailingWhitespaceEnabled()
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();
void Editor::deleteSelectionWithSmartDelete(bool smartDelete)
{
- if (m_frame.selection()->isNone())
+ if (m_frame.selection().isNone())
return;
applyCommand(DeleteSelectionCommand::create(m_frame.document(), smartDelete));
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;
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;
PassRefPtr<Range> Editor::selectedRange()
{
- return m_frame.selection()->toNormalizedRange();
+ return m_frame.selection().toNormalizedRange();
}
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);
bool Editor::tryDHTMLCut()
{
- if (m_frame.selection()->isInPasswordField())
+ if (m_frame.selection().isInPasswordField())
return false;
return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable);
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())
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;
}
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;
}
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());
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());
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());
void Editor::decreaseSelectionListLevel()
{
- if (!canEditRichly() || m_frame.selection()->isNone())
+ if (!canEditRichly() || m_frame.selection().isNone())
return;
DecreaseSelectionListLevelCommand::decreaseSelectionListLevel(m_frame.document());
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;
void Editor::applyParagraphStyle(StylePropertySet* style, EditAction editingAction)
{
- switch (m_frame.selection()->selectionType()) {
+ switch (m_frame.selection().selectionType()) {
case VisibleSelection::NoSelection:
// do nothing
break;
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);
}
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();
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)
// 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);
}
}
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);
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);
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
}
willWriteSelectionToPasteboard(selectedRange());
- if (enclosingTextFormControl(m_frame.selection()->start())) {
+ if (enclosingTextFormControl(m_frame.selection().start())) {
Pasteboard::generalPasteboard()->writePlainText(selectedTextForClipboard(),
canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
} else {
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());
{
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;
// 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()
else
selectComposition();
- if (m_frame.selection()->isNone()) {
+ if (m_frame.selection().isNone()) {
setIgnoreCompositionSelectionChange(false);
return;
}
selectComposition();
- if (m_frame.selection()->isNone()) {
+ if (m_frame.selection().isNone()) {
setIgnoreCompositionSelectionChange(false);
return;
}
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();
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);
}
}
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);
// 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);
// 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;
// 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);
// 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);
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();
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();
{
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);
// 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))
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())
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)
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))
}
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())
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);
}
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);
}
}
}
// 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.
if (m_ignoreCompositionSelectionChange)
return;
- m_frame.selection()->revealSelection(alignment, revealExtentOption);
+ m_frame.selection().revealSelection(alignment, revealExtentOption);
}
void Editor::setIgnoreCompositionSelectionChange(bool ignore)
{
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;
if (!canEdit())
return;
- VisibleSelection selection = m_frame.selection()->selection();
+ VisibleSelection selection = m_frame.selection().selection();
if (!selection.isCaret())
return;
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.
// 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 ^):
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)
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();
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)
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;
}
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));
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;
void Editor::toggleOverwriteModeEnabled()
{
m_overwriteModeEnabled = !m_overwriteModeEnabled;
- m_frame.selection()->setShouldShowBlockCursor(m_overwriteModeEnabled);
+ m_frame.selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
};
} // namespace WebCore
// 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;
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;
}
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;
}
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();
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;
}
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;
}
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);
}
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);
}
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);
}
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;
}
static bool executeSelectAll(Frame* frame, Event*, EditorCommandSource, const String&)
{
- frame->selection()->selectAll();
+ frame->selection().selectAll();
return true;
}
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;
}
static bool executeSetMark(Frame* frame, Event*, EditorCommandSource, const String&)
{
- frame->editor().setMark(frame->selection()->selection());
+ frame->editor().setMark(frame->selection().selection());
return true;
}
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;
}
static bool executeUnselect(Frame* frame, Event*, EditorCommandSource, const String&)
{
- frame->selection()->clear();
+ frame->selection().clear();
return true;
}
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)
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)
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());
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.
// 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);
}
}
// 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
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());
{
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)
{
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)
{
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.
// 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);
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
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);
applyCommand(command);
if (changeSelection) {
command->setEndingSelection(endingSelection);
- frame->selection()->setSelection(endingSelection);
+ frame->selection().setSelection(endingSelection);
}
}
Frame* frame = document->frame();
ASSERT(frame);
- if (!frame->selection()->isRange())
+ if (!frame->selection().isRange())
return;
if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame)) {
void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand* typingCommand, Frame* frame)
{
ASSERT(frame);
- VisibleSelection currentSelection = frame->selection()->selection();
+ VisibleSelection currentSelection = frame->selection().selection();
if (currentSelection == typingCommand->endingSelection())
return;
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.
RefPtr<Frame> frame = document->frame();
ASSERT(frame);
- VisibleSelection currentSelection = frame->selection()->selection();
+ VisibleSelection currentSelection = frame->selection().selection();
String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionUpdate);
if (selectionToDelete.isNone())
return;
- if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
+ if (selectionToDelete.isCaret() || !frame->selection().shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
if (selectionToDelete.isNone())
return;
- if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
+ if (selectionToDelete.isCaret() || !frame->selection().shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
// 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;
{
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();
{
hasMultipleFonts = false;
- if (!m_frame.selection()->isRange()) {
+ if (!m_frame.selection().isRange()) {
Node* nodeToRemove;
RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
}
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.
{
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();
{
hasMultipleFonts = false;
- if (!m_frame.selection()->isRange()) {
+ if (!m_frame.selection().isRange()) {
Node* nodeToRemove;
RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
}
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
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()
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);
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,
// 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;
else
restoreCachedSelection();
if (document()->frame())
- document()->frame()->selection()->revealSelection();
+ document()->frame()->selection().revealSelection();
} else
HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelection);
}
restoreCachedSelection();
if (document()->frame())
- document()->frame()->selection()->revealSelection();
+ document()->frame()->selection().revealSelection();
}
void HTMLTextAreaElement::defaultEventHandler(Event* event)
// 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;
newSelection.setIsDirectional(direction != SelectionHasNoDirection);
if (Frame* frame = document()->frame())
- frame->selection()->setSelection(newSelection);
+ frame->selection().setSelection(newSelection);
}
int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& pos) const
if (!frame)
return 0;
- return indexForVisiblePosition(frame->selection()->start());
+ return indexForVisiblePosition(frame->selection().start());
}
int HTMLTextFormControlElement::selectionEnd() const
if (!frame)
return 0;
- return indexForVisiblePosition(frame->selection()->end());
+ return indexForVisiblePosition(frame->selection().end());
}
static const AtomicString& directionString(TextFieldSelectionDirection direction)
if (!frame)
return SelectionHasNoDirection;
- const VisibleSelection& selection = frame->selection()->selection();
+ const VisibleSelection& selection = frame->selection().selection();
return selection.isDirectional() ? (selection.isBaseFirst() ? SelectionHasForwardDirection : SelectionHasBackwardDirection) : SelectionHasNoDirection;
}
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));
}
}
// 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.
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();
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);
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);
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;
RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), replaceOptions);
applyCommand(command);
- frameSelection->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
+ frameSelection.revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
}
break;
}
// 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();
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)))
}
}
} 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);
break;
case ContextMenuItemTagIgnoreSpelling:
case ContextMenuItemTagLearnSpelling:
- shouldEnable = frame->selection()->isRange();
+ shouldEnable = frame->selection().isRange();
break;
case ContextMenuItemTagPaste:
shouldEnable = frame->editor().canDHTMLPaste() || frame->editor().canPaste();
break;
}
case ContextMenuItemTagLookUpInDictionary:
- shouldEnable = frame->selection()->isRange();
+ shouldEnable = frame->selection().isRange();
break;
case ContextMenuItemTagCheckGrammarWithSpelling:
if (frame->editor().isGrammarCheckingEnabled())
static Node* selectionShadowAncestor(Frame* frame)
{
- Node* node = frame->selection()->selection().base().anchorNode();
+ Node* node = frame->selection().selection().base().anchorNode();
if (!node)
return 0;
const VisibleSelection& DOMSelection::visibleSelection() const
{
ASSERT(m_frame);
- return m_frame->selection()->selection();
+ return m_frame->selection().selection();
}
static Position anchorPosition(const VisibleSelection& selection)
{
if (!m_frame || selectionShadowAncestor(m_frame))
return true;
- return !m_frame->selection()->isRange();
+ return !m_frame->selection().isRange();
}
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";
}
{
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)
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)
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)
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)
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)
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)
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)
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)
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();
}
{
if (!m_frame)
return;
- m_frame->selection()->clear();
+ m_frame->selection().clear();
}
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.
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));
}
}
}
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;
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())
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
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.
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)
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()))
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
// 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)) {
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;
{
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)
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();
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();
// 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);
bool tryDHTMLDrag(DragData*, DragOperation&);
DragOperation dragOperation(DragData*);
void cancelDrag();
- bool dragIsMove(FrameSelection*, DragData*);
+ bool dragIsMove(FrameSelection&, DragData*);
bool isCopyKeyDown(DragData*);
void mouseMovedIntoDocument(Document*);
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)
m_selectionInitiationState = PlacedCaret;
}
- m_frame->selection()->setNonDirectionalSelectionIfNeeded(selection, granularity);
+ m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granularity);
return true;
}
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
// 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;
}
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()) {
} 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);
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())
// 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.
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)
#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();
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.
// 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)
#if ENABLE(DRAG_SUPPORT)
&& !m_mouseDownMayStartDrag
#endif
- && m_frame->selection()->isCaretOrRange() && !m_capturingMouseEventsNode)
+ && m_frame->selection().isCaretOrRange() && !m_capturingMouseEventsNode)
return iBeam;
if (renderer) {
}
}
- 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();
{
RefPtr<FrameView> protector(m_frame->view());
- m_frame->selection()->setCaretBlinkingSuspended(false);
+ m_frame->selection().setCaretBlinkingSuspended(false);
UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
{
RefPtr<FrameView> protector(m_frame->view());
- m_frame->selection()->setCaretBlinkingSuspended(false);
+ m_frame->selection().setCaretBlinkingSuspended(false);
#if ENABLE(TOUCH_EVENTS)
bool defaultPrevented = dispatchSyntheticTouchEventIfEnabled(mouseEvent);
// 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;
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);
}
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();
return retVal;
}
-static void handleKeyboardSelectionMovement(FrameSelection* selection, KeyboardEvent* event)
+static void handleKeyboardSelectionMovement(FrameSelection& selection, KeyboardEvent* event)
{
if (!event)
return;
}
FrameSelection::EAlteration alternation = event->getModifierState("Shift") ? FrameSelection::AlterationExtend : FrameSelection::AlterationMove;
- selection->modify(alternation, direction, granularity, UserTriggered);
+ selection.modify(alternation, direction, granularity, UserTriggered);
event->setDefaultHandled();
}
}
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.
// 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));
}
setFocusedFrame(m_page->mainFrame());
if (m_focusedFrame->view()) {
- m_focusedFrame->selection()->setFocused(focused);
+ m_focusedFrame->selection().setFocused(focused);
dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), focused);
}
}
bool caretBrowsing = frame->settings().caretBrowsingEnabled();
if (caretBrowsing && !currentNode)
- currentNode = frame->selection()->start().deprecatedNode();
+ currentNode = frame->selection().start().deprecatedNode();
document->updateLayoutIgnorePendingStylesheets();
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);
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;
}
}
- s->clear();
+ selection.clear();
}
bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newFocusedFrame, FocusDirection direction)
}
}
- focusedOrMainFrame()->selection()->pageActivationChanged();
+ focusedOrMainFrame()->selection().pageActivationChanged();
if (m_focusedFrame && isFocused())
dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), active);
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)
EventHandler& eventHandler() const;
FrameLoader& loader() const;
NavigationScheduler* navigationScheduler() const;
- FrameSelection* selection() const;
+ FrameSelection& selection() const;
FrameTree* tree() const;
AnimationController* animation() const;
ScriptController& script();
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
{
m_postLayoutTasksTimer.stop();
- frame().selection()->setCaretRectNeedsUpdate();
- frame().selection()->updateAppearance();
+ frame().selection().setCaretRectNeedsUpdate();
+ frame().selection().updateAppearance();
LayoutMilestones requestedMilestones = 0;
LayoutMilestones milestonesAchieved = 0;
// 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.
do {
if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) {
if (frame != startFrame)
- startFrame->selection()->clear();
+ startFrame->selection().clear();
focusController().setFocusedFrame(frame);
return true;
}
// 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;
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);
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) {
const VisibleSelection& Page::selection() const
{
- return focusController().focusedOrMainFrame()->selection()->selection();
+ return focusController().focusedOrMainFrame()->selection().selection();
}
void Page::setDefersLoading(bool defers)
DragImageRef Frame::dragImageForSelection()
{
- if (!selection()->isRange())
+ if (!selection().isRange())
return nil;
return selectionImage(this);
}
{
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;
}
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);
DragImageRef Frame::dragImageForSelection()
{
- if (selection()->isRange())
+ if (selection().isRange())
return imageFromSelection(this, false).leakPtr();
return 0;
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();
}
}
chosePlainText = true;
- fragment = createFragmentFromText(frame->selection()->toNormalizedRange().get(), (NSString*)value);
+ fragment = createFragmentFromText(frame->selection().toNormalizedRange().get(), (NSString*)value);
if (fragment)
return fragment.release();
}
if (!frame)
return false;
- return frame->selection()->contains(m_hitTestLocation.point());
+ return frame->selection().contains(m_hitTestLocation.point());
}
String HitTestResult::spellingToolTip(TextDirection& dir) const
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();
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);
}
{
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())
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)
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())
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();
{
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();
}
}
if (!color.isValid())
color = pseudoStyle->visitedDependentColor(CSSPropertyColor);
} else
- color = frame()->selection()->isFocusedAndActive() ?
+ color = frame()->selection().isFocusedAndActive() ?
theme()->activeSelectionForegroundColor() :
theme()->inactiveSelectionForegroundColor();
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;
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
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);
}
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)
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)
void SVGSVGElement::deselectAll()
{
if (Frame* frame = document()->frame())
- frame->selection()->clear();
+ frame->selection().clear();
}
float SVGSVGElement::createSVGNumber()
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)));
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)
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)
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)
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.
+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
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")
// 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;
}
{
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;
// 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;
}
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())
// 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);
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());
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.
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()
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.
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();
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;
}
}
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.
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;
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",
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());
// 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;
}
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
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.
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 */);
}
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");
}
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();
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 */)
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 */));
}
}
"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.
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();
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
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()) {
return;
}
- if (controller->selection() == newSelection) {
+ if (controller.selection() == newSelection) {
selectionPositionChanged(true /* forceUpdateWithoutChange */);
return;
}
newSelection = VisibleSelection(newSelection.extent(), newSelection.base());
}
- controller->setSelection(newSelection);
+ controller.setSelection(newSelection);
SelectionLog(Platform::LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated.");
}
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);
}
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
// 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))
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;
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();
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;
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,
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())
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;
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;
// 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 */);
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);
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;
{
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);
}
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.
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);
}
}
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(
+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
{
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
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();
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());
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);
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 ****************************************************/
+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
// 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()
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;
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());
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();
// 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)
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));
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());
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();
// 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());
}
+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
{
bool primary = true;
if (Frame* frame = core([self webFrame]))
- primary = frame->selection()->isFocusedAndActive();
+ primary = frame->selection().isFocusedAndActive();
return primary ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
}
// 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;
- (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
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);
// 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
- (void)_insertParagraphSeparatorInQuotedContent
{
- if (_private->coreFrame->selection()->isNone())
+ if (_private->coreFrame->selection().isNone())
return;
_private->coreFrame->editor().insertParagraphSeparatorInQuotedContent();
{
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());
- (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
- (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];
}
- (DOMElement *)currentForm
{
- return kit(core([_private->dataSource webFrame])->selection()->currentForm());
+ return kit(core([_private->dataSource webFrame])->selection().currentForm());
}
- (NSArray *)controlsInForm:(DOMElement *)form
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];
- (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
- (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
COMMAND_PROLOGUE
if (Frame* coreFrame = core([self _frame]))
- coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+ coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
}
- (BOOL)validateUserInterfaceItemWithoutDelegate:(id <NSValidatedUserInterfaceItem>)item
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;
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]];
// 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)
COMMAND_PROLOGUE
if (Frame* coreFrame = core([self _frame]))
- coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+ coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
}
- (NSData *)_selectionStartFontAttributesAsRTF
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
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];
_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];
}
{
if (![self _hasSelection])
return NSZeroRect;
- return core([self _frame])->selection()->bounds();
+ return core([self _frame])->selection().bounds();
}
- (NSArray *)selectionTextRects
Vector<FloatRect> list;
if (Frame* coreFrame = core([self _frame]))
- coreFrame->selection()->getClippedVisibleTextRectangles(list);
+ coreFrame->selection().getClippedVisibleTextRectangles(list);
size_t size = list.size();
{
if (![self _hasSelection])
return NSZeroRect;
- return core([self _frame])->selection()->bounds();
+ return core([self _frame])->selection().bounds();
}
- (NSArray *)pasteboardTypesForSelection
{
Frame* coreFrame = core([self _frame]);
if (coreFrame)
- coreFrame->selection()->selectAll();
+ coreFrame->selection().selectAll();
}
- (void)deselectAll
Frame* coreFrame = core([self _frame]);
if (!coreFrame)
return;
- coreFrame->selection()->clear();
+ coreFrame->selection().clear();
}
- (NSString *)string
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()];
}
}
// 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];
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
if (!coreFrame)
return;
- coreFrame->selection()->setSelectedRange(core(range), core(selectionAffinity), true);
+ coreFrame->selection().setSelectedRange(core(range), core(selectionAffinity), true);
}
}
Frame* coreFrame = core([self _selectedOrMainFrame]);
if (!coreFrame)
return nil;
- return kit(coreFrame->selection()->toNormalizedRange().get());
+ return kit(coreFrame->selection().toNormalizedRange().get());
}
- (NSSelectionAffinity)selectionAffinity
Frame* coreFrame = core([self _selectedOrMainFrame]);
if (!coreFrame)
return NSSelectionAffinityDownstream;
- return kit(coreFrame->selection()->affinity());
+ return kit(coreFrame->selection().affinity());
}
- (void)setEditable:(BOOL)flag
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();
}
}
}
Frame* coreFrame = core([self _selectedOrMainFrame]);
if (!coreFrame)
return NO;
- return coreFrame->selection()->isCaret();
+ return coreFrame->selection().isCaret();
}
- (BOOL)_selectionIsAll
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
+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
{
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());
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();
// 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);
}
if (!kevent || kevent->type() == PlatformEvent::KeyUp)
return;
- Node* start = frame->selection()->start().containerNode();
+ Node* start = frame->selection().start().containerNode();
if (!start)
return;
{
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();
}
}
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);
}
}
}
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;
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())));
}
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());
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);
// 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) {
}
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()) {
}
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));
}
}
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());
+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.
*currentForm = 0;
if (Frame* coreFrame = core(this)) {
- if (HTMLFormElement* formElement = coreFrame->selection()->currentForm())
+ if (HTMLFormElement* formElement = coreFrame->selection().currentForm())
*currentForm = DOMElement::createInstance(formElement);
}
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;
}
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();
if (!coreFrame)
return E_FAIL;
- coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+ coreFrame->selection().revealSelection(ScrollAlignment::alignCenterAlways);
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::hasSelectedRange(
/* [retval][out] */ BOOL* hasSelectedRange)
{
- *hasSelectedRange = m_page->mainFrame()->selection()->isRange();
+ *hasSelectedRange = m_page->mainFrame()->selection().isRange();
return S_OK;
}
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;
}
HRESULT STDMETHODCALLTYPE WebView::clearSelection( void)
{
- m_page->focusController().focusedOrMainFrame()->selection()->clear();
+ m_page->focusController().focusedOrMainFrame()->selection().clear();
return S_OK;
}
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());
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);
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);
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;
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);
}
+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
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);
+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
// 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);
}
}
// 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
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);
void WebContextMenuClient::lookUpInDictionary(Frame* frame)
{
- m_page->performDictionaryLookupForSelection(frame, frame->selection()->selection());
+ m_page->performDictionaryLookupForSelection(frame, frame->selection().selection());
}
bool WebContextMenuClient::isSpeaking()
Frame* selectionFrame = mainFrame;
for (; selectionFrame; selectionFrame = selectionFrame->tree()->traverseNext(mainFrame)) {
- if (selectionFrame->selection()->isRange())
+ if (selectionFrame->selection().isRange())
break;
}
if (!selectionFrame)
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;
}
m_webPage->corePage()->unmarkAllTextMatches();
if (selectedFrame)
- selectedFrame->selection()->clear();
+ selectedFrame->selection().clear();
hideFindIndicator();
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())
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;
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()
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;
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();
}
}
- 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();
size_t location = 0;
size_t length = 0;
- Element* selectionRoot = frame->selection()->rootEditableElementRespectingShadowTree();
+ Element* selectionRoot = frame->selection().rootEditableElementRespectingShadowTree();
Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();