| 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 "core/paint/ImagePainter.h" | 5 #include "core/paint/ImagePainter.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
| 9 #include "core/editing/FrameSelection.h" | 9 #include "core/editing/FrameSelection.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 HTMLAreaElement& areaElement = toHTMLAreaElement(*focusedElement); | 45 HTMLAreaElement& areaElement = toHTMLAreaElement(*focusedElement); |
| 46 if (areaElement.imageElement() != m_layoutImage.node()) | 46 if (areaElement.imageElement() != m_layoutImage.node()) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 // Even if the theme handles focus ring drawing for entire elements, it won't | 49 // Even if the theme handles focus ring drawing for entire elements, it won't |
| 50 // do it for an area within an image, so we don't call | 50 // do it for an area within an image, so we don't call |
| 51 // LayoutTheme::themeDrawsFocusRing here. | 51 // LayoutTheme::themeDrawsFocusRing here. |
| 52 | 52 |
| 53 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle(); | 53 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle(); |
| 54 int outlineWidth = areaElementStyle.outlineWidth(); | 54 // If the outline width is 0 we want to avoid drawing anything even if we |
| 55 if (!outlineWidth) | 55 // don't use the value directly. |
| 56 if (!areaElementStyle.outlineWidth()) |
| 56 return; | 57 return; |
| 57 | 58 |
| 58 Path path = areaElement.getPath(&m_layoutImage); | 59 Path path = areaElement.getPath(&m_layoutImage); |
| 59 if (path.isEmpty()) | 60 if (path.isEmpty()) |
| 60 return; | 61 return; |
| 61 | 62 |
| 62 LayoutPoint adjustedPaintOffset = paintOffset; | 63 LayoutPoint adjustedPaintOffset = paintOffset; |
| 63 adjustedPaintOffset.moveBy(m_layoutImage.location()); | 64 adjustedPaintOffset.moveBy(m_layoutImage.location()); |
| 64 path.translate(FloatSize(adjustedPaintOffset.x(), adjustedPaintOffset.y())); | 65 path.translate(FloatSize(adjustedPaintOffset.x(), adjustedPaintOffset.y())); |
| 65 | 66 |
| 66 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 67 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 67 paintInfo.context, m_layoutImage, DisplayItem::kImageAreaFocusRing)) | 68 paintInfo.context, m_layoutImage, DisplayItem::kImageAreaFocusRing)) |
| 68 return; | 69 return; |
| 69 | 70 |
| 70 LayoutRect focusRect = m_layoutImage.contentBoxRect(); | 71 LayoutRect focusRect = m_layoutImage.contentBoxRect(); |
| 71 focusRect.moveBy(adjustedPaintOffset); | 72 focusRect.moveBy(adjustedPaintOffset); |
| 72 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutImage, | 73 LayoutObjectDrawingRecorder drawingRecorder(paintInfo.context, m_layoutImage, |
| 73 DisplayItem::kImageAreaFocusRing, | 74 DisplayItem::kImageAreaFocusRing, |
| 74 focusRect); | 75 focusRect); |
| 75 | 76 |
| 76 // FIXME: Clip path instead of context when Skia pathops is ready. | 77 // FIXME: Clip path instead of context when Skia pathops is ready. |
| 77 // https://crbug.com/251206 | 78 // https://crbug.com/251206 |
| 78 | 79 |
| 79 paintInfo.context.save(); | 80 paintInfo.context.save(); |
| 80 paintInfo.context.clip(pixelSnappedIntRect(focusRect)); | 81 paintInfo.context.clip(pixelSnappedIntRect(focusRect)); |
| 81 paintInfo.context.drawFocusRing( | 82 paintInfo.context.drawFocusRing( |
| 82 path, outlineWidth, areaElementStyle.outlineOffset(), | 83 path, areaElementStyle.getOutlineStrokeWidthForFocusRing(), |
| 84 areaElementStyle.outlineOffset(), |
| 83 m_layoutImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); | 85 m_layoutImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); |
| 84 paintInfo.context.restore(); | 86 paintInfo.context.restore(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, | 89 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, |
| 88 const LayoutPoint& paintOffset) { | 90 const LayoutPoint& paintOffset) { |
| 89 LayoutUnit cWidth = m_layoutImage.contentWidth(); | 91 LayoutUnit cWidth = m_layoutImage.contentWidth(); |
| 90 LayoutUnit cHeight = m_layoutImage.contentHeight(); | 92 LayoutUnit cHeight = m_layoutImage.contentHeight(); |
| 91 | 93 |
| 92 GraphicsContext& context = paintInfo.context; | 94 GraphicsContext& context = paintInfo.context; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 InterpolationQuality previousInterpolationQuality = | 172 InterpolationQuality previousInterpolationQuality = |
| 171 context.imageInterpolationQuality(); | 173 context.imageInterpolationQuality(); |
| 172 context.setImageInterpolationQuality(interpolationQuality); | 174 context.setImageInterpolationQuality(interpolationQuality); |
| 173 context.drawImage( | 175 context.drawImage( |
| 174 image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode, | 176 image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode, |
| 175 LayoutObject::shouldRespectImageOrientation(&m_layoutImage)); | 177 LayoutObject::shouldRespectImageOrientation(&m_layoutImage)); |
| 176 context.setImageInterpolationQuality(previousInterpolationQuality); | 178 context.setImageInterpolationQuality(previousInterpolationQuality); |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |