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

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

Issue 1269123002: Preparation for combining paths of focus rings and outlines (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove debug from fast/css/focus-ring-recursive-continuations.html Created 5 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/paint/ObjectPainter.h" 6 #include "core/paint/ObjectPainter.h"
7 7
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 #include "core/layout/LayoutTheme.h" 9 #include "core/layout/LayoutTheme.h"
10 #include "core/paint/BoxBorderPainter.h" 10 #include "core/paint/BoxBorderPainter.h"
11 #include "core/paint/LayoutObjectDrawingRecorder.h" 11 #include "core/paint/LayoutObjectDrawingRecorder.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
13 #include "core/style/BorderEdge.h" 13 #include "core/style/BorderEdge.h"
14 #include "core/style/ComputedStyle.h" 14 #include "core/style/ComputedStyle.h"
15 #include "platform/geometry/LayoutPoint.h" 15 #include "platform/geometry/LayoutPoint.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 LayoutRect ObjectPainter::outlineBounds(const LayoutRect& objectBounds, const Co mputedStyle& style) 19 LayoutRect ObjectPainter::outlineBounds(const LayoutRect& objectBounds, const Co mputedStyle& style)
20 { 20 {
21 LayoutRect outlineBounds(objectBounds); 21 LayoutRect outlineBounds(objectBounds);
22 outlineBounds.inflate(style.outlineOutset()); 22 outlineBounds.inflate(style.outlineOutsetExtent());
23 return outlineBounds; 23 return outlineBounds;
24 } 24 }
25 25
26 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects) 26 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const ComputedSty le& style, const Vector<LayoutRect>& focusRingRects)
27 { 27 {
28 ASSERT(style.outlineStyleIsAuto()); 28 ASSERT(style.outlineStyleIsAuto());
29 Vector<IntRect> focusRingIntRects; 29 Vector<IntRect> focusRingIntRects;
30 for (size_t i = 0; i < focusRingRects.size(); ++i) 30 for (size_t i = 0; i < focusRingRects.size(); ++i)
31 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); 31 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i]));
32 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) ); 32 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) );
33 } 33 }
34 34
35 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds) 35 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& o bjectBounds, const LayoutRect& visualOverflowBounds)
36 { 36 {
37 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); 37 const ComputedStyle& styleToUse = m_layoutObject.styleRef();
38 if (!styleToUse.hasOutline()) 38 if (!styleToUse.hasOutline())
39 return; 39 return;
40 40
41 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase)) 41 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, paintInfo.phase))
42 return; 42 return;
43 43
44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds); 44 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai ntInfo.phase, visualOverflowBounds);
45 45
46 if (styleToUse.outlineStyleIsAuto()) { 46 if (styleToUse.outlineStyleIsAuto()) {
47 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) { 47 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) {
48 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 48 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
49 Vector<LayoutRect> focusRingRects; 49 Vector<LayoutRect> focusRingRects;
50 m_layoutObject.addFocusRingRects(focusRingRects, objectBounds.locati on()); 50 m_layoutObject.addOutlineRects(focusRingRects, objectBounds.location ());
51 paintFocusRing(paintInfo, styleToUse, focusRingRects); 51 paintFocusRing(paintInfo, styleToUse, focusRingRects);
52 } 52 }
53 return; 53 return;
54 } 54 }
55 55
56 if (styleToUse.outlineStyle() == BNONE) 56 if (styleToUse.outlineStyle() == BNONE)
57 return; 57 return;
58 58
59 LayoutRect inner(pixelSnappedIntRect(objectBounds)); 59 LayoutRect inner(pixelSnappedIntRect(objectBounds));
60 inner.inflate(styleToUse.outlineOffset()); 60 inner.inflate(styleToUse.outlineOffset());
(...skipping 10 matching lines...) Expand all
71 void ObjectPainter::addPDFURLRectIfNeeded(const PaintInfo& paintInfo, const Layo utPoint& paintOffset) 71 void ObjectPainter::addPDFURLRectIfNeeded(const PaintInfo& paintInfo, const Layo utPoint& paintOffset)
72 { 72 {
73 ASSERT(paintInfo.isPrinting()); 73 ASSERT(paintInfo.isPrinting());
74 if (m_layoutObject.isElementContinuation() || !m_layoutObject.node() || !m_l ayoutObject.node()->isLink() || m_layoutObject.styleRef().visibility() != VISIBL E) 74 if (m_layoutObject.isElementContinuation() || !m_layoutObject.node() || !m_l ayoutObject.node()->isLink() || m_layoutObject.styleRef().visibility() != VISIBL E)
75 return; 75 return;
76 76
77 KURL url = toElement(m_layoutObject.node())->hrefURL(); 77 KURL url = toElement(m_layoutObject.node())->hrefURL();
78 if (!url.isValid()) 78 if (!url.isValid())
79 return; 79 return;
80 80
81 Vector<LayoutRect> focusRingRects; 81 Vector<LayoutRect> outlineRects;
82 m_layoutObject.addFocusRingRects(focusRingRects, paintOffset); 82 m_layoutObject.addOutlineRects(outlineRects, paintOffset);
83 IntRect rect = pixelSnappedIntRect(unionRect(focusRingRects)); 83 IntRect rect = pixelSnappedIntRect(unionRect(outlineRects));
84 if (rect.isEmpty()) 84 if (rect.isEmpty())
85 return; 85 return;
86 86
87 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect)) 87 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect))
88 return; 88 return;
89 89
90 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis playItem::PrintedContentPDFURLRect, rect); 90 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis playItem::PrintedContentPDFURLRect, rect);
91 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la youtObject.document().baseURL())) { 91 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la youtObject.document().baseURL())) {
92 String fragmentName = url.fragmentIdentifier(); 92 String fragmentName = url.fragmentIdentifier();
93 if (m_layoutObject.document().findAnchor(fragmentName)) 93 if (m_layoutObject.document().findAnchor(fragmentName))
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); 340 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0));
341 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); 341 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0));
342 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); 342 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0));
343 break; 343 break;
344 } 344 }
345 345
346 graphicsContext->fillPolygon(4, quad, color, antialias); 346 graphicsContext->fillPolygon(4, quad, color, antialias);
347 } 347 }
348 348
349 } // namespace blink 349 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698