Commit 3bce54b1 authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

HTMLImportsController does not need to hold Document ptr.

Since it owns the HTMLImportTreeRoot, it can just ask it for the
master document. Additionally, remove indirection plumbing that's
just straightforward queries of master document.

No changes in behavior, refactoring.

R=morrita
BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175214 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent dbed7028
...@@ -104,7 +104,7 @@ LocalFrame* DocumentInit::frameForSecurityContext() const ...@@ -104,7 +104,7 @@ LocalFrame* DocumentInit::frameForSecurityContext() const
if (m_frame) if (m_frame)
return m_frame; return m_frame;
if (m_importsController) if (m_importsController)
return m_importsController->frame(); return m_importsController->master()->frame();
return 0; return 0;
} }
......
...@@ -55,7 +55,7 @@ using namespace HTMLNames; ...@@ -55,7 +55,7 @@ using namespace HTMLNames;
StyleEngine::StyleEngine(Document& document) StyleEngine::StyleEngine(Document& document)
: m_document(&document) : m_document(&document)
, m_isMaster(!document.importsController() || document.importsController()->isMaster(document) ) , m_isMaster(!document.importsController() || document.importsController()->master() == &document)
, m_pendingStylesheets(0) , m_pendingStylesheets(0)
, m_injectedStyleSheetCacheValid(false) , m_injectedStyleSheetCacheValid(false)
#if ENABLE(OILPAN) #if ENABLE(OILPAN)
......
...@@ -262,7 +262,7 @@ LocalFrame* ResourceFetcher::frame() const ...@@ -262,7 +262,7 @@ LocalFrame* ResourceFetcher::frame() const
if (m_documentLoader) if (m_documentLoader)
return m_documentLoader->frame(); return m_documentLoader->frame();
if (m_document && m_document->importsController()) if (m_document && m_document->importsController())
return m_document->importsController()->frame(); return m_document->importsController()->master()->frame();
return 0; return 0;
} }
......
...@@ -55,10 +55,10 @@ bool LinkResource::shouldLoadResource() const ...@@ -55,10 +55,10 @@ bool LinkResource::shouldLoadResource() const
LocalFrame* LinkResource::loadingFrame() const LocalFrame* LinkResource::loadingFrame() const
{ {
HTMLImportsController* import = m_owner->document().importsController(); HTMLImportsController* importsController = m_owner->document().importsController();
if (!import) if (!importsController)
return m_owner->document().frame(); return m_owner->document().frame();
return import->frame(); return importsController->master()->frame();
} }
void LinkResource::trace(Visitor* visitor) void LinkResource::trace(Visitor* visitor)
......
...@@ -50,29 +50,27 @@ void HTMLImportsController::provideTo(Document& master) ...@@ -50,29 +50,27 @@ void HTMLImportsController::provideTo(Document& master)
} }
HTMLImportsController::HTMLImportsController(Document& master) HTMLImportsController::HTMLImportsController(Document& master)
: m_master(&master) : m_root(HTMLImportTreeRoot::create(&master))
, m_root(HTMLImportTreeRoot::create(&master))
{ {
} }
HTMLImportsController::~HTMLImportsController() HTMLImportsController::~HTMLImportsController()
{ {
ASSERT(!m_master); ASSERT(!m_root);
} }
void HTMLImportsController::clear() void HTMLImportsController::clear()
{ {
Document* master = root()->document();
m_root.clear(); m_root.clear();
for (size_t i = 0; i < m_loaders.size(); ++i) for (size_t i = 0; i < m_loaders.size(); ++i)
m_loaders[i]->importDestroyed(); m_loaders[i]->importDestroyed();
m_loaders.clear(); m_loaders.clear();
if (m_master) if (master)
m_master->setImportsController(0); master->setImportsController(0);
m_master = 0; master = 0;
m_root.clear();
} }
static bool makesCycle(HTMLImport* parent, const KURL& url) static bool makesCycle(HTMLImport* parent, const KURL& url)
...@@ -108,9 +106,9 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild ...@@ -108,9 +106,9 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild
return child; return child;
} }
bool sameOriginRequest = securityOrigin()->canRequest(request.url()); bool sameOriginRequest = master()->securityOrigin()->canRequest(request.url());
request.setCrossOriginAccessControl( request.setCrossOriginAccessControl(
securityOrigin(), sameOriginRequest ? AllowStoredCredentials : DoNotAllowStoredCredentials, master()->securityOrigin(), sameOriginRequest ? AllowStoredCredentials : DoNotAllowStoredCredentials,
ClientDidNotRequestCredentials); ClientDidNotRequestCredentials);
ResourcePtr<RawResource> resource = parent->document()->fetcher()->fetchImport(request); ResourcePtr<RawResource> resource = parent->document()->fetcher()->fetchImport(request);
if (!resource) if (!resource)
...@@ -128,22 +126,12 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild ...@@ -128,22 +126,12 @@ HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild
void HTMLImportsController::showSecurityErrorMessage(const String& message) void HTMLImportsController::showSecurityErrorMessage(const String& message)
{ {
m_master->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message); master()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message);
}
SecurityOrigin* HTMLImportsController::securityOrigin() const
{
return m_master->securityOrigin();
}
ResourceFetcher* HTMLImportsController::fetcher() const
{
return m_master->fetcher();
} }
LocalFrame* HTMLImportsController::frame() const Document* HTMLImportsController::master() const
{ {
return m_master->frame(); return root()->document();
} }
bool HTMLImportsController::shouldBlockScriptExecution(const Document& document) const bool HTMLImportsController::shouldBlockScriptExecution(const Document& document) const
...@@ -157,7 +145,7 @@ bool HTMLImportsController::shouldBlockScriptExecution(const Document& document) ...@@ -157,7 +145,7 @@ bool HTMLImportsController::shouldBlockScriptExecution(const Document& document)
void HTMLImportsController::wasDetachedFrom(const Document& document) void HTMLImportsController::wasDetachedFrom(const Document& document)
{ {
ASSERT(document.importsController() == this); ASSERT(document.importsController() == this);
if (m_master == &document) if (master() == &document)
clear(); clear();
} }
......
...@@ -61,17 +61,13 @@ public: ...@@ -61,17 +61,13 @@ public:
HTMLImportTreeRoot* root() const { return m_root.get(); } HTMLImportTreeRoot* root() const { return m_root.get(); }
bool isMaster(const Document& document) const { return m_master == &document; }
bool shouldBlockScriptExecution(const Document&) const; bool shouldBlockScriptExecution(const Document&) const;
void wasDetachedFrom(const Document&); void wasDetachedFrom(const Document&);
HTMLImportChild* load(HTMLImport* parent, HTMLImportChildClient*, FetchRequest); HTMLImportChild* load(HTMLImport* parent, HTMLImportChildClient*, FetchRequest);
void showSecurityErrorMessage(const String&); void showSecurityErrorMessage(const String&);
SecurityOrigin* securityOrigin() const; Document* master() const;
ResourceFetcher* fetcher() const;
LocalFrame* frame() const;
Document* master() const { return m_master; }
HTMLImportLoader* createLoader(); HTMLImportLoader* createLoader();
...@@ -83,8 +79,6 @@ private: ...@@ -83,8 +79,6 @@ private:
HTMLImportChild* createChild(const KURL&, HTMLImportLoader*, HTMLImport* parent, HTMLImportChildClient*); HTMLImportChild* createChild(const KURL&, HTMLImportLoader*, HTMLImport* parent, HTMLImportChildClient*);
void clear(); void clear();
Document* m_master;
OwnPtr<HTMLImportTreeRoot> m_root; OwnPtr<HTMLImportTreeRoot> m_root;
typedef Vector<OwnPtr<HTMLImportLoader> > LoaderList; typedef Vector<OwnPtr<HTMLImportLoader> > LoaderList;
......
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