Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/ObjectPainter.h" | 6 #include "core/paint/ObjectPainter.h" |
| 7 | 7 |
| 8 #include "core/paint/DrawingRecorder.h" | 8 #include "core/paint/DrawingRecorder.h" |
| 9 #include "core/rendering/PaintInfo.h" | 9 #include "core/rendering/PaintInfo.h" |
| 10 #include "core/rendering/RenderObject.h" | 10 #include "core/rendering/RenderObject.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 case DOUBLE: | 127 case DOUBLE: |
| 128 drawDoubleBoxSide(graphicsContext, x1, y1, x2, y2, length, side, color, | 128 drawDoubleBoxSide(graphicsContext, x1, y1, x2, y2, length, side, color, |
| 129 thickness, adjacentWidth1, adjacentWidth2, antialias); | 129 thickness, adjacentWidth1, adjacentWidth2, antialias); |
| 130 break; | 130 break; |
| 131 case RIDGE: | 131 case RIDGE: |
| 132 case GROOVE: | 132 case GROOVE: |
| 133 drawRidgeOrGrooveBoxSide(graphicsContext, x1, y1, x2, y2, side, color, | 133 drawRidgeOrGrooveBoxSide(graphicsContext, x1, y1, x2, y2, side, color, |
| 134 style, adjacentWidth1, adjacentWidth2, antialias); | 134 style, adjacentWidth1, adjacentWidth2, antialias); |
| 135 break; | 135 break; |
| 136 case INSET: | 136 case INSET: |
| 137 // FIXME: Maybe we should lighten the colors on one side like Firefox. | |
| 138 // https://bugs.webkit.org/show_bug.cgi?id=58608 | |
| 139 if (side == BSTop || side == BSLeft) | |
| 140 color = color.dark(); | |
| 141 // fall through | |
| 142 case OUTSET: | 137 case OUTSET: |
| 143 if (style == OUTSET && (side == BSBottom || side == BSRight)) | 138 modifyBorderColorForStyleIfNeeded(style, side, color); |
| 144 color = color.dark(); | |
| 145 // fall through | 139 // fall through |
| 146 case SOLID: | 140 case SOLID: |
| 147 drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentW idth1, adjacentWidth2, antialias); | 141 drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentW idth1, adjacentWidth2, antialias); |
| 148 break; | 142 break; |
| 149 } | 143 } |
| 150 } | 144 } |
| 151 | 145 |
| 152 void ObjectPainter::drawDashedOrDottedBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, | 146 void ObjectPainter::drawDashedOrDottedBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, |
| 153 BoxSide side, Color color, int thickness, EBorderStyle style, bool antialias ) | 147 BoxSide side, Color color, int thickness, EBorderStyle style, bool antialias ) |
| 154 { | 148 { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); | 332 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); |
| 339 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 333 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
| 340 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 334 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
| 341 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 335 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
| 342 break; | 336 break; |
| 343 } | 337 } |
| 344 | 338 |
| 345 graphicsContext->fillPolygon(4, quad, color, antialias); | 339 graphicsContext->fillPolygon(4, quad, color, antialias); |
| 346 } | 340 } |
| 347 | 341 |
| 342 void ObjectPainter::modifyBorderColorForStyleIfNeeded(const EBorderStyle& style, const BoxSide& side, Color& color) | |
| 343 { | |
| 344 const RGBA32 baseDarkColor = 0xFF202020; | |
|
chrishtr
2014/12/01 22:51:31
This needs a comment explaining where these number
| |
| 345 const RGBA32 baseLightColor = 0xFFEBEBEB; | |
| 346 enum Operation { Darken, Lighten }; | |
| 347 Operation operation = (side == BSTop || side == BSLeft) == (style == INSET) ? | |
| 348 Darken : Lighten; | |
| 349 | |
| 350 if (operation == Darken) { | |
| 351 if (differenceSquared(color, Color::black) > | |
| 352 differenceSquared(baseDarkColor, Color::black)) { | |
|
pdr.
2014/12/02 02:55:49
differenceSquared(baseDarkColor, Color::black) and
| |
| 353 color = color.dark(); | |
| 354 } | |
| 355 } else { | |
| 356 if (differenceSquared(color, Color::white) > | |
| 357 differenceSquared(baseLightColor, Color::white)) { | |
| 358 color = color.light(); | |
| 359 } | |
| 360 } | |
| 361 } | |
| 362 | |
| 348 } // namespace blink | 363 } // namespace blink |
| OLD | NEW |