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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 | 86 |
87 drawLineForBoxSide(graphicsContext, leftOuter, topOuter, leftInner, bottomOu ter, BSLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth); | 87 drawLineForBoxSide(graphicsContext, leftOuter, topOuter, leftInner, bottomOu ter, BSLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth); |
88 drawLineForBoxSide(graphicsContext, leftOuter, topOuter, rightOuter, topInne r, BSTop, outlineColor, outlineStyle, outlineWidth, outlineWidth); | 88 drawLineForBoxSide(graphicsContext, leftOuter, topOuter, rightOuter, topInne r, BSTop, outlineColor, outlineStyle, outlineWidth, outlineWidth); |
89 drawLineForBoxSide(graphicsContext, rightInner, topOuter, rightOuter, bottom Outer, BSRight, outlineColor, outlineStyle, outlineWidth, outlineWidth); | 89 drawLineForBoxSide(graphicsContext, rightInner, topOuter, rightOuter, bottom Outer, BSRight, outlineColor, outlineStyle, outlineWidth, outlineWidth); |
90 drawLineForBoxSide(graphicsContext, leftOuter, bottomInner, rightOuter, bott omOuter, BSBottom, outlineColor, outlineStyle, outlineWidth, outlineWidth); | 90 drawLineForBoxSide(graphicsContext, leftOuter, bottomInner, rightOuter, bott omOuter, BSBottom, outlineColor, outlineStyle, outlineWidth, outlineWidth); |
91 | 91 |
92 if (useTransparencyLayer) | 92 if (useTransparencyLayer) |
93 graphicsContext->endLayer(); | 93 graphicsContext->endLayer(); |
94 } | 94 } |
95 | 95 |
96 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, | 96 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2, |
Timothy Loh
2014/12/01 03:03:12
Do we need to update BoxPainter::drawBoxSideFromPa
| |
97 BoxSide side, Color color, EBorderStyle style, | 97 BoxSide side, Color color, EBorderStyle style, |
98 int adjacentWidth1, int adjacentWidth2, bool antialias) | 98 int adjacentWidth1, int adjacentWidth2, bool antialias) |
99 { | 99 { |
100 int thickness; | 100 int thickness; |
101 int length; | 101 int length; |
102 if (side == BSTop || side == BSBottom) { | 102 if (side == BSTop || side == BSBottom) { |
103 thickness = y2 - y1; | 103 thickness = y2 - y1; |
104 length = x2 - x1; | 104 length = x2 - x1; |
105 } else { | 105 } else { |
106 thickness = x2 - x1; | 106 thickness = x2 - x1; |
(...skipping 20 matching lines...) Expand all 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; | |
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)) { | |
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 |