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

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

Issue 247803003: Remove assumption that null containerForRepaint assumes RenderView (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix zee nits Created 6 years, 8 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/RenderLayerScrollableArea.cpp ('k') | Source/core/rendering/RenderView.h » ('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 * (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 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1327
1328 void RenderObject::paint(PaintInfo&, const LayoutPoint&) 1328 void RenderObject::paint(PaintInfo&, const LayoutPoint&)
1329 { 1329 {
1330 } 1330 }
1331 1331
1332 RenderLayerModelObject* RenderObject::containerForRepaint() const 1332 RenderLayerModelObject* RenderObject::containerForRepaint() const
1333 { 1333 {
1334 if (!isRooted()) 1334 if (!isRooted())
1335 return 0; 1335 return 0;
1336 1336
1337 // FIXME: Repaint container should never be null when we're rooted. crbug.co m/363699
1338 RenderLayerModelObject* repaintContainer = 0; 1337 RenderLayerModelObject* repaintContainer = 0;
1339 1338
1340 RenderView* v = view(); 1339 RenderView* renderView = view();
1341 if (v->usesCompositing()) { 1340 if (renderView->usesCompositing()) {
1342 // FIXME: CompositingState is not necessarily up to date for many caller s of this function. 1341 // FIXME: CompositingState is not necessarily up to date for many caller s of this function.
1343 DisableCompositingQueryAsserts disabler; 1342 DisableCompositingQueryAsserts disabler;
1344 1343
1345 if (RenderLayer* compositingLayer = enclosingLayer()->enclosingCompositi ngLayerForRepaint()) 1344 if (RenderLayer* compositingLayer = enclosingLayer()->enclosingCompositi ngLayerForRepaint())
1346 repaintContainer = compositingLayer->renderer(); 1345 repaintContainer = compositingLayer->renderer();
1347 } 1346 }
1348 1347
1349 if (document().view()->hasSoftwareFilters()) { 1348 if (document().view()->hasSoftwareFilters()) {
1350 if (RenderLayer* enclosingFilterLayer = enclosingLayer()->enclosingFilte rLayer()) 1349 if (RenderLayer* enclosingFilterLayer = enclosingLayer()->enclosingFilte rLayer())
1351 return enclosingFilterLayer->renderer(); 1350 return enclosingFilterLayer->renderer();
1352 } 1351 }
1353 1352
1354 // If we have a flow thread, then we need to do individual repaints within t he RenderRegions instead. 1353 // If we have a flow thread, then we need to do individual repaints within t he RenderRegions instead.
1355 // Return the flow thread as a repaint container in order to create a chokep oint that allows us to change 1354 // Return the flow thread as a repaint container in order to create a chokep oint that allows us to change
1356 // repainting to do individual region repaints. 1355 // repainting to do individual region repaints.
1357 if (RenderFlowThread* parentRenderFlowThread = flowThreadContainingBlock()) { 1356 if (RenderFlowThread* parentRenderFlowThread = flowThreadContainingBlock()) {
1358 // If we have already found a repaint container then we will repaint int o that container only if it is part of the same 1357 // If we have already found a repaint container then we will repaint int o that container only if it is part of the same
1359 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread. 1358 // flow thread. Otherwise we will need to catch the repaint call and sen d it to the flow thread.
1360 if (!repaintContainer || repaintContainer->flowThreadContainingBlock() ! = parentRenderFlowThread) 1359 if (!repaintContainer || repaintContainer->flowThreadContainingBlock() ! = parentRenderFlowThread)
1361 repaintContainer = parentRenderFlowThread; 1360 repaintContainer = parentRenderFlowThread;
1362 } 1361 }
1363 return repaintContainer; 1362 return repaintContainer ? repaintContainer : renderView;
1364 } 1363 }
1365 1364
1366 template<typename T> PassRefPtr<JSONValue> jsonObjectForRect(const T& rect) 1365 template<typename T> PassRefPtr<JSONValue> jsonObjectForRect(const T& rect)
1367 { 1366 {
1368 RefPtr<JSONObject> object = JSONObject::create(); 1367 RefPtr<JSONObject> object = JSONObject::create();
1369 object->setNumber("x", rect.x()); 1368 object->setNumber("x", rect.x());
1370 object->setNumber("y", rect.y()); 1369 object->setNumber("y", rect.y());
1371 object->setNumber("width", rect.width()); 1370 object->setNumber("width", rect.width());
1372 object->setNumber("height", rect.height()); 1371 object->setNumber("height", rect.height());
1373 return object.release(); 1372 return object.release();
1374 } 1373 }
1375 1374
1376 static PassRefPtr<JSONValue> jsonObjectForRepaintInfo(const IntRect& rect, const String& invalidationReason) 1375 static PassRefPtr<JSONValue> jsonObjectForRepaintInfo(const IntRect& rect, const String& invalidationReason)
1377 { 1376 {
1378 RefPtr<JSONObject> object = JSONObject::create(); 1377 RefPtr<JSONObject> object = JSONObject::create();
1379 object->setValue("rect", jsonObjectForRect(rect)); 1378 object->setValue("rect", jsonObjectForRect(rect));
1380 object->setString("invalidation_reason", invalidationReason); 1379 object->setString("invalidation_reason", invalidationReason);
1381 return object.release(); 1380 return object.release();
1382 } 1381 }
1383 1382
1384 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r, InvalidationReason invalidationReason) const 1383 void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo ntainer, const IntRect& r, InvalidationReason invalidationReason) const
1385 { 1384 {
1386 if (r.isEmpty()) 1385 if (r.isEmpty())
1387 return; 1386 return;
1388 1387
1388 ASSERT(isRooted());
1389
1389 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaintUsingContainer()", 1390 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject: :repaintUsingContainer()",
1390 "object", this->debugName().ascii(), 1391 "object", this->debugName().ascii(),
1391 "info", TracedValue::fromJSONValue(jsonObjectForRepaintInfo(r, invalidat ionReasonToString(invalidationReason)))); 1392 "info", TracedValue::fromJSONValue(jsonObjectForRepaintInfo(r, invalidat ionReasonToString(invalidationReason))));
1392 1393
1393 // FIXME: Repaint container should never be null. crbug.com/363699
1394 if (!repaintContainer) {
1395 view()->repaintViewRectangle(r);
1396 return;
1397 }
1398
1399 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout. 1394 // FIXME: Don't read compositing state here since we do this in the middle o f recalc/layout.
1400 DisableCompositingQueryAsserts disabler; 1395 DisableCompositingQueryAsserts disabler;
1401 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) { 1396 if (repaintContainer->compositingState() == PaintsIntoGroupedBacking) {
1402 ASSERT(repaintContainer->groupedMapping()); 1397 ASSERT(repaintContainer->groupedMapping());
1403 ASSERT(repaintContainer->layer()); 1398 ASSERT(repaintContainer->layer());
1404 1399
1405 // Not clean, but if squashing layer does not yet exist here (e.g. repai nt invalidation coming from within recomputing compositing requirements) 1400 // Not clean, but if squashing layer does not yet exist here (e.g. repai nt invalidation coming from within recomputing compositing requirements)
1406 // then it's ok to just exit here, since the squashing layer will get re painted when it is newly created. 1401 // then it's ok to just exit here, since the squashing layer will get re painted when it is newly created.
1407 if (!repaintContainer->groupedMapping()->squashingLayer()) 1402 if (!repaintContainer->groupedMapping()->squashingLayer())
1408 return; 1403 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 if (!isRooted()) 1453 if (!isRooted())
1459 return; 1454 return;
1460 1455
1461 if (view()->document().printing()) 1456 if (view()->document().printing())
1462 return; // Don't repaint if we're printing. 1457 return; // Don't repaint if we're printing.
1463 1458
1464 // FIXME: really, we're in the repaint phase here, and the following queries are legal. 1459 // FIXME: really, we're in the repaint phase here, and the following queries are legal.
1465 // Until those states are fully fledged, I'll just disable the ASSERTS. 1460 // Until those states are fully fledged, I'll just disable the ASSERTS.
1466 DisableCompositingQueryAsserts disabler; 1461 DisableCompositingQueryAsserts disabler;
1467 RenderLayerModelObject* repaintContainer = containerForRepaint(); 1462 RenderLayerModelObject* repaintContainer = containerForRepaint();
1468 repaintUsingContainer(repaintContainer ? repaintContainer : view(), pixelSna ppedIntRect(clippedOverflowRectForRepaint(repaintContainer)), InvalidationRepain t); 1463 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(clippedOverflowR ectForRepaint(repaintContainer)), InvalidationRepaint);
1469 } 1464 }
1470 1465
1471 void RenderObject::repaintRectangle(const LayoutRect& r) const 1466 void RenderObject::repaintRectangle(const LayoutRect& r) const
1472 { 1467 {
1473 if (!isRooted()) 1468 if (!isRooted())
1474 return; 1469 return;
1475 1470
1476 if (view()->document().printing()) 1471 if (view()->document().printing())
1477 return; // Don't repaint if we're printing. 1472 return; // Don't repaint if we're printing.
1478 1473
1479 LayoutRect dirtyRect(r); 1474 LayoutRect dirtyRect(r);
1480 1475
1481 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { 1476 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
1482 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and 1477 // FIXME: layoutDelta needs to be applied in parts before/after transfor ms and
1483 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 1478 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308
1484 dirtyRect.move(view()->layoutDelta()); 1479 dirtyRect.move(view()->layoutDelta());
1485 } 1480 }
1486 1481
1487 RenderLayerModelObject* repaintContainer = containerForRepaint(); 1482 RenderLayerModelObject* repaintContainer = containerForRepaint();
1488 computeRectForRepaint(repaintContainer, dirtyRect); 1483 computeRectForRepaint(repaintContainer, dirtyRect);
1489 repaintUsingContainer(repaintContainer ? repaintContainer : view(), pixelSna ppedIntRect(dirtyRect), InvalidationRepaintRectangle); 1484 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(dirtyRect), Inva lidationRepaintRectangle);
1490 } 1485 }
1491 1486
1492 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const 1487 IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const
1493 { 1488 {
1494 return pixelSnappedIntRect(absoluteClippedOverflowRect()); 1489 return pixelSnappedIntRect(absoluteClippedOverflowRect());
1495 } 1490 }
1496 1491
1497 const char* RenderObject::invalidationReasonToString(InvalidationReason reason) const 1492 const char* RenderObject::invalidationReasonToString(InvalidationReason reason) const
1498 { 1493 {
1499 switch (reason) { 1494 switch (reason) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 if (invalidationReason == InvalidationIncremental && newBounds.location() != oldBounds.location()) 1581 if (invalidationReason == InvalidationIncremental && newBounds.location() != oldBounds.location())
1587 invalidationReason = InvalidationBoundsChange; 1582 invalidationReason = InvalidationBoundsChange;
1588 1583
1589 // If the size is zero on one of our bounds then we know we're going to have 1584 // If the size is zero on one of our bounds then we know we're going to have
1590 // to do a full invalidation of either old bounds or new bounds. If we fall 1585 // to do a full invalidation of either old bounds or new bounds. If we fall
1591 // into the incremental invalidation we'll issue two invalidations instead 1586 // into the incremental invalidation we'll issue two invalidations instead
1592 // of one. 1587 // of one.
1593 if (invalidationReason == InvalidationIncremental && (oldBounds.size().isZer o() || newBounds.size().isZero())) 1588 if (invalidationReason == InvalidationIncremental && (oldBounds.size().isZer o() || newBounds.size().isZero()))
1594 invalidationReason = InvalidationBoundsChange; 1589 invalidationReason = InvalidationBoundsChange;
1595 1590
1596 // FIXME: Repaint container should never be null. crbug.com/363699 1591 ASSERT(repaintContainer);
1597 if (!repaintContainer)
1598 repaintContainer = v;
1599 1592
1600 if (invalidationReason != InvalidationIncremental) { 1593 if (invalidationReason != InvalidationIncremental) {
1601 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds), invalidationReason); 1594 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds), invalidationReason);
1602 if (newBounds != oldBounds) 1595 if (newBounds != oldBounds)
1603 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s), invalidationReason); 1596 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBound s), invalidationReason);
1604 return true; 1597 return true;
1605 } 1598 }
1606 1599
1607 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x(); 1600 LayoutUnit deltaLeft = newBounds.x() - oldBounds.x();
1608 if (deltaLeft > 0) 1601 if (deltaLeft > 0)
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 { 3415 {
3423 if (object1) { 3416 if (object1) {
3424 const WebCore::RenderObject* root = object1; 3417 const WebCore::RenderObject* root = object1;
3425 while (root->parent()) 3418 while (root->parent())
3426 root = root->parent(); 3419 root = root->parent();
3427 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3420 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3428 } 3421 }
3429 } 3422 }
3430 3423
3431 #endif 3424 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerScrollableArea.cpp ('k') | Source/core/rendering/RenderView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698