| 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/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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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, const LayoutPoint& paintOff
set) |
| 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, paintOffset)) |
| 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, paintOffset); |
| 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.addOutlineRects(focusRingRects, objectBounds.location
()); | 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 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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> outlineRects; | 81 Vector<LayoutRect> outlineRects; |
| 82 m_layoutObject.addOutlineRects(outlineRects, paintOffset); | 82 m_layoutObject.addOutlineRects(outlineRects, paintOffset); |
| 83 IntRect rect = pixelSnappedIntRect(unionRect(outlineRects)); | 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, paintOffset)) |
| 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, paintOffset); |
| 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)) |
| 94 paintInfo.context->setURLFragmentForRect(fragmentName, rect); | 94 paintInfo.context->setURLFragmentForRect(fragmentName, rect); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 paintInfo.context->setURLForRect(url, rect); | 97 paintInfo.context->setURLForRect(url, rect); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, | 100 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |