Commit 6a48dba8 authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

Remove indirection plumbing from HTMLImportChild.

The indirection plumbing obscures what is really happening at the callsites
and should be removed. Also, strengthen up the assertions, since
now HTMLImportChild has HTMLImportLoader for (observable) life.

R=morrita@chromium.org
BUG=

Review URL: https://codereview.chromium.org/299313013

git-svn-id: svn://svn.chromium.org/blink/trunk@175244 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 38d51dd7
...@@ -63,7 +63,7 @@ void CustomElementMicrotaskImportStep::parentWasChanged() ...@@ -63,7 +63,7 @@ void CustomElementMicrotaskImportStep::parentWasChanged()
bool CustomElementMicrotaskImportStep::shouldWaitForImport() const bool CustomElementMicrotaskImportStep::shouldWaitForImport() const
{ {
return m_import && !m_import->isLoaded(); return m_import && !m_import->loader()->isDone();
} }
void CustomElementMicrotaskImportStep::didUpgradeAllCustomElements() void CustomElementMicrotaskImportStep::didUpgradeAllCustomElements()
......
...@@ -91,29 +91,20 @@ void HTMLImportChild::didFinishUpgradingCustomElements() ...@@ -91,29 +91,20 @@ void HTMLImportChild::didFinishUpgradingCustomElements()
m_customElementMicrotaskStep.clear(); m_customElementMicrotaskStep.clear();
} }
bool HTMLImportChild::isLoaded() const
{
return m_loader && m_loader->isDone();
}
bool HTMLImportChild::isFirst() const
{
return m_loader && m_loader->isFirstImport(this);
}
void HTMLImportChild::importDestroyed() void HTMLImportChild::importDestroyed()
{ {
if (parent()) if (parent())
parent()->removeChild(this); parent()->removeChild(this);
if (m_loader) {
m_loader->removeImport(this); ASSERT(m_loader);
m_loader = 0; m_loader->removeImport(this);
} m_loader = 0;
} }
Document* HTMLImportChild::document() const Document* HTMLImportChild::document() const
{ {
return m_loader ? m_loader->document() : 0; ASSERT(m_loader);
return m_loader->document();
} }
void HTMLImportChild::stateWillChange() void HTMLImportChild::stateWillChange()
...@@ -153,15 +144,18 @@ void HTMLImportChild::createCustomElementMicrotaskStepIfNeeded() ...@@ -153,15 +144,18 @@ void HTMLImportChild::createCustomElementMicrotaskStepIfNeeded()
bool HTMLImportChild::isDone() const bool HTMLImportChild::isDone() const
{ {
return m_loader && m_loader->isDone() && m_loader->microtaskQueue()->isEmpty() && !m_customElementMicrotaskStep; ASSERT(m_loader);
return m_loader->isDone() && m_loader->microtaskQueue()->isEmpty() && !m_customElementMicrotaskStep;
} }
bool HTMLImportChild::loaderHasError() const HTMLImportLoader* HTMLImportChild::loader() const
{ {
return m_loader && m_loader->hasError(); // This should never be called after importDestroyed.
ASSERT(m_loader);
return m_loader;
} }
void HTMLImportChild::setClient(HTMLImportChildClient* client) void HTMLImportChild::setClient(HTMLImportChildClient* client)
{ {
ASSERT(client); ASSERT(client);
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
// HTMLImport // HTMLImport
virtual Document* document() const OVERRIDE; virtual Document* document() const OVERRIDE;
virtual bool isDone() const OVERRIDE; virtual bool isDone() const OVERRIDE;
virtual HTMLImportLoader* loader() const OVERRIDE { return m_loader; } virtual HTMLImportLoader* loader() const OVERRIDE;
virtual void stateWillChange() OVERRIDE; virtual void stateWillChange() OVERRIDE;
virtual void stateDidChange() OVERRIDE; virtual void stateDidChange() OVERRIDE;
...@@ -76,12 +76,9 @@ public: ...@@ -76,12 +76,9 @@ public:
void setClient(HTMLImportChildClient*); void setClient(HTMLImportChildClient*);
void clearClient(); void clearClient();
bool loaderHasError() const;
void didFinishLoading(); void didFinishLoading();
void didFinishUpgradingCustomElements(); void didFinishUpgradingCustomElements();
bool isLoaded() const;
bool isFirst() const;
void normalize(); void normalize();
private: private:
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "core/html/imports/HTMLImport.h" #include "core/html/imports/HTMLImport.h"
#include "core/html/imports/HTMLImportChild.h" #include "core/html/imports/HTMLImportChild.h"
#include "core/html/imports/HTMLImportLoader.h"
namespace WebCore { namespace WebCore {
...@@ -40,10 +41,9 @@ inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) ...@@ -40,10 +41,9 @@ inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import)
{ {
if (!import->isSync()) if (!import->isSync())
return false; return false;
if (!toHTMLImportChild(import)->isFirst()) HTMLImportChild* child = toHTMLImportChild(import);
if (!child->loader()->isFirstImport(child))
return false; return false;
if (!import->loader())
return true;
return !import->state().isReady(); return !import->state().isReady();
} }
......
...@@ -120,7 +120,6 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild ...@@ -120,7 +120,6 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild
// Resource::addClient() immediately calls back to feed the bytes when the resource is cached. // Resource::addClient() immediately calls back to feed the bytes when the resource is cached.
loader->startLoading(resource); loader->startLoading(resource);
child->didStartLoading(); child->didStartLoading();
return child; return child;
} }
......
...@@ -125,7 +125,9 @@ HTMLLinkElement* LinkImport::link() ...@@ -125,7 +125,9 @@ HTMLLinkElement* LinkImport::link()
bool LinkImport::hasLoaded() const bool LinkImport::hasLoaded() const
{ {
return m_child && m_child->isDone() && !m_child->loaderHasError(); // Should never be called after importChildWasDestroyed was called.
ASSERT(m_owner);
return m_child && m_child->isDone() && !m_child->loader()->hasError();
} }
void LinkImport::trace(Visitor* visitor) void LinkImport::trace(Visitor* visitor)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment