Changeset 163689 in webkit


Ignore:
Timestamp:
Feb 7, 2014 7:50:22 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

FrameSelection's destructor shouldn't notify accessibility
https://bugs.webkit.org/show_bug.cgi?id=128421

Reviewed by Benjamin Poulain.

Extracted setSelectionWithoutUpdatingAppearance out of setSelection and called it in prepareForDestruction
instead of setting DoNotUpdateAppearance option. This new function doesn't reveal selection or notify
accessibility code in addition to not updating appearance.

Note that all implementations of notifyAccessibilityForSelectionChange in FrameSelectionAtk.cpp and
FrameSelectionMac.mm exit early when the selection type is not caret or either start or end is null,
which is already the case inside FrameSelection's destructor. In addition, revealSelection is never called
when selection change was not triggered by user so there should be no behavioral change from this patch.

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
(WebCore::FrameSelection::setSelection):
(WebCore::FrameSelection::prepareForDestruction):

  • editing/FrameSelection.h:

(WebCore::FrameSelection::notifyAccessibilityForSelectionChange): Added the trivial implementation in the case
accessibility is disabled to tidy up call sites.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163687 r163689  
     12014-02-07  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        FrameSelection's destructor shouldn't notify accessibility
     4        https://bugs.webkit.org/show_bug.cgi?id=128421
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Extracted setSelectionWithoutUpdatingAppearance out of setSelection and called it in prepareForDestruction
     9        instead of setting DoNotUpdateAppearance option. This new function doesn't reveal selection or notify
     10        accessibility code in addition to not updating appearance.
     11
     12        Note that all implementations of notifyAccessibilityForSelectionChange in FrameSelectionAtk.cpp and
     13        FrameSelectionMac.mm exit early when the selection type is not caret or either start or end is null,
     14        which is already the case inside FrameSelection's destructor. In addition, revealSelection is never called
     15        when selection change was not triggered by user so there should be no behavioral change from this patch.
     16
     17        * editing/FrameSelection.cpp:
     18        (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
     19        (WebCore::FrameSelection::setSelection):
     20        (WebCore::FrameSelection::prepareForDestruction):
     21        * editing/FrameSelection.h:
     22        (WebCore::FrameSelection::notifyAccessibilityForSelectionChange): Added the trivial implementation in the case
     23        accessibility is disabled to tidy up call sites.
     24
    1252014-02-07  Martin Robinson  <mrobinson@igalia.com>
    226
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r163617 r163689  
    251251}
    252252
    253 void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity)
     253bool FrameSelection::setSelectionWithoutUpdatingAppearance(const VisibleSelection& newSelection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity, EUserTriggered userTriggered)
    254254{
    255255    bool closeTyping = options & CloseTyping;
    256256    bool shouldClearTypingStyle = options & ClearTypingStyle;
    257     EUserTriggered userTriggered = selectionOptionsToUserTriggered(options);
    258257
    259258    VisibleSelection s = newSelection;
     
    263262    if (!m_frame) {
    264263        m_selection = s;
    265         return;
     264        return false;
    266265    }
    267266
     
    278277            if (guard->hasOneRef() && !m_selection.isNonOrphanedCaretOrRange())
    279278                clear();
    280             return;
     279            return false;
    281280        }
    282281    }
     
    297296        // Even if selection was not changed, selection offsets may have been changed.
    298297        updateSelectionCachesIfSelectionIsInsideTextFormControl(userTriggered);
    299         return;
     298        return false;
    300299    }
    301300
     
    307306    if (!s.isNone() && !(options & DoNotSetFocus))
    308307        setFocusedElementIfNeeded();
    309 
    310     if (!(options & DoNotUpdateAppearance)) {
    311 #if ENABLE(TEXT_CARET)
    312         m_frame->document()->updateLayoutIgnorePendingStylesheets();
    313 #else
    314         m_frame->document()->updateStyleIfNeeded();
    315 #endif
    316         updateAppearance();
    317     }
    318308
    319309    // Always clear the x position used for vertical arrow navigation.
     
    323313    updateSelectionCachesIfSelectionIsInsideTextFormControl(userTriggered);
    324314    m_frame->editor().respondToChangedSelection(oldSelection, options);
     315    m_frame->document()->enqueueDocumentEvent(Event::create(eventNames().selectionchangeEvent, false, false));
     316
     317    return true;
     318}
     319
     320void FrameSelection::setSelection(const VisibleSelection& selection, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity)
     321{
     322    EUserTriggered userTriggered = selectionOptionsToUserTriggered(options);
     323    if (!setSelectionWithoutUpdatingAppearance(selection, options, align, granularity, userTriggered))
     324        return;
     325
     326#if ENABLE(TEXT_CARET)
     327    m_frame->document()->updateLayoutIgnorePendingStylesheets();
     328#else
     329    m_frame->document()->updateStyleIfNeeded();
     330#endif
     331    updateAppearance();
     332
    325333    if (userTriggered == UserTriggered && !(options & DoNotRevealSelection)) {
    326334        ScrollAlignment alignment;
     
    333341        revealSelection(alignment, RevealExtent);
    334342    }
    335 #if HAVE(ACCESSIBILITY)
     343
    336344    notifyAccessibilityForSelectionChange();
    337 #endif
    338     m_frame->document()->enqueueDocumentEvent(Event::create(eventNames().selectionchangeEvent, false, false));
    339345}
    340346
     
    12381244        view->clearSelection();
    12391245
    1240     setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdateAppearance);
     1246    setSelectionWithoutUpdatingAppearance(VisibleSelection(), CloseTyping | ClearTypingStyle,
     1247        AlignCursorOnScrollIfNeeded, CharacterGranularity, NotUserTriggered);
    12411248    m_previousCaretNode.clear();
    12421249}
  • trunk/Source/WebCore/editing/FrameSelection.h

    r163232 r163689  
    125125        DoNotSetFocus = 1 << 4,
    126126        DictationTriggered = 1 << 5,
    127         DoNotUpdateAppearance = 1 << 6,
    128         DoNotRevealSelection = 1 << 7,
     127        DoNotRevealSelection = 1 << 6,
    129128    };
    130129    typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOption and EUserTriggered
     
    281280    enum EPositionType { START, END, BASE, EXTENT };
    282281
     282    bool setSelectionWithoutUpdatingAppearance(const VisibleSelection&, SetSelectionOptions, CursorAlignOnScroll, TextGranularity, EUserTriggered);
     283
    283284    void respondToNodeModification(Node*, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved);
    284285    TextDirection directionOfEnclosingBlock();
     
    303304#if HAVE(ACCESSIBILITY)
    304305    void notifyAccessibilityForSelectionChange();
     306#else
     307    void notifyAccessibilityForSelectionChange() { }
    305308#endif
    306309
Note: See TracChangeset for help on using the changeset viewer.