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

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

Issue 215843002: Dispel the myth that enclosingLayer can return zero (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/RenderBlock.cpp ('k') | Source/web/WebViewImpl.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 * (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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 1334
1335 RenderLayerModelObject* RenderObject::containerForRepaint() const 1335 RenderLayerModelObject* RenderObject::containerForRepaint() const
1336 { 1336 {
1337 RenderView* v = view(); 1337 RenderView* v = view();
1338 if (!v) 1338 if (!v)
1339 return 0; 1339 return 0;
1340 1340
1341 RenderLayerModelObject* repaintContainer = 0; 1341 RenderLayerModelObject* repaintContainer = 0;
1342 1342
1343 if (v->usesCompositing()) { 1343 if (v->usesCompositing()) {
1344 if (RenderLayer* parentLayer = enclosingLayer()) { 1344 // FIXME: CompositingState is not necessarily up to date for many caller s of this function.
1345 // FIXME: CompositingState is not necessarily up to date for many ca llers of this function. 1345 DisableCompositingQueryAsserts disabler;
1346 DisableCompositingQueryAsserts disabler;
1347 1346
1348 RenderLayer* compLayer = parentLayer->enclosingCompositingLayerForRe paint(); 1347 if (RenderLayer* compositingLayer = enclosingLayer()->enclosingCompositi ngLayerForRepaint())
1349 if (compLayer) 1348 repaintContainer = compositingLayer->renderer();
1350 repaintContainer = compLayer->renderer();
1351 }
1352 } 1349 }
1353 1350
1354 if (document().view()->hasSoftwareFilters()) { 1351 if (document().view()->hasSoftwareFilters()) {
1355 if (RenderLayer* parentLayer = enclosingLayer()) { 1352 if (RenderLayer* enclosingFilterLayer = enclosingLayer()->enclosingFilte rLayer())
1356 RenderLayer* enclosingFilterLayer = parentLayer->enclosingFilterLaye r(); 1353 return enclosingFilterLayer->renderer();
1357 if (enclosingFilterLayer)
1358 return enclosingFilterLayer->renderer();
1359 }
1360 } 1354 }
1361 1355
1362 // If we have a flow thread, then we need to do individual repaints within t he RenderRegions instead. 1356 // If we have a flow thread, then we need to do individual repaints within t he RenderRegions instead.
1363 // Return the flow thread as a repaint container in order to create a chokep oint that allows us to change 1357 // Return the flow thread as a repaint container in order to create a chokep oint that allows us to change
1364 // repainting to do individual region repaints. 1358 // repainting to do individual region repaints.
1365 RenderFlowThread* parentRenderFlowThread = flowThreadContainingBlock(); 1359 RenderFlowThread* parentRenderFlowThread = flowThreadContainingBlock();
1366 if (parentRenderFlowThread) { 1360 if (parentRenderFlowThread) {
1367 // The ancestor document will do the reparenting when the repaint propag ates further up. 1361 // The ancestor document will do the reparenting when the repaint propag ates further up.
1368 // We're just a seamless child document, and we don't need to do the hac king. 1362 // We're just a seamless child document, and we don't need to do the hac king.
1369 if (parentRenderFlowThread->document() != document()) 1363 if (parentRenderFlowThread->document() != document())
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 || m_style->zIndex() != newStyle->zIndex() 1977 || m_style->zIndex() != newStyle->zIndex()
1984 || m_style->hasAutoZIndex() != newStyle->hasAutoZIndex(); 1978 || m_style->hasAutoZIndex() != newStyle->hasAutoZIndex();
1985 if (visibilityChanged) { 1979 if (visibilityChanged) {
1986 document().setAnnotatedRegionsDirty(true); 1980 document().setAnnotatedRegionsDirty(true);
1987 if (AXObjectCache* cache = document().existingAXObjectCache()) 1981 if (AXObjectCache* cache = document().existingAXObjectCache())
1988 cache->childrenChanged(parent()); 1982 cache->childrenChanged(parent());
1989 } 1983 }
1990 1984
1991 // Keep layer hierarchy visibility bits up to date if visibility cha nges. 1985 // Keep layer hierarchy visibility bits up to date if visibility cha nges.
1992 if (m_style->visibility() != newStyle->visibility()) { 1986 if (m_style->visibility() != newStyle->visibility()) {
1993 if (RenderLayer* l = enclosingLayer()) { 1987 // We might not have an enclosing layer yet because we might not be in the tree.
1994 if (newStyle->visibility() == VISIBLE) 1988 if (RenderLayer* layer = enclosingLayer()) {
1995 l->setHasVisibleContent(); 1989 if (newStyle->visibility() == VISIBLE) {
1996 else if (l->hasVisibleContent() && (this == l->renderer() || l->renderer()->style()->visibility() != VISIBLE)) { 1990 layer->setHasVisibleContent();
1997 l->dirtyVisibleContentStatus(); 1991 } else if (layer->hasVisibleContent() && (this == layer->ren derer() || layer->renderer()->style()->visibility() != VISIBLE)) {
1992 layer->dirtyVisibleContentStatus();
1998 if (diff > StyleDifferenceRepaintLayer) 1993 if (diff > StyleDifferenceRepaintLayer)
1999 repaint(); 1994 repaint();
2000 } 1995 }
2001 } 1996 }
2002 } 1997 }
2003 } 1998 }
2004 1999
2005 if (m_parent && (newStyle->outlineSize() < m_style->outlineSize() || sho uldRepaintForStyleDifference(diff))) 2000 if (m_parent && (newStyle->outlineSize() < m_style->outlineSize() || sho uldRepaintForStyleDifference(diff)))
2006 repaint(); 2001 repaint();
2007 if (isFloating() && (m_style->floating() != newStyle->floating())) 2002 if (isFloating() && (m_style->floating() != newStyle->floating()))
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 2364
2370 void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const 2365 void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const
2371 { 2366 {
2372 // Figure out what layer our container is in. Any offset (or new layer) for this 2367 // Figure out what layer our container is in. Any offset (or new layer) for this
2373 // renderer within it's container will be applied in addLayerHitTestRects. 2368 // renderer within it's container will be applied in addLayerHitTestRects.
2374 LayoutPoint layerOffset; 2369 LayoutPoint layerOffset;
2375 const RenderLayer* currentLayer = 0; 2370 const RenderLayer* currentLayer = 0;
2376 2371
2377 if (!hasLayer()) { 2372 if (!hasLayer()) {
2378 RenderObject* container = this->container(); 2373 RenderObject* container = this->container();
2379 if (container) { 2374 currentLayer = container->enclosingLayer();
2380 currentLayer = container->enclosingLayer(); 2375 if (container && currentLayer->renderer() != container) {
2381 if (currentLayer && currentLayer->renderer() != container) { 2376 layerOffset.move(container->offsetFromAncestorContainer(currentLayer ->renderer()));
2382 layerOffset.move(container->offsetFromAncestorContainer(currentL ayer->renderer())); 2377 // If the layer itself is scrolled, we have to undo the subtraction of its scroll
2383 // If the layer itself is scrolled, we have to undo the subtract ion of its scroll 2378 // offset since we want the offset relative to the scrolling content , not the
2384 // offset since we want the offset relative to the scrolling con tent, not the 2379 // element itself.
2385 // element itself. 2380 if (currentLayer->renderer()->hasOverflowClip())
2386 if (currentLayer->renderer()->hasOverflowClip()) 2381 layerOffset.move(currentLayer->renderBox()->scrolledContentOffse t());
2387 layerOffset.move(currentLayer->renderBox()->scrolledContentO ffset());
2388 }
2389 } else {
2390 currentLayer = enclosingLayer();
2391 } 2382 }
2392 if (!currentLayer)
2393 return;
2394 } 2383 }
2395 2384
2396 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect ()); 2385 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect ());
2397 } 2386 }
2398 2387
2399 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren derLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& contai nerRect) const 2388 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren derLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& contai nerRect) const
2400 { 2389 {
2401 ASSERT(currentLayer); 2390 ASSERT(currentLayer);
2402 ASSERT(currentLayer == this->enclosingLayer()); 2391 ASSERT(currentLayer == this->enclosingLayer());
2403 2392
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 parent()->dirtyLinesFromChangedChild(this); 2625 parent()->dirtyLinesFromChangedChild(this);
2637 } 2626 }
2638 2627
2639 void RenderObject::willBeRemovedFromTree() 2628 void RenderObject::willBeRemovedFromTree()
2640 { 2629 {
2641 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first. 2630 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first.
2642 2631
2643 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more. 2632 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more.
2644 RenderLayer* layer = 0; 2633 RenderLayer* layer = 0;
2645 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2634 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2646 if ((layer = parent()->enclosingLayer())) 2635 layer = parent()->enclosingLayer();
2647 layer->dirtyVisibleContentStatus(); 2636 layer->dirtyVisibleContentStatus();
2648 } 2637 }
2649 2638
2650 // Keep our layer hierarchy updated. 2639 // Keep our layer hierarchy updated.
2651 if (firstChild() || hasLayer()) { 2640 if (firstChild() || hasLayer()) {
2652 if (!layer) 2641 if (!layer)
2653 layer = parent()->enclosingLayer(); 2642 layer = parent()->enclosingLayer();
2654 removeLayers(layer); 2643 removeLayers(layer);
2655 } 2644 }
2656 2645
2657 if (isOutOfFlowPositioned() && parent()->childrenInline()) 2646 if (isOutOfFlowPositioned() && parent()->childrenInline())
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
3347 { 3336 {
3348 if (object1) { 3337 if (object1) {
3349 const WebCore::RenderObject* root = object1; 3338 const WebCore::RenderObject* root = object1;
3350 while (root->parent()) 3339 while (root->parent())
3351 root = root->parent(); 3340 root = root->parent();
3352 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3341 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3353 } 3342 }
3354 } 3343 }
3355 3344
3356 #endif 3345 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698