#ifndef PendingScript_h
#define PendingScript_h
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
#include <wtf/text/TextPosition.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CachedScript;
class Element;
class PendingScript final : public CachedResourceClient {
public:
PendingScript()
: m_watchingForLoad(false)
, m_startingPosition(TextPosition::belowRangePosition())
{
}
PendingScript(Element* element, CachedScript* cachedScript)
: m_watchingForLoad(false)
, m_element(element)
{
setCachedScript(cachedScript);
}
PendingScript(const PendingScript& other)
: CachedResourceClient(other)
, m_watchingForLoad(other.m_watchingForLoad)
, m_element(other.m_element)
, m_startingPosition(other.m_startingPosition)
{
setCachedScript(other.cachedScript());
}
virtual ~PendingScript();
PendingScript& operator=(const PendingScript& other)
{
if (this == &other)
return *this;
m_watchingForLoad = other.m_watchingForLoad;
m_element = other.m_element;
m_startingPosition = other.m_startingPosition;
setCachedScript(other.cachedScript());
return *this;
}
TextPosition startingPosition() const { return m_startingPosition; }
void setStartingPosition(const TextPosition& position) { m_startingPosition = position; }
bool watchingForLoad() const { return m_watchingForLoad; }
void setWatchingForLoad(bool b) { m_watchingForLoad = b; }
Element* element() const { return m_element.get(); }
void setElement(Element* element) { m_element = element; }
RefPtr<Element> releaseElementAndClear();
CachedScript* cachedScript() const;
void setCachedScript(CachedScript*);
void notifyFinished(CachedResource*) override;
private:
bool m_watchingForLoad;
RefPtr<Element> m_element;
TextPosition m_startingPosition; CachedResourceHandle<CachedScript> m_cachedScript;
};
}
#endif