REGRESSION(r222507): Composition highlight doesn't render when using IME
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jan 2018 03:05:10 +0000 (03:05 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jan 2018 03:05:10 +0000 (03:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181485
<rdar://problem/35896516>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Fixes the order of arguments passed to paintTextSubrangeBackground from paintCompositionBackground.

Test: editing/marked-text-appearance.html

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintCompositionBackground):

Source/WebKit:

Add plumbing for a `suppressUnderline` argument when setting marked text.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetComposition):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setCompositionForTesting):
* WebProcess/WebPage/WebPage.h:

Tools:

Add a `suppressUnderline` argument to TextInputController.setMarkedText. This suppresses the custom underlines
rendered when testing IME on iOS in WebKit2. In this new test, suppressing underline rendering is needed to
allow rendering composition backgrounds (see InlineTextBox::paint).

* DumpRenderTree/ios/TextInputControllerIOS.m:
(+[TextInputController isSelectorExcludedFromWebScript:]):
(+[TextInputController webScriptNameForSelector:]):
(-[TextInputController setMarkedText:selectedFrom:length:suppressUnderline:]):
(-[TextInputController setMarkedText:selectedFrom:length:]): Deleted.
* DumpRenderTree/mac/TextInputControllerMac.m:
(+[TextInputController isSelectorExcludedFromWebScript:]):
(+[TextInputController webScriptNameForSelector:]):
(-[TextInputController setMarkedText:selectedFrom:length:suppressUnderline:]):
(-[TextInputController setMarkedText:selectedFrom:length:]): Deleted.
* WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl:
* WebKitTestRunner/InjectedBundle/TextInputController.cpp:
(WTR::TextInputController::setMarkedText):
* WebKitTestRunner/InjectedBundle/TextInputController.h:

LayoutTests:

Add a new layout test to ensure that in the absence of custom composition underlines, a marked composition
string appears different once it is confirmed.

* editing/marked-text-appearance-expected-mismatch.html: Added.
* editing/marked-text-appearance.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/marked-text-appearance-expected-mismatch.html [new file with mode: 0644]
LayoutTests/editing/marked-text-appearance.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Tools/ChangeLog
Tools/DumpRenderTree/ios/TextInputControllerIOS.m
Tools/DumpRenderTree/mac/TextInputControllerMac.m
Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl
Tools/WebKitTestRunner/InjectedBundle/TextInputController.cpp
Tools/WebKitTestRunner/InjectedBundle/TextInputController.h

index 6f8f613..4732faf 100644 (file)
@@ -1,3 +1,17 @@
+2018-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        REGRESSION(r222507): Composition highlight doesn't render when using IME
+        https://bugs.webkit.org/show_bug.cgi?id=181485
+        <rdar://problem/35896516>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a new layout test to ensure that in the absence of custom composition underlines, a marked composition
+        string appears different once it is confirmed.
+
+        * editing/marked-text-appearance-expected-mismatch.html: Added.
+        * editing/marked-text-appearance.html: Added.
+
 2018-01-10  Chris Dumez  <cdumez@apple.com>
 
         Multiple http/wpt/beacon/contentextensions/ test are flaky.
diff --git a/LayoutTests/editing/marked-text-appearance-expected-mismatch.html b/LayoutTests/editing/marked-text-appearance-expected-mismatch.html
new file mode 100644 (file)
index 0000000..b70286e
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<body contenteditable></body>
+<script>
+    document.body.focus();
+    if (window.textInputController) {
+        textInputController.setMarkedText("^^^^^", 0, 5, true);
+        textInputController.insertText("^^^^^");
+    }
+</script>
diff --git a/LayoutTests/editing/marked-text-appearance.html b/LayoutTests/editing/marked-text-appearance.html
new file mode 100644 (file)
index 0000000..37bac3b
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body contenteditable></body>
+<script>
+    document.body.focus();
+    if (window.textInputController)
+        textInputController.setMarkedText("^^^^^", 0, 5, true);
+</script>
index 3304196..0bada42 100644 (file)
@@ -1,3 +1,18 @@
+2018-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        REGRESSION(r222507): Composition highlight doesn't render when using IME
+        https://bugs.webkit.org/show_bug.cgi?id=181485
+        <rdar://problem/35896516>
+
+        Reviewed by Ryosuke Niwa.
+
+        Fixes the order of arguments passed to paintTextSubrangeBackground from paintCompositionBackground.
+
+        Test: editing/marked-text-appearance.html
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintCompositionBackground):
+
 2018-01-10  Youenn Fablet  <youenn@apple.com>
 
         Use no-cache fetch mode when loading main documents with location.reload()
