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

Side by Side Diff: third_party/WebKit/Source/core/paint/ObjectPainter.cpp

Issue 2711983002: Paint dotted borders using circular dots (Closed)
Patch Set: Refactor isDashedStroke Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
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 "core/paint/ObjectPainter.h" 5 #include "core/paint/ObjectPainter.h"
6 6
7 #include "core/layout/LayoutBlock.h" 7 #include "core/layout/LayoutBlock.h"
8 #include "core/layout/LayoutInline.h" 8 #include "core/layout/LayoutInline.h"
9 #include "core/layout/LayoutObject.h" 9 #include "core/layout/LayoutObject.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
11 #include "core/paint/BoxBorderPainter.h" 11 #include "core/paint/BoxBorderPainter.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/PaintInfo.h" 13 #include "core/paint/PaintInfo.h"
14 #include "core/style/BorderEdge.h" 14 #include "core/style/BorderEdge.h"
15 #include "core/style/ComputedStyle.h" 15 #include "core/style/ComputedStyle.h"
16 #include "platform/geometry/LayoutPoint.h" 16 #include "platform/geometry/LayoutPoint.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 namespace { 21 namespace {
21 22
22 void paintSingleRectangleOutline(const PaintInfo& paintInfo, 23 void paintSingleRectangleOutline(const PaintInfo& paintInfo,
23 const IntRect& rect, 24 const IntRect& rect,
24 const ComputedStyle& style, 25 const ComputedStyle& style,
25 const Color& color) { 26 const Color& color) {
26 DCHECK(!style.outlineStyleIsAuto()); 27 DCHECK(!style.outlineStyleIsAuto());
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 int y1, 409 int y1,
409 int x2, 410 int x2,
410 int y2, 411 int y2,
411 BoxSide side, 412 BoxSide side,
412 Color color, 413 Color color,
413 int thickness, 414 int thickness,
414 EBorderStyle style, 415 EBorderStyle style,
415 bool antialias) { 416 bool antialias) {
416 DCHECK_GT(thickness, 0); 417 DCHECK_GT(thickness, 0);
417 418
418 bool wasAntialiased = graphicsContext.shouldAntialias(); 419 GraphicsContextStateSaver stateSaver(graphicsContext);
419 StrokeStyle oldStrokeStyle = graphicsContext.getStrokeStyle();
420 graphicsContext.setShouldAntialias(antialias); 420 graphicsContext.setShouldAntialias(antialias);
421 graphicsContext.setStrokeColor(color); 421 graphicsContext.setStrokeColor(color);
422 graphicsContext.setStrokeThickness(thickness); 422 graphicsContext.setStrokeThickness(thickness);
423 graphicsContext.setStrokeStyle(style == BorderStyleDashed ? DashedStroke 423 graphicsContext.setStrokeStyle(style == BorderStyleDashed ? DashedStroke
424 : DottedStroke); 424 : DottedStroke);
425 425
426 switch (side) { 426 switch (side) {
427 case BSBottom: 427 case BSBottom:
428 case BSTop: { 428 case BSTop: {
429 int midY = y1 + thickness / 2; 429 int midY = y1 + thickness / 2;
430 graphicsContext.drawLine(IntPoint(x1, midY), IntPoint(x2, midY)); 430 graphicsContext.drawLine(IntPoint(x1, midY), IntPoint(x2, midY));
431 break; 431 break;
432 } 432 }
433 case BSRight: 433 case BSRight:
434 case BSLeft: { 434 case BSLeft: {
435 int midX = x1 + thickness / 2; 435 int midX = x1 + thickness / 2;
436 graphicsContext.drawLine(IntPoint(midX, y1), IntPoint(midX, y2)); 436 graphicsContext.drawLine(IntPoint(midX, y1), IntPoint(midX, y2));
437 break; 437 break;
438 } 438 }
439 } 439 }
440 graphicsContext.setShouldAntialias(wasAntialiased);
441 graphicsContext.setStrokeStyle(oldStrokeStyle);
442 } 440 }
443 441
444 void ObjectPainter::drawDoubleBoxSide(GraphicsContext& graphicsContext, 442 void ObjectPainter::drawDoubleBoxSide(GraphicsContext& graphicsContext,
445 int x1, 443 int x1,
446 int y1, 444 int y1,
447 int x2, 445 int x2,
448 int y2, 446 int y2,
449 int length, 447 int length,
450 BoxSide side, 448 BoxSide side,
451 Color color, 449 Color color,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 adjustedPaintOffset += toLayoutBox(m_layoutObject).location(); 707 adjustedPaintOffset += toLayoutBox(m_layoutObject).location();
710 DCHECK(m_layoutObject.paintOffset() == adjustedPaintOffset) 708 DCHECK(m_layoutObject.paintOffset() == adjustedPaintOffset)
711 << " Paint offset mismatch: " << m_layoutObject.debugName() 709 << " Paint offset mismatch: " << m_layoutObject.debugName()
712 << " from PaintPropertyTreeBuilder: " 710 << " from PaintPropertyTreeBuilder: "
713 << m_layoutObject.paintOffset().toString() 711 << m_layoutObject.paintOffset().toString()
714 << " from painter: " << adjustedPaintOffset.toString(); 712 << " from painter: " << adjustedPaintOffset.toString();
715 } 713 }
716 #endif 714 #endif
717 715
718 } // namespace blink 716 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698