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

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

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/core/paint/ObjectPainter.h ('k') | Source/core/paint/RenderDrawingRecorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/LayoutTheme.h" 9 #include "core/layout/LayoutTheme.h"
9 #include "core/paint/RenderDrawingRecorder.h" 10 #include "core/paint/RenderDrawingRecorder.h"
10 #include "core/rendering/PaintInfo.h" 11 #include "core/rendering/PaintInfo.h"
11 #include "core/rendering/RenderObject.h"
12 #include "core/rendering/style/RenderStyle.h" 12 #include "core/rendering/style/RenderStyle.h"
13 #include "platform/geometry/LayoutPoint.h" 13 #include "platform/geometry/LayoutPoint.h"
14 #include "platform/graphics/GraphicsContextStateSaver.h" 14 #include "platform/graphics/GraphicsContextStateSaver.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const LayoutPoint & paintOffset, const RenderStyle& style) 18 void ObjectPainter::paintFocusRing(const PaintInfo& paintInfo, const LayoutPoint & paintOffset, const RenderStyle& style)
19 { 19 {
20 Vector<LayoutRect> focusRingRects; 20 Vector<LayoutRect> focusRingRects;
21 m_renderObject.addFocusRingRects(focusRingRects, paintOffset); 21 m_layoutObject.addFocusRingRects(focusRingRects, paintOffset);
22 ASSERT(style.outlineStyleIsAuto()); 22 ASSERT(style.outlineStyleIsAuto());
23 Vector<IntRect> focusRingIntRects; 23 Vector<IntRect> focusRingIntRects;
24 for (size_t i = 0; i < focusRingRects.size(); ++i) 24 for (size_t i = 0; i < focusRingRects.size(); ++i)
25 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i])); 25 focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i]));
26 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_renderObject.resolveColor(style, CSSPropertyOutlineColor) ); 26 paintInfo.context->drawFocusRing(focusRingIntRects, style.outlineWidth(), st yle.outlineOffset(), m_layoutObject.resolveColor(style, CSSPropertyOutlineColor) );
27 } 27 }
28 28
29 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& p aintRect) 29 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutRect& p aintRect)
30 { 30 {
31 const RenderStyle& styleToUse = m_renderObject.styleRef(); 31 const RenderStyle& styleToUse = m_layoutObject.styleRef();
32 if (!styleToUse.hasOutline()) 32 if (!styleToUse.hasOutline())
33 return; 33 return;
34 34
35 RenderDrawingRecorder recorder(paintInfo.context, m_renderObject, paintInfo. phase, paintRect); 35 RenderDrawingRecorder recorder(paintInfo.context, m_layoutObject, paintInfo. phase, paintRect);
36 if (recorder.canUseCachedDrawing()) 36 if (recorder.canUseCachedDrawing())
37 return; 37 return;
38 38
39 if (styleToUse.outlineStyleIsAuto()) { 39 if (styleToUse.outlineStyleIsAuto()) {
40 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_renderObject)) { 40 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutObject)) {
41 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 41 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
42 paintFocusRing(paintInfo, paintRect.location(), styleToUse); 42 paintFocusRing(paintInfo, paintRect.location(), styleToUse);
43 } 43 }
44 return; 44 return;
45 } 45 }
46 46
47 if (styleToUse.outlineStyle() == BNONE) 47 if (styleToUse.outlineStyle() == BNONE)
48 return; 48 return;
49 49
50 IntRect inner = pixelSnappedIntRect(paintRect); 50 IntRect inner = pixelSnappedIntRect(paintRect);
51 inner.inflate(styleToUse.outlineOffset()); 51 inner.inflate(styleToUse.outlineOffset());
52 52
53 IntRect outer = pixelSnappedIntRect(inner); 53 IntRect outer = pixelSnappedIntRect(inner);
54 LayoutUnit outlineWidth = styleToUse.outlineWidth(); 54 LayoutUnit outlineWidth = styleToUse.outlineWidth();
55 outer.inflate(outlineWidth); 55 outer.inflate(outlineWidth);
56 56
57 // FIXME: This prevents outlines from painting inside the object. See bug 12 042 57 // FIXME: This prevents outlines from painting inside the object. See bug 12 042
58 if (outer.isEmpty()) 58 if (outer.isEmpty())
59 return; 59 return;
60 60
61 EBorderStyle outlineStyle = styleToUse.outlineStyle(); 61 EBorderStyle outlineStyle = styleToUse.outlineStyle();
62 Color outlineColor = m_renderObject.resolveColor(styleToUse, CSSPropertyOutl ineColor); 62 Color outlineColor = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutl ineColor);
63 63
64 GraphicsContext* graphicsContext = paintInfo.context; 64 GraphicsContext* graphicsContext = paintInfo.context;
65 bool useTransparencyLayer = outlineColor.hasAlpha(); 65 bool useTransparencyLayer = outlineColor.hasAlpha();
66 if (useTransparencyLayer) { 66 if (useTransparencyLayer) {
67 if (outlineStyle == SOLID) { 67 if (outlineStyle == SOLID) {
68 Path path; 68 Path path;
69 path.addRect(outer); 69 path.addRect(outer);
70 path.addRect(inner); 70 path.addRect(inner);
71 graphicsContext->setFillRule(RULE_EVENODD); 71 graphicsContext->setFillRule(RULE_EVENODD);
72 graphicsContext->setFillColor(outlineColor); 72 graphicsContext->setFillColor(outlineColor);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); 341 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0));
342 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); 342 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0));
343 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); 343 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0));
344 break; 344 break;
345 } 345 }
346 346
347 graphicsContext->fillPolygon(4, quad, color, antialias); 347 graphicsContext->fillPolygon(4, quad, color, antialias);
348 } 348 }
349 349
350 } // namespace blink 350 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ObjectPainter.h ('k') | Source/core/paint/RenderDrawingRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698