Title: [220690] releases/WebKitGTK/webkit-2.18
Revision
220690
Author
[email protected]
Date
2017-08-14 08:29:33 -0700 (Mon, 14 Aug 2017)

Log Message

Merge r220639 - Composition underline color is always black
https://bugs.webkit.org/show_bug.cgi?id=174675

Reviewed by Ryosuke Niwa.

Source/WebCore:

This patch uses the current color of the text instead of black
for the composition underline marker.
This makes it visible in the case we have a black/dark background.

Test: editing/composition-underline-color.html

* editing/CompositionUnderline.h:
(WebCore::CompositionUnderline::CompositionUnderline):
Added new attribute compositionUnderlineColor.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintCompositionUnderline):
Use the text color if compositionUnderlineColor is TextColor.

Source/WebKit:

This patch uses the current color of the text instead of black
for the composition underline marker.
This makes it visible in the case we have a black/dark background.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::extractUnderlines): If NSUnderlineColorAttributeName
is not present use text color for composition underline.
(WebKit::WebViewImpl::setMarkedText): Use text color
for composition underline in the plain text case.
* UIProcess/gtk/InputMethodFilter.cpp:
(WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults):
Use text color for composition underline.
(WebKit::InputMethodFilter::updatePreedit): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setCompositionForTesting): Ditto.

Source/WebKitLegacy/mac:

* WebView/WebHTMLView.mm:
(extractUnderlines): If NSUnderlineColorAttributeName
is not present use text color for composition underline.
(-[WebHTMLView setMarkedText:selectedRange:]): Use text color
for composition underline in the plain text case.

Source/WebKitLegacy/win:

* WebView.cpp:
(WebView::setCompositionForTesting): Use text color for
composition underline.

LayoutTests:

Added new test to check that the composition underline
is using the text color.
The test hides the text and the caret, so it only shows
the composition underline and checks against an -expected-mismatch
that the color of the composition marker is different.

* editing/composition-underline-color-expected-mismatch.html: Added.
* editing/composition-underline-color.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/LayoutTests/ChangeLog (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/ChangeLog	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/ChangeLog	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1,3 +1,19 @@
+2017-08-13  Manuel Rego Casasnovas  <[email protected]>
+
+        Composition underline color is always black
+        https://bugs.webkit.org/show_bug.cgi?id=174675
+
+        Reviewed by Ryosuke Niwa.
+
+        Added new test to check that the composition underline
+        is using the text color.
+        The test hides the text and the caret, so it only shows
+        the composition underline and checks against an -expected-mismatch
+        that the color of the composition marker is different.
+
+        * editing/composition-underline-color-expected-mismatch.html: Added.
+        * editing/composition-underline-color.html: Added.
+
 2017-08-10  Nan Wang  <[email protected]>
 
         Layout test accessibility/press-target-uses-text-descendant-node.html is flaky.

Added: releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color-expected-mismatch.html (0 => 220690)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color-expected-mismatch.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color-expected-mismatch.html	2017-08-14 15:29:33 UTC (rev 220690)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<style>
+  div {
+    position: absolute;
+    top: 0;
+    left: 0;
+  }
+  #test {
+    color: magenta;
+    font: 20px/1 Monospace;
+    outline: none;
+  }
+  #overlapping-top {
+    background: white;
+    width: 100px;
+    height: 15px;
+  }
+  #overlapping-right {
+    background: white;
+    width: 50px;
+    height: 50px;
+    left: 50px;
+  }
+</style>
+<div contenteditable id="test"></div>
+<!-- The overlapping DIVs are hiding the "^^^^^" characters and the caret to show only the composition underline. -->
+<div id="overlapping-top"></div>
+<div id="overlapping-right"></div>
+<script>
+  document.getElementById("test").focus();
+  if (window.textInputController)
+    textInputController.setMarkedText("^^^^^", 5, 0);
+</script>

Added: releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color.html (0 => 220690)


--- releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.18/LayoutTests/editing/composition-underline-color.html	2017-08-14 15:29:33 UTC (rev 220690)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<style>
+  div {
+    position: absolute;
+    top: 0;
+    left: 0;
+  }
+  #test {
+    color: lime;
+    font: 20px/1 Monospace;
+    outline: none;
+  }
+  #overlapping-top {
+    background: white;
+    width: 100px;
+    height: 15px;
+  }
+  #overlapping-right {
+    background: white;
+    width: 50px;
+    height: 50px;
+    left: 50px;
+  }
+</style>
+<div contenteditable id="test"></div>
+<!-- The overlapping DIVs are hiding the "^^^^^" characters and the caret to show only the composition underline. -->
+<div id="overlapping-top"></div>
+<div id="overlapping-right"></div>
+<script>
+  document.getElementById("test").focus();
+  if (window.textInputController)
+    textInputController.setMarkedText("^^^^^", 5, 0);
+</script>

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1,3 +1,23 @@
+2017-08-13  Manuel Rego Casasnovas  <[email protected]>
+
+        Composition underline color is always black
+        https://bugs.webkit.org/show_bug.cgi?id=174675
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch uses the current color of the text instead of black
+        for the composition underline marker.
+        This makes it visible in the case we have a black/dark background.
+
+        Test: editing/composition-underline-color.html
+
+        * editing/CompositionUnderline.h:
+        (WebCore::CompositionUnderline::CompositionUnderline):
+        Added new attribute compositionUnderlineColor.
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintCompositionUnderline):
+        Use the text color if compositionUnderlineColor is TextColor.
+
 2017-08-13  Carlos Garcia Campos  <[email protected]>
 
         [GTK] stop kinetic scrolling when a zero movement is reached

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/editing/CompositionUnderline.h (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/editing/CompositionUnderline.h	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/editing/CompositionUnderline.h	2017-08-14 15:29:33 UTC (rev 220690)
@@ -29,21 +29,26 @@
 
 namespace WebCore {
 
+enum class CompositionUnderlineColor { GivenColor, TextColor };
+
 struct CompositionUnderline {
+
     CompositionUnderline()
     {
     }
 
-    CompositionUnderline(unsigned s, unsigned e, const Color& c, bool t) 
-        : startOffset(s)
-        , endOffset(e)
-        , color(c)
-        , thick(t)
+    CompositionUnderline(unsigned startOffset, unsigned endOffset, CompositionUnderlineColor compositionUnderlineColor, const Color& color, bool thick)
+        : startOffset(startOffset)
+        , endOffset(endOffset)
+        , compositionUnderlineColor(compositionUnderlineColor)
+        , color(color)
+        , thick(thick)
     {
     }
 
     unsigned startOffset { 0 };
     unsigned endOffset { 0 };
+    CompositionUnderlineColor compositionUnderlineColor { CompositionUnderlineColor::TextColor };
     Color color;
     bool thick { false };
 };

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/InlineTextBox.cpp (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/InlineTextBox.cpp	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/InlineTextBox.cpp	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1007,7 +1007,7 @@
     start += 1;
     width -= 2;
 
-    context.setStrokeColor(underline.color);
+    context.setStrokeColor(underline.compositionUnderlineColor == CompositionUnderlineColor::TextColor ? renderer().style().visitedDependentColor(CSSPropertyWebkitTextFillColor) : underline.color);
     context.setStrokeThickness(lineThickness);
     context.drawLineForText(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + logicalHeight() - lineThickness), width, renderer().document().printing());
 }

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1,3 +1,26 @@
+2017-08-13  Manuel Rego Casasnovas  <[email protected]>
+
+        Composition underline color is always black
+        https://bugs.webkit.org/show_bug.cgi?id=174675
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch uses the current color of the text instead of black
+        for the composition underline marker.
+        This makes it visible in the case we have a black/dark background.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::extractUnderlines): If NSUnderlineColorAttributeName
+        is not present use text color for composition underline.
+        (WebKit::WebViewImpl::setMarkedText): Use text color
+        for composition underline in the plain text case.
+        * UIProcess/gtk/InputMethodFilter.cpp:
+        (WebKit::InputMethodFilter::handleKeyboardEventWithCompositionResults):
+        Use text color for composition underline.
+        (WebKit::InputMethodFilter::updatePreedit): Ditto.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setCompositionForTesting): Ditto.
+
 2017-08-13  Adrian Perez de Castro  <[email protected]>
 
         [WPE] Implement WebCore::standardUserAgent()

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2017-08-14 15:29:33 UTC (rev 220690)
@@ -4265,9 +4265,12 @@
 
         if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
             WebCore::Color color = WebCore::Color::black;
-            if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName])
+            WebCore::CompositionUnderlineColor compositionUnderlineColor = WebCore::CompositionUnderlineColor::TextColor;
+            if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName]) {
                 color = WebCore::colorFromNSColor(colorAttr);
-            result.append(WebCore::CompositionUnderline(range.location, NSMaxRange(range), color, style.intValue > 1));
+                compositionUnderlineColor = WebCore::CompositionUnderlineColor::GivenColor;
+            }
+            result.append(WebCore::CompositionUnderline(range.location, NSMaxRange(range), compositionUnderlineColor, color, style.intValue > 1));
         }
         
         i = range.location + range.length;
@@ -4599,8 +4602,10 @@
         // FIXME: We ignore most attributes from the string, so an input method cannot specify e.g. a font or a glyph variation.
         text = [string string];
         underlines = extractUnderlines(string);
