| Differences between
and this patch
- Source/WebCore/ChangeLog +102 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Removed numerous inline member functions of FrameSelection that depend on m_selection.
9
10
        This is needed to ensure all accesses to m_selection happen through FrameSelection::selection(),
11
        which in turn, allows us to update its call sites to use either validated selection that editing
12
        and rendering code uses or invalidated selection that's exposed to JavaScript.
13
14
        * WebCore.exp.in:
15
        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
16
        (-[WebAccessibilityObjectWrapper _convertToNSRange:]):
17
        (-[WebAccessibilityObjectWrapper _convertToDOMRange:]):
18
        * dom/Element.cpp:
19
        (WebCore::Element::updateFocusAppearance):
20
        * editing/Editor.cpp:
21
        (WebCore::Editor::canEdit):
22
        (WebCore::Editor::canEditRichly):
23
        (WebCore::Editor::canDHTMLCut):
24
        (WebCore::Editor::canDHTMLCopy):
25
        (WebCore::Editor::canCopy):
26
        (WebCore::Editor::canDelete):
27
        (WebCore::Editor::replaceSelectionWithFragment):
28
        (WebCore::Editor::tryDHTMLCopy):
29
        (WebCore::Editor::tryDHTMLCut):
30
        (WebCore::Editor::applyStyle):
31
        (WebCore::Editor::applyParagraphStyle):
32
        (WebCore::Editor::cut):
33
        (WebCore::Editor::copy):
34
        (WebCore::Editor::paste):
35
        (WebCore::Editor::setComposition):
36
        (WebCore::Editor::guessesForMisspelledOrUngrammatical):
37
        (WebCore::Editor::markMisspellingsAfterTypingToWord):
38
        (WebCore::Editor::isSpellCheckingEnabledInFocusedNode):
39
        (WebCore::Editor::markAndReplaceFor):
40
        (WebCore::Editor::getCompositionSelection):
41
        (WebCore::Editor::selectionStartHasMarkerFor):
42
        * editing/EditorCommand.cpp:
43
        (WebCore::expandSelectionToGranularity):
44
        (WebCore::enabledInRichlyEditableText):
45
        (WebCore::enabledRangeInEditableText):
46
        (WebCore::enabledRangeInRichlyEditableText):
47
        * editing/FrameSelection.cpp:
48
        (WebCore::FrameSelection::setSelection):
49
        (WebCore::CaretBase::updateCaretRect):
50
        (WebCore::FrameSelection::recomputeCaretRect):
51
        (WebCore::FrameSelection::selectAll):
52
        (WebCore::FrameSelection::updateAppearance):
53
        (WebCore::FrameSelection::updateSelectionCachesIfSelectionIsInsideTextFormControl):
54
        (WebCore::FrameSelection::setFocusedElementIfNeeded):
55
        (WebCore::FrameSelection::currentForm):
56
        (WebCore::FrameSelection::revealSelection):
57
        (WebCore::FrameSelection::setSelectionFromNone):
58
        (WebCore::FrameSelection::wordSelectionContainingCaretSelection):
59
        * editing/FrameSelection.h:
60
        (WebCore::FrameSelection::isCaretOrRange):
61
        * editing/RemoveFormatCommand.cpp:
62
        (WebCore::RemoveFormatCommand::doApply):
63
        * editing/VisibleSelection.cpp:
64
        (WebCore::VisibleSelection::isInPasswordField):
65
        * editing/VisibleSelection.h:
66
        * editing/mac/EditorMac.mm:
67
        (WebCore::Editor::canCopyExcludingStandaloneImages):
68
        (WebCore::Editor::readSelectionFromPasteboard):
69
        * html/HTMLAnchorElement.cpp:
70
        (WebCore::HTMLAnchorElement::defaultEventHandler):
71
        (WebCore::HTMLAnchorElement::setActive):
72
        * html/HTMLTextFormControlElement.cpp:
73
        (WebCore::HTMLTextFormControlElement::computeSelectionStart):
74
        (WebCore::HTMLTextFormControlElement::computeSelectionEnd):
75
        * page/ContextMenuController.cpp:
76
        (WebCore::ContextMenuController::contextMenuItemSelected):
77
        (WebCore::ContextMenuController::populate):
78
        * page/DragController.cpp:
79
        (WebCore::DragController::dragIsMove):
80
        (WebCore::setSelectionToDragCaret):
81
        (WebCore::DragController::concludeEditDrag):
82
        (WebCore::DragController::startDrag):
83
        * page/EventHandler.cpp:
84
        (WebCore::nodeIsNotBeingEdited):
85
        (WebCore::EventHandler::sendContextMenuEvent):
86
        (WebCore::EventHandler::sendContextMenuEventForKey):
87
        (WebCore::EventHandler::handleDrag):
88
        * page/FocusController.cpp:
89
        (WebCore::FocusController::advanceFocusInDocumentOrder):
90
        (WebCore::clearSelectionIfNeeded):
91
        * page/ios/FrameIOS.mm:
92
        (WebCore::Frame::caretRect):
93
        (WebCore::Frame::rectForScrollToVisible):
94
        (WebCore::Frame::styleAtSelectionStart):
95
        (WebCore::Frame::setRangedSelectionBaseToCurrentSelectionStart):
96
        (WebCore::Frame::setRangedSelectionBaseToCurrentSelectionEnd):
97
        (WebCore::Frame::setRangedSelectionInitialExtentToCurrentSelectionStart):
98
        (WebCore::Frame::setRangedSelectionInitialExtentToCurrentSelectionEnd):
99
        (WebCore::Frame::interpretationsForCurrentRoot):
100
        * rendering/RenderBlock.cpp:
101
        (WebCore::RenderBlock::paintCaret):
102
1
2014-01-30  Simon Fraser  <simon.fraser@apple.com>
103
2014-01-30  Simon Fraser  <simon.fraser@apple.com>
2
104
3
        Fix iOS build after r163156.
105
        Fix iOS build after r163156.
- Source/WebCore/WebCore.exp.in -1 / +1 lines
Lines 1534-1540 __ZNK7WebCore14DocumentLoader9isLoadingE Source/WebCore/WebCore.exp.in_sec1
1534
__ZNK7WebCore14DocumentMarker11descriptionEv
1534
__ZNK7WebCore14DocumentMarker11descriptionEv
1535
__ZNK7WebCore14FrameSelection11currentFormEv
1535
__ZNK7WebCore14FrameSelection11currentFormEv
1536
__ZNK7WebCore14FrameSelection15copyTypingStyleEv
1536
__ZNK7WebCore14FrameSelection15copyTypingStyleEv
1537
__ZNK7WebCore14FrameSelection17isInPasswordFieldEv
1538
__ZNK7WebCore14FrameSelection18isFocusedAndActiveEv
1537
__ZNK7WebCore14FrameSelection18isFocusedAndActiveEv
1539
__ZNK7WebCore14FrameSelection31getClippedVisibleTextRectanglesERN3WTF6VectorINS_9FloatRectELm0ENS1_15CrashOnOverflowEEE
1538
__ZNK7WebCore14FrameSelection31getClippedVisibleTextRectanglesERN3WTF6VectorINS_9FloatRectELm0ENS1_15CrashOnOverflowEEE
1540
__ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv
1539
__ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv
Lines 1613-1618 __ZNK7WebCore16IconDatabaseBase12databas Source/WebCore/WebCore.exp.in_sec2
1613
__ZNK7WebCore16ResourceResponse13nsURLResponseEv
1612
__ZNK7WebCore16ResourceResponse13nsURLResponseEv
1614
__ZNK7WebCore16ResourceResponse16certificateChainEv
1613
__ZNK7WebCore16ResourceResponse16certificateChainEv
1615
__ZNK7WebCore16VisibleSelection17isContentEditableEv
1614
__ZNK7WebCore16VisibleSelection17isContentEditableEv
1615
__ZNK7WebCore16VisibleSelection17isInPasswordFieldEv
1616
__ZNK7WebCore16VisibleSelection17toNormalizedRangeEv
1616
__ZNK7WebCore16VisibleSelection17toNormalizedRangeEv
1617
__ZNK7WebCore16VisibleSelection19rootEditableElementEv
1617
__ZNK7WebCore16VisibleSelection19rootEditableElementEv
1618
__ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
1618
__ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
- Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm -5 / +2 lines
Lines 1641-1649 - (NSRange)_convertToNSRange:(Range *)ra Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm_sec1
1641
        return NSMakeRange(NSNotFound, 0);
1641
        return NSMakeRange(NSNotFound, 0);
1642
    
1642
    
1643
    Document* document = m_object->document();
1643
    Document* document = m_object->document();
1644
    FrameSelection& frameSelection = document->frame()->selection();
1644
    Element* selectionRoot = document->frame()->selection().selection().rootEditableElement();
1645
    
1646
    Element* selectionRoot = frameSelection.rootEditableElement();
1647
    Element* scope = selectionRoot ? selectionRoot : document->documentElement();
1645
    Element* scope = selectionRoot ? selectionRoot : document->documentElement();
1648
    
1646
    
1649
    // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
1647
    // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
Lines 1679-1686 - (PassRefPtr<Range>)_convertToDOMRange: Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm_sec2
1679
    // to use the root editable element of the selection start as the positional base.
1677
    // to use the root editable element of the selection start as the positional base.
1680
    // That fits with AppKit's idea of an input context.
1678
    // That fits with AppKit's idea of an input context.
1681
    Document* document = m_object->document();
1679
    Document* document = m_object->document();
1682
    FrameSelection& frameSelection = document->frame()->selection();
1680
    Element* selectionRoot = document->frame()->selection().selection().rootEditableElement();
1683
    Element* selectionRoot = frameSelection.rootEditableElement();
1684
    Element* scope = selectionRoot ? selectionRoot : document->documentElement();
1681
    Element* scope = selectionRoot ? selectionRoot : document->documentElement();
1685
    return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
1682
    return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
