diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
commit | dd91e772430dc294e3bf478c119ef8d43c0a3358 (patch) | |
tree | 6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebCore/xml | |
parent | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff) | |
download | qtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz |
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/WebCore/xml')
-rw-r--r-- | Source/WebCore/xml/DOMWindowXML.idl | 37 | ||||
-rw-r--r-- | Source/WebCore/xml/XMLHttpRequest.cpp | 53 | ||||
-rw-r--r-- | Source/WebCore/xml/XMLHttpRequest.h | 2 | ||||
-rw-r--r-- | Source/WebCore/xml/parser/MarkupTokenBase.h | 14 | ||||
-rw-r--r-- | Source/WebCore/xml/parser/XMLToken.h | 2 | ||||
-rw-r--r-- | Source/WebCore/xml/parser/XMLTreeBuilder.cpp | 4 |
6 files changed, 49 insertions, 63 deletions
diff --git a/Source/WebCore/xml/DOMWindowXML.idl b/Source/WebCore/xml/DOMWindowXML.idl deleted file mode 100644 index e527350ca..000000000 --- a/Source/WebCore/xml/DOMWindowXML.idl +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -module window { - - interface [ - Supplemental=DOMWindow - ] DOMWindowXML { - // Mozilla has a separate XMLDocument object for XML documents. - // We just use Document for this. - attribute DocumentConstructor XMLDocument; - attribute DOMParserConstructor DOMParser; - attribute XMLSerializerConstructor XMLSerializer; - attribute XMLHttpRequestConstructor XMLHttpRequest; // Usable with the new operator - attribute XMLHttpRequestUploadConstructor XMLHttpRequestUpload; - attribute XMLHttpRequestExceptionConstructor XMLHttpRequestException; - attribute XMLHttpRequestProgressEventConstructor XMLHttpRequestProgressEvent; - attribute [Conditional=XSLT] XSLTProcessorConstructor XSLTProcessor; // Usable with the new operator - }; - -} diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp index 7ed8212ee..e3fb9d1c0 100644 --- a/Source/WebCore/xml/XMLHttpRequest.cpp +++ b/Source/WebCore/xml/XMLHttpRequest.cpp @@ -23,6 +23,7 @@ #include "XMLHttpRequest.h" #include "Blob.h" +#include "BlobData.h" #include "ContentSecurityPolicy.h" #include "CrossOriginAccessControl.h" #include "DOMFormData.h" @@ -262,12 +263,37 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec) } #if ENABLE(XHR_RESPONSE_BLOB) -Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const +Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) { if (m_responseTypeCode != ResponseTypeBlob) { ec = INVALID_STATE_ERR; return 0; } + // We always return null before DONE. + if (m_state != DONE) + return 0; + + if (!m_responseBlob.get()) { + // FIXME: This causes two (or more) unnecessary copies of the data. + // Chromium stores blob data in the browser process, so we're pulling the data + // from the network only to copy it into the renderer to copy it back to the browser. + // Ideally we'd get the blob/file-handle from the ResourceResponse directly + // instead of copying the bytes. Embedders who store blob data in the + // same process as WebCore would at least to teach BlobData to take + // a SharedBuffer, even if they don't get the Blob from the network layer directly. + OwnPtr<BlobData> blobData = BlobData::create(); + // If we errored out or got no data, we still return a blob, just an empty one. + if (m_binaryResponseBuilder.get()) { + RefPtr<RawData> rawData = RawData::create(); + size_t size = m_binaryResponseBuilder->size(); + rawData->mutableData()->append(m_binaryResponseBuilder->data(), size); + blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile); + blobData->setContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect. + m_binaryResponseBuilder.clear(); + } + m_responseBlob = Blob::create(blobData.release(), m_binaryResponseBuilder.get() ? m_binaryResponseBuilder->size() : 0); + } + return m_responseBlob.get(); } #endif @@ -287,10 +313,7 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec) m_binaryResponseBuilder.clear(); } - if (m_responseArrayBuffer.get()) - return m_responseArrayBuffer.get(); - - return 0; + return m_responseArrayBuffer.get(); } void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec) @@ -530,7 +553,7 @@ void XMLHttpRequest::send(Document* document, ExceptionCode& ec) if (!initSend(ec)) return; - if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { #if ENABLE(DASHBOARD_SUPPORT) @@ -561,7 +584,7 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec) if (!initSend(ec)) return; - if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { #if ENABLE(DASHBOARD_SUPPORT) @@ -588,7 +611,7 @@ void XMLHttpRequest::send(Blob* body, ExceptionCode& ec) if (!initSend(ec)) return; - if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { // FIXME: Should we set a Content-Type if one is not set. // FIXME: add support for uploading bundles. m_requestEntityBody = FormData::create(); @@ -608,7 +631,7 @@ void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) if (!initSend(ec)) return; - if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document()); // We need to ask the client to provide the generated file names if needed. When FormData fills the element @@ -631,7 +654,7 @@ void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec) if (!initSend(ec)) return; - if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::create(body->data(), body->byteLength()); if (m_upload) m_requestEntityBody->setAlwaysStream(true); @@ -1033,10 +1056,6 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) m_responseBuilder.shrinkToFit(); -#if ENABLE(XHR_RESPONSE_BLOB) - // FIXME: Set m_responseBlob to something here in the ResponseTypeBlob case. -#endif - InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(scriptExecutionContext(), identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber); bool hadLoader = m_loader; @@ -1106,7 +1125,11 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) if (useDecoder) m_responseBuilder.append(m_decoder->decode(data, len)); - else if (m_responseTypeCode == ResponseTypeArrayBuffer) { + else if (m_responseTypeCode == ResponseTypeArrayBuffer +#if ENABLE(XHR_RESPONSE_BLOB) + || m_responseTypeCode == ResponseTypeBlob +#endif + ) { // Buffer binary data. if (!m_binaryResponseBuilder) m_binaryResponseBuilder = SharedBuffer::create(); diff --git a/Source/WebCore/xml/XMLHttpRequest.h b/Source/WebCore/xml/XMLHttpRequest.h index 26ee65ceb..1373fe7bf 100644 --- a/Source/WebCore/xml/XMLHttpRequest.h +++ b/Source/WebCore/xml/XMLHttpRequest.h @@ -106,7 +106,7 @@ public: Document* responseXML(ExceptionCode&); Document* optionalResponseXML() const { return m_responseDocument.get(); } #if ENABLE(XHR_RESPONSE_BLOB) - Blob* responseBlob(ExceptionCode&) const; + Blob* responseBlob(ExceptionCode&); Blob* optionalResponseBlob() const { return m_responseBlob.get(); } #endif diff --git a/Source/WebCore/xml/parser/MarkupTokenBase.h b/Source/WebCore/xml/parser/MarkupTokenBase.h index 986538b8d..2a0aa3050 100644 --- a/Source/WebCore/xml/parser/MarkupTokenBase.h +++ b/Source/WebCore/xml/parser/MarkupTokenBase.h @@ -27,7 +27,7 @@ #ifndef MarkupTokenBase_h #define MarkupTokenBase_h -#include "NamedNodeMap.h" +#include "ElementAttributeData.h" #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> @@ -410,7 +410,7 @@ public: } } - AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, PassOwnPtr<NamedNodeMap> attributes = nullptr) + AtomicMarkupTokenBase(typename Token::Type::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr) : m_type(type) , m_name(name) , m_attributes(attributes) @@ -446,13 +446,13 @@ public: return m_attributes->getAttributeItem(attributeName); } - NamedNodeMap* attributes() const + AttributeVector* attributes() const { ASSERT(usesAttributes()); return m_attributes.get(); } - PassOwnPtr<NamedNodeMap> takeAttributes() + PassOwnPtr<AttributeVector> takeAttributes() { ASSERT(usesAttributes()); return m_attributes.release(); @@ -516,7 +516,7 @@ protected: // For StartTag and EndTag bool m_selfClosing; - OwnPtr<NamedNodeMap> m_attributes; + OwnPtr<AttributeVector> m_attributes; }; template<typename Token> @@ -526,7 +526,7 @@ inline void AtomicMarkupTokenBase<Token>::initializeAttributes(const typename To if (!size) return; - m_attributes = NamedNodeMap::create(); + m_attributes = AttributeVector::create(); m_attributes->reserveInitialCapacity(size); for (size_t i = 0; i < size; ++i) { const typename Token::Attribute& attribute = attributes[i]; @@ -541,7 +541,7 @@ inline void AtomicMarkupTokenBase<Token>::initializeAttributes(const typename To ASSERT(attribute.m_valueRange.m_end); AtomicString value(attribute.m_value.data(), attribute.m_value.size()); - m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value), false); + m_attributes->insertAttribute(Attribute::create(nameForAttribute(attribute), value)); } } diff --git a/Source/WebCore/xml/parser/XMLToken.h b/Source/WebCore/xml/parser/XMLToken.h index d1bdc0e6b..1ed16ca9b 100644 --- a/Source/WebCore/xml/parser/XMLToken.h +++ b/Source/WebCore/xml/parser/XMLToken.h @@ -431,7 +431,7 @@ public: } } - AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<NamedNodeMap> attributes = nullptr) + AtomicXMLToken(XMLTokenTypes::Type type, AtomicString name, PassOwnPtr<AttributeVector> attributes = nullptr) : AtomicMarkupTokenBase<XMLToken>(type, name, attributes) { } diff --git a/Source/WebCore/xml/parser/XMLTreeBuilder.cpp b/Source/WebCore/xml/parser/XMLTreeBuilder.cpp index 0c2b2d6a0..81793ed6d 100644 --- a/Source/WebCore/xml/parser/XMLTreeBuilder.cpp +++ b/Source/WebCore/xml/parser/XMLTreeBuilder.cpp @@ -301,7 +301,7 @@ void XMLTreeBuilder::processNamespaces(const AtomicXMLToken& token, NodeStackIte if (!token.attributes()) return; - for (size_t i = 0; i < token.attributes()->length(); ++i) { + for (size_t i = 0; i < token.attributes()->size(); ++i) { Attribute* attribute = token.attributes()->attributeItem(i); if (attribute->name().prefix() == xmlnsAtom) stackItem.setNamespaceURI(attribute->name().localName(), attribute->value()); @@ -315,7 +315,7 @@ void XMLTreeBuilder::processAttributes(const AtomicXMLToken& token, NodeStackIte if (!token.attributes()) return; - for (size_t i = 0; i < token.attributes()->length(); ++i) { + for (size_t i = 0; i < token.attributes()->size(); ++i) { Attribute* attribute = token.attributes()->attributeItem(i); ExceptionCode ec = 0; if (attribute->name().prefix() == xmlnsAtom) |