Changeset 195059 in webkit


Ignore:
Timestamp:
Jan 14, 2016 9:50:12 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r195002.
https://bugs.webkit.org/show_bug.cgi?id=153098

Crashes many/most editing tests (Requested by ap on #webkit).

Reverted changeset:

"WK2: Request completion candidates when needed"
https://bugs.webkit.org/show_bug.cgi?id=153040
http://trac.webkit.org/changeset/195002

Location:
trunk
Files:
1 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195058 r195059  
     12016-01-14  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r195002.
     4        https://bugs.webkit.org/show_bug.cgi?id=153098
     5
     6        Crashes many/most editing tests (Requested by ap on #webkit).
     7
     8        Reverted changeset:
     9
     10        "WK2: Request completion candidates when needed"
     11        https://bugs.webkit.org/show_bug.cgi?id=153040
     12        http://trac.webkit.org/changeset/195002
     13
    1142016-01-14  Martin Robinson  <mrobinson@igalia.com>
    215
  • trunk/LayoutTests/platform/mac/fast/dom/focus-contenteditable-expected.txt

    r195002 r195059  
    77        RenderText {#text} at (0,0) size 509x18
    88          text run at (0,0) width 509: "This test will try to call focus() on a contenteditable div, and then a normal div. "
    9         RenderBR {BR} at (0,0) size 0x0
     9        RenderBR {BR} at (508,14) size 1x0
    1010        RenderText {#text} at (0,18) size 379x18
    1111          text run at (0,18) width 379: "The window should scroll to reveal the contenteditable div."
  • trunk/Source/WebCore/ChangeLog

    r195058 r195059  
     12016-01-14  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r195002.
     4        https://bugs.webkit.org/show_bug.cgi?id=153098
     5
     6        Crashes many/most editing tests (Requested by ap on #webkit).
     7
     8        Reverted changeset:
     9
     10        "WK2: Request completion candidates when needed"
     11        https://bugs.webkit.org/show_bug.cgi?id=153040
     12        http://trac.webkit.org/changeset/195002
     13
    1142016-01-14  Martin Robinson  <mrobinson@igalia.com>
    215
  • trunk/Source/WebCore/editing/Editor.cpp

    r195002 r195059  
    35343534}
    35353535
    3536 static RefPtr<Range> candidateRangeForSelection(Frame& frame)
    3537 {
    3538     const VisibleSelection& selection = frame.selection().selection();
    3539     return selection.isCaret() ? wordRangeFromPosition(selection.start()) : frame.selection().toNormalizedRange();
    3540 }
    3541 
    3542 static bool candidateWouldReplaceText(const VisibleSelection& selection)
    3543 {
    3544     // If the character behind the caret in the current selection is anything but a space or a newline then we should
    3545     // replace the whole current word with the candidate.
    3546     UChar32 characterAfterSelection, characterBeforeSelection, twoCharacterBeforeSelection = 0;
    3547     charactersAroundPosition(selection.visibleStart(), characterAfterSelection, characterBeforeSelection, twoCharacterBeforeSelection);
    3548     return !(characterBeforeSelection == '\0' || characterBeforeSelection == '\n' || characterBeforeSelection == ' ');
    3549 }
    3550 
    3551 String Editor::stringForCandidateRequest() const
    3552 {
    3553     const VisibleSelection& selection = m_frame.selection().selection();
    3554     RefPtr<Range> rangeForCurrentlyTypedString = candidateRangeForSelection(m_frame);
    3555     if (rangeForCurrentlyTypedString && candidateWouldReplaceText(selection))
    3556         return plainText(rangeForCurrentlyTypedString.get());
    3557 
    3558     return String();
    3559 }
    3560 
    3561 void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate)
    3562 {
    3563     const VisibleSelection& selection = m_frame.selection().selection();
    3564     RefPtr<Range> candidateRange = candidateRangeForSelection(m_frame);
    3565 
    3566     if (candidateWouldReplaceText(selection))
    3567         m_frame.selection().setSelectedRange(candidateRange.get(), UPSTREAM, true);
    3568 
    3569     insertText(acceptedCandidate.replacement, 0);
    3570     insertText(String(" "), 0);
    3571 }
    3572 
    35733536bool Editor::unifiedTextCheckerEnabled() const
    35743537{
  • trunk/Source/WebCore/editing/Editor.h

    r195002 r195059  
    456456#endif
    457457
    458     WEBCORE_EXPORT String stringForCandidateRequest() const;
    459     WEBCORE_EXPORT void handleAcceptedCandidate(TextCheckingResult);
    460 
    461458private:
    462459    class WebContentReader;
  • trunk/Source/WebKit2/ChangeLog

    r195056 r195059  
     12016-01-14  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r195002.
     4        https://bugs.webkit.org/show_bug.cgi?id=153098
     5
     6        Crashes many/most editing tests (Requested by ap on #webkit).
     7
     8        Reverted changeset:
     9
     10        "WK2: Request completion candidates when needed"
     11        https://bugs.webkit.org/show_bug.cgi?id=153040
     12        http://trac.webkit.org/changeset/195002
     13
    1142016-01-14  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
    215
  • trunk/Source/WebKit2/Shared/EditorState.cpp

    r195002 r195059  
    4444    encoder << isMissingPostLayoutData;
    4545
    46 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     46#if PLATFORM(IOS) || PLATFORM(GTK)
    4747    if (!isMissingPostLayoutData)
    4848        m_postLayoutData.encode(encoder);
     
    8585        return false;
    8686
    87 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     87#if PLATFORM(IOS) || PLATFORM(GTK)
    8888    if (!result.isMissingPostLayoutData) {
    8989        if (!PostLayoutData::decode(decoder, result.postLayoutData()))
     
    104104}
    105105
    106 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     106#if PLATFORM(IOS) || PLATFORM(GTK)
    107107void EditorState::PostLayoutData::encode(IPC::ArgumentEncoder& encoder) const
    108108{
    109 #if PLATFORM(IOS) || PLATFORM(GTK)
    110109    encoder << typingAttributes;
    111110    encoder << caretRectAtStart;
    112 #endif
    113 #if PLATFORM(IOS) || PLATFORM(MAC)
    114     encoder << selectionClipRect;
    115     encoder << selectedTextLength;
    116 #endif
    117111#if PLATFORM(IOS)
    118112    encoder << caretRectAtEnd;
     113    encoder << selectionClipRect;
    119114    encoder << selectionRects;
    120115    encoder << wordAtSelection;
     116    encoder << selectedTextLength;
    121117    encoder << characterAfterSelection;
    122118    encoder << characterBeforeSelection;
     
    125121    encoder << hasContent;
    126122#endif
    127 #if PLATFORM(MAC)
    128     encoder << candidateRequestStartPosition;
    129     encoder << paragraphContextForCandidateRequest;
    130     encoder << stringForCandidateRequest;
    131 #endif
    132123}
    133124
    134125bool EditorState::PostLayoutData::decode(IPC::ArgumentDecoder& decoder, PostLayoutData& result)
    135126{
    136 #if PLATFORM(IOS) || PLATFORM(GTK)
    137127    if (!decoder.decode(result.typingAttributes))
    138128        return false;
    139129    if (!decoder.decode(result.caretRectAtStart))
    140130        return false;
    141 #endif
    142 #if PLATFORM(IOS) || PLATFORM(MAC)
    143     if (!decoder.decode(result.selectionClipRect))
    144         return false;
    145     if (!decoder.decode(result.selectedTextLength))
    146         return false;
    147 #endif
    148131#if PLATFORM(IOS)
    149132    if (!decoder.decode(result.caretRectAtEnd))
     133        return false;
     134    if (!decoder.decode(result.selectionClipRect))
    150135        return false;
    151136    if (!decoder.decode(result.selectionRects))
    152137        return false;
    153138    if (!decoder.decode(result.wordAtSelection))
     139        return false;
     140    if (!decoder.decode(result.selectedTextLength))
    154141        return false;
    155142    if (!decoder.decode(result.characterAfterSelection))
     
    164151        return false;
    165152#endif
    166 #if PLATFORM(MAC)
    167     if (!decoder.decode(result.candidateRequestStartPosition))
    168         return false;
    169 
    170     if (!decoder.decode(result.paragraphContextForCandidateRequest))
    171         return false;
    172 
    173     if (!decoder.decode(result.stringForCandidateRequest))
    174         return false;
    175 #endif
    176153
    177154    return true;
    178155}
    179 #endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     156#endif
    180157
    181158}
  • trunk/Source/WebKit2/Shared/EditorState.h

    r195002 r195059  
    6363#endif
    6464
    65 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     65#if PLATFORM(IOS) || PLATFORM(GTK)
    6666    struct PostLayoutData {
    67 #if PLATFORM(IOS) || PLATFORM(GTK)
    6867        uint32_t typingAttributes { AttributeNone };
    6968        WebCore::IntRect caretRectAtStart;
    70 #endif
    71 #if PLATFORM(IOS) || PLATFORM(MAC)
    72         WebCore::IntRect selectionClipRect;
    73         uint64_t selectedTextLength { 0 };
    74 #endif
    7569#if PLATFORM(IOS)
    7670        WebCore::IntRect caretRectAtEnd;
     71        WebCore::IntRect selectionClipRect;
    7772        Vector<WebCore::SelectionRect> selectionRects;
    7873        String wordAtSelection;
     74        uint64_t selectedTextLength { 0 };
    7975        UChar32 characterAfterSelection { 0 };
    8076        UChar32 characterBeforeSelection { 0 };
     
    8278        bool isReplaceAllowed { false };
    8379        bool hasContent { false };
    84 #endif
    85 #if PLATFORM(MAC)
    86         uint64_t candidateRequestStartPosition { 0 };
    87         String paragraphContextForCandidateRequest;
    88         String stringForCandidateRequest;
    8980#endif
    9081
     
    9586    const PostLayoutData& postLayoutData() const;
    9687    PostLayoutData& postLayoutData();
    97 #endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     88#endif // PLATFORM(IOS) || PLATFORM(GTK)
    9889
    9990    void encode(IPC::ArgumentEncoder&) const;
    10091    static bool decode(IPC::ArgumentDecoder&, EditorState&);
    10192
    102 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     93#if PLATFORM(IOS) || PLATFORM(GTK)
    10394private:
    10495    PostLayoutData m_postLayoutData;
     
    10697};
    10798
    108 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)
     99#if PLATFORM(IOS) || PLATFORM(GTK)
    109100inline auto EditorState::postLayoutData() -> PostLayoutData&
    110101{
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h

    r195002 r195059  
    295295    void capitalizeWord();
    296296
    297 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    298     void requestCandidatesForSelectionIfNeeded();
    299 #endif
    300 
    301297    void preferencesDidChange();
    302298
     
    503499    Vector<NSTouch *> touchesOrderedByAge();
    504500
    505 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    506     void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
    507     void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
    508 #endif
    509 
    510501    NSView <WebViewImplDelegate> *m_view;
    511502    std::unique_ptr<PageClient> m_pageClient;
     
    620611    Vector<RetainPtr<id <NSObject, NSCopying>>> m_activeTouchIdentities;
    621612    RetainPtr<NSArray> m_lastTouches;
    622 
    623 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    624     String m_lastStringForCandidateRequest;
    625 #endif
    626613};
    627614   
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm

    r195002 r195059  
    7676#import <WebCore/NSApplicationSPI.h>
    7777#import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
    78 #import <WebCore/NSSpellCheckerSPI.h>
    7978#import <WebCore/NSTextFinderSPI.h>
    8079#import <WebCore/NSWindowSPI.h>
     
    17251724{
    17261725    updateFontPanelIfNeeded();
    1727 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    1728     if (!m_page->editorState().isMissingPostLayoutData)
    1729         requestCandidatesForSelectionIfNeeded();
    1730 #endif
    17311726}
    17321727
     
    20932088    m_page->capitalizeWord();
    20942089}
    2095 
    2096 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    2097 void WebViewImpl::requestCandidatesForSelectionIfNeeded()
    2098 {
    2099     const EditorState& editorState = m_page->editorState();
    2100     if (!editorState.isContentEditable)
    2101         return;
    2102 
    2103     auto& postLayoutData = editorState.postLayoutData();
    2104     m_lastStringForCandidateRequest = postLayoutData.stringForCandidateRequest;
    2105 
    2106     NSRange rangeForCandidates = NSMakeRange(postLayoutData.candidateRequestStartPosition, postLayoutData.selectedTextLength);
    2107     NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
    2108     auto weakThis = createWeakPtr();
    2109     [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:rangeForCandidates inString:postLayoutData.paragraphContextForCandidateRequest types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakThis](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
    2110         dispatch_async(dispatch_get_main_queue(), ^{
    2111             if (!weakThis)
    2112                 return;
    2113             weakThis->handleRequestedCandidates(sequenceNumber, candidates);
    2114         });
    2115     }];
    2116 }
    2117 
    2118 void WebViewImpl::handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates)
    2119 {
    2120     const EditorState& editorState = m_page->editorState();
    2121     if (!editorState.isContentEditable)
    2122         return;
    2123 
    2124     auto& postLayoutData = editorState.postLayoutData();
    2125     if (m_lastStringForCandidateRequest != postLayoutData.stringForCandidateRequest)
    2126         return;
    2127 
    2128     auto weakEditor = m_weakPtrFactory.createWeakPtr();
    2129     [[NSSpellChecker sharedSpellChecker] showCandidates:candidates forString:postLayoutData.stringForCandidateRequest inRect:postLayoutData.selectionClipRect view:m_view completionHandler:[weakEditor](NSTextCheckingResult *acceptedCandidate) {
    2130         dispatch_async(dispatch_get_main_queue(), ^{
    2131             if (!weakEditor)
    2132                 return;
    2133             weakEditor->handleAcceptedCandidate(acceptedCandidate);
    2134         });
    2135     }];
    2136 }
    2137 
    2138 static WebCore::TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
    2139 {
    2140     WebCore::TextCheckingResult result;
    2141 
    2142     // FIXME: Right now we only request candidates for spelling, replacement, and correction, but we plan to
    2143     // support more types, and we will have to update this at that time.
    2144     switch ([nsResult resultType]) {
    2145     case NSTextCheckingTypeSpelling:
    2146         result.type = WebCore::TextCheckingTypeSpelling;
    2147         break;
    2148     case NSTextCheckingTypeReplacement:
    2149         result.type = WebCore::TextCheckingTypeReplacement;
    2150         break;
    2151     case NSTextCheckingTypeCorrection:
    2152         result.type = WebCore::TextCheckingTypeCorrection;
    2153         break;
    2154     default:
    2155         result.type = WebCore::TextCheckingTypeNone;
    2156     }
    2157 
    2158     NSRange resultRange = [nsResult range];
    2159     result.location = resultRange.location;
    2160     result.length = resultRange.length;
    2161     result.replacement = [nsResult replacementString];
    2162 
    2163     return result;
    2164 }
    2165 
    2166 void WebViewImpl::handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate)
    2167 {
    2168     const EditorState& editorState = m_page->editorState();
    2169     if (!editorState.isContentEditable)
    2170         return;
    2171 
    2172     auto& postLayoutData = editorState.postLayoutData();
    2173     if (m_lastStringForCandidateRequest != postLayoutData.stringForCandidateRequest)
    2174         return;
    2175 
    2176     m_page->handleAcceptedCandidate(textCheckingResultFromNSTextCheckingResult(acceptedCandidate));
    2177 }
    2178 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    21792090
    21802091void WebViewImpl::preferencesDidChange()
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r195002 r195059  
    60116011    m_nextViewStateChangeCallbacks.append(callbackID);
    60126012}
    6013 
    6014 void WebPageProxy::handleAcceptedCandidate(WebCore::TextCheckingResult acceptedCandidate)
    6015 {
    6016     m_process->send(Messages::WebPage::HandleAcceptedCandidate(acceptedCandidate), m_pageID);
    6017 }
    60186013#endif
    60196014
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r195002 r195059  
    10281028
    10291029    void installViewStateChangeCompletionHandler(void(^completionHandler)());
    1030 
    1031     void handleAcceptedCandidate(WebCore::TextCheckingResult);
    10321030#endif
    10331031
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r195002 r195059  
    11431143    void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
    11441144    void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
    1145 
    1146     void handleAcceptedCandidate(WebCore::TextCheckingResult);
    11471145#endif
    11481146
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r195002 r195059  
    405405    DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
    406406    DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
    407     HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
    408407#endif
    409408
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r195002 r195059  
    119119}
    120120
    121 void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint shouldIncludePostLayoutData) const
    122 {
    123     if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No) {
    124         result.isMissingPostLayoutData = true;
    125         return;
    126     }
    127 
    128     const VisibleSelection& selection = frame.selection().selection();
    129     RefPtr<Range> selectedRange = selection.toNormalizedRange();
    130     if (!selectedRange)
    131         return;
    132 
    133     auto& postLayoutData = result.postLayoutData();
    134     VisiblePosition selectionStart = selection.visibleStart();
    135     VisiblePosition selectionEnd = selection.visibleEnd();
    136     VisiblePosition paragraphStart = startOfParagraph(selectionStart);
    137     VisiblePosition paragraphEnd = endOfParagraph(selectionEnd);
    138 
    139     postLayoutData.candidateRequestStartPosition = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
    140     postLayoutData.selectedTextLength = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get()) - postLayoutData.candidateRequestStartPosition;
    141     postLayoutData.paragraphContextForCandidateRequest = plainText(makeRange(paragraphStart, paragraphEnd).get());
    142     postLayoutData.stringForCandidateRequest = frame.editor().stringForCandidateRequest();
    143 
    144     IntRect rectForSelectionCandidates;
    145     Vector<FloatQuad> quads;
    146     selectedRange->absoluteTextQuads(quads);
    147     if (!quads.isEmpty())
    148         postLayoutData.selectionClipRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
    149 }
    150 
    151 void WebPage::handleAcceptedCandidate(WebCore::TextCheckingResult acceptedCandidate)
    152 {
    153     Frame* frame = m_page->focusController().focusedFrame();
    154     if (!frame)
    155         return;
    156 
    157     frame->editor().handleAcceptedCandidate(acceptedCandidate);
     121void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint) const
     122{
    158123}
    159124
Note: See TracChangeset for help on using the changeset viewer.