- Revision
- 216018
- Author
- [email protected]
- Date
- 2017-05-01 10:36:46 -0700 (Mon, 01 May 2017)
Log Message
On-screen panel for candidate bar is in the wrong place when the caret is at the
start of a paragraph
https://bugs.webkit.org/show_bug.cgi?id=171453
-and corresponding-
rdar://problem/29779764
Reviewed by Tim Horton.
Source/WebKit/mac:
This bug only happens when the caret is at the beginning of the paragraph, and it
is because Range::absoluteTextQuads() returns no quads in this case. I think it
might be correct that absoluteTextQuads() returns no quads in this case, so this
patch fixes the bug at the call site by using absoluteCaretBounds() in this case.
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::handleRequestedCandidates):
Source/WebKit2:
This bug only happens when the caret is at the beginning of the paragraph, and it
is because Range::absoluteTextQuads() returns no quads in this case. I think it
might be correct that absoluteTextQuads() returns no quads in this case, so this
patch fixes the bug at the call site by using absoluteCaretBounds() in this case.
SPI for testing.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _candidateRect]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
Bug fix.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformEditorState):
Tools:
This test hard-codes the y-coordinate for the expected candidateRect.
* TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (216017 => 216018)
--- trunk/Source/WebKit/mac/ChangeLog 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit/mac/ChangeLog 2017-05-01 17:36:46 UTC (rev 216018)
@@ -1,3 +1,21 @@
+2017-05-01 Beth Dakin <[email protected]>
+
+ On-screen panel for candidate bar is in the wrong place when the caret is at the
+ start of a paragraph
+ https://bugs.webkit.org/show_bug.cgi?id=171453
+ -and corresponding-
+ rdar://problem/29779764
+
+ Reviewed by Tim Horton.
+
+ This bug only happens when the caret is at the beginning of the paragraph, and it
+ is because Range::absoluteTextQuads() returns no quads in this case. I think it
+ might be correct that absoluteTextQuads() returns no quads in this case, so this
+ patch fixes the bug at the call site by using absoluteCaretBounds() in this case.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::handleRequestedCandidates):
+
2017-04-30 Dan Bernstein <[email protected]>
[Cocoa] Replaces uses of [get…() alloc] with alloc…Instance()
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (216017 => 216018)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2017-05-01 17:36:46 UTC (rev 216018)
@@ -1251,6 +1251,11 @@
selectedRange->absoluteTextQuads(quads);
if (!quads.isEmpty())
rectForSelectionCandidates = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
+ else {
+ // Range::absoluteTextQuads() will be empty at the start of a paragraph.
+ if (selection.isCaret())
+ rectForSelectionCandidates = frame->view()->contentsToWindow(frame->selection().absoluteCaretBounds());
+ }
[m_webView showCandidates:candidates forString:m_paragraphContextForCandidateRequest.get() inRect:rectForSelectionCandidates forSelectedRange:m_rangeForCandidates view:m_webView completionHandler:nil];
}
Modified: trunk/Source/WebKit2/ChangeLog (216017 => 216018)
--- trunk/Source/WebKit2/ChangeLog 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit2/ChangeLog 2017-05-01 17:36:46 UTC (rev 216018)
@@ -1,3 +1,27 @@
+2017-05-01 Beth Dakin <[email protected]>
+
+ On-screen panel for candidate bar is in the wrong place when the caret is at the
+ start of a paragraph
+ https://bugs.webkit.org/show_bug.cgi?id=171453
+ -and corresponding-
+ rdar://problem/29779764
+
+ Reviewed by Tim Horton.
+
+ This bug only happens when the caret is at the beginning of the paragraph, and it
+ is because Range::absoluteTextQuads() returns no quads in this case. I think it
+ might be correct that absoluteTextQuads() returns no quads in this case, so this
+ patch fixes the bug at the call site by using absoluteCaretBounds() in this case.
+
+ SPI for testing.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _candidateRect]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+ Bug fix.
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::platformEditorState):
+
2017-05-01 Carlos Garcia Campos <[email protected]>
[GTK] Add automation session API
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (216017 => 216018)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-05-01 17:36:46 UTC (rev 216018)
@@ -5341,6 +5341,11 @@
[self insertText:string replacementRange:replacementRange];
}
+- (NSRect)_candidateRect
+{
+ return _page->editorState().postLayoutData().selectionClipRect;
+}
+
- (void)_setHeaderBannerHeight:(int)height
{
_page->setHeaderBannerHeightForTesting(height);
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (216017 => 216018)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-05-01 17:36:46 UTC (rev 216018)
@@ -357,6 +357,7 @@
- (void)_didUpdateCandidateListVisibility:(BOOL)visible WK_API_AVAILABLE(macosx(WK_MAC_TBA));
@property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (NSRect)_candidateRect WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_setHeaderBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (216017 => 216018)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2017-05-01 17:36:46 UTC (rev 216018)
@@ -149,6 +149,11 @@
selectedRange->absoluteTextQuads(quads);
if (!quads.isEmpty())
postLayoutData.selectionClipRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
+ else {
+ // Range::absoluteTextQuads() will be empty at the start of a paragraph.
+ if (selection.isCaret())
+ postLayoutData.selectionClipRect = frame.view()->contentsToWindow(frame.selection().absoluteCaretBounds());
+ }
}
void WebPage::handleAcceptedCandidate(WebCore::TextCheckingResult acceptedCandidate)
Modified: trunk/Tools/ChangeLog (216017 => 216018)
--- trunk/Tools/ChangeLog 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Tools/ChangeLog 2017-05-01 17:36:46 UTC (rev 216018)
@@ -1,3 +1,17 @@
+2017-05-01 Beth Dakin <[email protected]>
+
+ On-screen panel for candidate bar is in the wrong place when the caret is at the
+ start of a paragraph
+ https://bugs.webkit.org/show_bug.cgi?id=171453
+ -and corresponding-
+ rdar://problem/29779764
+
+ Reviewed by Tim Horton.
+
+ This test hard-codes the y-coordinate for the expected candidateRect.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm:
+ (TEST):
+
2017-05-01 David Kilzer <[email protected]>
check-webkit-style: Enable sprintf(), strcat(), strcpy() and printf() format checks
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm (216017 => 216018)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm 2017-05-01 17:06:40 UTC (rev 216017)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm 2017-05-01 17:36:46 UTC (rev 216018)
@@ -243,4 +243,11 @@
#endif
+TEST(WKWebViewCandidateTests, CandidateRectForEmptyParagraph)
+{
+ CandidateTestWebView *wkWebView = [CandidateTestWebView setUpWithFrame:NSMakeRect(0, 0, 800, 600) testPage:@"input-field-in-scrollable-document"];
+ NSRect candidateRect = [wkWebView _candidateRect];
+ EXPECT_NE(0, candidateRect.origin.y);
+}
+
#endif /* WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201 */