1686
}
1683
}
- Source/WebCore/dom/Element.cpp -1 / +1 lines
Lines 2007-2013 void Element::updateFocusAppearance(bool Source/WebCore/dom/Element.cpp_sec1
2007
            return;
2007
            return;
2008
        
2008
        
2009
        // When focusing an editable element in an iframe, don't reset the selection if it already contains a selection.
2009
        // When focusing an editable element in an iframe, don't reset the selection if it already contains a selection.
2010
        if (this == frame->selection().rootEditableElement())
2010
        if (this == frame->selection().selection().rootEditableElement())
2011
            return;
2011
            return;
2012
2012
2013
        // FIXME: We should restore the previous selection if there is one.
2013
        // FIXME: We should restore the previous selection if there is one.
- Source/WebCore/editing/Editor.cpp -30 / +33 lines
Lines 286-297 bool Editor::handleTextEvent(TextEvent* Source/WebCore/editing/Editor.cpp_sec1
286
286
287
bool Editor::canEdit() const
287
bool Editor::canEdit() const
288
{
288
{
289
    return m_frame.selection().rootEditableElement();
289
    return m_frame.selection().selection().rootEditableElement();
290
}
290
}
291
291
292
bool Editor::canEditRichly() const
292
bool Editor::canEditRichly() const
293
{
293
{
294
    return m_frame.selection().isContentRichlyEditable();
294
    return m_frame.selection().selection().isContentRichlyEditable();
295
}
295
}
296
296
297
// WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu items.  They
297
// WinIE uses onbeforecut and onbeforepaste to enables the cut and paste menu items.  They
Lines 301-312 bool Editor::canEditRichly() const Source/WebCore/editing/Editor.cpp_sec2
301
301
302
bool Editor::canDHTMLCut()
302
bool Editor::canDHTMLCut()
303
{
303
{
304
    return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb);
304
    return !m_frame.selection().selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecutEvent, ClipboardNumb);
305
}
305
}
306
306
307
bool Editor::canDHTMLCopy()
307
bool Editor::canDHTMLCopy()
308
{
308
{
309
    return !m_frame.selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb);
309
    return !m_frame.selection().selection().isInPasswordField() && !dispatchCPPEvent(eventNames().beforecopyEvent, ClipboardNumb);
310
}
310
}
311
311
312
bool Editor::canDHTMLPaste()
312
bool Editor::canDHTMLPaste()
Lines 340-346 bool Editor::canCopy() const Source/WebCore/editing/Editor.cpp_sec3
340
{
340
{
341
    if (imageElementFromImageDocument(document()))
341
    if (imageElementFromImageDocument(document()))
342
        return true;
342
        return true;
343
    FrameSelection& selection = m_frame.selection();
343
    const VisibleSelection& selection = m_frame.selection().selection();
344
    return selection.isRange() && !selection.isInPasswordField();
344
    return selection.isRange() && !selection.isInPasswordField();
345
}
345
}
346
346
Lines 351-357 bool Editor::canPaste() const Source/WebCore/editing/Editor.cpp_sec4
351
351
352
bool Editor::canDelete() const
352
bool Editor::canDelete() const
353
{
353
{
354
    FrameSelection& selection = m_frame.selection();
354
    const VisibleSelection& selection = m_frame.selection().selection();
355
    return selection.isRange() && selection.rootEditableElement();
355
    return selection.isRange() && selection.rootEditableElement();
356
}
356
}
357
357
Lines 598-604 bool Editor::shouldInsertFragment(PassRe Source/WebCore/editing/Editor.cpp_sec5
598
598
599
void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
599
void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
600
{
600
{
601
    if (m_frame.selection().isNone() || !m_frame.selection().isContentEditable() || !fragment)
601
    VisibleSelection selection = m_frame.selection().selection();
602
    if (selection.isNone() || !selection.isContentEditable() || !fragment)
602
        return;
603
        return;
603
604
604
    ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment;
605
    ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::PreventNesting | ReplaceSelectionCommand::SanitizeFragment;
Lines 611-619 void Editor::replaceSelectionWithFragmen Source/WebCore/editing/Editor.cpp_sec6
611
    applyCommand(ReplaceSelectionCommand::create(document(), fragment, options, EditActionPaste));
612
    applyCommand(ReplaceSelectionCommand::create(document(), fragment, options, EditActionPaste));
612
    revealSelectionAfterEditingOperation();
613
    revealSelectionAfterEditingOperation();
613
614
614
    if (m_frame.selection().isInPasswordField() || !isContinuousSpellCheckingEnabled())
615
    selection = m_frame.selection().selection();
616
    if (selection.isInPasswordField() || !isContinuousSpellCheckingEnabled())
615
        return;
617
        return;
616
    Node* nodeToCheck = m_frame.selection().rootEditableElement();
618
    Node* nodeToCheck = selection.rootEditableElement();
617
    if (!nodeToCheck)
619
    if (!nodeToCheck)
618
        return;
620
        return;
619
621
Lines 728-734 bool Editor::shouldDeleteRange(Range* ra Source/WebCore/editing/Editor.cpp_sec7
728
730
729
bool Editor::tryDHTMLCopy()
731
bool Editor::tryDHTMLCopy()
730
{   
732
{   
731
    if (m_frame.selection().isInPasswordField())
733
    if (m_frame.selection().selection().isInPasswordField())
732
        return false;
734
        return false;
733
735
734
    return !dispatchCPPEvent(eventNames().copyEvent, ClipboardWritable);
736
    return !dispatchCPPEvent(eventNames().copyEvent, ClipboardWritable);
Lines 736-742 bool Editor::tryDHTMLCopy() Source/WebCore/editing/Editor.cpp_sec8
736
738
737
bool Editor::tryDHTMLCut()
739
bool Editor::tryDHTMLCut()
738
{
740
{
739
    if (m_frame.selection().isInPasswordField())
741
    if (m_frame.selection().selection().isInPasswordField())
740
        return false;
742
        return false;
741
    
743
    
742
    return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable);
744
    return !dispatchCPPEvent(eventNames().cutEvent, ClipboardWritable);
Lines 970-976 Node* Editor::findEventTargetFromSelecti Source/WebCore/editing/Editor.cpp_sec9
970
972
971
void Editor::applyStyle(StyleProperties* style, EditAction editingAction)
973
void Editor::applyStyle(StyleProperties* style, EditAction editingAction)
972
{
974
{
973
    switch (m_frame.selection().selectionType()) {
975
    switch (m_frame.selection().selection().selectionType()) {
974
    case VisibleSelection::NoSelection:
976
    case VisibleSelection::NoSelection:
975
        // do nothing
977
        // do nothing
976
        break;
978
        break;
Lines 991-997 bool Editor::shouldApplyStyle(StylePrope Source/WebCore/editing/Editor.cpp_sec10
991
    
993
    
992
void Editor::applyParagraphStyle(StyleProperties* style, EditAction editingAction)
994
void Editor::applyParagraphStyle(StyleProperties* style, EditAction editingAction)
993
{
995
{
994
    switch (m_frame.selection().selectionType()) {
996
    switch (m_frame.selection().selection().selectionType()) {
995
    case VisibleSelection::NoSelection:
997
    case VisibleSelection::NoSelection:
996
        // do nothing
998
        // do nothing
997
        break;
999
        break;
Lines 1280-1286 void Editor::cut() Source/WebCore/editing/Editor.cpp_sec11
1280
    willWriteSelectionToPasteboard(selection);
1282
    willWriteSelectionToPasteboard(selection);
1281
    if (shouldDeleteRange(selection.get())) {
1283
    if (shouldDeleteRange(selection.get())) {
1282
        updateMarkersForWordsAffectedByEditing(true);
1284
        updateMarkersForWordsAffectedByEditing(true);
1283
        if (enclosingTextFormControl(m_frame.selection().start()))
1285
        if (enclosingTextFormControl(m_frame.selection().selection().start()))
1284
            Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
1286
            Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(), canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
1285
        else {
1287
        else {
1286
#if PLATFORM(MAC) || PLATFORM(EFL)
1288
#if PLATFORM(MAC) || PLATFORM(EFL)
Lines 1305-1311 void Editor::copy() Source/WebCore/editing/Editor.cpp_sec12
1305
    }
1307
    }
1306
1308
1307
    willWriteSelectionToPasteboard(selectedRange());
1309
    willWriteSelectionToPasteboard(selectedRange());
1308
    if (enclosingTextFormControl(m_frame.selection().start())) {
1310
    if (enclosingTextFormControl(m_frame.selection().selection().start())) {
1309
        Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(),
1311
        Pasteboard::createForCopyAndPaste()->writePlainText(selectedTextForClipboard(),
1310
            canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
1312
            canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
1311
    } else {
1313
    } else {
Lines 1342-1348 void Editor::paste(Pasteboard& pasteboar Source/WebCore/editing/Editor.cpp_sec13
1342
    updateMarkersForWordsAffectedByEditing(false);
1344
    updateMarkersForWordsAffectedByEditing(false);
1343
    CachedResourceLoader* loader = document().cachedResourceLoader();
1345
    CachedResourceLoader* loader = document().cachedResourceLoader();
1344
    ResourceCacheValidationSuppressor validationSuppressor(loader);
1346
    ResourceCacheValidationSuppressor validationSuppressor(loader);
1345
    if (m_frame.selection().isContentRichlyEditable())
1347
    if (m_frame.selection().selection().isContentRichlyEditable())
1346
        pasteWithPasteboard(&pasteboard, true);
1348
        pasteWithPasteboard(&pasteboard, true);
1347
    else
1349
    else
1348
        pasteAsPlainTextWithPasteboard(pasteboard);
1350
        pasteAsPlainTextWithPasteboard(pasteboard);
Lines 1842-1849 void Editor::setComposition(const String Source/WebCore/editing/Editor.cpp_sec14
1842
        TypingCommand::insertText(document(), text, TypingCommand::SelectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompositionUpdate);
1844
        TypingCommand::insertText(document(), text, TypingCommand::SelectInsertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextCompositionUpdate);
1843
1845
1844
        // Find out what node has the composition now.
1846
        // Find out what node has the composition now.
1845
        Position base = m_frame.selection().base().downstream();
1847
        Position base = m_frame.selection().selection().base().downstream();
1846
        Position extent = m_frame.selection().extent();
1848
        Position extent = m_frame.selection().selection().extent();
1847
        Node* baseNode = base.deprecatedNode();
1849
        Node* baseNode = base.deprecatedNode();
1848
        unsigned baseOffset = base.deprecatedEditingOffset();
1850
        unsigned baseOffset = base.deprecatedEditingOffset();
1849
        Node* extentNode = extent.deprecatedNode();
1851
        Node* extentNode = extent.deprecatedNode();
Lines 2161-2173 Vector<String> Editor::guessesForMisspel Source/WebCore/editing/Editor.cpp_sec15
2161
{
2163
{
2162
    if (unifiedTextCheckerEnabled()) {
2164
    if (unifiedTextCheckerEnabled()) {
2163
        RefPtr<Range> range;
2165
        RefPtr<Range> range;
2164
        FrameSelection& frameSelection = m_frame.selection();
2166
        VisibleSelection selection = m_frame.selection().selection();
2165
        if (frameSelection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
2167
        if (selection.isCaret() && behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
2166
            VisibleSelection wordSelection = VisibleSelection(frameSelection.base());
2168
            VisibleSelection wordSelection = VisibleSelection(selection.base());
2167
            wordSelection.expandUsingGranularity(WordGranularity);
2169
            wordSelection.expandUsingGranularity(WordGranularity);
2168
            range = wordSelection.toNormalizedRange();
2170
            range = wordSelection.toNormalizedRange();
2169
        } else
2171
        } else
2170
            range = frameSelection.toNormalizedRange();
2172
            range = selection.toNormalizedRange();
2171
        if (!range)
2173
        if (!range)
2172
            return Vector<String>();
2174
            return Vector<String>();
2173
        return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical);
2175
        return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical);
Lines 2301-2307 void Editor::markMisspellingsAfterTyping Source/WebCore/editing/Editor.cpp_sec16
2301
        m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false);
2303
        m_frame.editor().replaceSelectionWithText(autocorrectedString, false, false);
2302
2304
2303
        // Reset the charet one character further.
2305
        // Reset the charet one character further.
2304
        m_frame.selection().moveTo(m_frame.selection().end());
2306
        m_frame.selection().moveTo(m_frame.selection().selection().end());
2305
        m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2307
        m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2306
    }
2308
    }
2307
2309
Lines 2370-2376 bool Editor::isSpellCheckingEnabledFor(N Source/WebCore/editing/Editor.cpp_sec17
2370
2372
2371
bool Editor::isSpellCheckingEnabledInFocusedNode() const
2373
bool Editor::isSpellCheckingEnabledInFocusedNode() const
2372
{
2374
{
2373
    return isSpellCheckingEnabledFor(m_frame.selection().start().deprecatedNode());
2375
    return isSpellCheckingEnabledFor(m_frame.selection().selection().start().deprecatedNode());
2374
}
2376
}
2375
2377
2376
void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange)
2378
void Editor::markMisspellings(const VisibleSelection& selection, RefPtr<Range>& firstMisspellingRange)
Lines 2494-2502 void Editor::markAndReplaceFor(PassRefPt Source/WebCore/editing/Editor.cpp_sec18
2494
    bool adjustSelectionForParagraphBoundaries = false;
2496
    bool adjustSelectionForParagraphBoundaries = false;
2495
2497
2496
    if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) {
2498
    if (shouldPerformReplacement || shouldMarkSpelling || shouldCheckForCorrection) {
2497
        if (m_frame.selection().selectionType() == VisibleSelection::CaretSelection) {
2499
        if (m_frame.selection().selection().selectionType() == VisibleSelection::CaretSelection) {
2498
            // Attempt to save the caret position so we can restore it later if needed
2500
            // Attempt to save the caret position so we can restore it later if needed
2499
            Position caretPosition = m_frame.selection().end();
2501
            Position caretPosition = m_frame.selection().selection().end();
2500
            selectionOffset = paragraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION);
2502
            selectionOffset = paragraph.offsetTo(caretPosition, ASSERT_NO_EXCEPTION);
2501
            restoreSelectionAfterChange = true;
2503
            restoreSelectionAfterChange = true;
2502
            if (selectionOffset > 0 && (selectionOffset > paragraph.textLength() || paragraph.textCharAt(selectionOffset - 1) == newlineCharacter))
2504
            if (selectionOffset > 0 && (selectionOffset > paragraph.textLength() || paragraph.textCharAt(selectionOffset - 1) == newlineCharacter))
Lines 2625-2631 void Editor::markAndReplaceFor(PassRefPt Source/WebCore/editing/Editor.cpp_sec19
2625
                m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2627
                m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2626
        } else {
2628
        } else {
2627
            // If this fails for any reason, the fallback is to go one position beyond the last replacement
2629
            // If this fails for any reason, the fallback is to go one position beyond the last replacement
2628
            m_frame.selection().moveTo(m_frame.selection().end());
2630
            m_frame.selection().moveTo(m_frame.selection().selection().end());
2629
            m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2631
            m_frame.selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity);
2630
        }
2632
        }
2631
    }
2633
    }
Lines 2822-2831 bool Editor::getCompositionSelection(uns Source/WebCore/editing/Editor.cpp_sec20
2822
{
2824
{
2823
    if (!m_compositionNode)
2825
    if (!m_compositionNode)
2824
        return false;
2826
        return false;
2825
    Position start = m_frame.selection().start();
2827
    const VisibleSelection& selection = m_frame.selection().selection();
2828
    Position start = selection.start();
2826
    if (start.deprecatedNode() != m_compositionNode)
2829
    if (start.deprecatedNode() != m_compositionNode)
2827
        return false;
2830
        return false;
2828
    Position end = m_frame.selection().end();
2831
    Position end = selection.end();
2829
    if (end.deprecatedNode() != m_compositionNode)
2832
    if (end.deprecatedNode() != m_compositionNode)
2830
        return false;
2833
        return false;
2831
2834
Lines 3382-3388 static Node* findFirstMarkable(Node* nod Source/WebCore/editing/Editor.cpp_sec21
3382
3385
3383
bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const
3386
bool Editor::selectionStartHasMarkerFor(DocumentMarker::MarkerType markerType, int from, int length) const
3384
{
3387
{
3385
    Node* node = findFirstMarkable(m_frame.selection().start().deprecatedNode());
3388
    Node* node = findFirstMarkable(m_frame.selection().selection().start().deprecatedNode());
3386
    if (!node)
3389
    if (!node)
3387
        return false;
3390
        return false;
3388
3391
- Source/WebCore/editing/EditorCommand.cpp -5 / +6 lines
Lines 215-222 static bool expandSelectionToGranularity Source/WebCore/editing/EditorCommand.cpp_sec1
215
        return false;
215
        return false;
216
    if (newRange->collapsed(IGNORE_EXCEPTION))
216
    if (newRange->collapsed(IGNORE_EXCEPTION))
217
        return false;
217
        return false;
218
    RefPtr<Range> oldRange = frame.selection().selection().toNormalizedRange();
218
    RefPtr<Range> oldRange = selection.toNormalizedRange();
219
    EAffinity affinity = frame.selection().affinity();
219
    EAffinity affinity = selection.affinity();
220
    if (!frame.editor().client()->shouldChangeSelectedRange(oldRange.get(), newRange.get(), affinity, false))
220
    if (!frame.editor().client()->shouldChangeSelectedRange(oldRange.get(), newRange.get(), affinity, false))
221
        return false;
221
        return false;
222
    frame.selection().setSelectedRange(newRange.get(), affinity, true);
222
    frame.selection().setSelectedRange(newRange.get(), affinity, true);
Lines 1297-1303 static bool enabledInEditableTextOrCaret Source/WebCore/editing/EditorCommand.cpp_sec2
1297
1297
1298
static bool enabledInRichlyEditableText(Frame& frame, Event*, EditorCommandSource)
1298
static bool enabledInRichlyEditableText(Frame& frame, Event*, EditorCommandSource)
1299
{
1299
{
1300
    return frame.selection().isCaretOrRange() && frame.selection().isContentRichlyEditable() && frame.selection().rootEditableElement();
1300
    const VisibleSelection& selection = frame.selection().selection();
1301
    return selection.isCaretOrRange() && selection.isContentRichlyEditable() && selection.rootEditableElement();
1301
}
1302
}
1302
1303
1303
static bool enabledPaste(Frame& frame, Event*, EditorCommandSource)
1304
static bool enabledPaste(Frame& frame, Event*, EditorCommandSource)
Lines 1307-1318 static bool enabledPaste(Frame& frame, E Source/WebCore/editing/EditorCommand.cpp_sec3
1307
1308
1308
static bool enabledRangeInEditableText(Frame& frame, Event*, EditorCommandSource)
1309
static bool enabledRangeInEditableText(Frame& frame, Event*, EditorCommandSource)
1309
{
1310
{
1310
    return frame.selection().isRange() && frame.selection().isContentEditable();
1311
    return frame.selection().isRange() && frame.selection().selection().isContentEditable();
1311
}
1312
}
1312
1313
1313
static bool enabledRangeInRichlyEditableText(Frame& frame, Event*, EditorCommandSource)
1314
static bool enabledRangeInRichlyEditableText(Frame& frame, Event*, EditorCommandSource)
1314
{
1315
{
1315
    return frame.selection().isRange() && frame.selection().isContentRichlyEditable();
1316
    return frame.selection().isRange() && frame.selection().selection().isContentRichlyEditable();
1316
}
1317
}
1317
1318
1318
static bool enabledRedo(Frame& frame, Event*, EditorCommandSource)
1319
static bool enabledRedo(Frame& frame, Event*, EditorCommandSource)
- Source/WebCore/editing/FrameSelection.cpp -24 / +19 lines
Lines 1307-1313 static RenderObject* caretRenderer(Node* Source/WebCore/editing/FrameSelection.cpp_sec1
1307
1307
1308
bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition)
1308
bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition)
1309
{
1309
{
1310
    document->updateStyleIfNeeded();
1310
    document->updateLayoutIgnorePendingStylesheets();
1311
    m_caretLocalRect = LayoutRect();
1311
    m_caretLocalRect = LayoutRect();
1312
1312
1313
    m_caretRectNeedsUpdate = false;
1313
    m_caretRectNeedsUpdate = false;
Lines 1426-1432 bool FrameSelection::recomputeCaretRect( Source/WebCore/editing/FrameSelection.cpp_sec2
1426
1426
1427
#if ENABLE(TEXT_CARET)
1427
#if ENABLE(TEXT_CARET)
1428
    if (RenderView* view = m_frame->document()->renderView()) {
1428
    if (RenderView* view = m_frame->document()->renderView()) {
1429
        bool previousOrNewCaretNodeIsContentEditable = isContentEditable() || (m_previousCaretNode && m_previousCaretNode->isContentEditable());
1429
        bool previousOrNewCaretNodeIsContentEditable = m_selection.isContentEditable() || (m_previousCaretNode && m_previousCaretNode->isContentEditable());
1430
        if (shouldRepaintCaret(view, previousOrNewCaretNodeIsContentEditable)) {
1430
        if (shouldRepaintCaret(view, previousOrNewCaretNodeIsContentEditable)) {
1431
            if (m_previousCaretNode)
1431
            if (m_previousCaretNode)
1432
                repaintCaretForLocalRect(m_previousCaretNode.get(), oldRect);
1432
                repaintCaretForLocalRect(m_previousCaretNode.get(), oldRect);
Lines 1675-1681 void FrameSelection::selectAll() Source/WebCore/editing/FrameSelection.cpp_sec3
1675
1675
1676
    RefPtr<Node> root = 0;
1676
    RefPtr<Node> root = 0;
1677
    Node* selectStartTarget = 0;
1677
    Node* selectStartTarget = 0;
1678
    if (isContentEditable()) {
1678
    if (m_selection.isContentEditable()) {
1679
        root = highestEditableRoot(m_selection.start());
1679
        root = highestEditableRoot(m_selection.start());
1680
        if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode())
1680
        if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode())
1681
            selectStartTarget = shadowRoot->shadowHost();
1681
            selectStartTarget = shadowRoot->shadowHost();
Lines 1733-1744 bool FrameSelection::setSelectedRange(Ra Source/WebCore/editing/FrameSelection.cpp_sec4
1733
    return true;
1733
    return true;
1734
}
1734
}
1735
1735
1736
bool FrameSelection::isInPasswordField() const
1737
{
1738
    HTMLTextFormControlElement* textControl = enclosingTextFormControl(start());
1739
    return textControl && isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->isPasswordField();
1740
}
1741
1742
void FrameSelection::focusedOrActiveStateChanged()
1736
void FrameSelection::focusedOrActiveStateChanged()
1743
{
1737
{
1744
    bool activeAndFocused = isFocusedAndActive();
1738
    bool activeAndFocused = isFocusedAndActive();
Lines 1813-1820 void FrameSelection::updateAppearance() Source/WebCore/editing/FrameSelection.cpp_sec5
1813
1807
1814
    // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
1808
    // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
1815
    // the FrameSelection will paint a blinking caret as usual).
1809
    // the FrameSelection will paint a blinking caret as usual).
1810
    VisibleSelection oldSelection = selection();
1816
    VisiblePosition forwardPosition;
1811
    VisiblePosition forwardPosition;
1817
    if (m_shouldShowBlockCursor && m_selection.isCaret()) {
1812
    if (m_shouldShowBlockCursor && oldSelection.isCaret()) {
1818
        forwardPosition = modifyExtendingForward(CharacterGranularity);
1813
        forwardPosition = modifyExtendingForward(CharacterGranularity);
1819
        m_caretPaint = forwardPosition.isNull();
1814
        m_caretPaint = forwardPosition.isNull();
1820
    }
1815
    }
Lines 1823-1829 void FrameSelection::updateAppearance() Source/WebCore/editing/FrameSelection.cpp_sec6
1823
    bool caretRectChangedOrCleared = recomputeCaretRect();
1818
    bool caretRectChangedOrCleared = recomputeCaretRect();
1824
1819
1825
    bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
1820
    bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
1826
    bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull();
1821
    bool shouldBlink = caretIsVisible() && isCaret() && (oldSelection.isContentEditable() || caretBrowsing) && forwardPosition.isNull();
1827
1822
1828
    // If the caret moved, stop the blink timer so we can restart with a
1823
    // If the caret moved, stop the blink timer so we can restart with a
1829
    // black caret in the new location.
1824
    // black caret in the new location.
Lines 1849-1855 void FrameSelection::updateAppearance() Source/WebCore/editing/FrameSelection.cpp_sec7
1849
1844
1850
    // Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
1845
    // Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
1851
    // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
1846
    // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
1852
    VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : m_selection.visibleEnd());
1847
    VisibleSelection selection(oldSelection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : oldSelection.visibleEnd());
1853
1848
1854
    if (!selection.isRange()) {
1849
    if (!selection.isRange()) {
1855
        view->clearSelection();
1850
        view->clearSelection();
Lines 1912-1918 void FrameSelection::caretBlinkTimerFire Source/WebCore/editing/FrameSelection.cpp_sec8
1912
1907
1913
void FrameSelection::updateSelectionCachesIfSelectionIsInsideTextFormControl(EUserTriggered userTriggered)
1908
void FrameSelection::updateSelectionCachesIfSelectionIsInsideTextFormControl(EUserTriggered userTriggered)
1914
{
1909
{
1915
    if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()))
1910
    if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(m_selection.start()))
1916
        textControl->selectionChanged(userTriggered == UserTriggered);
1911
        textControl->selectionChanged(userTriggered == UserTriggered);
1917
}
1912
}
1918
1913
Lines 1936-1948 void FrameSelection::setFocusedElementIf Source/WebCore/editing/FrameSelection.cpp_sec9
1936
1931
1937
    bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
1932
    bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
1938
    if (caretBrowsing) {
1933
    if (caretBrowsing) {
1939
        if (Element* anchor = enclosingAnchorElement(base())) {
1934
        if (Element* anchor = enclosingAnchorElement(m_selection.base())) {
1940
            m_frame->page()->focusController().setFocusedElement(anchor, m_frame);
1935
            m_frame->page()->focusController().setFocusedElement(anchor, m_frame);
1941
            return;
1936
            return;
1942
        }
1937
        }
1943
    }
1938
    }
1944
1939
1945
    if (Element* target = rootEditableElement()) {
1940
    if (Element* target = m_selection.rootEditableElement()) {
1946
        // Walk up the DOM tree to search for an element to focus.
1941
        // Walk up the DOM tree to search for an element to focus.
1947
        while (target) {
1942
        while (target) {
1948
            // We don't want to set focus on a subframe when selecting in a parent frame,
1943
            // We don't want to set focus on a subframe when selecting in a parent frame,
Lines 2054-2060 HTMLFormElement* FrameSelection::current Source/WebCore/editing/FrameSelection.cpp_sec10
2054
    // Start looking either at the active (first responder) node, or where the selection is.
2049
    // Start looking either at the active (first responder) node, or where the selection is.
2055
    Element* start = m_frame->document()->focusedElement();
2050
    Element* start = m_frame->document()->focusedElement();
2056
    if (!start)
2051
    if (!start)
2057
        start = this->start().element();
2052
        start = m_selection.start().element();
2058
    if (!start)
2053
    if (!start)
2059
        return nullptr;
2054
        return nullptr;
2060
2055
Lines 2071-2088 void FrameSelection::revealSelection(con Source/WebCore/editing/FrameSelection.cpp_sec11
2071
{
2066
{
2072
    LayoutRect rect;
2067
    LayoutRect rect;
2073
2068
2074
    switch (selectionType()) {
2069
    switch (m_selection.selectionType()) {
2075
    case VisibleSelection::NoSelection:
2070
    case VisibleSelection::NoSelection:
2076
        return;
2071
        return;
2077
    case VisibleSelection::CaretSelection:
2072
    case VisibleSelection::CaretSelection:
2078
        rect = absoluteCaretBounds();
2073
        rect = absoluteCaretBounds();
2079
        break;
2074
        break;
2080
    case VisibleSelection::RangeSelection:
2075
    case VisibleSelection::RangeSelection:
2081
        rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).absoluteCaretBounds() : enclosingIntRect(bounds(false));
2076
        rect = revealExtentOption == RevealExtent ? VisiblePosition(m_selection.extent()).absoluteCaretBounds() : enclosingIntRect(bounds(false));
2082
        break;
2077
        break;
2083
    }
2078
    }
2084
2079
2085
    Position start = this->start();
2080
    Position start = m_selection.start();
2086
    ASSERT(start.deprecatedNode());
2081
    ASSERT(start.deprecatedNode());
2087
    if (start.deprecatedNode() && start.deprecatedNode()->renderer()) {
2082
    if (start.deprecatedNode() && start.deprecatedNode()->renderer()) {
2088
#if PLATFORM(IOS)
2083
#if PLATFORM(IOS)
Lines 2117-2123 void FrameSelection::setSelectionFromNon Source/WebCore/editing/FrameSelection.cpp_sec12
2117
    if (!isNone() || !(document->hasEditableStyle() || caretBrowsing))
2112
    if (!isNone() || !(document->hasEditableStyle() || caretBrowsing))
2118
        return;
2113
        return;
2119
#else
2114
#else
2120
    if (!document || !(isNone() || isStartOfDocument(VisiblePosition(selection().start(), selection().affinity()))) || !document->hasEditableStyle())
2115
    if (!document || !(isNone() || isStartOfDocument(VisiblePosition(m_selection.start(), m_selection.affinity()))) || !document->hasEditableStyle())
2121
        return;
2116
        return;
2122
#endif
2117
#endif
2123
2118
Lines 2431-2438 VisibleSelection FrameSelection::wordSel Source/WebCore/editing/FrameSelection.cpp_sec13
2431
    newSelection.expandUsingGranularity(WordGranularity);
2426
    newSelection.expandUsingGranularity(WordGranularity);
2432
    frameSelection.setSelection(newSelection, CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, frameSelection.granularity());
2427
    frameSelection.setSelection(newSelection, CloseTyping | ClearTypingStyle, AlignCursorOnScrollIfNeeded, frameSelection.granularity());
2433
2428
2434
    Position startPos(frameSelection.selection().start());
2429
    Position startPos(frameSelection.selection().selection().start());
2435
    Position endPos(frameSelection.selection().end());
2430
    Position endPos(frameSelection.selection().selection().end());
2436
2431
2437
    // Expansion cannot be allowed to change selection so that it is no longer
2432
    // Expansion cannot be allowed to change selection so that it is no longer
2438
    // touches (or contains) the original, unexpanded selection.
2433
    // touches (or contains) the original, unexpanded selection.
Lines 2479-2486 VisibleSelection FrameSelection::wordSel Source/WebCore/editing/FrameSelection.cpp_sec14
2479
        }
2474
        }
2480
        frameSelection.moveTo(startVisiblePos);
2475
        frameSelection.moveTo(startVisiblePos);
2481
        frameSelection.modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity);
2476
        frameSelection.modify(FrameSelection::AlterationExtend, DirectionBackward, WordGranularity);
2482
        startPos = frameSelection.selection().start();
2477
        startPos = frameSelection.selection().selection().start();
2483
        endPos = frameSelection.selection().end();
2478
        endPos = frameSelection.selection().selection().end();
2484
        startVisiblePos = VisiblePosition(startPos, VP_DEFAULT_AFFINITY);
2479
        startVisiblePos = VisiblePosition(startPos, VP_DEFAULT_AFFINITY);
2485
        endVisiblePos = VisiblePosition(endPos, VP_DEFAULT_AFFINITY);
2480
        endVisiblePos = VisiblePosition(endPos, VP_DEFAULT_AFFINITY);
2486
        if (startVisiblePos.isNull() || endVisiblePos.isNull()) {
2481
        if (startVisiblePos.isNull() || endVisiblePos.isNull()) {
- Source/WebCore/editing/FrameSelection.h -14 / +2 lines
Lines 135-146 public: Source/WebCore/editing/FrameSelection.h_sec1
135
135
136
    explicit FrameSelection(Frame* = 0);
136
    explicit FrameSelection(Frame* = 0);
137
137
138
    Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
139
    Element* rootEditableElementOrDocumentElement() const;
138
    Element* rootEditableElementOrDocumentElement() const;
140
141
    bool hasEditableStyle() const { return m_selection.hasEditableStyle(); }
142
    bool isContentEditable() const { return m_selection.isContentEditable(); }
143
    bool isContentRichlyEditable() const { return m_selection.isContentRichlyEditable(); }
144
     
139
     
145
    void moveTo(const Range*, EAffinity, EUserTriggered = NotUserTriggered);
140
    void moveTo(const Range*, EAffinity, EUserTriggered = NotUserTriggered);
146
    void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded);
141
    void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded);
Lines 157-166 public: Source/WebCore/editing/FrameSelection.h_sec2
157
152
158
    bool contains(const LayoutPoint&);
153
    bool contains(const LayoutPoint&);
159
154
160
    VisibleSelection::SelectionType selectionType() const { return m_selection.selectionType(); }
161
162
    EAffinity affinity() const { return m_selection.affinity(); }
163
164
    bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered = NotUserTriggered);
155
    bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered = NotUserTriggered);
165
    enum VerticalDirection { DirectionUp, DirectionDown };
156
    enum VerticalDirection { DirectionUp, DirectionDown };
166
    bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUserTriggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded);
157
    bool modify(EAlteration, unsigned verticalDistance, VerticalDirection, EUserTriggered = NotUserTriggered, CursorAlignOnScroll = AlignCursorOnScrollIfNeeded);
Lines 175-183 public: Source/WebCore/editing/FrameSelection.h_sec3
175
    void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered);
166
    void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered);
176
    void setExtent(const Position&, EAffinity, EUserTriggered = NotUserTriggered);
167
    void setExtent(const Position&, EAffinity, EUserTriggered = NotUserTriggered);
177
168
178
    Position base() const { return m_selection.base(); }
179
    Position extent() const { return m_selection.extent(); }
180
    Position start() const { return m_selection.start(); }
181
    Position end() const { return m_selection.end(); }
169
    Position end() const { return m_selection.end(); }
182
170
183
    // Return the renderer that is responsible for painting the caret (in the selection start node)
171
    // Return the renderer that is responsible for painting the caret (in the selection start node)
Lines 196-202 public: Source/WebCore/editing/FrameSelection.h_sec4
196
    bool isCaret() const { return m_selection.isCaret(); }
184
    bool isCaret() const { return m_selection.isCaret(); }
197
    bool isRange() const { return m_selection.isRange(); }
185
    bool isRange() const { return m_selection.isRange(); }
198
    bool isCaretOrRange() const { return m_selection.isCaretOrRange(); }
186
    bool isCaretOrRange() const { return m_selection.isCaretOrRange(); }
199
    bool isInPasswordField() const;
200
    bool isAll(EditingBoundaryCrossingRule rule = CannotCrossEditingBoundary) const { return m_selection.isAll(rule); }
187
    bool isAll(EditingBoundaryCrossingRule rule = CannotCrossEditingBoundary) const { return m_selection.isAll(rule); }
201
    
188
    
202
    PassRefPtr<Range> toNormalizedRange() const { return m_selection.toNormalizedRange(); }
189
    PassRefPtr<Range> toNormalizedRange() const { return m_selection.toNormalizedRange(); }
Lines 335-340 private: Source/WebCore/editing/FrameSelection.h_sec5
335
    LayoutUnit m_xPosForVerticalArrowNavigation;
322
    LayoutUnit m_xPosForVerticalArrowNavigation;
336
323
337
    VisibleSelection m_selection;
324
    VisibleSelection m_selection;
325
    mutable VisibleSelection m_validatedSelectionCache;
338
    VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary
326
    VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary
339
    TextGranularity m_granularity;
327
    TextGranularity m_granularity;
340
328
Lines 352-358 private: Source/WebCore/editing/FrameSelection.h_sec6
352
    bool m_shouldShowBlockCursor : 1;
340
    bool m_shouldShowBlockCursor : 1;
353
341
354
#if PLATFORM(IOS)
342
#if PLATFORM(IOS)
355
    bool m_updateAppearanceEnabled : 1;
343
    bool m_updateAppearanceEnabled : 1;DragController.cpp
356
    bool m_caretBlinks : 1;
344
    bool m_caretBlinks : 1;
357
    Color m_caretColor;
345
    Color m_caretColor;
358
    int m_closeTypingSuppressions;
346
    int m_closeTypingSuppressions;
- Source/WebCore/editing/RemoveFormatCommand.cpp -2 / +2 lines
Lines 77-88 static bool isElementForRemoveFormatComm Source/WebCore/editing/RemoveFormatCommand.cpp_sec1
77
77
78
void RemoveFormatCommand::doApply()
78
void RemoveFormatCommand::doApply()
79
{
79
{
80
    if (!frame().selection().selection().isNonOrphanedCaretOrRange())
80
    if (!endingSelection().isNonOrphanedCaretOrRange())
81
        return;
81
        return;
82
82
83
    // Get the default style for this editable root, it's the style that we'll give the
83
    // Get the default style for this editable root, it's the style that we'll give the
84
    // content that we're operating on.
84
    // content that we're operating on.
85
    Node* root = frame().selection().rootEditableElement();
85
    Node* root = endingSelection().rootEditableElement();
86
    RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root);
86
    RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root);
87
87
88
    // We want to remove everything but transparent background.
88
    // We want to remove everything but transparent background.
- Source/WebCore/editing/VisibleSelection.cpp +7 lines
Lines 28-33 Source/WebCore/editing/VisibleSelection.cpp_sec1
28
28
29
#include "Document.h"
29
#include "Document.h"
30
#include "Element.h"
30
#include "Element.h"
31
#include "HTMLInputElement.h"
31
#include "TextIterator.h"
32
#include "TextIterator.h"
32
#include "VisibleUnits.h"
33
#include "VisibleUnits.h"
33
#include "htmlediting.h"
34
#include "htmlediting.h"
Lines 666-671 Node* VisibleSelection::nonBoundaryShado Source/WebCore/editing/VisibleSelection.cpp_sec2
666
    return start().deprecatedNode() ? start().deprecatedNode()->nonBoundaryShadowTreeRootNode() : 0;
667
    return start().deprecatedNode() ? start().deprecatedNode()->nonBoundaryShadowTreeRootNode() : 0;
667
}
668
}
668
669
670
bool VisibleSelection::isInPasswordField() const
671
{
672
    HTMLTextFormControlElement* textControl = enclosingTextFormControl(start());
673
    return textControl && isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->isPasswordField();
674
}
675
669
#ifndef NDEBUG
676
#ifndef NDEBUG
670
677
671
void VisibleSelection::debugPosition() const
678
void VisibleSelection::debugPosition() const
- Source/WebCore/editing/VisibleSelection.h +2 lines
Lines 105-110 public: Source/WebCore/editing/VisibleSelection.h_sec1
105
    // ShadowRoot node for new shadow trees, or 0 for non-shadow trees.
105
    // ShadowRoot node for new shadow trees, or 0 for non-shadow trees.
106
    Node* nonBoundaryShadowTreeRootNode() const;
106
    Node* nonBoundaryShadowTreeRootNode() const;
107
107
108
    bool isInPasswordField() const;
109
108
#ifndef NDEBUG
110
#ifndef NDEBUG
109
    void debugPosition() const;
111
    void debugPosition() const;
110
    void formatForDebugger(char* buffer, unsigned length) const;
112
    void formatForDebugger(char* buffer, unsigned length) const;
- Source/WebCore/editing/mac/EditorMac.mm -2 / +2 lines
Lines 239-245 NSDictionary* Editor::fontAttributesForS Source/WebCore/editing/mac/EditorMac.mm_sec1
239
239
240
bool Editor::canCopyExcludingStandaloneImages()
240
bool Editor::canCopyExcludingStandaloneImages()
241
{
241
{
242
    FrameSelection& selection = m_frame.selection();
242
    const VisibleSelection& selection = m_frame.selection().selection();
243
    return selection.isRange() && !selection.isInPasswordField();
243
    return selection.isRange() && !selection.isInPasswordField();
244
}
244
}
245
245
Lines 259-265 void Editor::takeFindStringFromSelection Source/WebCore/editing/mac/EditorMac.mm_sec2
259
void Editor::readSelectionFromPasteboard(const String& pasteboardName)
259
void Editor::readSelectionFromPasteboard(const String& pasteboardName)
260
{
260
{
261
    Pasteboard pasteboard(pasteboardName);
261
    Pasteboard pasteboard(pasteboardName);
262
    if (m_frame.selection().isContentRichlyEditable())
262
    if (m_frame.selection().selection().isContentRichlyEditable())
263
        pasteWithPasteboard(&pasteboard, true);
263
        pasteWithPasteboard(&pasteboard, true);
264
    else
264
    else
265
        pasteAsPlainTextWithPasteboard(pasteboard);
265
        pasteAsPlainTextWithPasteboard(pasteboard);
- Source/WebCore/html/HTMLAnchorElement.cpp -2 / +2 lines
Lines 195-201 void HTMLAnchorElement::defaultEventHand Source/WebCore/html/HTMLAnchorElement.cpp_sec1
195
            // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
195
            // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
196
            // for the LiveWhenNotFocused editable link behavior
196
            // for the LiveWhenNotFocused editable link behavior
197
            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document().frame()) {
197
            if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document().frame()) {
198
                setRootEditableElementForSelectionOnMouseDown(document().frame()->selection().rootEditableElement());
198
                setRootEditableElementForSelectionOnMouseDown(document().frame()->selection().selection().rootEditableElement());
199
                m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
199
                m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
200
            } else if (event->type() == eventNames().mouseoverEvent) {
200
            } else if (event->type() == eventNames().mouseoverEvent) {
201
                // These are cleared on mouseover and not mouseout because their values are needed for drag events,
201
                // These are cleared on mouseover and not mouseout because their values are needed for drag events,
Lines 228-234 void HTMLAnchorElement::setActive(bool d Source/WebCore/html/HTMLAnchorElement.cpp_sec2
228
            // Don't set the link to be active if the current selection is in the same editable block as
228
            // Don't set the link to be active if the current selection is in the same editable block as
229
            // this link
229
            // this link
230
            case EditableLinkLiveWhenNotFocused:
230
            case EditableLinkLiveWhenNotFocused:
231
                if (down && document().frame() && document().frame()->selection().rootEditableElement() == rootEditableElement())
231
                if (down && document().frame() && document().frame()->selection().selection().rootEditableElement() == rootEditableElement())
232
                    return;
232
                    return;
233
                break;
233
                break;
234
            
234
            
- Source/WebCore/html/HTMLTextFormControlElement.cpp -2 / +2 lines
Lines 356-362 int HTMLTextFormControlElement::computeS Source/WebCore/html/HTMLTextFormControlElement.cpp_sec1
356
    if (!frame)
356
    if (!frame)
357
        return 0;
357
        return 0;
358
358
359
    return indexForVisiblePosition(frame->selection().start());
359
    return indexForVisiblePosition(frame->selection().selection().start());
360
}
360
}
361
361
362
int HTMLTextFormControlElement::selectionEnd() const
362
int HTMLTextFormControlElement::selectionEnd() const
Lines 375-381 int HTMLTextFormControlElement::computeS Source/WebCore/html/HTMLTextFormControlElement.cpp_sec2
375
    if (!frame)
375
    if (!frame)
376
        return 0;
376
        return 0;
377
377
378
    return indexForVisiblePosition(frame->selection().end());
378
    return indexForVisiblePosition(frame->selection().selection().end());
379
}
379
}
380
380
381
static const AtomicString& directionString(TextFieldSelectionDirection direction)
381
static const AtomicString& directionString(TextFieldSelectionDirection direction)
- Source/WebCore/page/ContextMenuController.cpp -7 / +7 lines
Lines 341-355 void ContextMenuController::contextMenuI Source/WebCore/page/ContextMenuController.cpp_sec1
341
        break;
341
        break;
342
#endif
342
#endif
343
    case ContextMenuItemTagSpellingGuess: {
343
    case ContextMenuItemTagSpellingGuess: {
344
        FrameSelection& frameSelection = frame->selection();
344
        VisibleSelection selection = frame->selection().selection();
345
        if (frame->editor().shouldInsertText(item->title(), frameSelection.toNormalizedRange().get(), EditorInsertActionPasted)) {
345
        if (frame->editor().shouldInsertText(item->title(), selection.toNormalizedRange().get(), EditorInsertActionPasted)) {
346
            ReplaceSelectionCommand::CommandOptions replaceOptions = ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting;
346
            ReplaceSelectionCommand::CommandOptions replaceOptions = ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting;
347
347
348
            if (frame->editor().behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
348
            if (frame->editor().behavior().shouldAllowSpellingSuggestionsWithoutSelection()) {
349
                ASSERT(frameSelection.isCaretOrRange());
349
                ASSERT(selection.isCaretOrRange());
350
                VisibleSelection wordSelection(frameSelection.base());
350
                VisibleSelection wordSelection(selection.base());
351
                wordSelection.expandUsingGranularity(WordGranularity);
351
                wordSelection.expandUsingGranularity(WordGranularity);
352
                frameSelection.setSelection(wordSelection);
352
                frame->selection().setSelection(wordSelection);
353
            } else {
353
            } else {
354
                ASSERT(frame->editor().selectedText().length());
354
                ASSERT(frame->editor().selectedText().length());
355
                replaceOptions |= ReplaceSelectionCommand::SelectReplacement;
355
                replaceOptions |= ReplaceSelectionCommand::SelectReplacement;
Lines 359-365 void ContextMenuController::contextMenuI Source/WebCore/page/ContextMenuController.cpp_sec2
359
            ASSERT(document);
359
            ASSERT(document);
360
            RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, item->title(), ""), replaceOptions);
360
            RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(*document, createFragmentFromMarkup(*document, item->title(), ""), replaceOptions);
361
            applyCommand(command);
361
            applyCommand(command);
362
            frameSelection.revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
362
            frame->selection().revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
363
        }
363
        }
364
        break;
364
        break;
365
    }
365
    }
Lines 921-927 void ContextMenuController::populate() Source/WebCore/page/ContextMenuController.cpp_sec3
921
            }
921
            }
922
        }
922
        }
923
    } else { // Make an editing context menu
923
    } else { // Make an editing context menu
924
        bool inPasswordField = frame->selection().isInPasswordField();
924
        bool inPasswordField = frame->selection().selection().isInPasswordField();
925
        if (!inPasswordField) {
925
        if (!inPasswordField) {
926
            bool haveContextMenuItemsForMisspellingOrGrammer = false;
926
            bool haveContextMenuItemsForMisspellingOrGrammer = false;
927
            bool spellCheckingEnabled = frame->editor().isSpellCheckingEnabledFor(node);
927
            bool spellCheckingEnabled = frame->editor().isSpellCheckingEnabledFor(node);
- Source/WebCore/page/DragController.cpp -7 / +9 lines
Lines 158-164 static PassRefPtr<DocumentFragment> docu Source/WebCore/page/DragController.cpp_sec1
158
158
159
bool DragController::dragIsMove(FrameSelection& selection, DragData& dragData)
159
bool DragController::dragIsMove(FrameSelection& selection, DragData& dragData)
160
{
160
{
161
    return m_documentUnderMouse == m_dragInitiator && selection.isContentEditable() && selection.isRange() && !isCopyKeyDown(dragData);
161
    const VisibleSelection& visibleSelection = selection.selection();
162
    return m_documentUnderMouse == m_dragInitiator && visibleSelection.isContentEditable() && visibleSelection.isRange() && !isCopyKeyDown(dragData);
162
}
163
}
163
164
164
// FIXME: This method is poorly named.  We're just clearing the selection from the document this drag is exiting.
165
// FIXME: This method is poorly named.  We're just clearing the selection from the document this drag is exiting.
Lines 413-424 DragOperation DragController::operationF Source/WebCore/page/DragController.cpp_sec2
413
static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, RefPtr<Range>& range, const IntPoint& point)
414
static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, RefPtr<Range>& range, const IntPoint& point)
414
{
415
{
415
    frame->selection().setSelection(dragCaret);
416
    frame->selection().setSelection(dragCaret);
416
    if (frame->selection().isNone()) {
417
    if (frame->selection().selection().isNone()) {
417
        dragCaret = frame->visiblePositionForPoint(point);
418
        dragCaret = frame->visiblePositionForPoint(point);
418
        frame->selection().setSelection(dragCaret);
419
        frame->selection().setSelection(dragCaret);
419
        range = dragCaret.toNormalizedRange();
420
        range = dragCaret.toNormalizedRange();
420
    }
421
    }
421
    return !frame->selection().isNone() && frame->selection().isContentEditable();
422
    return !frame->selection().isNone() && frame->selection().selection().isContentEditable();
422
}
423
}
423
424
424
bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData& dragData)
425
bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData& dragData)
Lines 482-488 bool DragController::concludeEditDrag(Dr Source/WebCore/page/DragController.cpp_sec3
482
    VisibleSelection dragCaret = m_page.dragCaretController().caretPosition();
483
    VisibleSelection dragCaret = m_page.dragCaretController().caretPosition();
483
    m_page.dragCaretController().clear();
484
    m_page.dragCaretController().clear();
484
    RefPtr<Range> range = dragCaret.toNormalizedRange();
485
    RefPtr<Range> range = dragCaret.toNormalizedRange();
485
    RefPtr<Element> rootEditableElement = innerFrame->selection().rootEditableElement();
486
    RefPtr<Element> rootEditableElement = innerFrame->selection().selection().rootEditableElement();
486
487
487
    // For range to be null a WebKit client must have done something bad while
488
    // For range to be null a WebKit client must have done something bad while
488
    // manually controlling drag behaviour
489
    // manually controlling drag behaviour
Lines 765-771 bool DragController::startDrag(Frame& sr Source/WebCore/page/DragController.cpp_sec4
765
766
766
            src.editor().willWriteSelectionToPasteboard(selectionRange.get());
767
            src.editor().willWriteSelectionToPasteboard(selectionRange.get());
767
768
768
            if (enclosingTextFormControl(src.selection().start()))
769
            if (enclosingTextFormControl(src.selection().selection().start()))
769
                clipboard.pasteboard().writePlainText(src.editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);
770
                clipboard.pasteboard().writePlainText(src.editor().selectedTextForClipboard(), Pasteboard::CannotSmartReplace);
770
            else {
771
            else {
771
#if PLATFORM(MAC) || PLATFORM(EFL)
772
#if PLATFORM(MAC) || PLATFORM(EFL)
Lines 812-822 bool DragController::startDrag(Frame& sr Source/WebCore/page/DragController.cpp_sec5
812
            // on the web page. This includes replacing newlines with spaces.
813
            // on the web page. This includes replacing newlines with spaces.
813
            src.editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard.pasteboard());
814
            src.editor().copyURL(linkURL, hitTestResult.textContent().simplifyWhiteSpace(), clipboard.pasteboard());
814
815
815
        if (src.selection().isCaret() && src.selection().isContentEditable()) {
816
        const VisibleSelection& srcSelection = src.selection().selection();
817
        if (srcSelection.isCaret() && srcSelection.isContentEditable()) {
816
            // a user can initiate a drag on a link without having any text
818
            // a user can initiate a drag on a link without having any text
817
            // selected.  In this case, we should expand the selection to
819
            // selected.  In this case, we should expand the selection to
818
            // the enclosing anchor element
820
            // the enclosing anchor element
819
            Position pos = src.selection().base();
821
            Position pos = srcSelection.base();
820
            Node* node = enclosingAnchorElement(pos);
822
            Node* node = enclosingAnchorElement(pos);
821
            if (node)
823
            if (node)
822
                src.selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
824
                src.selection().setSelection(VisibleSelection::selectionFromContentsOfNode(node));
- Source/WebCore/page/EventHandler.cpp -5 / +5 lines
Lines 1223-1229 static bool isSubmitImage(Node* node) Source/WebCore/page/EventHandler.cpp_sec1
1223
// Returns true if the node's editable block is not current focused for editing
1223
// Returns true if the node's editable block is not current focused for editing
1224
static bool nodeIsNotBeingEdited(const Node& node, const Frame& frame)
1224
static bool nodeIsNotBeingEdited(const Node& node, const Frame& frame)
1225
{
1225
{
1226
    return frame.selection().rootEditableElement() != node.rootEditableElement();
1226
    return frame.selection().selection().rootEditableElement() != node.rootEditableElement();
1227
}
1227
}
1228
1228
1229
bool EventHandler::useHandCursor(Node* node, bool isOverLink, bool shiftKey)
1229
bool EventHandler::useHandCursor(Node* node, bool isOverLink, bool shiftKey)
Lines 2640-2646 bool EventHandler::sendContextMenuEvent( Source/WebCore/page/EventHandler.cpp_sec2
2640
        // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
2640
        // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
2641
        // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
2641
        // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
2642
        // available for text selections.  But only if we're above text.
2642
        // available for text selections.  But only if we're above text.
2643
        && (m_frame.selection().isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) {
2643
        && (m_frame.selection().selection().isContentEditable() || (mev.targetNode() && mev.targetNode()->isTextNode()))) {
2644
        m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
2644
        m_mouseDownMayStartSelect = true; // context menu events are always allowed to perform a selection
2645
        selectClosestWordOrLinkFromMouseEvent(mev);
2645
        selectClosestWordOrLinkFromMouseEvent(mev);
2646
    }
2646
    }
Lines 2673-2680 bool EventHandler::sendContextMenuEventF Source/WebCore/page/EventHandler.cpp_sec3
2673
    IntPoint location;
2673
    IntPoint location;
2674
2674
2675
    Element* focusedElement = doc->focusedElement();
2675
    Element* focusedElement = doc->focusedElement();
2676
    FrameSelection& selection = m_frame.selection();
2676
    const VisibleSelection& selection = m_frame.selection().selection();
2677
    Position start = selection.selection().start();
2677
    Position start = selection.start();
2678
2678
2679
    if (start.deprecatedNode() && (selection.rootEditableElement() || selection.isRange())) {
2679
    if (start.deprecatedNode() && (selection.rootEditableElement() || selection.isRange())) {
2680
        RefPtr<Range> selectionRange = selection.toNormalizedRange();
2680
        RefPtr<Range> selectionRange = selection.toNormalizedRange();
Lines 3273-3279 bool EventHandler::handleDrag(const Mous Source/WebCore/page/EventHandler.cpp_sec4
3273
        } 
3273
        } 
3274
        
3274
        
3275
        m_mouseDownMayStartDrag = dispatchDragSrcEvent(eventNames().dragstartEvent, m_mouseDown)
3275
        m_mouseDownMayStartDrag = dispatchDragSrcEvent(eventNames().dragstartEvent, m_mouseDown)
3276
            && !m_frame.selection().isInPasswordField();
3276
            && !m_frame.selection().selection().isInPasswordField();
3277
        
3277
        
3278
        // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
3278
        // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
3279
        // image can still be changed as we drag, but not the pasteboard data.
3279
        // image can still be changed as we drag, but not the pasteboard data.
- Source/WebCore/page/FocusController.cpp -6 / +6 lines
Lines 281-287 bool FocusController::advanceFocusInDocu Source/WebCore/page/FocusController.cpp_sec1
281
    bool caretBrowsing = frame.settings().caretBrowsingEnabled();
281
    bool caretBrowsing = frame.settings().caretBrowsingEnabled();
282
282
283
    if (caretBrowsing && !currentNode)
283
    if (caretBrowsing && !currentNode)
284
        currentNode = frame.selection().start().deprecatedNode();
284
        currentNode = frame.selection().selection().start().deprecatedNode();
285
285
286
    document->updateLayoutIgnorePendingStylesheets();
286
    document->updateLayoutIgnorePendingStylesheets();
287
287
Lines 553-560 static void clearSelectionIfNeeded(Frame Source/WebCore/page/FocusController.cpp_sec2
553
        
553
        
554
    if (oldFocusedFrame->document() != newFocusedFrame->document())
554
    if (oldFocusedFrame->document() != newFocusedFrame->document())
555
        return;
555
        return;
556
    
556
557
    FrameSelection& selection = oldFocusedFrame->selection();
557
    const VisibleSelection& selection = oldFocusedFrame->selection().selection();
558
    if (selection.isNone())
558
    if (selection.isNone())
559
        return;
559
        return;
560
560
Lines 562-568 static void clearSelectionIfNeeded(Frame Source/WebCore/page/FocusController.cpp_sec3
562
    if (caretBrowsing)
562
    if (caretBrowsing)
563
        return;
563
        return;
564
564
565
    Node* selectionStartNode = selection.selection().start().deprecatedNode();
565
    Node* selectionStartNode = selection.start().deprecatedNode();
566
    if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newFocusedNode)
566
    if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newFocusedNode)
567
        return;
567
        return;
568
        
568
        
Lines 579-586 static void clearSelectionIfNeeded(Frame Source/WebCore/page/FocusController.cpp_sec4
579
            }
579
            }
580
        }
580
        }
581
    }
581
    }
582
    
582
583
    selection.clear();
583
    oldFocusedFrame->selection().clear();
584
}
584
}
585
585
586
bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newFocusedFrame, FocusDirection direction)
586
bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newFocusedFrame, FocusDirection direction)
- Source/WebCore/page/ios/FrameIOS.mm -14 / +13 lines
Lines 601-615 void Frame::updateLayout() const Source/WebCore/page/ios/FrameIOS.mm_sec1
601
601
602
NSRect Frame::caretRect() const
602
NSRect Frame::caretRect() const
603
{
603
{
604
    if (selection().isNone())
604
    VisibleSelection visibleSelection = selection().selection();
605
    if (visibleSelection.isNone())
605
        return CGRectZero;
606
        return CGRectZero;
606
    return selection().isCaret() ? selection().absoluteCaretBounds() : VisiblePosition(selection().end()).absoluteCaretBounds();
607
    return visibleSelection.isCaret() ? selection().absoluteCaretBounds() : VisiblePosition(visibleSelection.end()).absoluteCaretBounds();
607
}
608
}
608
609
609
NSRect Frame::rectForScrollToVisible() const
610
NSRect Frame::rectForScrollToVisible() const
610
{
611
{
611
    VisibleSelection selection(this->selection().selection());
612
    return rectForSelection(selection().selection());
612
    return rectForSelection(selection);
613
}
613
}
614
614
615
NSRect Frame::rectForSelection(VisibleSelection& selection) const
615
NSRect Frame::rectForSelection(VisibleSelection& selection) const
Lines 658-664 NSRect Frame::rectForSelection(VisibleSe Source/WebCore/page/ios/FrameIOS.mm_sec2
658
658
659
DOMCSSStyleDeclaration* Frame::styleAtSelectionStart() const
659
DOMCSSStyleDeclaration* Frame::styleAtSelectionStart() const
660
{
660
{
661
    Position start = selection().start();
662
    RefPtr<EditingStyle> editingStyle = EditingStyle::styleAtSelectionStart(selection().selection());
661
    RefPtr<EditingStyle> editingStyle = EditingStyle::styleAtSelectionStart(selection().selection());
663
    if (!editingStyle)
662
    if (!editingStyle)
664
        return nullptr;
663
        return nullptr;
Lines 737-750 void Frame::setRangedSelectionBaseToCurr Source/WebCore/page/ios/FrameIOS.mm_sec3
737
736
738
void Frame::setRangedSelectionBaseToCurrentSelectionStart()
737
void Frame::setRangedSelectionBaseToCurrentSelectionStart()
739
{
738
{
740
    FrameSelection& frameSelection = selection();
739
    const VisibleSelection& visibleSelection = selection().selection();
741
    m_rangedSelectionBase = VisibleSelection(frameSelection.selection().start(), frameSelection.affinity());
740
    m_rangedSelectionBase = VisibleSelection(visibleSelection.start(), visibleSelection.affinity());
742
}
741
}
743
742
744
void Frame::setRangedSelectionBaseToCurrentSelectionEnd()
743
void Frame::setRangedSelectionBaseToCurrentSelectionEnd()
745
{
744
{
746
    FrameSelection& frameSelection = selection();
745
    const VisibleSelection& visibleSelection = selection().selection();
747
    m_rangedSelectionBase = VisibleSelection(frameSelection.selection().end(), frameSelection.affinity());
746
    m_rangedSelectionBase = VisibleSelection(visibleSelection.end(), visibleSelection.affinity());
748
}
747
}
749
748
750
VisibleSelection Frame::rangedSelectionBase() const
749
VisibleSelection Frame::rangedSelectionBase() const
Lines 759-772 void Frame::clearRangedSelectionInitialE Source/WebCore/page/ios/FrameIOS.mm_sec4
759
758
760
void Frame::setRangedSelectionInitialExtentToCurrentSelectionStart()
759
void Frame::setRangedSelectionInitialExtentToCurrentSelectionStart()
761
{
760
{
762
    FrameSelection& frameSelection = selection();
761
    const VisibleSelection& visibleSelection = selection().selection();
763
    m_rangedSelectionInitialExtent = VisibleSelection(frameSelection.selection().start(), frameSelection.affinity());
762
    m_rangedSelectionInitialExtent = VisibleSelection(visibleSelection.start(), visibleSelection.affinity());
764
}
763
}
765
764
766
void Frame::setRangedSelectionInitialExtentToCurrentSelectionEnd()
765
void Frame::setRangedSelectionInitialExtentToCurrentSelectionEnd()
767
{
766
{
768
    FrameSelection& frameSelection = selection();
767
    const VisibleSelection& visibleSelection = selection().selection();
769
    m_rangedSelectionInitialExtent = VisibleSelection(frameSelection.selection().end(), frameSelection.affinity());
768
    m_rangedSelectionInitialExtent = VisibleSelection(visibleSelection.end(), visibleSelection.affinity());
770
}
769
}
771
770
772
VisibleSelection Frame::rangedSelectionInitialExtent() const
771
VisibleSelection Frame::rangedSelectionInitialExtent() const
Lines 787-793 NSArray *Frame::interpretationsForCurren Source/WebCore/page/ios/FrameIOS.mm_sec5
787
    if (!document())
786
    if (!document())
788
        return nil;
787
        return nil;
789
788
790
    Element* root = selection().selectionType() == VisibleSelection::NoSelection ? document()->body() : selection().rootEditableElement();
789
    Element* root = selection().selection().selectionType() == VisibleSelection::NoSelection ? document()->body() : selection().selection().rootEditableElement();
791
    unsigned rootChildCount = root->childNodeCount();
790
    unsigned rootChildCount = root->childNodeCount();
792
    RefPtr<Range> rangeOfRootContents = Range::create(*document(), createLegacyEditingPosition(root, 0), createLegacyEditingPosition(root, rootChildCount));
791
    RefPtr<Range> rangeOfRootContents = Range::create(*document(), createLegacyEditingPosition(root, 0), createLegacyEditingPosition(root, rootChildCount));
793
792
- Source/WebCore/rendering/RenderBlock.cpp -1 / +1 lines
Lines 2444-2450 void RenderBlock::paintCaret(PaintInfo& Source/WebCore/rendering/RenderBlock.cpp_sec1
2444
    bool isContentEditable;
2444
    bool isContentEditable;
2445
    if (type == CursorCaret) {
2445
    if (type == CursorCaret) {
2446
        caretPainter = frame().selection().caretRenderer();
2446
        caretPainter = frame().selection().caretRenderer();
2447
        isContentEditable = frame().selection().hasEditableStyle();
2447
        isContentEditable = frame().selection().selection().isContentEditable();
2448
    } else {
2448
    } else {
2449
        caretPainter = frame().page()->dragCaretController().caretRenderer();
2449
        caretPainter = frame().page()->dragCaretController().caretRenderer();
2450
        isContentEditable = frame().page()->dragCaretController().isContentEditable();
2450
        isContentEditable = frame().page()->dragCaretController().isContentEditable();
- Source/WebKit2/ChangeLog +20 lines
Lines 1-3 Source/WebKit2/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
9
        (WebKit::collapseSelection):
10
        * WebProcess/WebPage/WebPage.cpp:
11
        (WebKit::WebPage::editorState):
12
        (WebKit::WebPage::confirmComposition):
13
        (WebKit::WebPage::setComposition):
14
        * WebProcess/WebPage/ios/WebPageIOS.mm:
15
        (WebKit::WebPage::setComposition):
16
        (WebKit::WebPage::updateSelectionWithTouches):
17
        * WebProcess/WebPage/mac/WebPageMac.mm:
18
        (WebKit::WebPage::setComposition):
19
        (WebKit::WebPage::getAttributedSubstringFromRange):
20
1
2014-01-30  Simon Fraser  <simon.fraser@apple.com>
21
2014-01-30  Simon Fraser  <simon.fraser@apple.com>
2
22
3
        Fix iOS WK2 build after r163156.
23
        Fix iOS WK2 build after r163156.
- Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp -1 / +2 lines
Lines 166-172 static void collapseSelection(GtkClipboa Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp_sec1
166
166
167
    // Collapse the selection without clearing it.
167
    // Collapse the selection without clearing it.
168
    ASSERT(frame);
168
    ASSERT(frame);
169
    frame->selection().setBase(frame->selection().extent(), frame->selection().affinity());
169
    const VisibleSelection& selection = frame->selection().selection();
170
    frame->selection().setBase(selection.extent(), selection.affinity());
170
}
171
}
171
#endif
172
#endif
172
173
- Source/WebKit2/WebProcess/WebPage/WebPage.cpp -10 / +11 lines
Lines 643-658 EditorState WebPage::editorState() const Source/WebKit2/WebProcess/WebPage/WebPage.cpp_sec1
643
        }
643
        }
644
    }
644
    }
645
645
646
    result.selectionIsNone = frame.selection().isNone();
646
    const VisibleSelection& selection = frame.selection().selection();
647
    result.selectionIsRange = frame.selection().isRange();
647
648
    result.isContentEditable = frame.selection().isContentEditable();
648
    result.selectionIsNone = selection.isNone();
649
    result.isContentRichlyEditable = frame.selection().isContentRichlyEditable();
649
    result.selectionIsRange = selection.isRange();
650
    result.isInPasswordField = frame.selection().isInPasswordField();
650
    result.isContentEditable = selection.isContentEditable();
651
    result.isContentRichlyEditable = selection.isContentRichlyEditable();
652
    result.isInPasswordField = selection.isInPasswordField();
651
    result.hasComposition = frame.editor().hasComposition();
653
    result.hasComposition = frame.editor().hasComposition();
652
    result.shouldIgnoreCompositionSelectionChange = frame.editor().ignoreCompositionSelectionChange();
654
    result.shouldIgnoreCompositionSelectionChange = frame.editor().ignoreCompositionSelectionChange();
653
655
654
#if PLATFORM(IOS)
656
#if PLATFORM(IOS)
655
    FrameSelection& selection = frame.selection();
656
    if (frame.editor().hasComposition()) {
657
    if (frame.editor().hasComposition()) {
657
        RefPtr<Range> compositionRange = frame.editor().compositionRange();
658
        RefPtr<Range> compositionRange = frame.editor().compositionRange();
658
        Vector<WebCore::SelectionRect> compositionRects;
659
        Vector<WebCore::SelectionRect> compositionRects;
Lines 666-672 EditorState WebPage::editorState() const Source/WebKit2/WebProcess/WebPage/WebPage.cpp_sec2
666
        result.markedText = plainText(compositionRange.get());
667
        result.markedText = plainText(compositionRange.get());
667
    }
668
    }
668
    if (selection.isCaret()) {
669
    if (selection.isCaret()) {
669
        result.caretRectAtStart = selection.absoluteCaretBounds();
670
        result.caretRectAtStart = frame.selection().absoluteCaretBounds();
670
        result.caretRectAtEnd = result.caretRectAtStart;
671
        result.caretRectAtEnd = result.caretRectAtStart;
671
        if (m_shouldReturnWordAtSelection)
672
        if (m_shouldReturnWordAtSelection)
672
            result.wordAtSelection = plainText(wordRangeFromPosition(selection.start()).get());
673
            result.wordAtSelection = plainText(wordRangeFromPosition(selection.start()).get());
Lines 3812-3818 void WebPage::confirmComposition(const S Source/WebKit2/WebProcess/WebPage/WebPage.cpp_sec3
3812
        return;
3813
        return;
3813
    }
3814
    }
3814
3815
3815
    Element* scope = targetFrame->selection().rootEditableElement();
3816
    Element* scope = targetFrame->selection().selection().rootEditableElement();
3816
    RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(scope, selectionStart, selectionLength);
3817
    RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(scope, selectionStart, selectionLength);
3817
    ASSERT_WITH_MESSAGE(selectionRange, "Invalid selection: [%lld:%lld] in text of length %d", static_cast<long long>(selectionStart), static_cast<long long>(selectionLength), scope->innerText().length());
3818
    ASSERT_WITH_MESSAGE(selectionRange, "Invalid selection: [%lld:%lld] in text of length %d", static_cast<long long>(selectionStart), static_cast<long long>(selectionLength), scope->innerText().length());
3818
3819
Lines 3826-3832 void WebPage::confirmComposition(const S Source/WebKit2/WebProcess/WebPage/WebPage.cpp_sec4
3826
void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementStart, uint64_t replacementLength)
3827
void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementStart, uint64_t replacementLength)
3827
{
3828
{
3828
    Frame* targetFrame = targetFrameForEditing(this);
3829
    Frame* targetFrame = targetFrameForEditing(this);
3829
    if (!targetFrame || !targetFrame->selection().isContentEditable()) {
3830
    if (!targetFrame || !targetFrame->selection().selection().isContentEditable()) {
3830
        send(Messages::WebPageProxy::EditorStateChanged(editorState()));
3831
        send(Messages::WebPageProxy::EditorStateChanged(editorState()));
3831
        return;
3832
        return;
3832
    }
3833
    }
Lines 3835-3841 void WebPage::setComposition(const Strin Source/WebKit2/WebProcess/WebPage/WebPage.cpp_sec5
3835
        // The layout needs to be uptodate before setting a selection
3836
        // The layout needs to be uptodate before setting a selection
3836
        targetFrame->document()->updateLayout();
3837
        targetFrame->document()->updateLayout();
3837
3838
3838
        Element* scope = targetFrame->selection().rootEditableElement();
3839
        Element* scope = targetFrame->selection().selection().rootEditableElement();
3839
        RefPtr<Range> replacementRange = TextIterator::rangeFromLocationAndLength(scope, replacementStart, replacementLength);
3840
        RefPtr<Range> replacementRange = TextIterator::rangeFromLocationAndLength(scope, replacementStart, replacementLength);
3840
        targetFrame->editor().setIgnoreCompositionSelectionChange(true);
3841
        targetFrame->editor().setIgnoreCompositionSelectionChange(true);
3841
        targetFrame->selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
3842
        targetFrame->selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
- Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm -2 / +2 lines
Lines 96-102 void WebPage::setComposition(const Strin Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm_sec1
96
{
96
{
97
    Frame& frame = m_page->focusController().focusedOrMainFrame();
97
    Frame& frame = m_page->focusController().focusedOrMainFrame();
98
98
99
    if (frame.selection().isContentEditable())
99
    if (frame.selection().selection().isContentEditable())
100
        frame.editor().setComposition(text, underlines, selectionStart, selectionEnd);
100
        frame.editor().setComposition(text, underlines, selectionStart, selectionEnd);
101
}
101
}
102
102
Lines 590-596 void WebPage::updateSelectionWithTouches Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm_sec2
590
            break;
590
            break;
591
        
591
        
592
        case WKSelectionTouchEnded:
592
        case WKSelectionTouchEnded:
593
            if (frame.selection().isContentEditable()) {
593
            if (frame.selection().selection().isContentEditable()) {
594
                result = closestWordBoundaryForPosition(position);
594
                result = closestWordBoundaryForPosition(position);
595
                if (result.isNotNull())
595
                if (result.isNotNull())
596
                    range = Range::create(*frame.document(), result, result);
596
                    range = Range::create(*frame.document(), result, result);
- Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm -2 / +3 lines
Lines 260-266 void WebPage::setComposition(const Strin Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm_sec1
260
{
260
{
261
    Frame& frame = m_page->focusController().focusedOrMainFrame();
261
    Frame& frame = m_page->focusController().focusedOrMainFrame();
262
262
263
    if (frame.selection().isContentEditable()) {
263
    if (frame.selection().selection().isContentEditable()) {
264
        RefPtr<Range> replacementRange;
264
        RefPtr<Range> replacementRange;
265
        if (replacementRangeStart != NSNotFound) {
265
        if (replacementRangeStart != NSNotFound) {
266
            replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
266
            replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
Lines 360-366 void WebPage::getAttributedSubstringFrom Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm_sec2
360
{
360
{
361
    Frame& frame = m_page->focusController().focusedOrMainFrame();
361
    Frame& frame = m_page->focusController().focusedOrMainFrame();
362
362
363
    if (frame.selection().isNone() || !frame.selection().isContentEditable() || frame.selection().isInPasswordField())
363
    const VisibleSelection& selection = frame.selection().selection();
364
    if (selection.isNone() || !selection.isContentEditable() || selection.isInPasswordField())
364
        return;
365
        return;
365
366
366
    NSRange nsRange = NSMakeRange(location, length - location);
367
    NSRange nsRange = NSMakeRange(location, length - location);
- Source/WebKit/efl/ChangeLog +10 lines
Lines 1-3 Source/WebKit/efl/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * ewk/ewk_frame.cpp:
9
        (ewk_frame_text_selection_type_get):
10
1
2014-01-30  Andrei Bucur  <abucur@adobe.com>
11
2014-01-30  Andrei Bucur  <abucur@adobe.com>
2
12
3
        Remove the ACCELERATED_COMPOSITING flag
13
        Remove the ACCELERATED_COMPOSITING flag
- Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp -2 / +4 lines
Lines 61-66 Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp_sec1
61
#include <ScriptController.h>
61
#include <ScriptController.h>
62
#include <Settings.h>
62
#include <Settings.h>
63
#include <TextIterator.h>
63
#include <TextIterator.h>
64
#include <VisibleSelection.h>
64
#include <bindings/ScriptValue.h>
65
#include <bindings/ScriptValue.h>
65
#include <bindings/js/GCController.h>
66
#include <bindings/js/GCController.h>
66
#include <history/HistoryItem.h>
67
#include <history/HistoryItem.h>
Lines 639-649 bool DumpRenderTreeSupportEfl::selectedR Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp_sec2
639
    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
640
    DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
640
641
641
    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
642
    WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
642
    RefPtr<WebCore::Range> range = frame.selection().toNormalizedRange().get();
643
    const WebCore::VisibleSelection& selection = frame.selection().selection();
644
    RefPtr<WebCore::Range> range = selection.toNormalizedRange().get();
643
    if (!range)
645
    if (!range)
644
        return false;
646
        return false;
645
647
646
    WebCore::Element* selectionRoot = frame.selection().rootEditableElement();
648
    WebCore::Element* selectionRoot = selection.rootEditableElement();
647
    WebCore::Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
649
    WebCore::Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
648
650
649
    RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
651
    RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
- Source/WebKit/efl/ewk/ewk_frame.cpp -2 / +2 lines
Lines 1073-1081 Ewk_Text_Selection_Type ewk_frame_text_s Source/WebKit/efl/ewk/ewk_frame.cpp_sec1
1073
    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, EWK_TEXT_SELECTION_NONE);
1073
    EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, EWK_TEXT_SELECTION_NONE);
1074
    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, EWK_TEXT_SELECTION_NONE);
1074
    EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, EWK_TEXT_SELECTION_NONE);
1075
1075
1076
    WebCore::FrameSelection& controller = smartData->frame->selection();
1076
    const WebCore::VisibleSelection& selection = smartData->frame->selection().selection();
1077
1077
1078
    switch (controller.selectionType()) {
1078
    switch (selection.selectionType()) {
1079
    case WebCore::VisibleSelection::NoSelection:
1079
    case WebCore::VisibleSelection::NoSelection:
1080
        return EWK_TEXT_SELECTION_NONE;
1080
        return EWK_TEXT_SELECTION_NONE;
1081
    case WebCore::VisibleSelection::CaretSelection:
1081
    case WebCore::VisibleSelection::CaretSelection:
- Source/WebKit/gtk/ChangeLog +10 lines
Lines 1-3 Source/WebKit/gtk/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * WebCoreSupport/EditorClientGtk.cpp:
9
        (WebKit::collapseSelection):
10
1
2014-01-30  Andrei Bucur  <abucur@adobe.com>
11
2014-01-30  Andrei Bucur  <abucur@adobe.com>
2
12
3
        Remove the ACCELERATED_COMPOSITING flag
13
        Remove the ACCELERATED_COMPOSITING flag
- Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp -2 / +4 lines
Lines 67-72 Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp_sec1
67
#include "SecurityPolicy.h"
67
#include "SecurityPolicy.h"
68
#include "Settings.h"
68
#include "Settings.h"
69
#include "TextIterator.h"
69
#include "TextIterator.h"
70
#include "VisibleSelection.h"
70
#include "WebKitAccessibleWrapperAtk.h"
71
#include "WebKitAccessibleWrapperAtk.h"
71
#include "webkitglobalsprivate.h"
72
#include "webkitglobalsprivate.h"
72
#include "webkitwebframe.h"
73
#include "webkitwebframe.h"
Lines 389-399 bool DumpRenderTreeSupportGtk::selectedR Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp_sec2
389
390
390
    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
391
    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
391
392
392
    RefPtr<Range> range = frame.selection().toNormalizedRange().get();
393
    const VisibleSelection& selection = frame.selection().selection();
394
    RefPtr<Range> range = selection.toNormalizedRange().get();
393
    if (!range)
395
    if (!range)
394
        return false;
396
        return false;
395
397
396
    Element* selectionRoot = frame.selection().rootEditableElement();
398
    Element* selectionRoot = selection.rootEditableElement();
397
    Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
399
    Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
398
400
399
    RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
401
    RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
- Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp -1 / +2 lines
Lines 216-222 static void collapseSelection(GtkClipboa Source/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp_sec1
216
    Frame& frame = corePage->focusController().focusedOrMainFrame();
216
    Frame& frame = corePage->focusController().focusedOrMainFrame();
217
217
218
    // Collapse the selection without clearing it
218
    // Collapse the selection without clearing it
219
    frame.selection().setBase(frame.selection().extent(), frame.selection().affinity());
219
    const VisibleSelection& selection = frame.selection();
220
    frame.selection().setBase(selection.extent(), selection.affinity());
220
}
221
}
221
222
222
#if PLATFORM(X11)
223
#if PLATFORM(X11)
- Source/WebKit/ios/ChangeLog +10 lines
Lines 1-3 Source/WebKit/ios/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * WebCoreSupport/WebFrameIOS.mm:
9
        (-[WebFrame setBaseWritingDirection:]):
10
1
2014-01-30  Andrei Bucur  <abucur@adobe.com>
11
2014-01-30  Andrei Bucur  <abucur@adobe.com>
2
12
3
        Remove the ACCELERATED_COMPOSITING flag
13
        Remove the ACCELERATED_COMPOSITING flag
- Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm -1 / +1 lines
Lines 575-581 - (void)setBaseWritingDirection:(WKWriti Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm_sec1
575
    WKWritingDirection originalDirection = [self selectionBaseWritingDirection];
575
    WKWritingDirection originalDirection = [self selectionBaseWritingDirection];
576
576
577
    Frame *frame = [self coreFrame];
577
    Frame *frame = [self coreFrame];
578
    if (!frame->selection().isContentEditable())
578
    if (!frame->selection().selection().isContentEditable())
579
        return;
579
        return;
580
    
580
    
581
    WritingDirection wcDirection = LeftToRightWritingDirection;
581
    WritingDirection wcDirection = LeftToRightWritingDirection;
- Source/WebKit/mac/ChangeLog +25 lines
Lines 1-3 Source/WebKit/mac/ChangeLog_sec1
1
2014-01-30  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        Remove inline member functions of FrameSelection that access m_selection
4
        https://bugs.webkit.org/show_bug.cgi?id=127986
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * WebView/WebFrame.mm:
9
        (-[WebFrame hasEditableSelection]):
10
        (-[WebFrame selectionAffinity]):
11
        (-[WebFrame getDictationResultRanges:andMetadatas:]):
12
        (-[WebFrame focusedNodeHasContent]):
13
        * WebView/WebHTMLView.mm:
14
        (-[WebHTMLView readSelectionFromPasteboard:]):
15
        (-[WebHTMLView _hasSelection]):
16
        (-[WebHTMLView _hasSelectionOrInsertionPoint]):
17
        (-[WebHTMLView _hasInsertionPoint]):
18
        (-[WebHTMLView _isEditable]):
19
        (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]):
20
        (-[WebHTMLView maintainsInactiveSelection]):
21
        (isTextInput):
22
        (isInPasswordField):
23
        * WebView/WebView.mm:
24
        (-[WebView selectionAffinity]):
25
1
2014-01-30  David Kilzer  <ddkilzer@apple.com>
26
2014-01-30  David Kilzer  <ddkilzer@apple.com>
2
27
3
        Add security-checked cast for WebCore::CachedImage
28
        Add security-checked cast for WebCore::CachedImage
- Source/WebKit/mac/WebView/WebFrame.mm -6 / +8 lines
Lines 1348-1354 - (void)resetSelection Source/WebKit/mac/WebView/WebFrame.mm_sec1
1348
- (BOOL)hasEditableSelection
1348
- (BOOL)hasEditableSelection
1349
{
1349
{
1350
    WebCore::Frame *frame = core(self);
1350
    WebCore::Frame *frame = core(self);
1351
    return frame->selection().isContentEditable();
1351
    return frame->selection().selection().isContentEditable();
1352
}
1352
}
1353
1353
1354
- (int)preferredHeight
1354
- (int)preferredHeight
Lines 1473-1479 - (void)setSelectedDOMRange:(DOMRange *) Source/WebKit/mac/WebView/WebFrame.mm_sec2
1473
- (NSSelectionAffinity)selectionAffinity
1473
- (NSSelectionAffinity)selectionAffinity
1474
{
1474
{
1475
    WebCore::Frame *frame = core(self);
1475
    WebCore::Frame *frame = core(self);
1476
    return (NSSelectionAffinity)(frame->selection().affinity());
1476
    return (NSSelectionAffinity)(frame->selection().selection().affinity());
1477
}
1477
}
1478
1478
1479
- (void)expandSelectionToElementContainingCaretSelection
1479
- (void)expandSelectionToElementContainingCaretSelection
Lines 1714-1721 - (void)getDictationResultRanges:(NSArra Source/WebKit/mac/WebView/WebFrame.mm_sec3
1714
    
1714
    
1715
    Frame *frame = core(self);
1715
    Frame *frame = core(self);
1716
    Document *document = frame->document();
1716
    Document *document = frame->document();
1717
    
1717
1718
    Element *root = frame->selection().selectionType() == VisibleSelection::NoSelection ? frame->document()->body() : frame->selection().rootEditableElement();
1718
    const VisibleSelection& selection = frame->selection().selection();
1719
    Element *root = selection.selectionType() == VisibleSelection::NoSelection ? frame->document()->body() : selection.rootEditableElement();
1719
    
1720
    
1720
    DOMRange *previousDOMRange = nil;
1721
    DOMRange *previousDOMRange = nil;
1721
    id previousMetadata = nil;
1722
    id previousMetadata = nil;
Lines 2271-2281 - (BOOL)focusedNodeHasContent Source/WebKit/mac/WebView/WebFrame.mm_sec4
2271
    Frame* coreFrame = _private->coreFrame;
2272
    Frame* coreFrame = _private->coreFrame;
2272
   
2273
   
2273
    Element* root;
2274
    Element* root;
2274
    if (coreFrame->selection().isNone() || !coreFrame->selection().isContentEditable())
2275
    const VisibleSelection& selection = coreFrame->selection().selection();
2276
    if (selection.isNone() || !selection.isContentEditable())
2275
        root = coreFrame->document()->body();
2277
        root = coreFrame->document()->body();
2276
    else {
2278
    else {
2277
        // Can't use the focusedNode here because we want the root of the shadow tree for form elements.
2279
        // Can't use the focusedNode here because we want the root of the shadow tree for form elements.
2278
        root = coreFrame->selection().rootEditableElement();
2280
        root = selection.rootEditableElement();
2279
    }
2281
    }
2280
    // Early return to avoid the expense of creating VisiblePositions.
2282
    // Early return to avoid the expense of creating VisiblePositions.
2281
    // FIXME: We fail to compute a root for SVG, we have a null check here so that we don't crash.
2283
    // FIXME: We fail to compute a root for SVG, we have a null check here so that we don't crash.
- Source/WebKit/mac/WebView/WebHTMLView.mm -10 / +13 lines
Lines 1001-1007 - (BOOL)readSelectionFromPasteboard:(NSP Source/WebKit/mac/WebView/WebHTMLView.mm_sec1
1001
    Frame* coreFrame = core([self _frame]); 
1001
    Frame* coreFrame = core([self _frame]); 
1002
    if (!coreFrame) 
1002
    if (!coreFrame) 
1003
        return NO; 
1003
        return NO; 
1004
    if (coreFrame->selection().isContentRichlyEditable())
1004
    if (coreFrame->selection().selection().isContentRichlyEditable())
1005
        [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; 
1005
        [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; 
1006
    else 
1006
    else 
1007
        [self _pasteAsPlainTextWithPasteboard:pasteboard]; 
1007
        [self _pasteAsPlainTextWithPasteboard:pasteboard]; 
Lines 1986-2010 - (BOOL)_canAlterCurrentSelection Source/WebKit/mac/WebView/WebHTMLView.mm_sec2
1986
- (BOOL)_hasSelection
1986
- (BOOL)_hasSelection
1987
{
1987
{
1988
    Frame* coreFrame = core([self _frame]);
1988
    Frame* coreFrame = core([self _frame]);
1989
    return coreFrame && coreFrame->selection().isRange();
1989
    return coreFrame && coreFrame->selection().selection().isRange();
1990
}
1990
}
1991
1991
1992
- (BOOL)_hasSelectionOrInsertionPoint
1992
- (BOOL)_hasSelectionOrInsertionPoint
1993
{
1993
{
1994
    Frame* coreFrame = core([self _frame]);
1994
    Frame* coreFrame = core([self _frame]);
1995
    return coreFrame && coreFrame->selection().isCaretOrRange();
1995
    return coreFrame && coreFrame->selection().selection().isCaretOrRange();
1996
}
1996
}
1997
1997
1998
- (BOOL)_hasInsertionPoint
1998
- (BOOL)_hasInsertionPoint
1999
{
1999
{
2000
    Frame* coreFrame = core([self _frame]);
2000
    Frame* coreFrame = core([self _frame]);
2001
    return coreFrame && coreFrame->selection().isCaret();
2001
    return coreFrame && coreFrame->selection().selection().isCaret();
2002
}
2002
}
2003
2003
2004
- (BOOL)_isEditable
2004
- (BOOL)_isEditable
2005
{
2005
{
2006
    Frame* coreFrame = core([self _frame]);
2006
    Frame* coreFrame = core([self _frame]);
2007
    return coreFrame && coreFrame->selection().isContentEditable();
2007
    return coreFrame && coreFrame->selection().selection().isContentEditable();
2008
}
2008
}
2009
2009
2010
- (BOOL)_transparentBackground
2010
- (BOOL)_transparentBackground
Lines 2899-2905 - (BOOL)validateUserInterfaceItemWithout Source/WebKit/mac/WebView/WebHTMLView.mm_sec3
2899
    
2899
    
2900
    if (action == @selector(pasteAsRichText:))
2900
    if (action == @selector(pasteAsRichText:))
2901
        return frame && (frame->editor().canDHTMLPaste()
2901
        return frame && (frame->editor().canDHTMLPaste()
2902
            || (frame->editor().canPaste() && frame->selection().isContentRichlyEditable()));
2902
            || (frame->editor().canPaste() && frame->selection().selection().isContentRichlyEditable()));
2903
    
2903
    
2904
    if (action == @selector(performFindPanelAction:))
2904
    if (action == @selector(performFindPanelAction:))
2905
        return NO;
2905
        return NO;
Lines 3026-3032 - (BOOL)maintainsInactiveSelection Source/WebKit/mac/WebView/WebHTMLView.mm_sec4
3026
        return YES;
3026
        return YES;
3027
    
3027
    
3028
    Frame* coreFrame = core([self _frame]);
3028
    Frame* coreFrame = core([self _frame]);
3029
    return coreFrame && coreFrame->selection().isContentEditable();
3029
    return coreFrame && coreFrame->selection().selection().isContentEditable();
3030
#else
3030
#else
3031
    // This method helps to determine whether the WebHTMLView should maintain
3031
    // This method helps to determine whether the WebHTMLView should maintain
3032
    // an inactive selection when it's not first responder.
3032
    // an inactive selection when it's not first responder.
Lines 3057-3063 - (BOOL)maintainsInactiveSelection Source/WebKit/mac/WebView/WebHTMLView.mm_sec5
3057
        return YES;
3057
        return YES;
3058
3058
3059
    Frame* coreFrame = core([self _frame]);
3059
    Frame* coreFrame = core([self _frame]);
3060
    bool selectionIsEditable = coreFrame && coreFrame->selection().isContentEditable();
3060
    bool selectionIsEditable = coreFrame && coreFrame->selection().selection().isContentEditable();
3061
    bool nextResponderIsInWebView = [nextResponder isKindOfClass:[NSView class]]
3061
    bool nextResponderIsInWebView = [nextResponder isKindOfClass:[NSView class]]
3062
        && [nextResponder isDescendantOf:[[[self _webView] mainFrame] frameView]];
3062
        && [nextResponder isDescendantOf:[[[self _webView] mainFrame] frameView]];
3063
3063
Lines 4137-4149 - (BOOL)needsPanelToBecomeKey Source/WebKit/mac/WebView/WebHTMLView.mm_sec6
4137
// API when an editable region is not currently focused.
4137
// API when an editable region is not currently focused.
4138
static BOOL isTextInput(Frame* coreFrame)
4138
static BOOL isTextInput(Frame* coreFrame)
4139
{
4139
{
4140
    return coreFrame && !coreFrame->selection().isNone() && coreFrame->selection().isContentEditable();
4140
    if (!coreFrame)
4141
        return NO;
4142
    const VisibleSelection& selection = coreFrame->selection().selection();
4143
    return !selection.isNone() && selection.isContentEditable();
4141
}
4144
}
4142
4145
4143
#if !PLATFORM(IOS)
4146
#if !PLATFORM(IOS)
4144
static BOOL isInPasswordField(Frame* coreFrame)
4147
static BOOL isInPasswordField(Frame* coreFrame)
4145
{
4148
{
4146
    return coreFrame && coreFrame->selection().isInPasswordField();
4149
    return coreFrame && coreFrame->selection().selection().isInPasswordField();
4147
}
4150
}
4148
#endif
4151
#endif
4149
4152
- Source/WebKit/mac/WebView/WebView.mm -1 / +1 lines
Lines 7244-7250 - (NSSelectionAffinity)selectionAffinity Source/WebKit/mac/WebView/WebView.mm_sec1
7244
    Frame* coreFrame = core([self _selectedOrMainFrame]);
7244
    Frame* coreFrame = core([self _selectedOrMainFrame]);
7245
    if (!coreFrame)
7245
    if (!coreFrame)
7246
        return NSSelectionAffinityDownstream;
7246
        return NSSelectionAffinityDownstream;
7247
    return kit(coreFrame->selection().affinity());
7247
    return kit(coreFrame->selection().selection().affinity());
7248
}
7248
}
7249
7249
7250
- (void)setEditable:(BOOL)flag
7250
- (void)setEditable:(BOOL)flag

Return to Bug 127986