| 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/rendering/PaintInfo.h" | 8 #include "core/rendering/PaintInfo.h" |
| 9 #include "core/rendering/RenderObject.h" | 9 #include "core/rendering/RenderObject.h" |
| 10 #include "core/rendering/RenderTheme.h" | 10 #include "core/rendering/RenderTheme.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias); | 292 side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias); |
| 293 drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(-ad
jacentWidth1 + 1, 0) / 2, x2, y2 - std::max(-adjacentWidth2 + 1, 0) / 2, | 293 drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(-ad
jacentWidth1 + 1, 0) / 2, x2, y2 - std::max(-adjacentWidth2 + 1, 0) / 2, |
| 294 side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias); | 294 side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias); |
| 295 break; | 295 break; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ObjectPainter::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, i
nt y1, int x2, int y2, | 299 void ObjectPainter::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, i
nt y1, int x2, int y2, |
| 300 BoxSide side, Color color, int adjacentWidth1, int adjacentWidth2, bool anti
alias) | 300 BoxSide side, Color color, int adjacentWidth1, int adjacentWidth2, bool anti
alias) |
| 301 { | 301 { |
| 302 StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle(); | |
| 303 graphicsContext->setStrokeStyle(NoStroke); | |
| 304 graphicsContext->setFillColor(color); | |
| 305 ASSERT(x2 >= x1); | 302 ASSERT(x2 >= x1); |
| 306 ASSERT(y2 >= y1); | 303 ASSERT(y2 >= y1); |
| 304 |
| 307 if (!adjacentWidth1 && !adjacentWidth2) { | 305 if (!adjacentWidth1 && !adjacentWidth2) { |
| 308 // Turn off antialiasing to match the behavior of drawConvexPolygon(); | 306 // Tweak antialiasing to match the behavior of fillPolygon(); |
| 309 // this matters for rects in transformed contexts. | 307 // this matters for rects in transformed contexts. |
| 310 bool wasAntialiased = graphicsContext->shouldAntialias(); | 308 bool wasAntialiased = graphicsContext->shouldAntialias(); |
| 311 graphicsContext->setShouldAntialias(antialias); | 309 if (antialias != wasAntialiased) |
| 312 graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1)); | 310 graphicsContext->setShouldAntialias(antialias); |
| 313 graphicsContext->setShouldAntialias(wasAntialiased); | 311 graphicsContext->fillRect(IntRect(x1, y1, x2 - x1, y2 - y1), color); |
| 314 graphicsContext->setStrokeStyle(oldStrokeStyle); | 312 if (antialias != wasAntialiased) |
| 313 graphicsContext->setShouldAntialias(wasAntialiased); |
| 315 return; | 314 return; |
| 316 } | 315 } |
| 316 |
| 317 FloatPoint quad[4]; | 317 FloatPoint quad[4]; |
| 318 switch (side) { | 318 switch (side) { |
| 319 case BSTop: | 319 case BSTop: |
| 320 quad[0] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y1); | 320 quad[0] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y1); |
| 321 quad[1] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y2); | 321 quad[1] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y2); |
| 322 quad[2] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y2); | 322 quad[2] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y2); |
| 323 quad[3] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y1); | 323 quad[3] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y1); |
| 324 break; | 324 break; |
| 325 case BSBottom: | 325 case BSBottom: |
| 326 quad[0] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y1); | 326 quad[0] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y1); |
| 327 quad[1] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y2); | 327 quad[1] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y2); |
| 328 quad[2] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y2); | 328 quad[2] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y2); |
| 329 quad[3] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y1); | 329 quad[3] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y1); |
| 330 break; | 330 break; |
| 331 case BSLeft: | 331 case BSLeft: |
| 332 quad[0] = FloatPoint(x1, y1 + std::max(-adjacentWidth1, 0)); | 332 quad[0] = FloatPoint(x1, y1 + std::max(-adjacentWidth1, 0)); |
| 333 quad[1] = FloatPoint(x1, y2 - std::max(-adjacentWidth2, 0)); | 333 quad[1] = FloatPoint(x1, y2 - std::max(-adjacentWidth2, 0)); |
| 334 quad[2] = FloatPoint(x2, y2 - std::max(adjacentWidth2, 0)); | 334 quad[2] = FloatPoint(x2, y2 - std::max(adjacentWidth2, 0)); |
| 335 quad[3] = FloatPoint(x2, y1 + std::max(adjacentWidth1, 0)); | 335 quad[3] = FloatPoint(x2, y1 + std::max(adjacentWidth1, 0)); |
| 336 break; | 336 break; |
| 337 case BSRight: | 337 case BSRight: |
| 338 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); | 338 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); |
| 339 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 339 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
| 340 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 340 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
| 341 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 341 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
| 342 break; | 342 break; |
| 343 } | 343 } |
| 344 | 344 |
| 345 graphicsContext->drawConvexPolygon(4, quad, antialias); | 345 graphicsContext->fillPolygon(4, quad, color, antialias); |
| 346 graphicsContext->setStrokeStyle(oldStrokeStyle); | |
| 347 } | 346 } |
| 348 | 347 |
| 349 } // namespace blink | 348 } // namespace blink |
| OLD | NEW |