diff options
author | hiroshige <hiroshige@chromium.org> | 2016-03-25 20:55:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-26 03:56:25 +0000 |
commit | ba00e4a1b03fa6ca3f2498397c1e6f1628027b5d (patch) | |
tree | f44fb2e190c97aafb4b19f3f63e5435f460b989b /third_party/WebKit/Source/core/layout | |
parent | 66a21dd7fb6eba1be3b1cab587eb510eb5fd5f2a (diff) | |
download | chromium_src-ba00e4a1b03fa6ca3f2498397c1e6f1628027b5d.zip chromium_src-ba00e4a1b03fa6ca3f2498397c1e6f1628027b5d.tar.gz chromium_src-ba00e4a1b03fa6ca3f2498397c1e6f1628027b5d.tar.bz2 |
Split ImageResourceClient into ResourceClient and ImageResourceObserver [2/2]
This CL makes LayoutImage to be no longer ResourceClient by adding
imageNotifyFinished() to ImageResourceObserver, which is called around when
ResourceClient::notifyFinished() would be called.
This CL adds |ImageResource::m_finishedObservers| in order to avoid
imageNotifyFinished() from being called multiple times.
BUG=587663
Review URL: https://codereview.chromium.org/1728313003
Cr-Commit-Position: refs/heads/master@{#383441}
Diffstat (limited to 'third_party/WebKit/Source/core/layout')
8 files changed, 11 insertions, 21 deletions
diff --git a/third_party/WebKit/Source/core/layout/LayoutImage.cpp b/third_party/WebKit/Source/core/layout/LayoutImage.cpp index bb23422..5d07c7f 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImage.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutImage.cpp @@ -89,7 +89,7 @@ void LayoutImage::setImageResource(PassOwnPtrWillBeRawPtr<LayoutImageResource> i { ASSERT(!m_imageResource); m_imageResource = imageResource; - m_imageResource->initialize(this, this); + m_imageResource->initialize(this); } void LayoutImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect) @@ -175,7 +175,7 @@ void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() contentChanged(ImageChanged); } -void LayoutImage::notifyFinished(Resource* newImage) +void LayoutImage::imageNotifyFinished(ImageResource* newImage) { if (!m_imageResource) return; diff --git a/third_party/WebKit/Source/core/layout/LayoutImage.h b/third_party/WebKit/Source/core/layout/LayoutImage.h index c81ed4e..2824bcf 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImage.h +++ b/third_party/WebKit/Source/core/layout/LayoutImage.h @@ -44,7 +44,7 @@ class HTMLMapElement; // // The class is image type agnostic as it only manipulates decoded images. // See LayoutImageResource that holds this image. -class CORE_EXPORT LayoutImage : public LayoutReplaced, public ResourceClient { +class CORE_EXPORT LayoutImage : public LayoutReplaced { public: // These are the paddings to use when displaying either alt text or an image. static const unsigned short paddingWidth = 4; @@ -78,7 +78,6 @@ public: } const char* name() const override { return "LayoutImage"; } - String debugName() const final { return LayoutObject::debugName(); } protected: bool needsPreferredWidthsRecalculation() const final; @@ -107,7 +106,7 @@ private: LayoutUnit minimumReplacedHeight() const override; - void notifyFinished(Resource*) final; + void imageNotifyFinished(ImageResource*) final; bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final; bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, const InlineFlowBox*) const final; diff --git a/third_party/WebKit/Source/core/layout/LayoutImageResource.cpp b/third_party/WebKit/Source/core/layout/LayoutImageResource.cpp index ed4aab3..9ce3365 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImageResource.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutImageResource.cpp @@ -36,7 +36,6 @@ namespace blink { LayoutImageResource::LayoutImageResource() : m_layoutObject(nullptr) , m_cachedImage(nullptr) - , m_client(nullptr) { } @@ -44,12 +43,11 @@ LayoutImageResource::~LayoutImageResource() { } -void LayoutImageResource::initialize(LayoutObject* layoutObject, ResourceClient* client) +void LayoutImageResource::initialize(LayoutObject* layoutObject) { ASSERT(!m_layoutObject); ASSERT(layoutObject); m_layoutObject = layoutObject; - m_client = client; } void LayoutImageResource::shutdown() @@ -58,8 +56,6 @@ void LayoutImageResource::shutdown() if (!m_cachedImage) return; - if (m_client) - m_cachedImage->removeClient(m_client); m_cachedImage->removeObserver(m_layoutObject); } @@ -71,14 +67,10 @@ void LayoutImageResource::setImageResource(ImageResource* newImage) return; if (m_cachedImage) { - if (m_client) - m_cachedImage->removeClient(m_client); m_cachedImage->removeObserver(m_layoutObject); } m_cachedImage = newImage; if (m_cachedImage) { - if (m_client) - m_cachedImage->addClient(m_client); m_cachedImage->addObserver(m_layoutObject); if (m_cachedImage->errorOccurred()) m_layoutObject->imageChanged(m_cachedImage.get()); diff --git a/third_party/WebKit/Source/core/layout/LayoutImageResource.h b/third_party/WebKit/Source/core/layout/LayoutImageResource.h index 9b87daf..9680c5a 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImageResource.h +++ b/third_party/WebKit/Source/core/layout/LayoutImageResource.h @@ -44,7 +44,7 @@ public: return adoptPtrWillBeNoop(new LayoutImageResource); } - virtual void initialize(LayoutObject*, ResourceClient*); + virtual void initialize(LayoutObject*); virtual void shutdown(); void setImageResource(ImageResource*); @@ -69,7 +69,6 @@ protected: LayoutImageResource(); LayoutObject* m_layoutObject; RefPtrWillBeMember<ImageResource> m_cachedImage; - ResourceClient* m_client; }; } // namespace blink diff --git a/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.cpp b/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.cpp index 017015c..390a214 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.cpp @@ -44,9 +44,9 @@ LayoutImageResourceStyleImage::~LayoutImageResourceStyleImage() ASSERT(!m_cachedImage); } -void LayoutImageResourceStyleImage::initialize(LayoutObject* layoutObject, ResourceClient* client) +void LayoutImageResourceStyleImage::initialize(LayoutObject* layoutObject) { - LayoutImageResource::initialize(layoutObject, client); + LayoutImageResource::initialize(layoutObject); if (m_styleImage->isImageResource()) m_cachedImage = toStyleFetchedImage(m_styleImage)->cachedImage(); diff --git a/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.h b/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.h index 9ef29b1..0cc4051 100644 --- a/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.h +++ b/third_party/WebKit/Source/core/layout/LayoutImageResourceStyleImage.h @@ -42,7 +42,7 @@ public: { return adoptPtrWillBeNoop(new LayoutImageResourceStyleImage(styleImage)); } - void initialize(LayoutObject*, ResourceClient*) override; + void initialize(LayoutObject*) override; void shutdown() override; bool hasImage() const override { return true; } diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h index 0e7df46..e331b41 100644 --- a/third_party/WebKit/Source/core/layout/LayoutObject.h +++ b/third_party/WebKit/Source/core/layout/LayoutObject.h @@ -233,7 +233,7 @@ public: // DisplayItemClient methods. LayoutRect visualRect() const override; - String debugName() const override; + String debugName() const final; LayoutObject* parent() const { return m_parent; } bool isDescendantOf(const LayoutObject*) const; diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp index 5a8bf3a..ccb9c17 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp @@ -47,7 +47,7 @@ LayoutSVGImage::LayoutSVGImage(SVGImageElement* impl) , m_needsTransformUpdate(true) , m_imageResource(LayoutImageResource::create()) { - m_imageResource->initialize(this, nullptr); + m_imageResource->initialize(this); } LayoutSVGImage::~LayoutSVGImage() |