summaryrefslogtreecommitdiffstats
path: root/WebCore/xml
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/xml')
-rw-r--r--WebCore/xml/XMLHttpRequest.cpp51
-rw-r--r--WebCore/xml/XMLHttpRequest.h14
-rw-r--r--WebCore/xml/XPathParser.cpp4
-rw-r--r--WebCore/xml/XPathParser.h1
-rw-r--r--WebCore/xml/XPathStep.cpp4
5 files changed, 28 insertions, 46 deletions
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp
index 07a816d..afab73d 100644
--- a/WebCore/xml/XMLHttpRequest.cpp
+++ b/WebCore/xml/XMLHttpRequest.cpp
@@ -35,7 +35,7 @@
#include "File.h"
#include "HTTPParsers.h"
#include "InspectorController.h"
-#include "InspectorTimelineAgent.h"
+#include "InspectorInstrumentation.h"
#include "ResourceError.h"
#include "ResourceRequest.h"
#include "SecurityOrigin.h"
@@ -173,7 +173,6 @@ XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext* context)
, m_asBlob(false)
#endif
, m_state(UNSENT)
- , m_responseText("")
, m_createdDocument(false)
, m_error(false)
, m_uploadEventsAllowed(true)
@@ -226,7 +225,7 @@ XMLHttpRequest::State XMLHttpRequest::readyState() const
return m_state;
}
-const ScriptString& XMLHttpRequest::responseText(ExceptionCode& ec) const
+String XMLHttpRequest::responseText(ExceptionCode& ec)
{
#if ENABLE(XHR_RESPONSE_BLOB)
if (m_asBlob)
@@ -234,10 +233,10 @@ const ScriptString& XMLHttpRequest::responseText(ExceptionCode& ec) const
#else
UNUSED_PARAM(ec);
#endif
- return m_responseText;
+ return m_responseBuilder.toStringPreserveCapacity();
}
-Document* XMLHttpRequest::responseXML(ExceptionCode& ec) const
+Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
{
#if ENABLE(XHR_RESPONSE_BLOB)
if (m_asBlob) {
@@ -259,7 +258,7 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec) const
m_responseXML = Document::create(0, m_url);
m_responseXML->open();
// FIXME: Set Last-Modified.
- m_responseXML->write(String(m_responseText));
+ m_responseXML->write(m_responseBuilder.toStringPreserveCapacity());
m_responseXML->finishParsing();
m_responseXML->close();
@@ -303,35 +302,17 @@ void XMLHttpRequest::callReadyStateChangeListener()
if (!scriptExecutionContext())
return;
-#if ENABLE(INSPECTOR)
- InspectorTimelineAgent* timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
- bool callTimelineAgentOnReadyStateChange = timelineAgent && hasEventListeners(eventNames().readystatechangeEvent);
- if (callTimelineAgentOnReadyStateChange)
- timelineAgent->willChangeXHRReadyState(m_url.string(), m_state);
-#endif
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willChangeXHRReadyState(scriptExecutionContext(), this);
if (m_async || (m_state <= OPENED || m_state == DONE))
m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
-#if ENABLE(INSPECTOR)
- if (callTimelineAgentOnReadyStateChange && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
- timelineAgent->didChangeXHRReadyState();
-#endif
+ InspectorInstrumentation::didChangeXHRReadyState(cookie);
if (m_state == DONE && !m_error) {
-#if ENABLE(INSPECTOR)
- timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext());
- bool callTimelineAgentOnLoad = timelineAgent && hasEventListeners(eventNames().loadEvent);
- if (callTimelineAgentOnLoad)
- timelineAgent->willLoadXHR(m_url.string());
-#endif
-
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLoadXHR(scriptExecutionContext(), this);
m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));
-
-#if ENABLE(INSPECTOR)
- if (callTimelineAgentOnLoad && (timelineAgent = InspectorTimelineAgent::retrieve(scriptExecutionContext())))
- timelineAgent->didLoadXHR();
-#endif
+ InspectorInstrumentation::didLoadXHR(cookie);
}
}
@@ -645,7 +626,7 @@ void XMLHttpRequest::abort()
internalAbort();
- m_responseText = "";
+ m_responseBuilder.clear();
m_createdDocument = false;
m_responseXML = 0;
#if ENABLE(XHR_RESPONSE_BLOB)
@@ -694,7 +675,7 @@ void XMLHttpRequest::internalAbort()
void XMLHttpRequest::clearResponse()
{
m_response = ResourceResponse();
- m_responseText = "";
+ m_responseBuilder.clear();
m_createdDocument = false;
m_responseXML = 0;
#if ENABLE(XHR_RESPONSE_BLOB)
@@ -751,7 +732,7 @@ void XMLHttpRequest::dropProtection()
// report the extra cost at that point.
JSC::JSGlobalData* globalData = scriptExecutionContext()->globalData();
if (hasCachedDOMObjectWrapper(globalData, this))
- globalData->heap.reportExtraMemoryCost(m_responseText.size() * 2);
+ globalData->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
#endif
unsetPendingActivity(this);
@@ -960,7 +941,9 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier)
changeState(HEADERS_RECEIVED);
if (m_decoder)
- m_responseText += m_decoder->flush();
+ m_responseBuilder.append(m_decoder->flush());
+
+ m_responseBuilder.shrinkToFit();
#if ENABLE(XHR_RESPONSE_BLOB)
// FIXME: Set m_responseBlob to something here in the m_asBlob case.
@@ -968,7 +951,7 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier)
#if ENABLE(INSPECTOR)
if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
- inspector->resourceRetrievedByXMLHttpRequest(identifier, m_responseText, m_url, m_lastSendURL, m_lastSendLineNumber);
+ inspector->resourceRetrievedByXMLHttpRequest(identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber);
#endif
bool hadLoader = m_loader;
@@ -1037,7 +1020,7 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
if (len == -1)
len = strlen(data);
- m_responseText += m_decoder->decode(data, len);
+ m_responseBuilder.append(m_decoder->decode(data, len));
if (!m_error) {
long long expectedLength = m_response.expectedContentLength();
diff --git a/WebCore/xml/XMLHttpRequest.h b/WebCore/xml/XMLHttpRequest.h
index 481b51f..cb4e1cf 100644
--- a/WebCore/xml/XMLHttpRequest.h
+++ b/WebCore/xml/XMLHttpRequest.h
@@ -26,11 +26,11 @@
#include "EventTarget.h"
#include "FormData.h"
#include "ResourceResponse.h"
-#include "ScriptString.h"
#include "ThreadableLoaderClient.h"
#include "XMLHttpRequestProgressEventThrottle.h"
#include <wtf/OwnPtr.h>
#include <wtf/text/AtomicStringHash.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -89,8 +89,8 @@ public:
void overrideMimeType(const String& override);
String getAllResponseHeaders(ExceptionCode&) const;
String getResponseHeader(const AtomicString& name, ExceptionCode&) const;
- const ScriptString& responseText(ExceptionCode&) const;
- Document* responseXML(ExceptionCode&) const;
+ String responseText(ExceptionCode&);
+ Document* responseXML(ExceptionCode&);
#if ENABLE(XHR_RESPONSE_BLOB)
Blob* responseBlob(ExceptionCode&) const;
#endif
@@ -176,13 +176,7 @@ private:
RefPtr<TextResourceDecoder> m_decoder;
- // Unlike most strings in the DOM, we keep this as a ScriptString, not a WTF::String.
- // That's because these strings can easily get huge (they are filled from the network with
- // no parsing) and because JS can easily observe many intermediate states, so it's very useful
- // to be able to share the buffer with JavaScript versions of the whole or partial string.
- // In contrast, this string doesn't interact much with the rest of the engine so it's not that
- // big a cost that it isn't a String.
- ScriptString m_responseText;
+ StringBuilder m_responseBuilder;
mutable bool m_createdDocument;
mutable RefPtr<Document> m_responseXML;
diff --git a/WebCore/xml/XPathParser.cpp b/WebCore/xml/XPathParser.cpp
index 20e7590..c242a5c 100644
--- a/WebCore/xml/XPathParser.cpp
+++ b/WebCore/xml/XPathParser.cpp
@@ -410,6 +410,10 @@ Parser::Parser()
reset(String());
}
+Parser::~Parser()
+{
+}
+
void Parser::reset(const String& data)
{
m_nextPos = 0;
diff --git a/WebCore/xml/XPathParser.h b/WebCore/xml/XPathParser.h
index e779603..44a8e48 100644
--- a/WebCore/xml/XPathParser.h
+++ b/WebCore/xml/XPathParser.h
@@ -61,6 +61,7 @@ namespace WebCore {
class Parser : public Noncopyable {
public:
Parser();
+ ~Parser();
XPathNSResolver* resolver() const { return m_resolver.get(); }
bool expandQName(const String& qName, String& localName, String& namespaceURI);
diff --git a/WebCore/xml/XPathStep.cpp b/WebCore/xml/XPathStep.cpp
index 6e60952..ddd8c3c 100644
--- a/WebCore/xml/XPathStep.cpp
+++ b/WebCore/xml/XPathStep.cpp
@@ -255,11 +255,11 @@ void Step::nodesInAxis(Node* context, NodeSet& nodes) const
return;
case ParentAxis:
if (context->isAttributeNode()) {
- Node* n = static_cast<Attr*>(context)->ownerElement();
+ Element* n = static_cast<Attr*>(context)->ownerElement();
if (nodeMatches(n, ParentAxis, m_nodeTest))
nodes.append(n);
} else {
- Node* n = context->parentNode();
+ ContainerNode* n = context->parentNode();
if (n && nodeMatches(n, ParentAxis, m_nodeTest))
nodes.append(n);
}