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 calculateBorderStyleColor(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::calculateBorderStyleColor(const EBorderStyle& style, const B oxSide& side, Color& color) | |
mstensho (USE GERRIT)
2014/11/27 09:33:29
Should probably be called modifyBorderColorForStyl
| |
343 { | |
344 const RGBA32 baseDarkColor = 0xFF202020; | |
345 const RGBA32 baseLightColor = 0xFFEBEBEB; | |
346 | |
347 if ((side == BSTop || side == BSLeft)) { | |
mstensho (USE GERRIT)
2014/11/27 09:33:29
Extraneous pair of parentheses.
| |
348 if (style == INSET) { | |
349 if (differenceSquared(color, Color::black) > differenceSquared(baseD arkColor, Color::black)) | |
350 color = color.dark(); | |
351 } else if (style == OUTSET) { | |
352 if (differenceSquared(color, Color::white) > differenceSquared(baseL ightColor, Color::white)) | |
353 color = color.light(); | |
354 } | |
355 } | |
356 | |
357 if ((side == BSBottom || side == BSRight)) { | |
mstensho (USE GERRIT)
2014/11/27 09:33:29
Should be "else if", or actually just "else" (I me
| |
358 if (style == INSET) { | |
359 if (differenceSquared(color, Color::white) > differenceSquared(baseL ightColor, Color::white)) | |
360 color = color.light(); | |
361 } else if (style == OUTSET) { | |
362 if (differenceSquared(color, Color::black) > differenceSquared(baseD arkColor, Color::black)) | |
363 color = color.dark(); | |
364 } | |
365 } | |
366 } | |
367 | |
348 } // namespace blink | 368 } // namespace blink |
OLD | NEW |