Changeset 195059 in webkit
- Timestamp:
- Jan 14, 2016 9:50:12 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195058 r195059 1 2016-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 1 14 2016-01-14 Martin Robinson <mrobinson@igalia.com> 2 15 -
trunk/LayoutTests/platform/mac/fast/dom/focus-contenteditable-expected.txt
r195002 r195059 7 7 RenderText {#text} at (0,0) size 509x18 8 8 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 0x09 RenderBR {BR} at (508,14) size 1x0 10 10 RenderText {#text} at (0,18) size 379x18 11 11 text run at (0,18) width 379: "The window should scroll to reveal the contenteditable div." -
trunk/Source/WebCore/ChangeLog
r195058 r195059 1 2016-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 1 14 2016-01-14 Martin Robinson <mrobinson@igalia.com> 2 15 -
trunk/Source/WebCore/editing/Editor.cpp
r195002 r195059 3534 3534 } 3535 3535 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 should3545 // 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() const3552 {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 3573 3536 bool Editor::unifiedTextCheckerEnabled() const 3574 3537 { -
trunk/Source/WebCore/editing/Editor.h
r195002 r195059 456 456 #endif 457 457 458 WEBCORE_EXPORT String stringForCandidateRequest() const;459 WEBCORE_EXPORT void handleAcceptedCandidate(TextCheckingResult);460 461 458 private: 462 459 class WebContentReader; -
trunk/Source/WebKit2/ChangeLog
r195056 r195059 1 2016-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 1 14 2016-01-14 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 15 -
trunk/Source/WebKit2/Shared/EditorState.cpp
r195002 r195059 44 44 encoder << isMissingPostLayoutData; 45 45 46 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)46 #if PLATFORM(IOS) || PLATFORM(GTK) 47 47 if (!isMissingPostLayoutData) 48 48 m_postLayoutData.encode(encoder); … … 85 85 return false; 86 86 87 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)87 #if PLATFORM(IOS) || PLATFORM(GTK) 88 88 if (!result.isMissingPostLayoutData) { 89 89 if (!PostLayoutData::decode(decoder, result.postLayoutData())) … … 104 104 } 105 105 106 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)106 #if PLATFORM(IOS) || PLATFORM(GTK) 107 107 void EditorState::PostLayoutData::encode(IPC::ArgumentEncoder& encoder) const 108 108 { 109 #if PLATFORM(IOS) || PLATFORM(GTK)110 109 encoder << typingAttributes; 111 110 encoder << caretRectAtStart; 112 #endif113 #if PLATFORM(IOS) || PLATFORM(MAC)114 encoder << selectionClipRect;115 encoder << selectedTextLength;116 #endif117 111 #if PLATFORM(IOS) 118 112 encoder << caretRectAtEnd; 113 encoder << selectionClipRect; 119 114 encoder << selectionRects; 120 115 encoder << wordAtSelection; 116 encoder << selectedTextLength; 121 117 encoder << characterAfterSelection; 122 118 encoder << characterBeforeSelection; … … 125 121 encoder << hasContent; 126 122 #endif 127 #if PLATFORM(MAC)128 encoder << candidateRequestStartPosition;129 encoder << paragraphContextForCandidateRequest;130 encoder << stringForCandidateRequest;131 #endif132 123 } 133 124 134 125 bool EditorState::PostLayoutData::decode(IPC::ArgumentDecoder& decoder, PostLayoutData& result) 135 126 { 136 #if PLATFORM(IOS) || PLATFORM(GTK)137 127 if (!decoder.decode(result.typingAttributes)) 138 128 return false; 139 129 if (!decoder.decode(result.caretRectAtStart)) 140 130 return false; 141 #endif142 #if PLATFORM(IOS) || PLATFORM(MAC)143 if (!decoder.decode(result.selectionClipRect))144 return false;145 if (!decoder.decode(result.selectedTextLength))146 return false;147 #endif148 131 #if PLATFORM(IOS) 149 132 if (!decoder.decode(result.caretRectAtEnd)) 133 return false; 134 if (!decoder.decode(result.selectionClipRect)) 150 135 return false; 151 136 if (!decoder.decode(result.selectionRects)) 152 137 return false; 153 138 if (!decoder.decode(result.wordAtSelection)) 139 return false; 140 if (!decoder.decode(result.selectedTextLength)) 154 141 return false; 155 142 if (!decoder.decode(result.characterAfterSelection)) … … 164 151 return false; 165 152 #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 #endif176 153 177 154 return true; 178 155 } 179 #endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)156 #endif 180 157 181 158 } -
trunk/Source/WebKit2/Shared/EditorState.h
r195002 r195059 63 63 #endif 64 64 65 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)65 #if PLATFORM(IOS) || PLATFORM(GTK) 66 66 struct PostLayoutData { 67 #if PLATFORM(IOS) || PLATFORM(GTK)68 67 uint32_t typingAttributes { AttributeNone }; 69 68 WebCore::IntRect caretRectAtStart; 70 #endif71 #if PLATFORM(IOS) || PLATFORM(MAC)72 WebCore::IntRect selectionClipRect;73 uint64_t selectedTextLength { 0 };74 #endif75 69 #if PLATFORM(IOS) 76 70 WebCore::IntRect caretRectAtEnd; 71 WebCore::IntRect selectionClipRect; 77 72 Vector<WebCore::SelectionRect> selectionRects; 78 73 String wordAtSelection; 74 uint64_t selectedTextLength { 0 }; 79 75 UChar32 characterAfterSelection { 0 }; 80 76 UChar32 characterBeforeSelection { 0 }; … … 82 78 bool isReplaceAllowed { false }; 83 79 bool hasContent { false }; 84 #endif85 #if PLATFORM(MAC)86 uint64_t candidateRequestStartPosition { 0 };87 String paragraphContextForCandidateRequest;88 String stringForCandidateRequest;89 80 #endif 90 81 … … 95 86 const PostLayoutData& postLayoutData() const; 96 87 PostLayoutData& postLayoutData(); 97 #endif // PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)88 #endif // PLATFORM(IOS) || PLATFORM(GTK) 98 89 99 90 void encode(IPC::ArgumentEncoder&) const; 100 91 static bool decode(IPC::ArgumentDecoder&, EditorState&); 101 92 102 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)93 #if PLATFORM(IOS) || PLATFORM(GTK) 103 94 private: 104 95 PostLayoutData m_postLayoutData; … … 106 97 }; 107 98 108 #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC)99 #if PLATFORM(IOS) || PLATFORM(GTK) 109 100 inline auto EditorState::postLayoutData() -> PostLayoutData& 110 101 { -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
r195002 r195059 295 295 void capitalizeWord(); 296 296 297 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200298 void requestCandidatesForSelectionIfNeeded();299 #endif300 301 297 void preferencesDidChange(); 302 298 … … 503 499 Vector<NSTouch *> touchesOrderedByAge(); 504 500 505 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200506 void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);507 void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);508 #endif509 510 501 NSView <WebViewImplDelegate> *m_view; 511 502 std::unique_ptr<PageClient> m_pageClient; … … 620 611 Vector<RetainPtr<id <NSObject, NSCopying>>> m_activeTouchIdentities; 621 612 RetainPtr<NSArray> m_lastTouches; 622 623 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200624 String m_lastStringForCandidateRequest;625 #endif626 613 }; 627 614 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
r195002 r195059 76 76 #import <WebCore/NSApplicationSPI.h> 77 77 #import <WebCore/NSImmediateActionGestureRecognizerSPI.h> 78 #import <WebCore/NSSpellCheckerSPI.h>79 78 #import <WebCore/NSTextFinderSPI.h> 80 79 #import <WebCore/NSWindowSPI.h> … … 1725 1724 { 1726 1725 updateFontPanelIfNeeded(); 1727 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1012001728 if (!m_page->editorState().isMissingPostLayoutData)1729 requestCandidatesForSelectionIfNeeded();1730 #endif1731 1726 } 1732 1727 … … 2093 2088 m_page->capitalizeWord(); 2094 2089 } 2095 2096 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1012002097 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 to2143 // 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 >= 1012002179 2090 2180 2091 void WebViewImpl::preferencesDidChange() -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r195002 r195059 6011 6011 m_nextViewStateChangeCallbacks.append(callbackID); 6012 6012 } 6013 6014 void WebPageProxy::handleAcceptedCandidate(WebCore::TextCheckingResult acceptedCandidate)6015 {6016 m_process->send(Messages::WebPage::HandleAcceptedCandidate(acceptedCandidate), m_pageID);6017 }6018 6013 #endif 6019 6014 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r195002 r195059 1028 1028 1029 1029 void installViewStateChangeCompletionHandler(void(^completionHandler)()); 1030 1031 void handleAcceptedCandidate(WebCore::TextCheckingResult);1032 1030 #endif 1033 1031 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r195002 r195059 1143 1143 void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID); 1144 1144 void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID); 1145 1146 void handleAcceptedCandidate(WebCore::TextCheckingResult);1147 1145 #endif 1148 1146 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r195002 r195059 405 405 DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay) 406 406 DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay) 407 HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)408 407 #endif 409 408 -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r195002 r195059 119 119 } 120 120 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); 121 void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint) const 122 { 158 123 } 159 124
Note: See TracChangeset
for help on using the changeset viewer.