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

Side by Side Diff: Source/core/layout/LayoutObject.cpp

Issue 1174373003: Deregister image client in LayoutObject::willBeDestroyed() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/layout/LayoutObject.h ('k') | Source/core/layout/LayoutPart.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 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 if (registry.eventHandlerTargets(EventHandlerRegistry::TouchEvent)->cont ains(node())) 2410 if (registry.eventHandlerTargets(EventHandlerRegistry::TouchEvent)->cont ains(node()))
2411 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE vent); 2411 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE vent);
2412 } 2412 }
2413 2413
2414 setAncestorLineBoxDirty(false); 2414 setAncestorLineBoxDirty(false);
2415 2415
2416 if (selectionPaintInvalidationMap) 2416 if (selectionPaintInvalidationMap)
2417 selectionPaintInvalidationMap->remove(this); 2417 selectionPaintInvalidationMap->remove(this);
2418 2418
2419 clearLayoutRootIfNeeded(); 2419 clearLayoutRootIfNeeded();
2420
2421 if (m_style) {
2422 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b gLayer = bgLayer->next()) {
2423 if (StyleImage* backgroundImage = bgLayer->image())
2424 backgroundImage->removeClient(this);
2425 }
2426
2427 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas kLayer = maskLayer->next()) {
2428 if (StyleImage* maskImage = maskLayer->image())
2429 maskImage->removeClient(this);
2430 }
2431
2432 if (StyleImage* borderImage = m_style->borderImage().image())
2433 borderImage->removeClient(this);
2434
2435 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image())
2436 maskBoxImage->removeClient(this);
2437
2438 removeShapeImageClient(m_style->shapeOutside());
2439 }
2440 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLayout Object(this);
2420 } 2441 }
2421 2442
2422 void LayoutObject::insertedIntoTree() 2443 void LayoutObject::insertedIntoTree()
2423 { 2444 {
2424 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. 2445 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion.
2425 2446
2426 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children 2447 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children
2427 // and don't have a layer attached to ourselves. 2448 // and don't have a layer attached to ourselves.
2428 DeprecatedPaintLayer* layer = nullptr; 2449 DeprecatedPaintLayer* layer = nullptr;
2429 if (slowFirstChild() || hasLayer()) { 2450 if (slowFirstChild() || hasLayer()) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 } 2552 }
2532 2553
2533 destroyRoot->destroy(); 2554 destroyRoot->destroy();
2534 2555
2535 // WARNING: |this| is deleted here. 2556 // WARNING: |this| is deleted here.
2536 } 2557 }
2537 2558
2538 void LayoutObject::destroy() 2559 void LayoutObject::destroy()
2539 { 2560 {
2540 willBeDestroyed(); 2561 willBeDestroyed();
2541 postDestroy(); 2562 delete this;
2542 } 2563 }
2543 2564
2544 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) 2565 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue)
2545 { 2566 {
2546 if (!shapeValue) 2567 if (!shapeValue)
2547 return; 2568 return;
2548 if (StyleImage* shapeImage = shapeValue->image()) 2569 if (StyleImage* shapeImage = shapeValue->image())
2549 shapeImage->removeClient(this); 2570 shapeImage->removeClient(this);
2550 } 2571 }
2551 2572
2552 void LayoutObject::postDestroy()
2553 {
2554 // It seems ugly that this is not in willBeDestroyed().
trchen 2015/06/16 04:05:55 Hello cevans@, I noticed you added this comment in
2555 if (m_style) {
2556 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b gLayer = bgLayer->next()) {
2557 if (StyleImage* backgroundImage = bgLayer->image())
2558 backgroundImage->removeClient(this);
2559 }
2560
2561 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas kLayer = maskLayer->next()) {
2562 if (StyleImage* maskImage = maskLayer->image())
2563 maskImage->removeClient(this);
2564 }
2565
2566 if (StyleImage* borderImage = m_style->borderImage().image())
2567 borderImage->removeClient(this);
2568
2569 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image())
2570 maskBoxImage->removeClient(this);
2571
2572 removeShapeImageClient(m_style->shapeOutside());
2573 }
2574 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLayout Object(this);
2575 delete this;
2576 }
2577
2578 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) 2573 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&)
2579 { 2574 {
2580 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); 2575 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM);
2581 } 2576 }
2582 2577
2583 void LayoutObject::updateDragState(bool dragOn) 2578 void LayoutObject::updateDragState(bool dragOn)
2584 { 2579 {
2585 bool valueChanged = (dragOn != isDragging()); 2580 bool valueChanged = (dragOn != isDragging());
2586 setIsDragging(dragOn); 2581 setIsDragging(dragOn);
2587 if (valueChanged && node()) { 2582 if (valueChanged && node()) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 bool LayoutObject::isInert() const 2916 bool LayoutObject::isInert() const
2922 { 2917 {
2923 const LayoutObject* layoutObject = this; 2918 const LayoutObject* layoutObject = this;
2924 while (!layoutObject->node()) 2919 while (!layoutObject->node())
2925 layoutObject = layoutObject->parent(); 2920 layoutObject = layoutObject->parent();
2926 return layoutObject->node()->isInert(); 2921 return layoutObject->node()->isInert();
2927 } 2922 }
2928 2923
2929 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) 2924 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect)
2930 { 2925 {
2926 ASSERT(m_node);
2931 imageChanged(static_cast<WrappedImagePtr>(image), rect); 2927 imageChanged(static_cast<WrappedImagePtr>(image), rect);
2932 } 2928 }
2933 2929
2934 Element* LayoutObject::offsetParent() const 2930 Element* LayoutObject::offsetParent() const
2935 { 2931 {
2936 if (isDocumentElement() || isBody()) 2932 if (isDocumentElement() || isBody())
2937 return nullptr; 2933 return nullptr;
2938 2934
2939 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) 2935 if (isOutOfFlowPositioned() && style()->position() == FixedPosition)
2940 return nullptr; 2936 return nullptr;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 const blink::LayoutObject* root = object1; 3266 const blink::LayoutObject* root = object1;
3271 while (root->parent()) 3267 while (root->parent())
3272 root = root->parent(); 3268 root = root->parent();
3273 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3269 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3274 } else { 3270 } else {
3275 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3271 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3276 } 3272 }
3277 } 3273 }
3278 3274
3279 #endif 3275 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutPart.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698