summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/PendingScript.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/PendingScript.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/dom/PendingScript.cpp')
-rw-r--r--Source/WebCore/dom/PendingScript.cpp73
1 files changed, 53 insertions, 20 deletions
diff --git a/Source/WebCore/dom/PendingScript.cpp b/Source/WebCore/dom/PendingScript.cpp
index c602a1126..2f986822a 100644
--- a/Source/WebCore/dom/PendingScript.cpp
+++ b/Source/WebCore/dom/PendingScript.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,43 +27,75 @@
#include "config.h"
#include "PendingScript.h"
-#include "CachedScript.h"
-#include "Element.h"
+#include "PendingScriptClient.h"
+#include "ScriptElement.h"
namespace WebCore {
+Ref<PendingScript> PendingScript::create(ScriptElement& element, LoadableScript& loadableScript)
+{
+ auto pendingScript = adoptRef(*new PendingScript(element, loadableScript));
+ loadableScript.addClient(pendingScript.get());
+ return pendingScript;
+}
+
+Ref<PendingScript> PendingScript::create(ScriptElement& element, TextPosition scriptStartPosition)
+{
+ return adoptRef(*new PendingScript(element, scriptStartPosition));
+}
+
+PendingScript::PendingScript(ScriptElement& element, TextPosition startingPosition)
+ : m_element(element)
+ , m_startingPosition(startingPosition)
+{
+}
+
+PendingScript::PendingScript(ScriptElement& element, LoadableScript& loadableScript)
+ : m_element(element)
+ , m_loadableScript(&loadableScript)
+{
+}
+
PendingScript::~PendingScript()
{
- if (m_cachedScript)
- m_cachedScript->removeClient(this);
+ if (m_loadableScript)
+ m_loadableScript->removeClient(*this);
+}
+
+void PendingScript::notifyClientFinished()
+{
+ Ref<PendingScript> protectedThis(*this);
+ if (m_client)
+ m_client->notifyFinished(*this);
+}
+
+void PendingScript::notifyFinished(LoadableScript&)
+{
+ notifyClientFinished();
}
-PassRefPtr<Element> PendingScript::releaseElementAndClear()
+bool PendingScript::isLoaded() const
{
- setCachedScript(0);
- m_watchingForLoad = false;
- m_startingPosition = TextPosition::belowRangePosition();
- return m_element.release();
+ return m_loadableScript && m_loadableScript->isLoaded();
}
-void PendingScript::setCachedScript(CachedScript* cachedScript)
+bool PendingScript::error() const
{
- if (m_cachedScript == cachedScript)
- return;
- if (m_cachedScript)
- m_cachedScript->removeClient(this);
- m_cachedScript = cachedScript;
- if (m_cachedScript)
- m_cachedScript->addClient(this);
+ return m_loadableScript && m_loadableScript->error();
}
-CachedScript* PendingScript::cachedScript() const
+void PendingScript::setClient(PendingScriptClient& client)
{
- return m_cachedScript.get();
+ ASSERT(!m_client);
+ m_client = &client;
+ if (isLoaded())
+ notifyClientFinished();
}
-void PendingScript::notifyFinished(CachedResource*)
+void PendingScript::clearClient()
{
+ ASSERT(m_client);
+ m_client = nullptr;
}
}