Chromium Code Reviews| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 #include "core/rendering/compositing/RenderLayerCompositor.h" | 75 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 76 #include "core/rendering/style/ContentData.h" | 76 #include "core/rendering/style/ContentData.h" |
| 77 #include "core/rendering/style/CursorList.h" | 77 #include "core/rendering/style/CursorList.h" |
| 78 #include "core/rendering/style/ShadowList.h" | 78 #include "core/rendering/style/ShadowList.h" |
| 79 #include "core/rendering/svg/SVGRenderSupport.h" | 79 #include "core/rendering/svg/SVGRenderSupport.h" |
| 80 #include "platform/Partitions.h" | 80 #include "platform/Partitions.h" |
| 81 #include "platform/geometry/TransformState.h" | 81 #include "platform/geometry/TransformState.h" |
| 82 #include "platform/graphics/GraphicsContext.h" | 82 #include "platform/graphics/GraphicsContext.h" |
| 83 #include "wtf/RefCountedLeakCounter.h" | 83 #include "wtf/RefCountedLeakCounter.h" |
| 84 #include "wtf/text/StringBuilder.h" | 84 #include "wtf/text/StringBuilder.h" |
| 85 #include "wtf/text/WTFString.h" | |
| 85 #include <algorithm> | 86 #include <algorithm> |
| 86 #ifndef NDEBUG | 87 #ifndef NDEBUG |
| 87 #include <stdio.h> | 88 #include <stdio.h> |
| 88 #endif | 89 #endif |
| 89 | 90 |
| 90 using namespace std; | 91 using namespace std; |
| 91 | 92 |
| 92 namespace WebCore { | 93 namespace WebCore { |
| 93 | 94 |
| 94 using namespace HTMLNames; | 95 using namespace HTMLNames; |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1371 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread. | 1372 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread. |
| 1372 RenderFlowThread* repaintContainerFlowThread = repaintContainer ? repain tContainer->flowThreadContainingBlock() : 0; | 1373 RenderFlowThread* repaintContainerFlowThread = repaintContainer ? repain tContainer->flowThreadContainingBlock() : 0; |
| 1373 if (!repaintContainerFlowThread || repaintContainerFlowThread != parentR enderFlowThread) | 1374 if (!repaintContainerFlowThread || repaintContainerFlowThread != parentR enderFlowThread) |
| 1374 repaintContainer = parentRenderFlowThread; | 1375 repaintContainer = parentRenderFlowThread; |
| 1375 } | 1376 } |
| 1376 return repaintContainer; | 1377 return repaintContainer; |
| 1377 } | 1378 } |
| 1378 | 1379 |
| 1379 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r) const | 1380 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r) const |
| 1380 { | 1381 { |
| 1382 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "RenderObject::repa intUsingContainer()", | |
| 1383 "object", TRACE_STR_COPY(this->debugName().ascii().data()), | |
| 1384 "rect", TRACE_STR_COPY(String::format("%d,%d %dx%d", r.x(), r.y(), r.wid th(), r.height()).ascii().data())); | |
| 1385 | |
| 1381 if (!repaintContainer) { | 1386 if (!repaintContainer) { |
| 1382 view()->repaintViewRectangle(r); | 1387 view()->repaintViewRectangle(r); |
| 1383 return; | 1388 return; |
| 1384 } | 1389 } |
| 1385 | 1390 |
| 1386 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout. | 1391 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout. |
| 1387 DisableCompositingQueryAsserts disabler; | 1392 DisableCompositingQueryAsserts disabler; |
| 1388 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) { | 1393 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) { |
| 1389 ASSERT(repaintContainer->groupedMapping()); | 1394 ASSERT(repaintContainer->groupedMapping()); |
| 1390 | 1395 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 void RenderObject::repaint() const | 1447 void RenderObject::repaint() const |
| 1443 { | 1448 { |
| 1444 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) | 1449 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) |
| 1445 RenderView* view; | 1450 RenderView* view; |
| 1446 if (!isRooted(&view)) | 1451 if (!isRooted(&view)) |
| 1447 return; | 1452 return; |
| 1448 | 1453 |
| 1449 if (view->document().printing()) | 1454 if (view->document().printing()) |
| 1450 return; // Don't repaint if we're printing. | 1455 return; // Don't repaint if we're printing. |
| 1451 | 1456 |
| 1457 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "RenderObject::repa int()", | |
| 1458 "object", TRACE_STR_COPY(this->debugName().ascii().data())); | |
| 1459 | |
| 1452 // FIXME: really, we're in the repaint phase here, and the following queries are legal. | 1460 // FIXME: really, we're in the repaint phase here, and the following queries are legal. |
| 1453 // Until those states are fully fledged, I'll just disable the ASSERTS. | 1461 // Until those states are fully fledged, I'll just disable the ASSERTS. |
| 1454 DisableCompositingQueryAsserts disabler; | 1462 DisableCompositingQueryAsserts disabler; |
| 1455 RenderLayerModelObject* repaintContainer = containerForRepaint(); | 1463 RenderLayerModelObject* repaintContainer = containerForRepaint(); |
| 1456 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(clippedOverflowRectForRepaint(repaintContainer))); | 1464 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(clippedOverflowRectForRepaint(repaintContainer))); |
| 1457 } | 1465 } |
| 1458 | 1466 |
| 1459 void RenderObject::repaintRectangle(const LayoutRect& r) const | 1467 void RenderObject::repaintRectangle(const LayoutRect& r) const |
| 1460 { | 1468 { |
| 1461 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) | 1469 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) |
| 1462 RenderView* view; | 1470 RenderView* view; |
| 1463 if (!isRooted(&view)) | 1471 if (!isRooted(&view)) |
| 1464 return; | 1472 return; |
| 1465 | 1473 |
| 1466 if (view->document().printing()) | 1474 if (view->document().printing()) |
| 1467 return; // Don't repaint if we're printing. | 1475 return; // Don't repaint if we're printing. |
| 1468 | 1476 |
| 1477 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "RenderObject::repa intRectangle()", | |
|
Julien - ping for review
2014/03/21 18:35:34
Is there a lot of values in tracing callers of rep
dsinclair
2014/03/24 15:04:31
The invalidationReasons are only coming from repai
| |
| 1478 "object", TRACE_STR_COPY(this->debugName().ascii().data())); | |
| 1479 | |
| 1469 LayoutRect dirtyRect(r); | 1480 LayoutRect dirtyRect(r); |
| 1470 | 1481 |
| 1471 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { | 1482 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { |
| 1472 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and | 1483 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and |
| 1473 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 | 1484 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 |
| 1474 dirtyRect.move(view->layoutDelta()); | 1485 dirtyRect.move(view->layoutDelta()); |
| 1475 } | 1486 } |
| 1476 | 1487 |
| 1477 RenderLayerModelObject* repaintContainer = containerForRepaint(); | 1488 RenderLayerModelObject* repaintContainer = containerForRepaint(); |
| 1478 computeRectForRepaint(repaintContainer, dirtyRect); | 1489 computeRectForRepaint(repaintContainer, dirtyRect); |
| 1479 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(dirtyRect)); | 1490 repaintUsingContainer(repaintContainer ? repaintContainer : view, pixelSnapp edIntRect(dirtyRect)); |
| 1480 } | 1491 } |
| 1481 | 1492 |
| 1482 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const | 1493 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const |
| 1483 { | 1494 { |
| 1484 return pixelSnappedIntRect(absoluteClippedOverflowRect()); | 1495 return pixelSnappedIntRect(absoluteClippedOverflowRect()); |
| 1485 } | 1496 } |
| 1486 | 1497 |
| 1498 const char* RenderObject::repaintReasonToString(const RepaintReason reason) cons t | |
| 1499 { | |
| 1500 switch (reason) { | |
| 1501 case RepaintNone: | |
| 1502 return "none"; | |
| 1503 case RepaintSelfLayout: | |
| 1504 return "self layout"; | |
| 1505 case RepaintBorderFitLines: | |
| 1506 return "border fit lines"; | |
| 1507 case RepaintBorderRadius: | |
| 1508 return "border radius"; | |
| 1509 case RepaintOutlineBoxChange: | |
| 1510 return "outline box change"; | |
| 1511 case RepaintBoundsChange: | |
| 1512 return "bounds change"; | |
| 1513 default: | |
| 1514 return "unknown"; | |
| 1515 } | |
| 1516 } | |
| 1517 | |
| 1487 bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa intContainer, bool wasSelfLayout, | 1518 bool RenderObject::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repa intContainer, bool wasSelfLayout, |
| 1488 const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, | 1519 const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, |
| 1489 const LayoutRect* newBoundsPtr, const LayoutRect* newOutlineBoxRectPtr) | 1520 const LayoutRect* newBoundsPtr, const LayoutRect* newOutlineBoxRectPtr) |
| 1490 { | 1521 { |
| 1491 RenderView* v = view(); | 1522 RenderView* v = view(); |
| 1492 if (v->document().printing()) | 1523 if (v->document().printing()) |
| 1493 return false; // Don't repaint if we're printing. | 1524 return false; // Don't repaint if we're printing. |
| 1494 | 1525 |
| 1526 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "RenderObject::repa intAfterLayoutIfNeeded", | |
| 1527 "object", TRACE_STR_COPY(this->debugName().ascii().data())); | |
| 1528 | |
| 1495 // This ASSERT fails due to animations. See https://bugs.webkit.org/show_bu g.cgi?id=37048 | 1529 // This ASSERT fails due to animations. See https://bugs.webkit.org/show_bu g.cgi?id=37048 |
| 1496 // ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(re paintContainer)); | 1530 // ASSERT(!newBoundsPtr || *newBoundsPtr == clippedOverflowRectForRepaint(re paintContainer)); |
| 1497 LayoutRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectFor Repaint(repaintContainer); | 1531 LayoutRect newBounds = newBoundsPtr ? *newBoundsPtr : clippedOverflowRectFor Repaint(repaintContainer); |
| 1498 LayoutRect newOutlineBox; | 1532 LayoutRect newOutlineBox; |
| 1499 | 1533 |
| 1500 bool fullRepaint = wasSelfLayout; | 1534 RepaintReason repaintReason = RepaintNone; |
|
Julien - ping for review
2014/03/21 18:35:34
I hate RepaintNone as a default reason. I think th
dsinclair
2014/03/24 15:04:31
Done.
| |
| 1535 if (wasSelfLayout) | |
| 1536 repaintReason = RepaintSelfLayout; | |
| 1537 | |
| 1501 // Presumably a background or a border exists if border-fit:lines was specif ied. | 1538 // Presumably a background or a border exists if border-fit:lines was specif ied. |
| 1502 if (!fullRepaint && style()->borderFit() == BorderFitLines) | 1539 if (repaintReason == RepaintNone && style()->borderFit() == BorderFitLines) |
| 1503 fullRepaint = true; | 1540 repaintReason = RepaintBorderFitLines; |
| 1504 if (!fullRepaint && style()->hasBorderRadius()) { | 1541 |
| 1542 if (repaintReason == RepaintNone&& style()->hasBorderRadius()) { | |
| 1505 // If a border-radius exists and width/height is smaller than | 1543 // If a border-radius exists and width/height is smaller than |
| 1506 // radius width/height, we cannot use delta-repaint. | 1544 // radius width/height, we cannot use delta-repaint. |
| 1507 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(oldBounds); | 1545 RoundedRect oldRoundedRect = style()->getRoundedBorderFor(oldBounds); |
| 1508 RoundedRect newRoundedRect = style()->getRoundedBorderFor(newBounds); | 1546 RoundedRect newRoundedRect = style()->getRoundedBorderFor(newBounds); |
| 1509 fullRepaint = oldRoundedRect.radii() != newRoundedRect.radii(); | 1547 if (oldRoundedRect.radii() != newRoundedRect.radii()) |
| 1548 repaintReason = RepaintBorderRadius; | |
| 1510 } | 1549 } |
| 1511 if (!fullRepaint) { | 1550 |
| 1551 if (repaintReason == RepaintNone) { | |
| 1512 // This ASSERT fails due to animations. See https://bugs.webkit.org/sho w_bug.cgi?id=37048 | 1552 // This ASSERT fails due to animations. See https://bugs.webkit.org/sho w_bug.cgi?id=37048 |
| 1513 // ASSERT(!newOutlineBoxRectPtr || *newOutlineBoxRectPtr == outlineBound sForRepaint(repaintContainer)); | 1553 // ASSERT(!newOutlineBoxRectPtr || *newOutlineBoxRectPtr == outlineBound sForRepaint(repaintContainer)); |
| 1514 newOutlineBox = newOutlineBoxRectPtr ? *newOutlineBoxRectPtr : outlineBo undsForRepaint(repaintContainer); | 1554 newOutlineBox = newOutlineBoxRectPtr ? *newOutlineBoxRectPtr : outlineBo undsForRepaint(repaintContainer); |
| 1515 | 1555 |
| 1516 if ((hasOutline() && newOutlineBox.location() != oldOutlineBox.location( )) | 1556 if ((hasOutline() && newOutlineBox.location() != oldOutlineBox.location( )) |
| 1517 || (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds || (h asOutline() && newOutlineBox != oldOutlineBox)))) | 1557 || (mustRepaintBackgroundOrBorder() && (newBounds != oldBounds || (h asOutline() && newOutlineBox != oldOutlineBox)))) |
| 1518 fullRepaint = true; | 1558 repaintReason = RepaintOutlineBoxChange; |
| 1519 } | 1559 } |
| 1520 | 1560 |
| 1521 // If there is no intersection between the old and the new bounds, invalidat ing | 1561 // If there is no intersection between the old and the new bounds, invalidat ing |
| 1522 // the difference is more expensive than just doing a full repaint. | 1562 // the difference is more expensive than just doing a full repaint. |
| 1523 if (!fullRepaint && !newBounds.intersects(oldBounds)) | 1563 if (repaintReason == RepaintNone && !newBounds.intersects(oldBounds)) |
| 1524 fullRepaint = true; | 1564 repaintReason = RepaintBoundsChange; |
|
Julien - ping for review
2014/03/21 18:35:34
Sir, this is a change in behavior! We don't want t
dsinclair
2014/03/24 15:04:31
I'm not sure I understand, there should be no beha
| |
| 1525 | 1565 |
| 1526 if (!repaintContainer) | 1566 if (!repaintContainer) |
| 1527 repaintContainer = v; | 1567 repaintContainer = v; |
| 1528 | 1568 |
| 1529 if (fullRepaint) { | 1569 if (repaintReason != RepaintNone) { |
| 1570 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "repain t_reason::full", | |
| 1571 "object", TRACE_STR_COPY(this->debugName().ascii().data()), | |
| 1572 "reason", repaintReasonToString(repaintReason)); | |
| 1573 | |
| 1530 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); | 1574 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); |
| 1531 if (newBounds != oldBounds) | 1575 if (newBounds != oldBounds) |
| 1532 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s)); | 1576 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s)); |
| 1533 return true; | 1577 return true; |
| 1534 } | 1578 } |
| 1535 | 1579 |
| 1536 if (newBounds == oldBounds && newOutlineBox == oldOutlineBox) | 1580 if (newBounds == oldBounds && newOutlineBox == oldOutlineBox) |
| 1537 return false; | 1581 return false; |
| 1538 | 1582 |
| 1583 repaintReason = RepaintBoundsChange; | |
| 1584 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("blink.repaint"), "repaint_re ason::delta", | |
| 1585 "object", TRACE_STR_COPY(this->debugName().ascii().data()), | |
| 1586 "reason", repaintReasonToString(repaintReason)); | |
| 1587 | |
| 1539 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x(); | 1588 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x(); |
| 1540 if (deltaLeft > 0) | 1589 if (deltaLeft > 0) |
| 1541 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.x( ), oldBounds.y(), deltaLeft, oldBounds.height())); | 1590 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.x( ), oldBounds.y(), deltaLeft, oldBounds.height())); |
| 1542 else if (deltaLeft < 0) | 1591 else if (deltaLeft < 0) |
| 1543 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds.x( ), newBounds.y(), -deltaLeft, newBounds.height())); | 1592 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds.x( ), newBounds.y(), -deltaLeft, newBounds.height())); |
| 1544 | 1593 |
| 1545 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); | 1594 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); |
| 1546 if (deltaRight > 0) | 1595 if (deltaRight > 0) |
| 1547 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.ma xX(), newBounds.y(), deltaRight, newBounds.height())); | 1596 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds.ma xX(), newBounds.y(), deltaRight, newBounds.height())); |
| 1548 else if (deltaRight < 0) | 1597 else if (deltaRight < 0) |
| (...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3408 { | 3457 { |
| 3409 if (object1) { | 3458 if (object1) { |
| 3410 const WebCore::RenderObject* root = object1; | 3459 const WebCore::RenderObject* root = object1; |
| 3411 while (root->parent()) | 3460 while (root->parent()) |
| 3412 root = root->parent(); | 3461 root = root->parent(); |
| 3413 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3462 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3414 } | 3463 } |
| 3415 } | 3464 } |
| 3416 | 3465 |
| 3417 #endif | 3466 #endif |
| OLD | NEW |