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 6f8f613ddec41e6d7403367ec2ecfe0c27c7e07b..4732faf1022bb6c56b6bd631ae050e0007a4e0dc 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 3304196415991c56528902f2d3194fd489aa1c6f..0bada421a50e60be03c9be545e07974d8341c1f0 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 fc5d233606b7a30679b5bef34a4ce0a9cc0ee790..c4900328edb9262b50fd60f4781ef029c218abbf 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 2a1c2668b302b64fc75be6a58ce3d10e8703f94f..64e6d40a0d8e2dad6d35da4ec0f1d5dd1e662eba 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 8b1f2aef06a8c6916ec6a5e0af9d57f1236494bb..5b30f3873933b0c10046c2d6c9f8f883090f15cb 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 0458d966ac57b1d17d76e2bb2c2668579993b826..f5088c5b4ba8b4465d0e5b2efdbd56ceb1488576 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 d9429f3a3e39ca3a7ecc574ac3af743a3d6bea68..88fa6b6c9bb3a9556b7b80012a63e59b724dd327 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 9073b5ed37ed93a0da368ce1c0fa1310680bd1c4..5385685e5fd55559cff8b25f7a0490c398e7b676 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 23b16edb79e6bab303936f3a5a3980ffe2a61353..2f8ac06dc038f06a22f9c96058607ed09e255a73 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 66bc8bc306e1495c98f35bdafad9c44ab01fb4cf..09979836062479e0be69311bb5fcefe45d65db93 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 4eb55df46f97bdd35b42e3fe2dfc0f98eff273e0..f79930d1ce2cadd2a18f07bf543ca780420e81ff 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 d95a6985d92e5fcb6d9601f0531d0a9c2b178a5c..a73ad967c99aad9cad1d500289adab678d8b92ae 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 2e304e28c593d901463a6f402605926773345a32..3366c70af1d963e0366a6a98fe118ab60b4d64bb 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 ed174816f356ba799507d7212b75b07e9a6f1d01..4ea72044c88705abed498716f8dbfe4f8d794b00 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);