Title: [173246] trunk
Revision
173246
Author
mmaxfi...@apple.com
Date
2014-09-03 17:55:07 -0700 (Wed, 03 Sep 2014)

Log Message

Text caret changes to color of text in Mail and Notes
https://bugs.webkit.org/show_bug.cgi?id=135904

Patch by Myles C. Maxfield <mmaxfi...@apple.com> on 2014-09-03
Reviewed by Simon Fraser.

Source/WebCore:

Consult with the background color of spans inside editable divs to determine what color
the caret should be.

Test: editing/caret/color-span-inside-editable.html

* editing/FrameSelection.cpp:
(WebCore::CaretBase::paintCaret):

LayoutTests:

Make sure the caret is the correct color.

* editing/caret/color-span-inside-editable-expected.html: Added.
* editing/caret/color-span-inside-editable.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (173245 => 173246)


--- trunk/LayoutTests/ChangeLog	2014-09-04 00:53:16 UTC (rev 173245)
+++ trunk/LayoutTests/ChangeLog	2014-09-04 00:55:07 UTC (rev 173246)
@@ -1,3 +1,15 @@
+2014-09-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Text caret changes to color of text in Mail and Notes
+        https://bugs.webkit.org/show_bug.cgi?id=135904
+
+        Reviewed by Simon Fraser.
+
+        Make sure the caret is the correct color.
+
+        * editing/caret/color-span-inside-editable-expected.html: Added.
+        * editing/caret/color-span-inside-editable.html: Added.
+
 2014-09-03  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Mark a number of passing tests.

Added: trunk/LayoutTests/editing/caret/color-span-inside-editable-expected.html (0 => 173246)


--- trunk/LayoutTests/editing/caret/color-span-inside-editable-expected.html	                        (rev 0)
+++ trunk/LayoutTests/editing/caret/color-span-inside-editable-expected.html	2014-09-04 00:55:07 UTC (rev 173246)
@@ -0,0 +1,4 @@
+This test makes sure that carets in content editable divs remain black even if there is a span inside them with a foreground color specified.
+<div style="width: 505px; height: 505px; overflow: hidden;">
+<div style="width: 50px; height: 500px; background-color: black"></div>
+</div>

Added: trunk/LayoutTests/editing/caret/color-span-inside-editable.html (0 => 173246)


--- trunk/LayoutTests/editing/caret/color-span-inside-editable.html	                        (rev 0)
+++ trunk/LayoutTests/editing/caret/color-span-inside-editable.html	2014-09-04 00:55:07 UTC (rev 173246)
@@ -0,0 +1,8 @@
+This test makes sure that carets in content editable divs remain black even if there is a span inside them with a foreground color specified.
+<div style="width: 505px; height: 505px; overflow: hidden;">
+<div id="edit" contenteditable="true" style="-webkit-transform-origin: left top; -webkit-transform: scale(50, 50); outline: none; font-family: Ahem; font-size: 10px;"><span id="spn" style="color: red;">&nbsp;&nbsp;</span></div>
+</div>
+<script>
+var edit = document.getElementById("edit");
+edit.focus();
+</script>

Modified: trunk/Source/WebCore/ChangeLog (173245 => 173246)


--- trunk/Source/WebCore/ChangeLog	2014-09-04 00:53:16 UTC (rev 173245)
+++ trunk/Source/WebCore/ChangeLog	2014-09-04 00:55:07 UTC (rev 173246)
@@ -1,3 +1,18 @@
+2014-09-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Text caret changes to color of text in Mail and Notes
+        https://bugs.webkit.org/show_bug.cgi?id=135904
+
+        Reviewed by Simon Fraser.
+
+        Consult with the background color of spans inside editable divs to determine what color
+        the caret should be.
+
+        Test: editing/caret/color-span-inside-editable.html
+
+        * editing/FrameSelection.cpp:
+        (WebCore::CaretBase::paintCaret):
+
 2014-09-03  Tim Horton  <timothy_hor...@apple.com>
 
         Fix the iOS build after r173230

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (173245 => 173246)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2014-09-04 00:53:16 UTC (rev 173245)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2014-09-04 00:55:07 UTC (rev 173246)
@@ -1493,10 +1493,23 @@
     Color caretColor = Color::black;
     ColorSpace colorSpace = ColorSpaceDeviceRGB;
     Element* element = node->isElementNode() ? toElement(node) : node->parentElement();
+    Element* rootEditableElement = node->rootEditableElement();
 
     if (element && element->renderer()) {
-        caretColor = element->renderer()->style().visitedDependentColor(CSSPropertyColor);
-        colorSpace = element->renderer()->style().colorSpace();
+        bool setToRootEditableElement = false;
+        if (rootEditableElement && rootEditableElement->renderer()) {
+            const auto& rootEditableStyle = rootEditableElement->renderer()->style();
+            const auto& elementStyle = element->renderer()->style();
+            if (rootEditableStyle.visitedDependentColor(CSSPropertyBackgroundColor) == elementStyle.visitedDependentColor(CSSPropertyBackgroundColor)) {
+                caretColor = rootEditableElement->renderer()->style().visitedDependentColor(CSSPropertyColor);
+                colorSpace = rootEditableElement->renderer()->style().colorSpace();
+                setToRootEditableElement = true;
+            }
+        }
+        if (!setToRootEditableElement) {
+            caretColor = element->renderer()->style().visitedDependentColor(CSSPropertyColor);
+            colorSpace = element->renderer()->style().colorSpace();
+        }
     }
 
     context->fillRect(caret, caretColor, colorSpace);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to