| 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/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
| 9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // The width of the angled part of starting and ending joint of the current
edge. | 170 // The width of the angled part of starting and ending joint of the current
edge. |
| 171 int adjacentWidthStart = firstAdjacentWidth; | 171 int adjacentWidthStart = firstAdjacentWidth; |
| 172 int adjacentWidthEnd; | 172 int adjacentWidthEnd; |
| 173 for (size_t i = 0; i < count; ++i) { | 173 for (size_t i = 0; i < count; ++i) { |
| 174 OutlineEdgeInfo& edge = edges[i]; | 174 OutlineEdgeInfo& edge = edges[i]; |
| 175 adjacentWidthEnd = i == count - 1 ? firstAdjacentWidth : adjustJoint(wid
th, edge, edges[i + 1]); | 175 adjacentWidthEnd = i == count - 1 ? firstAdjacentWidth : adjustJoint(wid
th, edge, edges[i + 1]); |
| 176 int adjacentWidth1 = adjacentWidthStart; | 176 int adjacentWidth1 = adjacentWidthStart; |
| 177 int adjacentWidth2 = adjacentWidthEnd; | 177 int adjacentWidth2 = adjacentWidthEnd; |
| 178 if (edge.side == BSLeft || edge.side == BSBottom) | 178 if (edge.side == BSLeft || edge.side == BSBottom) |
| 179 std::swap(adjacentWidth1, adjacentWidth2); | 179 std::swap(adjacentWidth1, adjacentWidth2); |
| 180 ObjectPainter::drawLineForBoxSide(&graphicsContext, edge.x1, edge.y1, ed
ge.x2, edge.y2, edge.side, outlineColor, style.outlineStyle(), adjacentWidth1, a
djacentWidth2, false); | 180 ObjectPainter::drawLineForBoxSide(graphicsContext, edge.x1, edge.y1, edg
e.x2, edge.y2, edge.side, outlineColor, style.outlineStyle(), adjacentWidth1, ad
jacentWidth2, false); |
| 181 adjacentWidthStart = adjacentWidthEnd; | 181 adjacentWidthStart = adjacentWidthEnd; |
| 182 } | 182 } |
| 183 | 183 |
| 184 if (useTransparencyLayer) | 184 if (useTransparencyLayer) |
| 185 graphicsContext.endLayer(); | 185 graphicsContext.endLayer(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace | 188 } // namespace |
| 189 | 189 |
| 190 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 190 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
| 191 { | 191 { |
| 192 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase
SelfOutline); | 192 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase
SelfOutline); |
| 193 | 193 |
| 194 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); | 194 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); |
| 195 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) | 195 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) |
| 196 return; | 196 return; |
| 197 | 197 |
| 198 // Only paint the focus ring by hand if the theme isn't able to draw the foc
us ring. | 198 // Only paint the focus ring by hand if the theme isn't able to draw the foc
us ring. |
| 199 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau
ltFocusRing(m_layoutObject)) | 199 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau
ltFocusRing(m_layoutObject)) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 Vector<LayoutRect> outlineRects; | 202 Vector<LayoutRect> outlineRects; |
| 203 m_layoutObject.addOutlineRects(outlineRects, paintOffset, m_layoutObject.out
lineRectsShouldIncludeBlockVisualOverflow()); | 203 m_layoutObject.addOutlineRects(outlineRects, paintOffset, m_layoutObject.out
lineRectsShouldIncludeBlockVisualOverflow()); |
| 204 if (outlineRects.isEmpty()) | 204 if (outlineRects.isEmpty()) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, paintInfo.phase, paintOffset)) | 207 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, paintInfo.phase, paintOffset)) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 // The result rects are in coordinates of m_layoutObject's border box. | 210 // The result rects are in coordinates of m_layoutObject's border box. |
| 211 // Block flipping is not applied yet if !m_layoutObject.isBox(). | 211 // Block flipping is not applied yet if !m_layoutObject.isBox(). |
| 212 if (!m_layoutObject.isBox() && m_layoutObject.styleRef().isFlippedBlocksWrit
ingMode()) { | 212 if (!m_layoutObject.isBox() && m_layoutObject.styleRef().isFlippedBlocksWrit
ingMode()) { |
| 213 LayoutBlock* container = m_layoutObject.containingBlock(); | 213 LayoutBlock* container = m_layoutObject.containingBlock(); |
| 214 if (container) { | 214 if (container) { |
| 215 m_layoutObject.localToContainerRects(outlineRects, container, -paint
Offset, paintOffset); | 215 m_layoutObject.localToContainerRects(outlineRects, container, -paint
Offset, paintOffset); |
| 216 if (outlineRects.isEmpty()) | 216 if (outlineRects.isEmpty()) |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 Vector<IntRect> pixelSnappedOutlineRects; | 221 Vector<IntRect> pixelSnappedOutlineRects; |
| 222 for (auto& r : outlineRects) | 222 for (auto& r : outlineRects) |
| 223 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); | 223 pixelSnappedOutlineRects.append(pixelSnappedIntRect(r)); |
| 224 | 224 |
| 225 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects); | 225 IntRect unitedOutlineRect = unionRectEvenIfEmpty(pixelSnappedOutlineRects); |
| 226 IntRect bounds = unitedOutlineRect; | 226 IntRect bounds = unitedOutlineRect; |
| 227 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); | 227 bounds.inflate(m_layoutObject.styleRef().outlineOutsetExtent()); |
| 228 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, pai
ntInfo.phase, bounds, paintOffset); | 228 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, pain
tInfo.phase, bounds, paintOffset); |
| 229 | 229 |
| 230 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); | 230 Color color = m_layoutObject.resolveColor(styleToUse, CSSPropertyOutlineColo
r); |
| 231 if (styleToUse.outlineStyleIsAuto()) { | 231 if (styleToUse.outlineStyleIsAuto()) { |
| 232 paintInfo.context->drawFocusRing(pixelSnappedOutlineRects, styleToUse.ou
tlineWidth(), styleToUse.outlineOffset(), color); | 232 paintInfo.context.drawFocusRing(pixelSnappedOutlineRects, styleToUse.out
lineWidth(), styleToUse.outlineOffset(), color); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { | 236 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { |
| 237 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); | 237 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co
lor); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 paintComplexOutline(*paintInfo.context, pixelSnappedOutlineRects, styleToUse
, color); | 240 paintComplexOutline(paintInfo.context, pixelSnappedOutlineRects, styleToUse,
color); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void ObjectPainter::paintInlineChildrenOutlines(const PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset) | 243 void ObjectPainter::paintInlineChildrenOutlines(const PaintInfo& paintInfo, cons
t LayoutPoint& paintOffset) |
| 244 { | 244 { |
| 245 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase
ChildOutlines); | 245 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase
ChildOutlines); |
| 246 | 246 |
| 247 PaintInfo childPaintInfo(paintInfo); | 247 PaintInfo childPaintInfo(paintInfo); |
| 248 childPaintInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPha
seOutline : paintInfo.phase; | 248 childPaintInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPha
seOutline : paintInfo.phase; |
| 249 | 249 |
| 250 for (LayoutObject* child = m_layoutObject.slowFirstChild(); child; child = c
hild->nextSibling()) { | 250 for (LayoutObject* child = m_layoutObject.slowFirstChild(); child; child = c
hild->nextSibling()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 262 KURL url = toElement(m_layoutObject.node())->hrefURL(); | 262 KURL url = toElement(m_layoutObject.node())->hrefURL(); |
| 263 if (!url.isValid()) | 263 if (!url.isValid()) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 Vector<LayoutRect> visualOverflowRects; | 266 Vector<LayoutRect> visualOverflowRects; |
| 267 m_layoutObject.addElementVisualOverflowRects(visualOverflowRects, paintOffse
t); | 267 m_layoutObject.addElementVisualOverflowRects(visualOverflowRects, paintOffse
t); |
| 268 IntRect rect = pixelSnappedIntRect(unionRect(visualOverflowRects)); | 268 IntRect rect = pixelSnappedIntRect(unionRect(visualOverflowRects)); |
| 269 if (rect.isEmpty()) | 269 if (rect.isEmpty()) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutObject, DisplayItem::PrintedContentPDFURLRect, paintOffset)) | 272 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutObject, DisplayItem::PrintedContentPDFURLRect, paintOffset)) |
| 273 return; | 273 return; |
| 274 | 274 |
| 275 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutObject, Dis
playItem::PrintedContentPDFURLRect, rect, paintOffset); | 275 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutObject, Disp
layItem::PrintedContentPDFURLRect, rect, paintOffset); |
| 276 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { | 276 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, m_la
youtObject.document().baseURL())) { |
| 277 String fragmentName = url.fragmentIdentifier(); | 277 String fragmentName = url.fragmentIdentifier(); |
| 278 if (m_layoutObject.document().findAnchor(fragmentName)) | 278 if (m_layoutObject.document().findAnchor(fragmentName)) |
| 279 paintInfo.context->setURLFragmentForRect(fragmentName, rect); | 279 paintInfo.context.setURLFragmentForRect(fragmentName, rect); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 paintInfo.context->setURLForRect(url, rect); | 282 paintInfo.context.setURLForRect(url, rect); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void ObjectPainter::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, | 285 void ObjectPainter::drawLineForBoxSide(GraphicsContext& graphicsContext, int x1,
int y1, int x2, int y2, |
| 286 BoxSide side, Color color, EBorderStyle style, | 286 BoxSide side, Color color, EBorderStyle style, |
| 287 int adjacentWidth1, int adjacentWidth2, bool antialias) | 287 int adjacentWidth1, int adjacentWidth2, bool antialias) |
| 288 { | 288 { |
| 289 int thickness; | 289 int thickness; |
| 290 int length; | 290 int length; |
| 291 if (side == BSTop || side == BSBottom) { | 291 if (side == BSTop || side == BSBottom) { |
| 292 thickness = y2 - y1; | 292 thickness = y2 - y1; |
| 293 length = x2 - x1; | 293 length = x2 - x1; |
| 294 } else { | 294 } else { |
| 295 thickness = x2 - x1; | 295 thickness = x2 - x1; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 case OUTSET: | 331 case OUTSET: |
| 332 if (style == OUTSET && (side == BSBottom || side == BSRight)) | 332 if (style == OUTSET && (side == BSBottom || side == BSRight)) |
| 333 color = color.dark(); | 333 color = color.dark(); |
| 334 // fall through | 334 // fall through |
| 335 case SOLID: | 335 case SOLID: |
| 336 drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentW
idth1, adjacentWidth2, antialias); | 336 drawSolidBoxSide(graphicsContext, x1, y1, x2, y2, side, color, adjacentW
idth1, adjacentWidth2, antialias); |
| 337 break; | 337 break; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 void ObjectPainter::drawDashedOrDottedBoxSide(GraphicsContext* graphicsContext,
int x1, int y1, int x2, int y2, | 341 void ObjectPainter::drawDashedOrDottedBoxSide(GraphicsContext& graphicsContext,
int x1, int y1, int x2, int y2, |
| 342 BoxSide side, Color color, int thickness, EBorderStyle style, bool antialias
) | 342 BoxSide side, Color color, int thickness, EBorderStyle style, bool antialias
) |
| 343 { | 343 { |
| 344 if (thickness <= 0) | 344 if (thickness <= 0) |
| 345 return; | 345 return; |
| 346 | 346 |
| 347 bool wasAntialiased = graphicsContext->shouldAntialias(); | 347 bool wasAntialiased = graphicsContext.shouldAntialias(); |
| 348 StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle(); | 348 StrokeStyle oldStrokeStyle = graphicsContext.strokeStyle(); |
| 349 graphicsContext->setShouldAntialias(antialias); | 349 graphicsContext.setShouldAntialias(antialias); |
| 350 graphicsContext->setStrokeColor(color); | 350 graphicsContext.setStrokeColor(color); |
| 351 graphicsContext->setStrokeThickness(thickness); | 351 graphicsContext.setStrokeThickness(thickness); |
| 352 graphicsContext->setStrokeStyle(style == DASHED ? DashedStroke : DottedStrok
e); | 352 graphicsContext.setStrokeStyle(style == DASHED ? DashedStroke : DottedStroke
); |
| 353 | 353 |
| 354 switch (side) { | 354 switch (side) { |
| 355 case BSBottom: | 355 case BSBottom: |
| 356 case BSTop: { | 356 case BSTop: { |
| 357 int midY = y1 + thickness / 2; | 357 int midY = y1 + thickness / 2; |
| 358 graphicsContext->drawLine(IntPoint(x1, midY), IntPoint(x2, midY)); | 358 graphicsContext.drawLine(IntPoint(x1, midY), IntPoint(x2, midY)); |
| 359 break; | 359 break; |
| 360 } | 360 } |
| 361 case BSRight: | 361 case BSRight: |
| 362 case BSLeft: { | 362 case BSLeft: { |
| 363 int midX = x1 + thickness / 2; | 363 int midX = x1 + thickness / 2; |
| 364 graphicsContext->drawLine(IntPoint(midX, y1), IntPoint(midX, y2)); | 364 graphicsContext.drawLine(IntPoint(midX, y1), IntPoint(midX, y2)); |
| 365 break; | 365 break; |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 graphicsContext->setShouldAntialias(wasAntialiased); | 368 graphicsContext.setShouldAntialias(wasAntialiased); |
| 369 graphicsContext->setStrokeStyle(oldStrokeStyle); | 369 graphicsContext.setStrokeStyle(oldStrokeStyle); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void ObjectPainter::drawDoubleBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, | 372 void ObjectPainter::drawDoubleBoxSide(GraphicsContext& graphicsContext, int x1,
int y1, int x2, int y2, |
| 373 int length, BoxSide side, Color color, int thickness, int adjacentWidth1, in
t adjacentWidth2, bool antialias) | 373 int length, BoxSide side, Color color, int thickness, int adjacentWidth1, in
t adjacentWidth2, bool antialias) |
| 374 { | 374 { |
| 375 int thirdOfThickness = (thickness + 1) / 3; | 375 int thirdOfThickness = (thickness + 1) / 3; |
| 376 ASSERT(thirdOfThickness); | 376 ASSERT(thirdOfThickness); |
| 377 | 377 |
| 378 if (!adjacentWidth1 && !adjacentWidth2) { | 378 if (!adjacentWidth1 && !adjacentWidth2) { |
| 379 StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle(); | 379 StrokeStyle oldStrokeStyle = graphicsContext.strokeStyle(); |
| 380 graphicsContext->setStrokeStyle(NoStroke); | 380 graphicsContext.setStrokeStyle(NoStroke); |
| 381 graphicsContext->setFillColor(color); | 381 graphicsContext.setFillColor(color); |
| 382 | 382 |
| 383 bool wasAntialiased = graphicsContext->shouldAntialias(); | 383 bool wasAntialiased = graphicsContext.shouldAntialias(); |
| 384 graphicsContext->setShouldAntialias(antialias); | 384 graphicsContext.setShouldAntialias(antialias); |
| 385 | 385 |
| 386 switch (side) { | 386 switch (side) { |
| 387 case BSTop: | 387 case BSTop: |
| 388 case BSBottom: | 388 case BSBottom: |
| 389 graphicsContext->drawRect(IntRect(x1, y1, length, thirdOfThickness))
; | 389 graphicsContext.drawRect(IntRect(x1, y1, length, thirdOfThickness)); |
| 390 graphicsContext->drawRect(IntRect(x1, y2 - thirdOfThickness, length,
thirdOfThickness)); | 390 graphicsContext.drawRect(IntRect(x1, y2 - thirdOfThickness, length,
thirdOfThickness)); |
| 391 break; | 391 break; |
| 392 case BSLeft: | 392 case BSLeft: |
| 393 case BSRight: | 393 case BSRight: |
| 394 graphicsContext->drawRect(IntRect(x1, y1, thirdOfThickness, length))
; | 394 graphicsContext.drawRect(IntRect(x1, y1, thirdOfThickness, length)); |
| 395 graphicsContext->drawRect(IntRect(x2 - thirdOfThickness, y1, thirdOf
Thickness, length)); | 395 graphicsContext.drawRect(IntRect(x2 - thirdOfThickness, y1, thirdOfT
hickness, length)); |
| 396 break; | 396 break; |
| 397 } | 397 } |
| 398 | 398 |
| 399 graphicsContext->setShouldAntialias(wasAntialiased); | 399 graphicsContext.setShouldAntialias(wasAntialiased); |
| 400 graphicsContext->setStrokeStyle(oldStrokeStyle); | 400 graphicsContext.setStrokeStyle(oldStrokeStyle); |
| 401 return; | 401 return; |
| 402 } | 402 } |
| 403 | 403 |
| 404 int adjacent1BigThird = ((adjacentWidth1 > 0) ? adjacentWidth1 + 1 : adjacen
tWidth1 - 1) / 3; | 404 int adjacent1BigThird = ((adjacentWidth1 > 0) ? adjacentWidth1 + 1 : adjacen
tWidth1 - 1) / 3; |
| 405 int adjacent2BigThird = ((adjacentWidth2 > 0) ? adjacentWidth2 + 1 : adjacen
tWidth2 - 1) / 3; | 405 int adjacent2BigThird = ((adjacentWidth2 > 0) ? adjacentWidth2 + 1 : adjacen
tWidth2 - 1) / 3; |
| 406 | 406 |
| 407 switch (side) { | 407 switch (side) { |
| 408 case BSTop: | 408 case BSTop: |
| 409 drawLineForBoxSide(graphicsContext, x1 + std::max((-adjacentWidth1 * 2 +
1) / 3, 0), | 409 drawLineForBoxSide(graphicsContext, x1 + std::max((-adjacentWidth1 * 2 +
1) / 3, 0), |
| 410 y1, x2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), y1 + thirdOfThi
ckness, | 410 y1, x2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), y1 + thirdOfThi
ckness, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 435 side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias)
; | 435 side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias)
; |
| 436 drawLineForBoxSide(graphicsContext, x2 - thirdOfThickness, y1 + std::max
((-adjacentWidth1 * 2 + 1) / 3, 0), | 436 drawLineForBoxSide(graphicsContext, x2 - thirdOfThickness, y1 + std::max
((-adjacentWidth1 * 2 + 1) / 3, 0), |
| 437 x2, y2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), | 437 x2, y2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), |
| 438 side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias)
; | 438 side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias)
; |
| 439 break; | 439 break; |
| 440 default: | 440 default: |
| 441 break; | 441 break; |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 void ObjectPainter::drawRidgeOrGrooveBoxSide(GraphicsContext* graphicsContext, i
nt x1, int y1, int x2, int y2, | 445 void ObjectPainter::drawRidgeOrGrooveBoxSide(GraphicsContext& graphicsContext, i
nt x1, int y1, int x2, int y2, |
| 446 BoxSide side, Color color, EBorderStyle style, int adjacentWidth1, int adjac
entWidth2, bool antialias) | 446 BoxSide side, Color color, EBorderStyle style, int adjacentWidth1, int adjac
entWidth2, bool antialias) |
| 447 { | 447 { |
| 448 EBorderStyle s1; | 448 EBorderStyle s1; |
| 449 EBorderStyle s2; | 449 EBorderStyle s2; |
| 450 if (style == GROOVE) { | 450 if (style == GROOVE) { |
| 451 s1 = INSET; | 451 s1 = INSET; |
| 452 s2 = OUTSET; | 452 s2 = OUTSET; |
| 453 } else { | 453 } else { |
| 454 s1 = OUTSET; | 454 s1 = OUTSET; |
| 455 s2 = INSET; | 455 s2 = INSET; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 479 break; | 479 break; |
| 480 case BSRight: | 480 case BSRight: |
| 481 drawLineForBoxSide(graphicsContext, x1, y1 + std::max(adjacentWidth1, 0)
/ 2, (x1 + x2 + 1) / 2, y2 - std::max(adjacentWidth2, 0) / 2, | 481 drawLineForBoxSide(graphicsContext, x1, y1 + std::max(adjacentWidth1, 0)
/ 2, (x1 + x2 + 1) / 2, y2 - std::max(adjacentWidth2, 0) / 2, |
| 482 side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias); | 482 side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias); |
| 483 drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(-ad
jacentWidth1 + 1, 0) / 2, x2, y2 - std::max(-adjacentWidth2 + 1, 0) / 2, | 483 drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(-ad
jacentWidth1 + 1, 0) / 2, x2, y2 - std::max(-adjacentWidth2 + 1, 0) / 2, |
| 484 side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias); | 484 side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias); |
| 485 break; | 485 break; |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| 489 void ObjectPainter::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, i
nt y1, int x2, int y2, | 489 void ObjectPainter::drawSolidBoxSide(GraphicsContext& graphicsContext, int x1, i
nt y1, int x2, int y2, |
| 490 BoxSide side, Color color, int adjacentWidth1, int adjacentWidth2, bool anti
alias) | 490 BoxSide side, Color color, int adjacentWidth1, int adjacentWidth2, bool anti
alias) |
| 491 { | 491 { |
| 492 ASSERT(x2 >= x1); | 492 ASSERT(x2 >= x1); |
| 493 ASSERT(y2 >= y1); | 493 ASSERT(y2 >= y1); |
| 494 | 494 |
| 495 if (!adjacentWidth1 && !adjacentWidth2) { | 495 if (!adjacentWidth1 && !adjacentWidth2) { |
| 496 // Tweak antialiasing to match the behavior of fillPolygon(); | 496 // Tweak antialiasing to match the behavior of fillPolygon(); |
| 497 // this matters for rects in transformed contexts. | 497 // this matters for rects in transformed contexts. |
| 498 bool wasAntialiased = graphicsContext->shouldAntialias(); | 498 bool wasAntialiased = graphicsContext.shouldAntialias(); |
| 499 if (antialias != wasAntialiased) | 499 if (antialias != wasAntialiased) |
| 500 graphicsContext->setShouldAntialias(antialias); | 500 graphicsContext.setShouldAntialias(antialias); |
| 501 graphicsContext->fillRect(IntRect(x1, y1, x2 - x1, y2 - y1), color); | 501 graphicsContext.fillRect(IntRect(x1, y1, x2 - x1, y2 - y1), color); |
| 502 if (antialias != wasAntialiased) | 502 if (antialias != wasAntialiased) |
| 503 graphicsContext->setShouldAntialias(wasAntialiased); | 503 graphicsContext.setShouldAntialias(wasAntialiased); |
| 504 return; | 504 return; |
| 505 } | 505 } |
| 506 | 506 |
| 507 FloatPoint quad[4]; | 507 FloatPoint quad[4]; |
| 508 switch (side) { | 508 switch (side) { |
| 509 case BSTop: | 509 case BSTop: |
| 510 quad[0] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y1); | 510 quad[0] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y1); |
| 511 quad[1] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y2); | 511 quad[1] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y2); |
| 512 quad[2] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y2); | 512 quad[2] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y2); |
| 513 quad[3] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y1); | 513 quad[3] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 525 quad[3] = FloatPoint(x2, y1 + std::max(adjacentWidth1, 0)); | 525 quad[3] = FloatPoint(x2, y1 + std::max(adjacentWidth1, 0)); |
| 526 break; | 526 break; |
| 527 case BSRight: | 527 case BSRight: |
| 528 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); | 528 quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0)); |
| 529 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); | 529 quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0)); |
| 530 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 530 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
| 531 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 531 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
| 532 break; | 532 break; |
| 533 } | 533 } |
| 534 | 534 |
| 535 graphicsContext->fillPolygon(4, quad, color, antialias); | 535 graphicsContext.fillPolygon(4, quad, color, antialias); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace blink | 538 } // namespace blink |
| OLD | NEW |