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

Unified Diff: Source/core/paint/ObjectPainter.cpp

Issue 759373002: Better handling border color style decoration (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changing the test per reviewer's request. Created 6 years 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
Index: Source/core/paint/ObjectPainter.cpp
diff --git a/Source/core/paint/ObjectPainter.cpp b/Source/core/paint/ObjectPainter.cpp
index 976976753229652d44e93f25d7aa2640f0b76bff..6d3521b5881086e219c32d58ef5bebed260a0af2 100644
--- a/Source/core/paint/ObjectPainter.cpp
+++ b/Source/core/paint/ObjectPainter.cpp
@@ -134,14 +134,8 @@ void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
style, adjacentWidth1, adjacentWidth2, antialias);
break;
case INSET:
- // FIXME: Maybe we should lighten the colors on one side like Firefox.
- // https://bugs.webkit.org/show_bug.cgi?id=58608
- if (side == BSTop || side == BSLeft)
- color = color.dark();
- // fall through
case OUTSET:
- if (style == OUTSET && (side == BSBottom || side == BSRight))
- color = color.dark();
+ modifyBorderColorForStyleIfNeeded(style, side, color);
// fall through
case SOLID:
drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentWidth1, adjacentWidth2, antialias);
@@ -345,4 +339,25 @@ void ObjectPainter::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, i
graphicsContext->fillPolygon(4, quad, color, antialias);
}
+void ObjectPainter::modifyBorderColorForStyleIfNeeded(const EBorderStyle& style, const BoxSide& side, Color& color)
+{
+ const RGBA32 baseDarkColor = 0xFF202020;
chrishtr 2014/12/01 22:51:31 This needs a comment explaining where these number
+ const RGBA32 baseLightColor = 0xFFEBEBEB;
+ enum Operation { Darken, Lighten };
+ Operation operation = (side == BSTop || side == BSLeft) == (style == INSET) ?
+ Darken : Lighten;
+
+ if (operation == Darken) {
+ if (differenceSquared(color, Color::black) >
+ differenceSquared(baseDarkColor, Color::black)) {
pdr. 2014/12/02 02:55:49 differenceSquared(baseDarkColor, Color::black) and
+ color = color.dark();
+ }
+ } else {
+ if (differenceSquared(color, Color::white) >
+ differenceSquared(baseLightColor, Color::white)) {
+ color = color.light();
+ }
+ }
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698