| 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/InlinePainter.h" | 6 #include "core/paint/InlinePainter.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
| 9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
| 10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_layoutInline); | 24 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_layoutInline); |
| 25 LineBoxListPainter(*m_layoutInline.lineBoxes()).paint(&m_layoutInline, paint
Info, paintOffset); | 25 LineBoxListPainter(*m_layoutInline.lineBoxes()).paint(&m_layoutInline, paint
Info, paintOffset); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 28 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
| 29 { | 29 { |
| 30 const LayoutStyle& styleToUse = m_layoutInline.styleRef(); | 30 const LayoutStyle& styleToUse = m_layoutInline.styleRef(); |
| 31 if (!styleToUse.hasOutline()) | 31 if (!styleToUse.hasOutline()) |
| 32 return; | 32 return; |
| 33 | 33 |
| 34 LayoutRect bounds; | |
| 35 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | |
| 36 // FIXME: Use tighter bounds. | |
| 37 LayoutBlock* cb = m_layoutInline.containingBlock(); | |
| 38 bounds = cb->visualOverflowRect(); | |
| 39 bounds.moveBy(paintOffset); | |
| 40 } | |
| 41 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutInline, pain
tInfo.phase, bounds); | |
| 42 if (recorder.canUseCachedDrawing()) | |
| 43 return; | |
| 44 | |
| 45 if (styleToUse.outlineStyleIsAuto()) { | 34 if (styleToUse.outlineStyleIsAuto()) { |
| 46 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) { | 35 if (LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) { |
| 36 Vector<LayoutRect> focusRingRects; |
| 37 m_layoutInline.addFocusRingRects(focusRingRects, paintOffset); |
| 38 LayoutRect focusRingBoundingRect; |
| 39 for (const auto& rect : focusRingRects) |
| 40 focusRingBoundingRect.unite(rect); |
| 41 |
| 42 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutInli
ne, paintInfo.phase, focusRingBoundingRect); |
| 43 if (recorder.canUseCachedDrawing()) |
| 44 return; |
| 45 |
| 47 // Only paint the focus ring by hand if the theme isn't able to draw
the focus ring. | 46 // Only paint the focus ring by hand if the theme isn't able to draw
the focus ring. |
| 48 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, paintOffset,
styleToUse); | 47 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse,
focusRingRects); |
| 49 } | 48 } |
| 50 return; | 49 return; |
| 51 } | 50 } |
| 52 | 51 |
| 53 if (styleToUse.outlineStyle() == BNONE) | 52 if (styleToUse.outlineStyle() == BNONE) |
| 54 return; | 53 return; |
| 55 | 54 |
| 56 Vector<LayoutRect> rects; | 55 Vector<LayoutRect> rects; |
| 57 | 56 |
| 58 rects.append(LayoutRect()); | 57 rects.append(LayoutRect()); |
| 59 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr-
>nextLineBox()) { | 58 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr-
>nextLineBox()) { |
| 60 RootInlineBox& root = curr->root(); | 59 RootInlineBox& root = curr->root(); |
| 61 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop()
); | 60 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop()
); |
| 62 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica
lBottom()); | 61 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica
lBottom()); |
| 63 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t
op)); | 62 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t
op)); |
| 64 } | 63 } |
| 65 rects.append(LayoutRect()); | 64 rects.append(LayoutRect()); |
| 66 | 65 |
| 67 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl
ineColor); | 66 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl
ineColor); |
| 68 bool useTransparencyLayer = outlineColor.hasAlpha(); | 67 bool useTransparencyLayer = outlineColor.hasAlpha(); |
| 69 | 68 |
| 69 LayoutRect bounds; |
| 70 for (const auto& rect : rects) |
| 71 bounds.unite(rect); |
| 72 bounds.moveBy(paintOffset); |
| 73 |
| 74 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutInline, pain
tInfo.phase, bounds); |
| 75 if (recorder.canUseCachedDrawing()) |
| 76 return; |
| 77 |
| 70 GraphicsContext* graphicsContext = paintInfo.context; | 78 GraphicsContext* graphicsContext = paintInfo.context; |
| 71 if (useTransparencyLayer) { | 79 if (useTransparencyLayer) { |
| 72 graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor.
alpha()) / 255); | 80 graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor.
alpha()) / 255); |
| 73 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo
lor.blue()); | 81 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo
lor.blue()); |
| 74 } | 82 } |
| 75 | 83 |
| 76 for (unsigned i = 1; i < rects.size() - 1; i++) | 84 for (unsigned i = 1; i < rects.size() - 1; i++) |
| 77 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects
.at(i), rects.at(i + 1), outlineColor); | 85 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects
.at(i), rects.at(i + 1), outlineColor); |
| 78 | 86 |
| 79 if (useTransparencyLayer) | 87 if (useTransparencyLayer) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 pixelSnappedBox.maxX() + outlineWidth, | 198 pixelSnappedBox.maxX() + outlineWidth, |
| 191 pixelSnappedBox.maxY() + outlineWidth, | 199 pixelSnappedBox.maxY() + outlineWidth, |
| 192 BSBottom, outlineColor, outlineStyle, | 200 BSBottom, outlineColor, outlineStyle, |
| 193 outlineWidth, | 201 outlineWidth, |
| 194 outlineWidth, | 202 outlineWidth, |
| 195 antialias); | 203 antialias); |
| 196 } | 204 } |
| 197 } | 205 } |
| 198 | 206 |
| 199 } // namespace blink | 207 } // namespace blink |
| OLD | NEW |