Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: Source/core/rendering/RenderInline.cpp

Issue 585743003: Move paint code from RenderInline into InlinePainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderInline.h ('k') | Source/core/rendering/RenderLineBoxList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/RenderInline.h" 24 #include "core/rendering/RenderInline.h"
25 25
26 #include "core/dom/Fullscreen.h" 26 #include "core/dom/Fullscreen.h"
27 #include "core/dom/StyleEngine.h" 27 #include "core/dom/StyleEngine.h"
28 #include "core/page/Chrome.h" 28 #include "core/page/Chrome.h"
29 #include "core/page/Page.h" 29 #include "core/page/Page.h"
30 #include "core/paint/BoxPainter.h" 30 #include "core/paint/BoxPainter.h"
31 #include "core/paint/InlinePainter.h"
31 #include "core/paint/ObjectPainter.h" 32 #include "core/paint/ObjectPainter.h"
32 #include "core/rendering/GraphicsContextAnnotator.h" 33 #include "core/rendering/GraphicsContextAnnotator.h"
33 #include "core/rendering/HitTestResult.h" 34 #include "core/rendering/HitTestResult.h"
34 #include "core/rendering/InlineTextBox.h" 35 #include "core/rendering/InlineTextBox.h"
35 #include "core/rendering/RenderBlock.h" 36 #include "core/rendering/RenderBlock.h"
36 #include "core/rendering/RenderFlowThread.h" 37 #include "core/rendering/RenderFlowThread.h"
37 #include "core/rendering/RenderFullScreen.h" 38 #include "core/rendering/RenderFullScreen.h"
38 #include "core/rendering/RenderGeometryMap.h" 39 #include "core/rendering/RenderGeometryMap.h"
39 #include "core/rendering/RenderLayer.h" 40 #include "core/rendering/RenderLayer.h"
40 #include "core/rendering/RenderTheme.h" 41 #include "core/rendering/RenderTheme.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (childInline == bcpInline || (beforeChild && beforeChild->isInline()) ) 548 if (childInline == bcpInline || (beforeChild && beforeChild->isInline()) )
548 return beforeChildParent->addChildIgnoringContinuation(newChild, bef oreChild); 549 return beforeChildParent->addChildIgnoringContinuation(newChild, bef oreChild);
549 if (flowInline == childInline) 550 if (flowInline == childInline)
550 return flow->addChildIgnoringContinuation(newChild, 0); // Just trea t like an append. 551 return flow->addChildIgnoringContinuation(newChild, 0); // Just trea t like an append.
551 return beforeChildParent->addChildIgnoringContinuation(newChild, beforeC hild); 552 return beforeChildParent->addChildIgnoringContinuation(newChild, beforeC hild);
552 } 553 }
553 } 554 }
554 555
555 void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 556 void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
556 { 557 {
557 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); 558 InlinePainter(*this).paint(paintInfo, paintOffset);
558 m_lineBoxes.paint(this, paintInfo, paintOffset);
559 } 559 }
560 560
561 template<typename GeneratorContext> 561 template<typename GeneratorContext>
562 void RenderInline::generateLineBoxRects(GeneratorContext& yield) const 562 void RenderInline::generateLineBoxRects(GeneratorContext& yield) const
563 { 563 {
564 if (!alwaysCreateLineBoxes()) 564 if (!alwaysCreateLineBoxes())
565 generateCulledLineBoxRects(yield, this); 565 generateCulledLineBoxRects(yield, this);
566 else if (InlineFlowBox* curr = firstLineBox()) { 566 else if (InlineFlowBox* curr = firstLineBox()) {
567 for (; curr; curr = curr->nextLineBox()) 567 for (; curr; curr = curr->nextLineBox())
568 yield(FloatRect(curr->topLeft(), curr->size())); 568 yield(FloatRect(curr->topLeft(), curr->size()));
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 continuation()->addFocusRingRects(rects, additionalOffset + (toRende rBox(continuation())->location() - containingBlock()->location()), paintContaine r); 1401 continuation()->addFocusRingRects(rects, additionalOffset + (toRende rBox(continuation())->location() - containingBlock()->location()), paintContaine r);
1402 } 1402 }
1403 } 1403 }
1404 1404
1405 void RenderInline::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layo utPoint& layerOffset) const 1405 void RenderInline::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layo utPoint& layerOffset) const
1406 { 1406 {
1407 AbsoluteLayoutRectsGeneratorContext context(rects, layerOffset); 1407 AbsoluteLayoutRectsGeneratorContext context(rects, layerOffset);
1408 generateLineBoxRects(context); 1408 generateLineBoxRects(context);
1409 } 1409 }
1410 1410
1411 void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
1412 {
1413 RenderStyle* styleToUse = style();
1414 if (!styleToUse->hasOutline())
1415 return;
1416
1417 if (styleToUse->outlineStyleIsAuto()) {
1418 if (RenderTheme::theme().shouldDrawDefaultFocusRing(this)) {
1419 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
1420 ObjectPainter(*this).paintFocusRing(paintInfo, paintOffset, styleToU se);
1421 }
1422 return;
1423 }
1424
1425 if (styleToUse->outlineStyle() == BNONE)
1426 return;
1427
1428 Vector<LayoutRect> rects;
1429
1430 rects.append(LayoutRect());
1431 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
1432 RootInlineBox& root = curr->root();
1433 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() );
1434 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom());
1435 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op));
1436 }
1437 rects.append(LayoutRect());
1438
1439 Color outlineColor = resolveColor(styleToUse, CSSPropertyOutlineColor);
1440 bool useTransparencyLayer = outlineColor.hasAlpha();
1441
1442 GraphicsContext* graphicsContext = paintInfo.context;
1443 if (useTransparencyLayer) {
1444 graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor. alpha()) / 255);
1445 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue());
1446 }
1447
1448 for (unsigned i = 1; i < rects.size() - 1; i++)
1449 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor);
1450
1451 if (useTransparencyLayer)
1452 graphicsContext->endLayer();
1453 }
1454
1455 void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L ayoutPoint& paintOffset,
1456 const LayoutRect& lastline, const LayoutR ect& thisline, const LayoutRect& nextline,
1457 const Color outlineColor)
1458 {
1459 RenderStyle* styleToUse = style();
1460 int outlineWidth = styleToUse->outlineWidth();
1461 EBorderStyle outlineStyle = styleToUse->outlineStyle();
1462
1463 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext);
1464
1465 int offset = style()->outlineOffset();
1466
1467 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOff set.y() + thisline.y() - offset),
1468 LayoutSize(thisline.width() + offset, thisline.height() + offset));
1469
1470 IntRect pixelSnappedBox = pixelSnappedIntRect(box);
1471 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0)
1472 return;
1473 IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastlin e.x(), 0, lastline.width(), 0);
1474 IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextlin e.x(), 0, nextline.width(), 0);
1475
1476 // left edge
1477 ObjectPainter::drawLineForBoxSide(graphicsContext,
1478 pixelSnappedBox.x() - outlineWidth,
1479 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
1480 pixelSnappedBox.x(),
1481 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
1482 BSLeft,
1483 outlineColor, outlineStyle,
1484 (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
1485 (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
1486 antialias);
1487
1488 // right edge
1489 ObjectPainter::drawLineForBoxSide(graphicsContext,
1490 pixelSnappedBox.maxX(),
1491 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline. maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0),
1492 pixelSnappedBox.maxX() + outlineWidth,
1493 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisl ine.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0),
1494 BSRight,
1495 outlineColor, outlineStyle,
1496 (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.ma xX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth),
1497 (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.m axX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth),
1498 antialias);
1499 // upper edge
1500 if (thisline.x() < lastline.x())
1501 ObjectPainter::drawLineForBoxSide(graphicsContext,
1502 pixelSnappedBox.x() - outlineWidth,
1503 pixelSnappedBox.y() - outlineWidth,
1504 std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())),
1505 pixelSnappedBox.y(),
1506 BSTop, outlineColor, outlineStyle,
1507 outlineWidth,
1508 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
1509 antialias);
1510
1511 if (lastline.maxX() < thisline.maxX())
1512 ObjectPainter::drawLineForBoxSide(graphicsContext,
1513 std::max(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX() , pixelSnappedBox.x() - outlineWidth),
1514 pixelSnappedBox.y() - outlineWidth,
1515 pixelSnappedBox.maxX() + outlineWidth,
1516 pixelSnappedBox.y(),
1517 BSTop, outlineColor, outlineStyle,
1518 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth,
1519 outlineWidth, antialias);
1520
1521 if (thisline.x() == thisline.maxX())
1522 ObjectPainter::drawLineForBoxSide(graphicsContext,
1523 pixelSnappedBox.x() - outlineWidth,
1524 pixelSnappedBox.y() - outlineWidth,
1525 pixelSnappedBox.maxX() + outlineWidth,
1526 pixelSnappedBox.y(),
1527 BSTop, outlineColor, outlineStyle,
1528 outlineWidth,
1529 outlineWidth,
1530 antialias);
1531
1532 // lower edge
1533 if (thisline.x() < nextline.x())
1534 ObjectPainter::drawLineForBoxSide(graphicsContext,
1535 pixelSnappedBox.x() - outlineWidth,
1536 pixelSnappedBox.maxY(),
1537 std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000),
1538 pixelSnappedBox.maxY() + outlineWidth,
1539 BSBottom, outlineColor, outlineStyle,
1540 outlineWidth,
1541 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
1542 antialias);
1543
1544 if (nextline.maxX() < thisline.maxX())
1545 ObjectPainter::drawLineForBoxSide(graphicsContext,
1546 std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -100000 0, pixelSnappedBox.x() - outlineWidth),
1547 pixelSnappedBox.maxY(),
1548 pixelSnappedBox.maxX() + outlineWidth,
1549 pixelSnappedBox.maxY() + outlineWidth,
1550 BSBottom, outlineColor, outlineStyle,
1551 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth,
1552 outlineWidth, antialias);
1553
1554 if (thisline.x() == thisline.maxX())
1555 ObjectPainter::drawLineForBoxSide(graphicsContext,
1556 pixelSnappedBox.x() - outlineWidth,
1557 pixelSnappedBox.maxY(),
1558 pixelSnappedBox.maxX() + outlineWidth,
1559 pixelSnappedBox.maxY() + outlineWidth,
1560 BSBottom, outlineColor, outlineStyle,
1561 outlineWidth,
1562 outlineWidth,
1563 antialias);
1564 }
1565
1566 void RenderInline::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) 1411 void RenderInline::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
1567 { 1412 {
1568 // Convert the style regions to absolute coordinates. 1413 // Convert the style regions to absolute coordinates.
1569 if (style()->visibility() != VISIBLE) 1414 if (style()->visibility() != VISIBLE)
1570 return; 1415 return;
1571 1416
1572 if (style()->getDraggableRegionMode() == DraggableRegionNone) 1417 if (style()->getDraggableRegionMode() == DraggableRegionNone)
1573 return; 1418 return;
1574 1419
1575 AnnotatedRegionValue region; 1420 AnnotatedRegionValue region;
1576 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; 1421 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag;
1577 region.bounds = linesBoundingBox(); 1422 region.bounds = linesBoundingBox();
1578 1423
1579 RenderObject* container = containingBlock(); 1424 RenderObject* container = containingBlock();
1580 if (!container) 1425 if (!container)
1581 container = this; 1426 container = this;
1582 1427
1583 FloatPoint absPos = container->localToAbsolute(); 1428 FloatPoint absPos = container->localToAbsolute();
1584 region.bounds.setX(absPos.x() + region.bounds.x()); 1429 region.bounds.setX(absPos.x() + region.bounds.x());
1585 region.bounds.setY(absPos.y() + region.bounds.y()); 1430 region.bounds.setY(absPos.y() + region.bounds.y());
1586 1431
1587 regions.append(region); 1432 regions.append(region);
1588 } 1433 }
1589 1434
1590 } // namespace blink 1435 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderInline.h ('k') | Source/core/rendering/RenderLineBoxList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698