| 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/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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); | 193 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); |
| 194 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) | 194 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) |
| 195 return; | 195 return; |
| 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 bool paintFocusRing = styleToUse.outlineStyleIsAuto(); | 198 bool paintFocusRing = styleToUse.outlineStyleIsAuto(); |
| 199 if (paintFocusRing && !LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_la
youtObject)) | 199 if (paintFocusRing && !LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_la
youtObject)) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, paintInfo.phase)) | 202 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, paintInfo.phase, paintOffset)) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 Vector<LayoutRect> outlineRects; | 205 Vector<LayoutRect> outlineRects; |
| 206 m_layoutObject.addOutlineRects(outlineRects, paintOffset); | 206 m_layoutObject.addOutlineRects(outlineRects, paintOffset); |
| 207 | 207 |
| 208 Vector<IntRect> pixelSnappedOutlineRects; | 208 Vector<IntRect> pixelSnappedOutlineRects; |
| 209 for (auto& r : outlineRects) | 209 for (auto& r : outlineRects) |
| 210 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); | 210 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); |
| 211 | 211 |
| 212 IntRect unitedOutlineRect = unionRect(pixelSnappedOutlineRects); | 212 IntRect unitedOutlineRect = unionRect(pixelSnappedOutlineRects); |
| 213 if (unitedOutlineRect.isEmpty()) { | 213 if (unitedOutlineRect.isEmpty()) { |
| 214 if (paintFocusRing) | 214 if (paintFocusRing) |
| 215 return; | 215 return; |
| 216 // We need to draw an outline around an empty point. | 216 // We need to draw an outline around an empty point. |
| 217 IntRect emptyPointRect = pixelSnappedIntRect(LayoutRect(paintOffset, Lay
outSize())); | 217 IntRect emptyPointRect = pixelSnappedIntRect(LayoutRect(paintOffset, Lay
outSize())); |
| 218 pixelSnappedOutlineRects.append(emptyPointRect); | 218 pixelSnappedOutlineRects.append(emptyPointRect); |
| 219 unitedOutlineRect = emptyPointRect; | 219 unitedOutlineRect = emptyPointRect; |
| 220 } | 220 } |
| 221 | 221 |
| 222 IntRect bounds = unitedOutlineRect; | 222 IntRect bounds = unitedOutlineRect; |
| 223 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); | 223 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); |
| 224 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai
ntInfo.phase, bounds); | 224 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai
ntInfo.phase, bounds, paintOffset); |
| 225 | 225 |
| 226 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); | 226 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); |
| 227 if (styleToUse.outlineStyleIsAuto()) { | 227 if (styleToUse.outlineStyleIsAuto()) { |
| 228 paintInfo.context->drawFocusRing(pixelSnappedOutlineRects, styleToUse.ou
tlineWidth(), styleToUse.outlineOffset(), color); | 228 paintInfo.context->drawFocusRing(pixelSnappedOutlineRects, styleToUse.ou
tlineWidth(), styleToUse.outlineOffset(), color); |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 | 231 |
| 232 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { | 232 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { |
| 233 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); | 233 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); |
| 234 return; | 234 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 258 KURL url = toElement(m_layoutObject.node())->hrefURL(); | 258 KURL url = toElement(m_layoutObject.node())->hrefURL(); |
| 259 if (!url.isValid()) | 259 if (!url.isValid()) |
| 260 return; | 260 return; |
| 261 | 261 |
| 262 Vector<LayoutRect> outlineRects; | 262 Vector<LayoutRect> outlineRects; |
| 263 m_layoutObject.addOutlineRects(outlineRects, paintOffset); | 263 m_layoutObject.addOutlineRects(outlineRects, paintOffset); |
| 264 IntRect rect = pixelSnappedIntRect(unionRect(outlineRects)); | 264 IntRect rect = pixelSnappedIntRect(unionRect(outlineRects)); |
| 265 if (rect.isEmpty()) | 265 if (rect.isEmpty()) |
| 266 return; | 266 return; |
| 267 | 267 |
| 268 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect)) | 268 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect, paintOffset)) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis
playItem::PrintedContentPDFURLRect, rect); | 271 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis
playItem::PrintedContentPDFURLRect, rect, paintOffset); |
| 272 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { | 272 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { |
| 273 String fragmentName = url.fragmentIdentifier(); | 273 String fragmentName = url.fragmentIdentifier(); |
| 274 if (m_layoutObject.document().findAnchor(fragmentName)) | 274 if (m_layoutObject.document().findAnchor(fragmentName)) |
| 275 paintInfo.context->setURLFragmentForRect(fragmentName, rect); | 275 paintInfo.context->setURLFragmentForRect(fragmentName, rect); |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 paintInfo.context->setURLForRect(url, rect); | 278 paintInfo.context->setURLForRect(url, rect); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, | 281 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... |
| 521 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 521 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
| 522 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 522 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
| 523 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 523 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
| 524 break; | 524 break; |
| 525 } | 525 } |
| 526 | 526 |
| 527 graphicsContext->fillPolygon(4, quad, color, antialias); | 527 graphicsContext->fillPolygon(4, quad, color, antialias); |
| 528 } | 528 } |
| 529 | 529 |
| 530 } // namespace blink | 530 } // namespace blink |
| OLD | NEW |