class SourceProvider : public RefCounted<SourceProvider> {
public:
- SourceProvider(const UString& url, SourceProviderCache* cache = 0)
+ static const intptr_t nullID = 1;
+
+ SourceProvider(const UString& url, const TextPosition& startPosition, SourceProviderCache* cache = 0)
: m_url(url)
+ , m_startPosition(startPosition)
, m_validated(false)
, m_cache(cache ? cache : new SourceProviderCache)
, m_cacheOwned(!cache)
{
+ turnOffVerifier();
}
virtual ~SourceProvider()
{
}
virtual UString getRange(int start, int end) const = 0;
- virtual const UChar* data() const = 0;
+ virtual const StringImpl* data() const = 0;
virtual int length() const = 0;
const UString& url() { return m_url; }
- virtual TextPosition1 startPosition() const { return TextPosition1::minimumPosition(); }
- intptr_t asID() { return reinterpret_cast<intptr_t>(this); }
+ TextPosition startPosition() const { return m_startPosition; }
+ intptr_t asID()
+ {
+ ASSERT(this);
+ if (!this) // Be defensive in release mode.
+ return nullID;
+ return reinterpret_cast<intptr_t>(this);
+ }
bool isValid() const { return m_validated; }
void setValid() { m_validated = true; }
virtual void cacheSizeChanged(int delta) { UNUSED_PARAM(delta); }
UString m_url;
+ TextPosition m_startPosition;
bool m_validated;
SourceProviderCache* m_cache;
bool m_cacheOwned;
class UStringSourceProvider : public SourceProvider {
public:
- static PassRefPtr<UStringSourceProvider> create(const UString& source, const UString& url)
+ static PassRefPtr<UStringSourceProvider> create(const UString& source, const UString& url, const TextPosition& startPosition = TextPosition::minimumPosition())
{
- return adoptRef(new UStringSourceProvider(source, url));
+ return adoptRef(new UStringSourceProvider(source, url, startPosition));
}
- UString getRange(int start, int end) const
+ virtual UString getRange(int start, int end) const OVERRIDE
{
return m_source.substringSharingImpl(start, end - start);
}
- const UChar* data() const { return m_source.characters(); }
+ const StringImpl* data() const { return m_source.impl(); }
int length() const { return m_source.length(); }
private:
- UStringSourceProvider(const UString& source, const UString& url)
- : SourceProvider(url)
+ UStringSourceProvider(const UString& source, const UString& url, const TextPosition& startPosition)
+ : SourceProvider(url, startPosition)
, m_source(source)
{
}