https://bugs.webkit.org/show_bug.cgi?id=138029
Reviewed by Simon Fraser.
Source/WebCore:
Previously, we were only checking whether the background colors of the foreground and background
elements were the same, rather than taking validity and opacity into consideration.
Test: editing/caret/color-span-inside-editable-background.html
* editing/FrameSelection.cpp:
(WebCore::disappearsIntoBackground):
(WebCore::CaretBase::paintCaret):
LayoutTests:
Test the case where the content editable root has a background color specified.
* editing/caret/color-span-inside-editable-background-expected.html: Added.
* editing/caret/color-span-inside-editable-background.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175152
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-10-23 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Carets in GMail and iCloud compositions are the foreground text color
+ https://bugs.webkit.org/show_bug.cgi?id=138029
+
+ Reviewed by Simon Fraser.
+
+ Test the case where the content editable root has a background color specified.
+
+ * editing/caret/color-span-inside-editable-background-expected.html: Added.
+ * editing/caret/color-span-inside-editable-background.html: Added.
+
2014-10-23 Roger Fong <roger_fong@apple.com>
[Windows] Unreviewed gardening after removing SafariTheme.
--- /dev/null
+This test makes sure that carets in content editable divs with a background color specified 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>
--- /dev/null
+This test makes sure that carets in content editable divs with a background color specified 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="background: #fff; -webkit-transform-origin: left top; -webkit-transform: scale(50, 50); outline: none; font-family: Ahem; font-size: 10px;"><span id="spn" style="color: red;"> </span></div>
+</div>
+<script>
+var edit = document.getElementById("edit");
+edit.focus();
+</script>
+2014-10-23 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Carets in GMail and iCloud compositions are the foreground text color
+ https://bugs.webkit.org/show_bug.cgi?id=138029
+
+ Reviewed by Simon Fraser.
+
+ Previously, we were only checking whether the background colors of the foreground and background
+ elements were the same, rather than taking validity and opacity into consideration.
+
+ Test: editing/caret/color-span-inside-editable-background.html
+
+ * editing/FrameSelection.cpp:
+ (WebCore::disappearsIntoBackground):
+ (WebCore::CaretBase::paintCaret):
+
2014-10-23 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Provide a way to have alternate inspector agents
CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, paintOffset, clipRect);
}
+static inline bool disappearsIntoBackground(Color foreground, Color background)
+{
+ return background.blend(foreground) == background;
+}
+
void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const
{
#if ENABLE(TEXT_CARET)
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();
+ auto rootEditableBGColor = rootEditableStyle.visitedDependentColor(CSSPropertyBackgroundColor);
+ auto elementBGColor = elementStyle.visitedDependentColor(CSSPropertyBackgroundColor);
+ if (disappearsIntoBackground(elementBGColor, rootEditableBGColor)) {
+ caretColor = rootEditableStyle.visitedDependentColor(CSSPropertyColor);
+ colorSpace = rootEditableStyle.colorSpace();
setToRootEditableElement = true;
}
}