-    } else
+    } else {
         text = string;
+        underlines.append(WebCore::CompositionUnderline(0, [text length], WebCore::CompositionUnderlineColor::TextColor, WebCore::Color::black, false));
+    }
 
     if (inSecureInputState()) {
         // In password fields, we only allow ASCII dead keys, and don't allow inline input, matching NSSecureTextInputField.

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/UIProcess/gtk/InputMethodFilter.cpp	2017-08-14 15:29:33 UTC (rev 220690)
@@ -153,7 +153,7 @@
         m_page->confirmComposition(m_confirmedComposition, -1, 0);
 
     if (resultsToSend & Preedit && !m_preedit.isNull()) {
-        m_page->setComposition(m_preedit, Vector<CompositionUnderline>{ CompositionUnderline(0, m_preedit.length(), Color(1, 1, 1), false) },
+        m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
             m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
     }
 }
@@ -260,7 +260,7 @@
     }
 #endif
     // FIXME: We should parse the PangoAttrList that we get from the IM context here.
-    m_page->setComposition(m_preedit, Vector<CompositionUnderline>{ CompositionUnderline(0, m_preedit.length(), Color(1, 1, 1), false) },
+    m_page->setComposition(m_preedit, Vector<CompositionUnderline> { CompositionUnderline(0, m_preedit.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false) },
         m_cursorOffset, m_cursorOffset, 0 /* replacement start */, 0 /* replacement end */);
     m_preeditChanged = false;
 }

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/WebProcess/WebPage/WebPage.cpp (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-08-14 15:29:33 UTC (rev 220690)
@@ -4669,7 +4669,7 @@
         return;
 
     Vector<CompositionUnderline> underlines;
-    underlines.append(CompositionUnderline(0, compositionString.length(), Color(Color::black), false));
+    underlines.append(CompositionUnderline(0, compositionString.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false));
     frame.editor().setComposition(compositionString, underlines, from, from + length);
 }
 

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/ChangeLog (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/ChangeLog	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/ChangeLog	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1,3 +1,16 @@
+2017-08-13  Manuel Rego Casasnovas  <[email protected]>
+
+        Composition underline color is always black
+        https://bugs.webkit.org/show_bug.cgi?id=174675
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebView/WebHTMLView.mm:
+        (extractUnderlines): If NSUnderlineColorAttributeName
+        is not present use text color for composition underline.
+        (-[WebHTMLView setMarkedText:selectedRange:]): Use text color
+        for composition underline in the plain text case.
+
 2017-08-08  Brady Eidson  <[email protected]>
 
         Don't enable default icon loading in WK1 for apps linked against old SDKs.

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2017-08-14 15:29:33 UTC (rev 220690)
@@ -6945,9 +6945,12 @@
 
         if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
             Color color = Color::black;
-            if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName])
+            CompositionUnderlineColor compositionUnderlineColor = CompositionUnderlineColor::TextColor;
+            if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName]) {
                 color = colorFromNSColor(colorAttr);
-            result.append(CompositionUnderline(range.location, NSMaxRange(range), color, [style intValue] > 1));
+                compositionUnderlineColor = CompositionUnderlineColor::GivenColor;
+            }
+            result.append(CompositionUnderline(range.location, NSMaxRange(range), compositionUnderlineColor, color, [style intValue] > 1));
         }
 
         i = range.location + range.length;
@@ -6997,9 +7000,13 @@
             replacementRange = NSRangeFromString(rangeString);
 
         extractUnderlines(string, underlines);
-    } else
+    } else {
+        text = string;
+        underlines.append(CompositionUnderline(0, [text length], CompositionUnderlineColor::TextColor, Color::black, false));
+    }
+#else
+    text = string;
 #endif
-        text = string;
 
     if (replacementRange.location != NSNotFound)
         [[self _frame] _selectNSRange:replacementRange];

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/ChangeLog (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/ChangeLog	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/ChangeLog	2017-08-14 15:29:33 UTC (rev 220690)
@@ -1,3 +1,14 @@
+2017-08-13  Manuel Rego Casasnovas  <[email protected]>
+
+        Composition underline color is always black
+        https://bugs.webkit.org/show_bug.cgi?id=174675
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebView.cpp:
+        (WebView::setCompositionForTesting): Use text color for
+        composition underline.
+
 2017-07-25  Said Abou-Hallawa  <[email protected]>
 
         Async image decoding for large images should be disabled after the first time a tile is painted

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/WebView.cpp (220689 => 220690)


--- releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/WebView.cpp	2017-08-14 15:26:53 UTC (rev 220689)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKitLegacy/win/WebView.cpp	2017-08-14 15:29:33 UTC (rev 220690)
@@ -7564,7 +7564,7 @@
     String compositionStr = toString(composition);
 
     Vector<CompositionUnderline> underlines;
-    underlines.append(CompositionUnderline(0, compositionStr.length(), Color(Color::black), false));
+    underlines.append(CompositionUnderline(0, compositionStr.length(), CompositionUnderlineColor::TextColor, Color(Color::black), false));
     frame.editor().setComposition(compositionStr, underlines, from, from + length);
 
     return S_OK;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to