index fc5d233..c490032 100644 (file)
@@ -1044,7 +1044,7 @@ void InlineTextBox::paintTextSubrangeDecoration(GraphicsContext& context, const
 
 void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin)
 {
-    paintTextSubrangeBackground(context, boxOrigin, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd()), Color::compositionFill);
+    paintTextSubrangeBackground(context, boxOrigin, Color::compositionFill, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd()));
 }
 
 void InlineTextBox::paintCompositionUnderlines(GraphicsContext& context, const FloatPoint& boxOrigin) const
index 2a1c266..64e6d40 100644 (file)
@@ -1,3 +1,20 @@
+2018-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        REGRESSION(r222507): Composition highlight doesn't render when using IME
+        https://bugs.webkit.org/show_bug.cgi?id=181485
+        <rdar://problem/35896516>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add plumbing for a `suppressUnderline` argument when setting marked text.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageSetComposition):
+        * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setCompositionForTesting):
+        * WebProcess/WebPage/WebPage.h:
+
 2018-01-10  Tim Horton  <timothy_horton@apple.com>
 
         REGRESSION (r213590): Swipe from edge to go to previous page is significantly slower than tapping back button on Twitter
index 8b1f2ae..5b30f38 100644 (file)
@@ -540,9 +540,9 @@ WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef)
     return toAPI(&toImpl(pageRef)->trackedRepaintRects().leakRef());
 }
 
-void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length)
+void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length, bool suppressUnderline)
 {
-    toImpl(pageRef)->setCompositionForTesting(toWTFString(text), from, length);
+    toImpl(pageRef)->setCompositionForTesting(toWTFString(text), from, length, suppressUnderline);
 }
 
 bool WKBundlePageHasComposition(WKBundlePageRef pageRef)
index 0458d96..f5088c5 100644 (file)
@@ -72,7 +72,7 @@ WK_EXPORT bool WKBundlePageIsTrackingRepaints(WKBundlePageRef page);
 WK_EXPORT void WKBundlePageResetTrackedRepaints(WKBundlePageRef page);
 WK_EXPORT WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef page);
 
-WK_EXPORT void WKBundlePageSetComposition(WKBundlePageRef page, WKStringRef text, int from, int length);
+WK_EXPORT void WKBundlePageSetComposition(WKBundlePageRef page, WKStringRef text, int from, int length, bool suppressUnderline);
 WK_EXPORT bool WKBundlePageHasComposition(WKBundlePageRef page);
 WK_EXPORT void WKBundlePageConfirmComposition(WKBundlePageRef page);
 WK_EXPORT void WKBundlePageConfirmCompositionWithText(WKBundlePageRef page, WKStringRef text);
index d9429f3..88fa6b6 100644 (file)
@@ -4417,14 +4417,16 @@ void WebPage::simulateMouseMotion(WebCore::IntPoint position, WallTime time)
     mouseEvent(WebMouseEvent(WebMouseEvent::MouseMove, WebMouseEvent::NoButton, 0, position, position, 0, 0, 0, 0, WebMouseEvent::Modifiers(), time, 0, WebMouseEvent::NoTap));
 }
 
-void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length)
+void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length, bool suppressUnderline)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     if (!frame.editor().canEdit())
         return;
 
     Vector<CompositionUnderline> underlines;
-    underlines.append(CompositionUnderline(0, compositionString.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false));
+    if (!suppressUnderline)
+        underlines.append(CompositionUnderline(0, compositionString.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false));
+
     frame.editor().setComposition(compositionString, underlines, from, from + length);
 }
 
index 9073b5e..5385685 100644 (file)
@@ -735,7 +735,7 @@ public:
     void updateAccessibilityTree();
 #endif
 
-    void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
+    void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length, bool suppressUnderline);
     bool hasCompositionForTesting();
     void confirmCompositionForTesting(const String& compositionString);
 
index 23b16ed..2f8ac06 100644 (file)
@@ -1,3 +1,30 @@
+2018-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        REGRESSION(r222507): Composition highlight doesn't render when using IME
+        https://bugs.webkit.org/show_bug.cgi?id=181485
+        <rdar://problem/35896516>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a `suppressUnderline` argument to TextInputController.setMarkedText. This suppresses the custom underlines
+        rendered when testing IME on iOS in WebKit2. In this new test, suppressing underline rendering is needed to
+        allow rendering composition backgrounds (see InlineTextBox::paint).
+
+        * DumpRenderTree/ios/TextInputControllerIOS.m:
+        (+[TextInputController isSelectorExcludedFromWebScript:]):
+        (+[TextInputController webScriptNameForSelector:]):
+        (-[TextInputController setMarkedText:selectedFrom:length:suppressUnderline:]):
+        (-[TextInputController setMarkedText:selectedFrom:length:]): Deleted.
+        * DumpRenderTree/mac/TextInputControllerMac.m:
+        (+[TextInputController isSelectorExcludedFromWebScript:]):
+        (+[TextInputController webScriptNameForSelector:]):
+        (-[TextInputController setMarkedText:selectedFrom:length:suppressUnderline:]):
+        (-[TextInputController setMarkedText:selectedFrom:length:]): Deleted.
+        * WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl:
+        * WebKitTestRunner/InjectedBundle/TextInputController.cpp:
+        (WTR::TextInputController::setMarkedText):
+        * WebKitTestRunner/InjectedBundle/TextInputController.h:
+
 2018-01-10  JF Bastien  <jfbastien@apple.com>
 
         Poison small JSObject derivatives which only contain pointers
