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

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: Groove/inset/outset borders show solid if the color is black Created 6 years, 1 month 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..54c8edbf162e124f89029a346f988ca90bdd190a 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();
+ calculateBorderStyleColor(style, side, color);
// fall through
case SOLID:
drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentWidth1, adjacentWidth2, antialias);
@@ -345,4 +339,30 @@ void ObjectPainter::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, i
graphicsContext->fillPolygon(4, quad, color, antialias);
}
+void ObjectPainter::calculateBorderStyleColor(const EBorderStyle& style, const BoxSide& side, Color& color)
mstensho (USE GERRIT) 2014/11/27 09:33:29 Should probably be called modifyBorderColorForStyl
+{
+ const RGBA32 baseDarkColor = 0xFF202020;
+ const RGBA32 baseLightColor = 0xFFEBEBEB;
+
+ if ((side == BSTop || side == BSLeft)) {
mstensho (USE GERRIT) 2014/11/27 09:33:29 Extraneous pair of parentheses.
+ if (style == INSET) {
+ if (differenceSquared(color, Color::black) > differenceSquared(baseDarkColor, Color::black))
+ color = color.dark();
+ } else if (style == OUTSET) {
+ if (differenceSquared(color, Color::white) > differenceSquared(baseLightColor, Color::white))
+ color = color.light();
+ }
+ }
+
+ if ((side == BSBottom || side == BSRight)) {
mstensho (USE GERRIT) 2014/11/27 09:33:29 Should be "else if", or actually just "else" (I me
+ if (style == INSET) {
+ if (differenceSquared(color, Color::white) > differenceSquared(baseLightColor, Color::white))
+ color = color.light();
+ } else if (style == OUTSET) {
+ if (differenceSquared(color, Color::black) > differenceSquared(baseDarkColor, Color::black))
+ color = color.dark();
+ }
+ }
+}
+
} // namespace blink
« LayoutTests/fast/borders/mixed-border-style2.html ('K') | « Source/core/paint/ObjectPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698