| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 // Since we clipped, no need to draw with a mitre. | 1291 // Since we clipped, no need to draw with a mitre. |
| 1292 mitreAdjacentSide1 = false; | 1292 mitreAdjacentSide1 = false; |
| 1293 mitreAdjacentSide2 = false; | 1293 mitreAdjacentSide2 = false; |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 drawLineForBoxSide(graphicsContext, sideRect.x(), sideRect.y(), sideRect
.maxX(), sideRect.maxY(), side, colorToPaint, edgeToRender.style, | 1296 drawLineForBoxSide(graphicsContext, sideRect.x(), sideRect.y(), sideRect
.maxX(), sideRect.maxY(), side, colorToPaint, edgeToRender.style, |
| 1297 mitreAdjacentSide1 ? adjacentEdge1.width : 0, mitreAdjacentSide2
? adjacentEdge2.width : 0, antialias); | 1297 mitreAdjacentSide1 ? adjacentEdge1.width : 0, mitreAdjacentSide2
? adjacentEdge2.width : 0, antialias); |
| 1298 } | 1298 } |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const Border
Edge edges[], int side) |
| 1302 { |
| 1303 LayoutRect sideRect = outerBorder.rect(); |
| 1304 int width = edges[side].width; |
| 1305 |
| 1306 if (side == BSTop) |
| 1307 sideRect.setHeight(width); |
| 1308 else if (side == BSBottom) |
| 1309 sideRect.shiftYEdgeTo(sideRect.maxY() - width); |
| 1310 else if (side == BSLeft) |
| 1311 sideRect.setWidth(width); |
| 1312 else |
| 1313 sideRect.shiftXEdgeTo(sideRect.maxX() - width); |
| 1314 |
| 1315 return sideRect; |
| 1316 } |
| 1317 |
| 1301 void RenderBoxModelObject::paintBorderSides(GraphicsContext* graphicsContext, co
nst RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& inner
Border, | 1318 void RenderBoxModelObject::paintBorderSides(GraphicsContext* graphicsContext, co
nst RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& inner
Border, |
| 1302 const BorderEdge edges[], BorderEdge
Flags edgeSet, BackgroundBleedAvoidance bleedAvoidance, | 1319 const BorderEdge edges[], BorderEdge
Flags edgeSet, BackgroundBleedAvoidance bleedAvoidance, |
| 1303 bool includeLogicalLeftEdge, bool in
cludeLogicalRightEdge, bool antialias, const Color* overrideColor) | 1320 bool includeLogicalLeftEdge, bool in
cludeLogicalRightEdge, bool antialias, const Color* overrideColor) |
| 1304 { | 1321 { |
| 1305 bool renderRadii = outerBorder.isRounded(); | 1322 bool renderRadii = outerBorder.isRounded(); |
| 1306 | 1323 |
| 1307 Path roundedPath; | 1324 Path roundedPath; |
| 1308 if (renderRadii) | 1325 if (renderRadii) |
| 1309 roundedPath.addRoundedRect(outerBorder); | 1326 roundedPath.addRoundedRect(outerBorder); |
| 1310 | 1327 |
| 1311 if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) { | 1328 if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) { |
| 1312 LayoutRect sideRect = outerBorder.rect(); | 1329 LayoutRect sideRect = calculateSideRect(outerBorder, edges, BSTop); |
| 1313 sideRect.setHeight(edges[BSTop].width); | |
| 1314 | 1330 |
| 1315 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSTop].st
yle) || borderWillArcInnerEdge(innerBorder.radii().topLeft(), innerBorder.radii(
).topRight())); | 1331 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSTop].st
yle) || borderWillArcInnerEdge(innerBorder.radii().topLeft(), innerBorder.radii(
).topRight())); |
| 1316 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSTop, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoidance
, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); | 1332 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSTop, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoidance
, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); |
| 1317 } | 1333 } |
| 1318 | 1334 |
| 1319 if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) { | 1335 if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) { |
| 1320 LayoutRect sideRect = outerBorder.rect(); | 1336 LayoutRect sideRect = calculateSideRect(outerBorder, edges, BSBottom); |
| 1321 sideRect.shiftYEdgeTo(sideRect.maxY() - edges[BSBottom].width); | |
| 1322 | 1337 |
| 1323 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSBottom]
.style) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.
radii().bottomRight())); | 1338 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSBottom]
.style) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.
radii().bottomRight())); |
| 1324 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSBottom, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoida
nce, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); | 1339 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSBottom, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoida
nce, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); |
| 1325 } | 1340 } |
| 1326 | 1341 |
| 1327 if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) { | 1342 if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) { |
| 1328 LayoutRect sideRect = outerBorder.rect(); | 1343 LayoutRect sideRect = calculateSideRect(outerBorder, edges, BSLeft); |
| 1329 sideRect.setWidth(edges[BSLeft].width); | |
| 1330 | 1344 |
| 1331 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSLeft].s
tyle) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.ra
dii().topLeft())); | 1345 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSLeft].s
tyle) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.ra
dii().topLeft())); |
| 1332 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSLeft, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidanc
e, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); | 1346 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSLeft, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidanc
e, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); |
| 1333 } | 1347 } |
| 1334 | 1348 |
| 1335 if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) { | 1349 if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) { |
| 1336 LayoutRect sideRect = outerBorder.rect(); | 1350 LayoutRect sideRect = calculateSideRect(outerBorder, edges, BSRight); |
| 1337 sideRect.shiftXEdgeTo(sideRect.maxX() - edges[BSRight].width); | |
| 1338 | 1351 |
| 1339 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSRight].
style) || borderWillArcInnerEdge(innerBorder.radii().bottomRight(), innerBorder.
radii().topRight())); | 1352 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSRight].
style) || borderWillArcInnerEdge(innerBorder.radii().bottomRight(), innerBorder.
radii().topRight())); |
| 1340 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSRight, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidan
ce, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); | 1353 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sid
eRect, BSRight, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidan
ce, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); |
| 1341 } | 1354 } |
| 1342 } | 1355 } |
| 1343 | 1356 |
| 1344 void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext* graphics
Context, const RenderStyle* style, const RoundedRect& outerBorder, const Rounded
Rect& innerBorder, | 1357 void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext* graphics
Context, const RenderStyle* style, const RoundedRect& outerBorder, const Rounded
Rect& innerBorder, |
| 1345 const BorderEdge edges[],
BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool incl
udeLogicalRightEdge, bool antialias) | 1358 const BorderEdge edges[],
BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool incl
udeLogicalRightEdge, bool antialias) |
| 1346 { | 1359 { |
| 1347 BorderEdgeFlags edgesToDraw = AllBorderEdges; | 1360 BorderEdgeFlags edgesToDraw = AllBorderEdges; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 bool haveAlphaColor = false; | 1459 bool haveAlphaColor = false; |
| 1447 bool haveAllSolidEdges = true; | 1460 bool haveAllSolidEdges = true; |
| 1448 bool allEdgesVisible = true; | 1461 bool allEdgesVisible = true; |
| 1449 bool allEdgesShareColor = true; | 1462 bool allEdgesShareColor = true; |
| 1450 int firstVisibleEdge = -1; | 1463 int firstVisibleEdge = -1; |
| 1451 | 1464 |
| 1452 for (int i = BSTop; i <= BSLeft; ++i) { | 1465 for (int i = BSTop; i <= BSLeft; ++i) { |
| 1453 const BorderEdge& currEdge = edges[i]; | 1466 const BorderEdge& currEdge = edges[i]; |
| 1454 if (currEdge.presentButInvisible()) { | 1467 if (currEdge.presentButInvisible()) { |
| 1455 allEdgesVisible = false; | 1468 allEdgesVisible = false; |
| 1469 allEdgesShareColor = false; |
| 1456 continue; | 1470 continue; |
| 1457 } | 1471 } |
| 1458 | 1472 |
| 1459 if (!currEdge.width) { | 1473 if (!currEdge.width) { |
| 1460 allEdgesVisible = false; | 1474 allEdgesVisible = false; |
| 1461 continue; | 1475 continue; |
| 1462 } | 1476 } |
| 1463 | 1477 |
| 1464 if (firstVisibleEdge == -1) | 1478 if (firstVisibleEdge == -1) |
| 1465 firstVisibleEdge = i; | 1479 firstVisibleEdge = i; |
| 1466 else if (currEdge.color != edges[firstVisibleEdge].color) | 1480 else if (currEdge.color != edges[firstVisibleEdge].color) |
| 1467 allEdgesShareColor = false; | 1481 allEdgesShareColor = false; |
| 1468 | 1482 |
| 1469 if (currEdge.color.hasAlpha()) | 1483 if (currEdge.color.hasAlpha()) |
| 1470 haveAlphaColor = true; | 1484 haveAlphaColor = true; |
| 1471 | 1485 |
| 1472 if (currEdge.style != SOLID) | 1486 if (currEdge.style != SOLID) |
| 1473 haveAllSolidEdges = false; | 1487 haveAllSolidEdges = false; |
| 1474 } | 1488 } |
| 1475 | 1489 |
| 1476 // If one of the corners falls outside the clip region, pretend it has no | 1490 // If one of the corners falls outside the clip region, pretend it has no |
| 1477 // radius to improve performance. | 1491 // radius to improve performance. |
| 1478 if (haveAllSolidEdges) | 1492 if (haveAllSolidEdges) |
| 1479 unroundClippedCorners(outerBorder, info.rect); | 1493 unroundClippedCorners(outerBorder, info.rect); |
| 1480 | 1494 |
| 1481 // isRenderable() check avoids issue described in https://bugs.webkit.org/sh
ow_bug.cgi?id=38787 | 1495 // isRenderable() check avoids issue described in https://bugs.webkit.org/sh
ow_bug.cgi?id=38787 |
| 1482 if (haveAllSolidEdges && allEdgesVisible && allEdgesShareColor && innerBorde
r.isRenderable()) { | 1496 if (haveAllSolidEdges && allEdgesShareColor && innerBorder.isRenderable()) { |
| 1483 // Fast path for drawing all solid edges. | 1497 // Fast path for drawing all solid edges. |
| 1484 if (outerBorder.isRounded() || haveAlphaColor) { | 1498 if (allEdgesVisible && (outerBorder.isRounded() || haveAlphaColor)) { |
| 1485 Path path; | 1499 Path path; |
| 1486 | 1500 |
| 1487 if (outerBorder.isRounded() && bleedAvoidance != BackgroundBleedUseT
ransparencyLayer) | 1501 if (outerBorder.isRounded() && bleedAvoidance != BackgroundBleedUseT
ransparencyLayer) |
| 1488 path.addRoundedRect(outerBorder); | 1502 path.addRoundedRect(outerBorder); |
| 1489 else | 1503 else |
| 1490 path.addRect(outerBorder.rect()); | 1504 path.addRect(outerBorder.rect()); |
| 1491 | 1505 |
| 1492 if (innerBorder.isRounded()) | 1506 if (innerBorder.isRounded()) |
| 1493 path.addRoundedRect(innerBorder); | 1507 path.addRoundedRect(innerBorder); |
| 1494 else | 1508 else |
| 1495 path.addRect(innerBorder.rect()); | 1509 path.addRect(innerBorder.rect()); |
| 1496 | 1510 |
| 1497 graphicsContext->setFillRule(RULE_EVENODD); | 1511 graphicsContext->setFillRule(RULE_EVENODD); |
| 1498 graphicsContext->setFillColor(edges[firstVisibleEdge].color, style->
colorSpace()); | 1512 graphicsContext->setFillColor(edges[firstVisibleEdge].color, style->
colorSpace()); |
| 1499 graphicsContext->fillPath(path); | 1513 graphicsContext->fillPath(path); |
| 1500 } else | 1514 return; |
| 1501 paintBorderSides(graphicsContext, style, outerBorder, innerBorder, e
dges, AllBorderEdges, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRigh
tEdge, antialias); | 1515 } |
| 1502 | 1516 // Avoid creating transparent layers |
| 1503 return; | 1517 if (!allEdgesVisible && !outerBorder.isRounded() && haveAlphaColor) { |
| 1518 Path path; |
| 1519 |
| 1520 for (int i = BSTop; i <= BSLeft; ++i) { |
| 1521 const BorderEdge& currEdge = edges[i]; |
| 1522 if (currEdge.shouldRender()) { |
| 1523 LayoutRect sideRect = calculateSideRect(outerBorder, edges,
i); |
| 1524 path.addRect(sideRect); |
| 1525 } |
| 1526 } |
| 1527 |
| 1528 graphicsContext->setFillRule(RULE_NONZERO); |
| 1529 graphicsContext->setFillColor(edges[firstVisibleEdge].color, style->
colorSpace()); |
| 1530 graphicsContext->fillPath(path); |
| 1531 return; |
| 1532 } |
| 1504 } | 1533 } |
| 1505 | 1534 |
| 1506 bool clipToOuterBorder = outerBorder.isRounded(); | 1535 bool clipToOuterBorder = outerBorder.isRounded(); |
| 1507 GraphicsContextStateSaver stateSaver(*graphicsContext, clipToOuterBorder); | 1536 GraphicsContextStateSaver stateSaver(*graphicsContext, clipToOuterBorder); |
| 1508 if (clipToOuterBorder) { | 1537 if (clipToOuterBorder) { |
| 1509 // Clip to the inner and outer radii rects. | 1538 // Clip to the inner and outer radii rects. |
| 1510 if (bleedAvoidance != BackgroundBleedUseTransparencyLayer) | 1539 if (bleedAvoidance != BackgroundBleedUseTransparencyLayer) |
| 1511 graphicsContext->addRoundedRectClip(outerBorder); | 1540 graphicsContext->addRoundedRectClip(outerBorder); |
| 1512 graphicsContext->clipOutRoundedRect(innerBorder); | 1541 graphicsContext->clipOutRoundedRect(innerBorder); |
| 1513 } | 1542 } |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 if (!continuationMap) | 2378 if (!continuationMap) |
| 2350 continuationMap = new ContinuationMap; | 2379 continuationMap = new ContinuationMap; |
| 2351 continuationMap->set(this, continuation); | 2380 continuationMap->set(this, continuation); |
| 2352 } else { | 2381 } else { |
| 2353 if (continuationMap) | 2382 if (continuationMap) |
| 2354 continuationMap->remove(this); | 2383 continuationMap->remove(this); |
| 2355 } | 2384 } |
| 2356 } | 2385 } |
| 2357 | 2386 |
| 2358 } // namespace WebCore | 2387 } // namespace WebCore |
| OLD | NEW |