Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: Source/WebCore/editing/FrameSelection.cpp

Issue 14098003: Change the caret color according to the lightness of the background color. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/WebCore/platform/graphics/Color.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/editing/FrameSelection.cpp
diff --git a/Source/WebCore/editing/FrameSelection.cpp b/Source/WebCore/editing/FrameSelection.cpp
index 059f0352a4f433829554256c1a3144d608947837..32c0eaf58e5ad33f80e246acca03a27c83e691c7 100644
--- a/Source/WebCore/editing/FrameSelection.cpp
+++ b/Source/WebCore/editing/FrameSelection.cpp
@@ -1444,9 +1444,29 @@ void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi
Color caretColor = Color::black;
ColorSpace colorSpace = ColorSpaceDeviceRGB;
- Element* element = node->rootEditableElement();
+ Element* element = static_cast<Element *>(node);
if (element && element->renderer()) {
- caretColor = element->renderer()->style()->visitedDependentColor(CSSPropertyColor);
eseidel 2013/04/18 16:03:16 I'm confused. This is clearly not always black, a
joone 2013/04/19 00:25:22 Yes, the caret color is not always black. I misund
+ bool isTransparentPage = true;
+ RenderObject* renderer = element->renderer();
+ while (renderer) {
+ if (renderer->style()->hasBackground()) {
eseidel 2013/04/18 16:03:16 I'm not sure what it means to be a transparent pag
joone 2013/04/19 00:25:22 Yes, RenderView paints the background with FrameVi
joone 2013/04/26 19:12:55 How about isBackgroundWhite instead of isTranspare
+ isTransparentPage = false;
+ break;
+ }
+ if (!renderer->isRoot())
+ renderer = renderer->parent();
+ else
+ break;
+ }
+
+ Color backgroundColor;
+ if (!isTransparentPage) {
+ backgroundColor = renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+ if (backgroundColor.lightness() < 0.5)
+ caretColor = Color::white;
+ } else
+ caretColor = Color::black;
+
colorSpace = element->renderer()->style()->colorSpace();
}
« no previous file with comments | « no previous file | Source/WebCore/platform/graphics/Color.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698