index 66bc8bc..0997983 100644 (file)
@@ -39,7 +39,7 @@
 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
 {
     if (aSelector == @selector(insertText:)
-        || aSelector == @selector(setMarkedText:selectedFrom:length:)
+        || aSelector == @selector(setMarkedText:selectedFrom:length:suppressUnderline:)
         || aSelector == @selector(markedRange))
         return NO;
 
@@ -50,7 +50,7 @@
 {
     if (aSelector == @selector(insertText:))
         return @"insertText";
-    if (aSelector == @selector(setMarkedText:selectedFrom:length:))
+    if (aSelector == @selector(setMarkedText:selectedFrom:length:suppressUnderline:))
         return @"setMarkedText";
     if (aSelector == @selector(markedRange))
         return @"markedRange";
@@ -83,7 +83,7 @@
     [[webView mainFrame] confirmMarkedText:text];
 }
 
-- (void)setMarkedText:(NSString *)text selectedFrom:(NSInteger)selectionStart length:(NSInteger)selectionLength
+- (void)setMarkedText:(NSString *)text selectedFrom:(NSInteger)selectionStart length:(NSInteger)selectionLength suppressUnderline:(BOOL)suppressUnderline
 {
     if (selectionStart == -1)
         selectionStart = NSNotFound;
index 4eb55df..f79930d 100644 (file)
@@ -223,7 +223,7 @@ NSString *NSTextInsertionUndoableAttributeName;
 {
     if (aSelector == @selector(insertText:)
         || aSelector == @selector(doCommand:)
-        || aSelector == @selector(setMarkedText:selectedFrom:length:)
+        || aSelector == @selector(setMarkedText:selectedFrom:length:suppressUnderline:)
         || aSelector == @selector(unmarkText)
         || aSelector == @selector(hasMarkedText)
         || aSelector == @selector(conversationIdentifier)
@@ -249,7 +249,7 @@ NSString *NSTextInsertionUndoableAttributeName;
         return @"insertText";
     if (aSelector == @selector(doCommand:))
         return @"doCommand";
-    if (aSelector == @selector(setMarkedText:selectedFrom:length:))
+    if (aSelector == @selector(setMarkedText:selectedFrom:length:suppressUnderline:))
         return @"setMarkedText";
     if (aSelector == @selector(substringFrom:length:))
         return @"substringFromRange";
@@ -312,7 +312,7 @@ NSString *NSTextInsertionUndoableAttributeName;
         [textInput doCommandBySelector:NSSelectorFromString(aCommand)];
 }
 
-- (void)setMarkedText:(NSString *)aString selectedFrom:(int)from length:(int)length
+- (void)setMarkedText:(NSString *)aString selectedFrom:(int)from length:(int)length suppressUnderline:(BOOL)suppressUnderline
 {
     NSObject <NSTextInput> *textInput = [self textInput];
 
index d95a698..a73ad96 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 interface TextInputController {
-    void setMarkedText(DOMString string, long from, long length);
+    void setMarkedText(DOMString string, long from, long length, boolean suppressUnderline);
     boolean hasMarkedText();
     void unmarkText();
     void insertText(DOMString string);
index 2e304e2..3366c70 100644 (file)
@@ -57,9 +57,9 @@ void TextInputController::makeWindowObject(JSContextRef context, JSObjectRef win
     setProperty(context, windowObject, "textInputController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
 }
 
-void TextInputController::setMarkedText(JSStringRef text, int from, int length)
+void TextInputController::setMarkedText(JSStringRef text, int from, int length, bool suppressUnderline)
 {
-    WKBundlePageSetComposition(InjectedBundle::singleton().page()->page(), toWK(text).get(), from, length);
+    WKBundlePageSetComposition(InjectedBundle::singleton().page()->page(), toWK(text).get(), from, length, suppressUnderline);
 }
 
 bool TextInputController::hasMarkedText()
index ed17481..4ea7204 100644 (file)
@@ -40,7 +40,7 @@ public:
 
     void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
 
-    void setMarkedText(JSStringRef text, int from, int length);
+    void setMarkedText(JSStringRef text, int from, int length, bool suppressUnderline);
     bool hasMarkedText();
     void unmarkText();
     void insertText(JSStringRef text);