 Chromium Code Reviews
 Chromium Code Reviews Issue 24921002:
  Make compositingState explicit  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 24921002:
  Make compositingState explicit  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| 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 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 } | 1360 } | 
| 1361 | 1361 | 
| 1362 if (repaintContainer->hasFilter() && repaintContainer->layer() && repaintCon tainer->layer()->requiresFullLayerImageForFilters()) { | 1362 if (repaintContainer->hasFilter() && repaintContainer->layer() && repaintCon tainer->layer()->requiresFullLayerImageForFilters()) { | 
| 1363 repaintContainer->layer()->setFilterBackendNeedsRepaintingInRect(r); | 1363 repaintContainer->layer()->setFilterBackendNeedsRepaintingInRect(r); | 
| 1364 return; | 1364 return; | 
| 1365 } | 1365 } | 
| 1366 | 1366 | 
| 1367 RenderView* v = view(); | 1367 RenderView* v = view(); | 
| 1368 if (repaintContainer->isRenderView()) { | 1368 if (repaintContainer->isRenderView()) { | 
| 1369 ASSERT(repaintContainer == v); | 1369 ASSERT(repaintContainer == v); | 
| 1370 bool viewHasCompositedLayer = v->hasLayer() && v->layer()->isComposited( ); | 1370 bool viewHasCompositedLayer = v->hasLayer() && v->layer()->compositingSt ate() == PaintsIntoOwnBacking; | 
| 1371 if (!viewHasCompositedLayer) { | 1371 if (!viewHasCompositedLayer) { | 
| 1372 IntRect repaintRectangle = r; | 1372 IntRect repaintRectangle = r; | 
| 1373 if (viewHasCompositedLayer && v->layer()->transform()) | 1373 if (viewHasCompositedLayer && v->layer()->transform()) | 
| 1374 repaintRectangle = v->layer()->transform()->mapRect(r); | 1374 repaintRectangle = v->layer()->transform()->mapRect(r); | 
| 1375 v->repaintViewRectangle(repaintRectangle); | 1375 v->repaintViewRectangle(repaintRectangle); | 
| 1376 return; | 1376 return; | 
| 1377 } | 1377 } | 
| 1378 } | 1378 } | 
| 1379 | 1379 | 
| 1380 if (v->usesCompositing()) { | 1380 if (v->usesCompositing()) { | 
| 1381 ASSERT(repaintContainer->hasLayer() && repaintContainer->layer()->isComp osited()); | 1381 ASSERT(repaintContainer->hasLayer() && repaintContainer->layer()->compos itingState() == PaintsIntoOwnBacking); | 
| 1382 repaintContainer->layer()->setBackingNeedsRepaintInRect(r); | 1382 repaintContainer->layer()->setBackingNeedsRepaintInRect(r); | 
| 1383 } | 1383 } | 
| 1384 } | 1384 } | 
| 1385 | 1385 | 
| 1386 void RenderObject::repaint() const | 1386 void RenderObject::repaint() const | 
| 1387 { | 1387 { | 
| 1388 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) | 1388 // Don't repaint if we're unrooted (note that view() still returns the view when unrooted) | 
| 1389 RenderView* view; | 1389 RenderView* view; | 
| 1390 if (!isRooted(&view)) | 1390 if (!isRooted(&view)) | 
| 1391 return; | 1391 return; | 
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1741 setStyle(style); | 1741 setStyle(style); | 
| 1742 } | 1742 } | 
| 1743 | 1743 | 
| 1744 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const | 1744 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign ed contextSensitiveProperties) const | 
| 1745 { | 1745 { | 
| 1746 // If transform changed, and we are not composited, need to do a layout. | 1746 // If transform changed, and we are not composited, need to do a layout. | 
| 1747 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { | 1747 if (contextSensitiveProperties & ContextSensitivePropertyTransform) { | 
| 1748 // Text nodes share style with their parents but transforms don't apply to them, | 1748 // Text nodes share style with their parents but transforms don't apply to them, | 
| 1749 // hence the !isText() check. | 1749 // hence the !isText() check. | 
| 1750 // FIXME: when transforms are taken into account for overflow, we will n eed to do a layout. | 1750 // FIXME: when transforms are taken into account for overflow, we will n eed to do a layout. | 
| 1751 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->isComposited())) { | 1751 if (!isText() && (!hasLayer() || toRenderLayerModelObject(this)->layer() ->compositingState() != PaintsIntoOwnBacking)) { | 
| 1752 // We need to set at least SimplifiedLayout, but if PositionedMoveme ntOnly is already set | 1752 // We need to set at least SimplifiedLayout, but if PositionedMoveme ntOnly is already set | 
| 1753 // then we actually need SimplifiedLayoutAndPositionedMovement. | 1753 // then we actually need SimplifiedLayoutAndPositionedMovement. | 
| 1754 if (!hasLayer()) | 1754 if (!hasLayer()) | 
| 1755 diff = StyleDifferenceLayout; // FIXME: Do this for now since Si mplifiedLayout cannot handle updating floating objects lists. | 1755 diff = StyleDifferenceLayout; // FIXME: Do this for now since Si mplifiedLayout cannot handle updating floating objects lists. | 
| 1756 else if (diff < StyleDifferenceLayoutPositionedMovementOnly) | 1756 else if (diff < StyleDifferenceLayoutPositionedMovementOnly) | 
| 1757 diff = StyleDifferenceSimplifiedLayout; | 1757 diff = StyleDifferenceSimplifiedLayout; | 
| 1758 else if (diff < StyleDifferenceSimplifiedLayout) | 1758 else if (diff < StyleDifferenceSimplifiedLayout) | 
| 1759 diff = StyleDifferenceSimplifiedLayoutAndPositionedMovement; | 1759 diff = StyleDifferenceSimplifiedLayoutAndPositionedMovement; | 
| 1760 } else if (diff < StyleDifferenceRecompositeLayer) | 1760 } else if (diff < StyleDifferenceRecompositeLayer) | 
| 1761 diff = StyleDifferenceRecompositeLayer; | 1761 diff = StyleDifferenceRecompositeLayer; | 
| 1762 } | 1762 } | 
| 1763 | 1763 | 
| 1764 // If opacity changed, and we are not composited, need to repaint (also | 1764 // If opacity changed, and we are not composited, need to repaint (also | 
| 1765 // ignoring text nodes) | 1765 // ignoring text nodes) | 
| 1766 if (contextSensitiveProperties & ContextSensitivePropertyOpacity) { | 1766 if (contextSensitiveProperties & ContextSensitivePropertyOpacity) { | 
| 1767 if (!isText() && (!hasLayer() || !toRenderLayerModelObject(this)->layer( )->isComposited())) | 1767 if (!isText() && (!hasLayer() || toRenderLayerModelObject(this)->layer() ->compositingState() != PaintsIntoOwnBacking)) | 
| 
Julien - ping for review
2013/10/03 20:08:36
This looks like it is solving some bugs when we pa
 
shawnsingh
2013/10/07 11:45:04
will look into it. =)
 | |
| 1768 diff = StyleDifferenceRepaintLayer; | 1768 diff = StyleDifferenceRepaintLayer; | 
| 1769 else if (diff < StyleDifferenceRecompositeLayer) | 1769 else if (diff < StyleDifferenceRecompositeLayer) | 
| 1770 diff = StyleDifferenceRecompositeLayer; | 1770 diff = StyleDifferenceRecompositeLayer; | 
| 1771 } | 1771 } | 
| 1772 | 1772 | 
| 1773 if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLaye r()) { | 1773 if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLaye r()) { | 
| 1774 RenderLayer* layer = toRenderLayerModelObject(this)->layer(); | 1774 RenderLayer* layer = toRenderLayerModelObject(this)->layer(); | 
| 1775 if (!layer->isComposited() || layer->paintsWithFilters()) | 1775 if (layer->compositingState() != PaintsIntoOwnBacking || layer->paintsWi thFilters()) | 
| 1776 diff = StyleDifferenceRepaintLayer; | 1776 diff = StyleDifferenceRepaintLayer; | 
| 1777 else if (diff < StyleDifferenceRecompositeLayer) | 1777 else if (diff < StyleDifferenceRecompositeLayer) | 
| 1778 diff = StyleDifferenceRecompositeLayer; | 1778 diff = StyleDifferenceRecompositeLayer; | 
| 1779 } | 1779 } | 
| 1780 | 1780 | 
| 1781 // The answer to requiresLayer() for plugins, iframes, and canvas can change without the actual | 1781 // The answer to requiresLayer() for plugins, iframes, and canvas can change without the actual | 
| 1782 // style changing, since it depends on whether we decide to composite these elements. When the | 1782 // style changing, since it depends on whether we decide to composite these elements. When the | 
| 1783 // layer status of one of these elements changes, we need to force a layout. | 1783 // layer status of one of these elements changes, we need to force a layout. | 
| 1784 if (diff == StyleDifferenceEqual && style() && isLayerModelObject()) { | 1784 if (diff == StyleDifferenceEqual && style() && isLayerModelObject()) { | 
| 1785 if (hasLayer() != toRenderLayerModelObject(this)->requiresLayer()) | 1785 if (hasLayer() != toRenderLayerModelObject(this)->requiresLayer()) | 
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2713 void RenderObject::updateDragState(bool dragOn) | 2713 void RenderObject::updateDragState(bool dragOn) | 
| 2714 { | 2714 { | 
| 2715 bool valueChanged = (dragOn != isDragging()); | 2715 bool valueChanged = (dragOn != isDragging()); | 
| 2716 setIsDragging(dragOn); | 2716 setIsDragging(dragOn); | 
| 2717 if (valueChanged && node() && (style()->affectedByDrag() || (node()->isEleme ntNode() && toElement(node())->childrenAffectedByDrag()))) | 2717 if (valueChanged && node() && (style()->affectedByDrag() || (node()->isEleme ntNode() && toElement(node())->childrenAffectedByDrag()))) | 
| 2718 node()->setNeedsStyleRecalc(); | 2718 node()->setNeedsStyleRecalc(); | 
| 2719 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) | 2719 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) | 
| 2720 curr->updateDragState(dragOn); | 2720 curr->updateDragState(dragOn); | 
| 2721 } | 2721 } | 
| 2722 | 2722 | 
| 2723 bool RenderObject::isComposited() const | 2723 CompositingState RenderObject::compositingState() const | 
| 2724 { | 2724 { | 
| 2725 return hasLayer() && toRenderLayerModelObject(this)->layer()->isComposited() ; | 2725 return hasLayer() ? toRenderLayerModelObject(this)->layer()->compositingStat e() : NotComposited; | 
| 2726 } | 2726 } | 
| 2727 | 2727 | 
| 2728 bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter) | 2728 bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter) | 
| 2729 { | 2729 { | 
| 2730 bool inside = false; | 2730 bool inside = false; | 
| 2731 if (hitTestFilter != HitTestSelf) { | 2731 if (hitTestFilter != HitTestSelf) { | 
| 2732 // First test the foreground layer (lines and inlines). | 2732 // First test the foreground layer (lines and inlines). | 
| 2733 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf fset, HitTestForeground); | 2733 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf fset, HitTestForeground); | 
| 2734 | 2734 | 
| 2735 // Test floats next. | 2735 // Test floats next. | 
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3342 { | 3342 { | 
| 3343 if (object1) { | 3343 if (object1) { | 
| 3344 const WebCore::RenderObject* root = object1; | 3344 const WebCore::RenderObject* root = object1; | 
| 3345 while (root->parent()) | 3345 while (root->parent()) | 
| 3346 root = root->parent(); | 3346 root = root->parent(); | 
| 3347 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3347 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 
| 3348 } | 3348 } | 
| 3349 } | 3349 } | 
| 3350 | 3350 | 
| 3351 #endif | 3351 #endif | 
| OLD | NEW |