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/ImagePainter.h" | 6 #include "core/paint/ImagePainter.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle(); | 56 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle(); |
57 int outlineWidth = areaElementStyle.outlineWidth(); | 57 int outlineWidth = areaElementStyle.outlineWidth(); |
58 if (!outlineWidth) | 58 if (!outlineWidth) |
59 return; | 59 return; |
60 | 60 |
61 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutImage, paintInfo.phase)) | 61 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutImage, paintInfo.phase)) |
62 return; | 62 return; |
63 | 63 |
64 IntRect focusRect = m_layoutImage.absoluteContentBox(); | 64 IntRect focusRect = m_layoutImage.absoluteContentBox(); |
65 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutImag e, paintInfo.phase, focusRect); | 65 LayoutObjectDrawingRecorder drawingRecorder(*paintInfo.context, m_layoutImag e, paintInfo.phase, LayoutRect(focusRect)); |
jbroman
2015/08/26 19:06:43
ditto
chrishtr
2015/08/26 20:53:51
Fixed.
| |
66 | 66 |
67 // FIXME: Clip path instead of context when Skia pathops is ready. | 67 // FIXME: Clip path instead of context when Skia pathops is ready. |
68 // https://crbug.com/251206 | 68 // https://crbug.com/251206 |
69 | 69 |
70 paintInfo.context->save(); | 70 paintInfo.context->save(); |
71 paintInfo.context->clip(focusRect); | 71 paintInfo.context->clip(focusRect); |
72 paintInfo.context->drawFocusRing(path, outlineWidth, | 72 paintInfo.context->drawFocusRing(path, outlineWidth, |
73 areaElementStyle.outlineOffset(), | 73 areaElementStyle.outlineOffset(), |
74 m_layoutImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); | 74 m_layoutImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); |
75 paintInfo.context->restore(); | 75 paintInfo.context->restore(); |
76 } | 76 } |
77 | 77 |
78 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 78 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
79 { | 79 { |
80 LayoutUnit cWidth = m_layoutImage.contentWidth(); | 80 LayoutUnit cWidth = m_layoutImage.contentWidth(); |
81 LayoutUnit cHeight = m_layoutImage.contentHeight(); | 81 LayoutUnit cHeight = m_layoutImage.contentHeight(); |
82 | 82 |
83 GraphicsContext* context = paintInfo.context; | 83 GraphicsContext* context = paintInfo.context; |
84 | 84 |
85 if (!m_layoutImage.imageResource()->hasImage()) { | 85 if (!m_layoutImage.imageResource()->hasImage()) { |
86 if (paintInfo.phase == PaintPhaseSelection) | 86 if (paintInfo.phase == PaintPhaseSelection) |
87 return; | 87 return; |
88 if (cWidth > 2 && cHeight > 2) { | 88 if (cWidth > 2 && cHeight > 2) { |
89 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context , m_layoutImage, paintInfo.phase)) | 89 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context , m_layoutImage, paintInfo.phase)) |
90 return; | 90 return; |
91 // Draw an outline rect where the image should be. | 91 // Draw an outline rect where the image should be. |
92 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_layoutImage.borderLeft() + m_layoutImage.paddingLeft(), paintOffset.y() + m_l ayoutImage.borderTop() + m_layoutImage.paddingTop(), cWidth, cHeight)); | 92 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_layoutImage.borderLeft() + m_layoutImage.paddingLeft(), paintOffset.y() + m_l ayoutImage.borderTop() + m_layoutImage.paddingTop(), cWidth, cHeight)); |
93 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutImage, paintInfo.phase, paintRect); | 93 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutImage, paintInfo.phase, LayoutRect(paintRect)); |
jbroman
2015/08/26 19:06:43
ditto
chrishtr
2015/08/26 20:53:51
Fixed.
| |
94 context->setStrokeStyle(SolidStroke); | 94 context->setStrokeStyle(SolidStroke); |
95 context->setStrokeColor(Color::lightGray); | 95 context->setStrokeColor(Color::lightGray); |
96 context->setFillColor(Color::transparent); | 96 context->setFillColor(Color::transparent); |
97 context->drawRect(paintRect); | 97 context->drawRect(paintRect); |
98 } | 98 } |
99 } else if (cWidth > 0 && cHeight > 0) { | 99 } else if (cWidth > 0 && cHeight > 0) { |
100 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_ layoutImage, paintInfo.phase)) | 100 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_ layoutImage, paintInfo.phase)) |
101 return; | 101 return; |
102 LayoutRect contentRect = m_layoutImage.contentBoxRect(); | 102 LayoutRect contentRect = m_layoutImage.contentBoxRect(); |
103 contentRect.moveBy(paintOffset); | 103 contentRect.moveBy(paintOffset); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 | 137 |
138 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data", InspectorPaintImageEvent::data(m_layoutImage)); | 138 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data", InspectorPaintImageEvent::data(m_layoutImage)); |
139 | 139 |
140 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality(); | 140 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality(); |
141 context->setImageInterpolationQuality(interpolationQuality); | 141 context->setImageInterpolationQuality(interpolationQuality); |
142 context->drawImage(image.get(), alignedRect, SkXfermode::kSrcOver_Mode, m_la youtImage.shouldRespectImageOrientation()); | 142 context->drawImage(image.get(), alignedRect, SkXfermode::kSrcOver_Mode, m_la youtImage.shouldRespectImageOrientation()); |
143 context->setImageInterpolationQuality(previousInterpolationQuality); | 143 context->setImageInterpolationQuality(previousInterpolationQuality); |
144 } | 144 } |
145 | 145 |
146 } // namespace blink | 146 } // namespace blink |
OLD | NEW |