| 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/ObjectPainter.h" | 5 #include "core/paint/ObjectPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
| 8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
| 9 #include "core/layout/LayoutObject.h" | 9 #include "core/layout/LayoutObject.h" |
| 10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 // Only paint the focus ring by hand if the theme isn't able to draw the foc
us ring. | 197 // Only paint the focus ring by hand if the theme isn't able to draw the foc
us ring. |
| 198 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau
ltFocusRing(m_layoutObject)) | 198 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau
ltFocusRing(m_layoutObject)) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 Vector<LayoutRect> outlineRects; | 201 Vector<LayoutRect> outlineRects; |
| 202 m_layoutObject.addOutlineRects(outlineRects, paintOffset, m_layoutObject.out
lineRectsShouldIncludeBlockVisualOverflow()); | 202 m_layoutObject.addOutlineRects(outlineRects, paintOffset, m_layoutObject.out
lineRectsShouldIncludeBlockVisualOverflow()); |
| 203 if (outlineRects.isEmpty()) | 203 if (outlineRects.isEmpty()) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, paintInfo.phase, paintOffset)) | 206 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, paintInfo.phase)) |
| 207 return; | 207 return; |
| 208 | 208 |
| 209 // The result rects are in coordinates of m_layoutObject's border box. | 209 // The result rects are in coordinates of m_layoutObject's border box. |
| 210 // Block flipping is not applied yet if !m_layoutObject.isBox(). | 210 // Block flipping is not applied yet if !m_layoutObject.isBox(). |
| 211 if (!m_layoutObject.isBox() && m_layoutObject.styleRef().isFlippedBlocksWrit
ingMode()) { | 211 if (!m_layoutObject.isBox() && m_layoutObject.styleRef().isFlippedBlocksWrit
ingMode()) { |
| 212 LayoutBlock* container = m_layoutObject.containingBlock(); | 212 LayoutBlock* container = m_layoutObject.containingBlock(); |
| 213 if (container) { | 213 if (container) { |
| 214 m_layoutObject.localToAncestorRects(outlineRects, container, -paintO
ffset, paintOffset); | 214 m_layoutObject.localToAncestorRects(outlineRects, container, -paintO
ffset, paintOffset); |
| 215 if (outlineRects.isEmpty()) | 215 if (outlineRects.isEmpty()) |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 Vector<IntRect> pixelSnappedOutlineRects; | 220 Vector<IntRect> pixelSnappedOutlineRects; |
| 221 for (auto& r : outlineRects) | 221 for (auto& r : outlineRects) |
| 222 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); | 222 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); |
| 223 | 223 |
| 224 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects); | 224 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects); |
| 225 IntRect bounds = unitedOutlineRect; | 225 IntRect bounds = unitedOutlineRect; |
| 226 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); | 226 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); |
| 227 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, pain
tInfo.phase, bounds, paintOffset); | 227 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, pain
tInfo.phase, bounds); |
| 228 | 228 |
| 229 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); | 229 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); |
| 230 if (styleToUse.outlineStyleIsAuto()) { | 230 if (styleToUse.outlineStyleIsAuto()) { |
| 231 paintInfo.context.drawFocusRing(pixelSnappedOutlineRects, styleToUse.out
lineWidth(), styleToUse.outlineOffset(), color); | 231 paintInfo.context.drawFocusRing(pixelSnappedOutlineRects, styleToUse.out
lineWidth(), styleToUse.outlineOffset(), color); |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 | 234 |
| 235 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { | 235 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { |
| 236 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); | 236 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); |
| 237 return; | 237 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 259 KURL url = toElement(m_layoutObject.node())->hrefURL(); | 259 KURL url = toElement(m_layoutObject.node())->hrefURL(); |
| 260 if (!url.isValid()) | 260 if (!url.isValid()) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 Vector<LayoutRect> visualOverflowRects; | 263 Vector<LayoutRect> visualOverflowRects; |
| 264 m_layoutObject.addElementVisualOverflowRects(visualOverflowRects, paintOffse
t); | 264 m_layoutObject.addElementVisualOverflowRects(visualOverflowRects, paintOffse
t); |
| 265 IntRect rect = pixelSnappedIntRect(unionRect(visualOverflowRects)); | 265 IntRect rect = pixelSnappedIntRect(unionRect(visualOverflowRects)); |
| 266 if (rect.isEmpty()) | 266 if (rect.isEmpty()) |
| 267 return; | 267 return; |
| 268 | 268 |
| 269 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, DisplayItem::PrintedContentPDFURLRect, paintOffset)) | 269 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, DisplayItem::PrintedContentPDFURLRect)) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, Disp
layItem::PrintedContentPDFURLRect, rect, paintOffset); | 272 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, Disp
layItem::PrintedContentPDFURLRect, rect); |
| 273 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { | 273 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { |
| 274 String fragmentName = url.fragmentIdentifier(); | 274 String fragmentName = url.fragmentIdentifier(); |
| 275 if (m_layoutObject.document().findAnchor(fragmentName)) | 275 if (m_layoutObject.document().findAnchor(fragmentName)) |
| 276 paintInfo.context.setURLFragmentForRect(fragmentName, rect); | 276 paintInfo.context.setURLFragmentForRect(fragmentName, rect); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 paintInfo.context.setURLForRect(url, rect); | 279 paintInfo.context.setURLForRect(url, rect); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void ObjectPainter::drawLineForBoxSide(GraphicsContext& graphicsContext, int x1,
int y1, int x2, int y2, | 282 void ObjectPainter::drawLineForBoxSide(GraphicsContext& graphicsContext, int x1,
int y1, int x2, int y2, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 m_layoutObject.paint(info, paintOffset); | 549 m_layoutObject.paint(info, paintOffset); |
| 550 info.phase = PaintPhaseFloat; | 550 info.phase = PaintPhaseFloat; |
| 551 m_layoutObject.paint(info, paintOffset); | 551 m_layoutObject.paint(info, paintOffset); |
| 552 info.phase = PaintPhaseForeground; | 552 info.phase = PaintPhaseForeground; |
| 553 m_layoutObject.paint(info, paintOffset); | 553 m_layoutObject.paint(info, paintOffset); |
| 554 info.phase = PaintPhaseOutline; | 554 info.phase = PaintPhaseOutline; |
| 555 m_layoutObject.paint(info, paintOffset); | 555 m_layoutObject.paint(info, paintOffset); |
| 556 } | 556 } |
| 557 | 557 |
| 558 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |