diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch) | |
tree | d49911209b132da58d838efa852daf28d516df21 /WebCore/xml | |
parent | 87eb0cb35bad8784770ebc807e6c982432e47107 (diff) | |
download | external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2 |
Initial Contribution
Diffstat (limited to 'WebCore/xml')
-rw-r--r-- | WebCore/xml/DOMParser.h | 8 | ||||
-rw-r--r-- | WebCore/xml/NativeXPathNSResolver.h | 7 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequest.cpp | 125 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequest.h | 26 | ||||
-rw-r--r-- | WebCore/xml/XMLSerializer.h | 6 | ||||
-rw-r--r-- | WebCore/xml/XPathEvaluator.cpp | 2 | ||||
-rw-r--r-- | WebCore/xml/XPathEvaluator.h | 7 | ||||
-rw-r--r-- | WebCore/xml/XPathExpression.cpp | 4 | ||||
-rw-r--r-- | WebCore/xml/XPathExpression.h | 6 | ||||
-rw-r--r-- | WebCore/xml/XPathFunctions.cpp | 6 | ||||
-rw-r--r-- | WebCore/xml/XPathNSResolver.h | 3 | ||||
-rw-r--r-- | WebCore/xml/XPathResult.h | 4 | ||||
-rw-r--r-- | WebCore/xml/XPathValue.cpp | 2 | ||||
-rw-r--r-- | WebCore/xml/XPathValue.h | 23 | ||||
-rw-r--r-- | WebCore/xml/XSLImportRule.cpp | 6 | ||||
-rw-r--r-- | WebCore/xml/XSLStyleSheet.cpp | 10 | ||||
-rw-r--r-- | WebCore/xml/XSLStyleSheet.h | 4 | ||||
-rw-r--r-- | WebCore/xml/XSLTProcessor.cpp | 14 | ||||
-rw-r--r-- | WebCore/xml/XSLTProcessor.h | 7 |
19 files changed, 123 insertions, 147 deletions
diff --git a/WebCore/xml/DOMParser.h b/WebCore/xml/DOMParser.h index 5036d22..2097a6e 100644 --- a/WebCore/xml/DOMParser.h +++ b/WebCore/xml/DOMParser.h @@ -1,4 +1,5 @@ /* + * This file is part of the KDE libraries * Copyright (C) 2003, 2006 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or @@ -23,19 +24,12 @@ #include "Document.h" namespace WebCore { - class String; class DOMParser : public RefCounted<DOMParser> { public: - static PassRefPtr<DOMParser> create() { return adoptRef(new DOMParser); } - PassRefPtr<Document> parseFromString(const String& str, const String& contentType); - - private: - DOMParser() { } }; - } #endif // XMLSerializer.h diff --git a/WebCore/xml/NativeXPathNSResolver.h b/WebCore/xml/NativeXPathNSResolver.h index 212b929..c3070d8 100644 --- a/WebCore/xml/NativeXPathNSResolver.h +++ b/WebCore/xml/NativeXPathNSResolver.h @@ -29,20 +29,21 @@ #if ENABLE(XPATH) #include "XPathNSResolver.h" -#include "Node.h" +#include <wtf/Forward.h> #include <wtf/RefPtr.h> namespace WebCore { + class Node; + class NativeXPathNSResolver : public XPathNSResolver { public: - static PassRefPtr<NativeXPathNSResolver> create(PassRefPtr<Node> node) { return adoptRef(new NativeXPathNSResolver(node)); } + NativeXPathNSResolver(PassRefPtr<Node>); virtual ~NativeXPathNSResolver(); virtual String lookupNamespaceURI(const String& prefix); private: - NativeXPathNSResolver(PassRefPtr<Node>); RefPtr<Node> m_node; }; diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp index fcaa37d..7413f72 100644 --- a/WebCore/xml/XMLHttpRequest.cpp +++ b/WebCore/xml/XMLHttpRequest.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. + * This file is part of the KDE libraries + * Copyright (C) 2004, 2006 Apple Computer, Inc. * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> * Copyright (C) 2007 Julien Chaffraix <julien.chaffraix@gmail.com> * @@ -22,20 +23,31 @@ #include "XMLHttpRequest.h" #include "CString.h" +#include "Cache.h" #include "DOMImplementation.h" #include "Event.h" #include "EventException.h" #include "EventListener.h" #include "EventNames.h" +#include "ExceptionCode.h" +#include "FormData.h" #include "Frame.h" #include "FrameLoader.h" +#include "HTMLDocument.h" #include "HTTPParsers.h" #include "Page.h" +#include "PlatformString.h" +#include "RegularExpression.h" +#include "ResourceHandle.h" +#include "ResourceRequest.h" #include "Settings.h" #include "SubresourceLoader.h" +#include "TextEncoding.h" #include "TextResourceDecoder.h" #include "XMLHttpRequestException.h" #include "kjs_binding.h" +#include <kjs/protect.h> +#include <wtf/Vector.h> namespace WebCore { @@ -156,7 +168,7 @@ Document* XMLHttpRequest::getResponseXML(ExceptionCode& ec) const } else { m_responseXML = m_doc->implementation()->createDocument(0); m_responseXML->open(); - m_responseXML->setURL(m_url); + m_responseXML->setURL(m_url.deprecatedString()); // FIXME: set Last-Modified and cookies (currently, those are only available for HTMLDocuments). m_responseXML->write(String(m_responseText)); m_responseXML->finishParsing(); @@ -300,10 +312,13 @@ bool XMLHttpRequest::urlMatchesDocumentDomain(const KURL& url) const { // a local file can load anything if (m_doc->isAllowedToLoadLocalResources()) +#ifdef ANDROID_FILE_SECURITY + if (FrameLoader::shouldTreatURLAsLocal(url.string())) +#endif return true; // but a remote document can only load from the same port on the server - KURL documentURL(m_doc->url()); + KURL documentURL = m_doc->url(); if (documentURL.protocol().lower() == url.protocol().lower() && documentURL.host().lower() == url.host().lower() && documentURL.port() == url.port()) @@ -314,9 +329,7 @@ bool XMLHttpRequest::urlMatchesDocumentDomain(const KURL& url) const void XMLHttpRequest::open(const String& method, const KURL& url, bool async, ExceptionCode& ec) { - internalAbort(); - XMLHttpRequestState previousState = m_state; - m_state = Uninitialized; + abort(); m_aborted = false; // clear stuff from possible previous load @@ -355,26 +368,19 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc || methodUpper == "INDEX" || methodUpper == "LOCK" || methodUpper == "M-POST" || methodUpper == "MKCOL" || methodUpper == "MOVE" || methodUpper == "OPTIONS" || methodUpper == "POST" || methodUpper == "PROPFIND" || methodUpper == "PROPPATCH" || methodUpper == "PUT" || methodUpper == "UNLOCK") - m_method = methodUpper; + m_method = methodUpper.deprecatedString(); else - m_method = method; + m_method = method.deprecatedString(); m_async = async; - ASSERT(!m_loader); - - // Check previous state to avoid dispatching readyState event - // when calling open several times in a row. - if (previousState != Open) - changeState(Open); - else - m_state = Open; + changeState(Open); } void XMLHttpRequest::open(const String& method, const KURL& url, bool async, const String& user, ExceptionCode& ec) { KURL urlWithCredentials(url); - urlWithCredentials.setUser(user); + urlWithCredentials.setUser(user.deprecatedString()); open(method, urlWithCredentials, async, ec); } @@ -382,8 +388,8 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, con void XMLHttpRequest::open(const String& method, const KURL& url, bool async, const String& user, const String& password, ExceptionCode& ec) { KURL urlWithCredentials(url); - urlWithCredentials.setUser(user); - urlWithCredentials.setPass(password); + urlWithCredentials.setUser(user.deprecatedString()); + urlWithCredentials.setPass(password.deprecatedString()); open(method, urlWithCredentials, async, ec); } @@ -393,16 +399,20 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec) if (!m_doc) return; - if (m_state != Open || m_loader) { + if (m_state != Open) { ec = INVALID_STATE_ERR; return; } + + // FIXME: Should this abort or raise an exception instead if we already have a m_loader going? + if (m_loader) + return; m_aborted = false; ResourceRequest request(m_url); request.setHTTPMethod(m_method); - + if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && (m_url.protocol().lower() == "http" || m_url.protocol().lower() == "https")) { String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { @@ -421,7 +431,8 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec) TextEncoding m_encoding(charset); if (!m_encoding.isValid()) // FIXME: report an error? m_encoding = UTF8Encoding(); - request.setHTTPBody(FormData::create(m_encoding.encode(body.characters(), body.length()))); + + request.setHTTPBody(PassRefPtr<FormData>(new FormData(m_encoding.encode(body.characters(), body.length())))); } if (m_requestHeaders.size() > 0) @@ -466,34 +477,16 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec) ref(); KJS::JSLock lock; - gcProtectNullTolerant(ScriptInterpreter::getDOMObject(this)); + KJS::gcProtectNullTolerant(KJS::ScriptInterpreter::getDOMObject(this)); } } void XMLHttpRequest::abort() { - bool sendFlag = m_loader; - - internalAbort(); - - // Clear headers as required by the spec - m_requestHeaders.clear(); - - if ((m_state <= Open && !sendFlag) || m_state == Loaded) - m_state = Uninitialized; - else { - ASSERT(!m_loader); - changeState(Loaded); - m_state = Uninitialized; - } -} - -void XMLHttpRequest::internalAbort() -{ bool hadLoader = m_loader; m_aborted = true; - + if (hadLoader) { m_loader->cancel(); m_loader = 0; @@ -503,13 +496,15 @@ void XMLHttpRequest::internalAbort() if (hadLoader) dropProtection(); + + m_state = Uninitialized; } void XMLHttpRequest::dropProtection() { { KJS::JSLock lock; - KJS::JSValue* wrapper = ScriptInterpreter::getDOMObject(this); + KJS::JSValue* wrapper = KJS::ScriptInterpreter::getDOMObject(this); KJS::gcUnprotectNullTolerant(wrapper); // the XHR object itself holds on to the responseText, and @@ -533,7 +528,7 @@ void XMLHttpRequest::overrideMIMEType(const String& override) void XMLHttpRequest::setRequestHeader(const String& name, const String& value, ExceptionCode& ec) { - if (m_state != Open || m_loader) { + if (m_state != Open) { Settings* settings = m_doc ? m_doc->settings() : 0; if (settings && settings->usesDashboardBackwardCompatibilityMode()) return; @@ -625,36 +620,38 @@ bool XMLHttpRequest::responseIsXML() const int XMLHttpRequest::getStatus(ExceptionCode& ec) const { - if (m_response.httpStatusCode()) - return m_response.httpStatusCode(); - - if (m_state == Open) { - // Firefox only raises an exception in this state; we match it. - // Note the case of local file requests, where we have no HTTP response code! Firefox never raises an exception for those, but we match HTTP case for consistency. - ec = INVALID_STATE_ERR; + if (m_state == Uninitialized) + return 0; + + if (m_response.httpStatusCode() == 0) { + if (m_state != Receiving && m_state != Loaded) + // status MUST be available in these states, but we don't get any headers from non-HTTP requests + ec = INVALID_STATE_ERR; } - return 0; + return m_response.httpStatusCode(); } String XMLHttpRequest::getStatusText(ExceptionCode& ec) const { - // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=3547> XMLHttpRequest.statusText returns always "OK". - if (m_response.httpStatusCode()) - return "OK"; - - if (m_state == Open) { - // See comments in getStatus() above. - ec = INVALID_STATE_ERR; + if (m_state == Uninitialized) + return ""; + + if (m_response.httpStatusCode() == 0) { + if (m_state != Receiving && m_state != Loaded) + // statusText MUST be available in these states, but we don't get any headers from non-HTTP requests + ec = INVALID_STATE_ERR; + return String(); } - return String(); + // FIXME: should try to preserve status text in response + return "OK"; } void XMLHttpRequest::processSyncLoadResults(const Vector<char>& data, const ResourceResponse& response) { if (!urlMatchesDocumentDomain(response.url())) { - internalAbort(); + abort(); return; } @@ -707,7 +704,7 @@ void XMLHttpRequest::didFinishLoading(SubresourceLoader* loader) void XMLHttpRequest::willSendRequest(SubresourceLoader*, ResourceRequest& request, const ResourceResponse& redirectResponse) { if (!urlMatchesDocumentDomain(request.url())) - internalAbort(); + abort(); } void XMLHttpRequest::didReceiveResponse(SubresourceLoader*, const ResourceResponse& response) @@ -770,7 +767,7 @@ void XMLHttpRequest::cancelRequests(Document* m_doc) RequestsSet copy = *requests; RequestsSet::const_iterator end = copy.end(); for (RequestsSet::const_iterator it = copy.begin(); it != end; ++it) - (*it)->internalAbort(); + (*it)->abort(); } void XMLHttpRequest::detachRequests(Document* m_doc) @@ -782,7 +779,7 @@ void XMLHttpRequest::detachRequests(Document* m_doc) RequestsSet::const_iterator end = requests->end(); for (RequestsSet::const_iterator it = requests->begin(); it != end; ++it) { (*it)->m_doc = 0; - (*it)->internalAbort(); + (*it)->abort(); } delete requests; } diff --git a/WebCore/xml/XMLHttpRequest.h b/WebCore/xml/XMLHttpRequest.h index a1c7119..6a22c31 100644 --- a/WebCore/xml/XMLHttpRequest.h +++ b/WebCore/xml/XMLHttpRequest.h @@ -1,5 +1,7 @@ +// -*- c-basic-offset: 2 -*- /* - * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. + * This file is part of the KDE libraries + * Copyright (C) 2003, 2006 Apple Computer, Inc. * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com> * * This library is free software; you can redistribute it and/or @@ -21,13 +23,26 @@ #define XMLHttpRequest_h #include "EventTarget.h" +#include "HTTPHeaderMap.h" +#include "KURL.h" +#include "PlatformString.h" #include "ResourceResponse.h" +#include "StringHash.h" #include "SubresourceLoaderClient.h" +#include <kjs/ustring.h> + +#include <wtf/HashMap.h> +#include <wtf/Vector.h> namespace WebCore { -class Document; class TextResourceDecoder; +class Document; +class Event; +class EventListener; +class String; + +typedef int ExceptionCode; // these exact numeric values are important because JS expects them enum XMLHttpRequestState { @@ -40,7 +55,7 @@ enum XMLHttpRequestState { class XMLHttpRequest : public RefCounted<XMLHttpRequest>, public EventTarget, private SubresourceLoaderClient { public: - static PassRefPtr<XMLHttpRequest> create(Document *document) { return adoptRef(new XMLHttpRequest(document)); } + XMLHttpRequest(Document*); ~XMLHttpRequest(); virtual XMLHttpRequest* toXMLHttpRequest() { return this; } @@ -83,8 +98,6 @@ public: using RefCounted<XMLHttpRequest>::deref; private: - XMLHttpRequest(Document*); - virtual void refEventTarget() { ref(); } virtual void derefEventTarget() { deref(); } @@ -107,7 +120,6 @@ private: void changeState(XMLHttpRequestState newState); void callReadyStateChangeListener(); void dropProtection(); - void internalAbort(); Document* m_doc; @@ -116,7 +128,7 @@ private: EventListenersMap m_eventListeners; KURL m_url; - String m_method; + DeprecatedString m_method; HTTPHeaderMap m_requestHeaders; String m_mimeTypeOverride; bool m_async; diff --git a/WebCore/xml/XMLSerializer.h b/WebCore/xml/XMLSerializer.h index 33e94b7..34f1a05 100644 --- a/WebCore/xml/XMLSerializer.h +++ b/WebCore/xml/XMLSerializer.h @@ -1,4 +1,5 @@ /* + * This file is part of the KDE libraries * Copyright (C) 2003, 2006 Apple Computer, Inc. * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) * @@ -31,12 +32,7 @@ namespace WebCore { class XMLSerializer : public RefCounted<XMLSerializer> { public: - static PassRefPtr<XMLSerializer> create() { return adoptRef(new XMLSerializer); } - String serializeToString(Node*, ExceptionCode&); - - private: - XMLSerializer() { } }; } // namespace WebCore diff --git a/WebCore/xml/XPathEvaluator.cpp b/WebCore/xml/XPathEvaluator.cpp index 8fb203f..1707012 100644 --- a/WebCore/xml/XPathEvaluator.cpp +++ b/WebCore/xml/XPathEvaluator.cpp @@ -49,7 +49,7 @@ PassRefPtr<XPathExpression> XPathEvaluator::createExpression(const String& expre PassRefPtr<XPathNSResolver> XPathEvaluator::createNSResolver(Node* nodeResolver) { - return NativeXPathNSResolver::create(nodeResolver); + return new NativeXPathNSResolver(nodeResolver); } PassRefPtr<XPathResult> XPathEvaluator::evaluate(const String& expression, diff --git a/WebCore/xml/XPathEvaluator.h b/WebCore/xml/XPathEvaluator.h index c8e456e..03dc7db 100644 --- a/WebCore/xml/XPathEvaluator.h +++ b/WebCore/xml/XPathEvaluator.h @@ -30,7 +30,7 @@ #if ENABLE(XPATH) #include <wtf/RefCounted.h> -#include <wtf/PassRefPtr.h> +#include <wtf/Forward.h> namespace WebCore { @@ -44,15 +44,10 @@ namespace WebCore { class XPathEvaluator : public RefCounted<XPathEvaluator> { public: - static PassRefPtr<XPathEvaluator> create() { return adoptRef(new XPathEvaluator); } - PassRefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&); PassRefPtr<XPathNSResolver> createNSResolver(Node* nodeResolver); PassRefPtr<XPathResult> evaluate(const String& expression, Node* contextNode, XPathNSResolver*, unsigned short type, XPathResult*, ExceptionCode&); - - private: - XPathEvaluator() { } }; } diff --git a/WebCore/xml/XPathExpression.cpp b/WebCore/xml/XPathExpression.cpp index 446a7ad..38369f8 100644 --- a/WebCore/xml/XPathExpression.cpp +++ b/WebCore/xml/XPathExpression.cpp @@ -45,7 +45,7 @@ using namespace XPath; PassRefPtr<XPathExpression> XPathExpression::createExpression(const String& expression, XPathNSResolver* resolver, ExceptionCode& ec) { - RefPtr<XPathExpression> expr = XPathExpression::create(); + RefPtr<XPathExpression> expr = new XPathExpression; Parser parser; expr->m_topExpression = parser.parseStatement(expression, resolver, ec); @@ -75,7 +75,7 @@ PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh evaluationContext.node = contextNode; evaluationContext.size = 1; evaluationContext.position = 1; - RefPtr<XPathResult> result = XPathResult::create(eventTarget, m_topExpression->evaluate()); + RefPtr<XPathResult> result = new XPathResult(eventTarget, m_topExpression->evaluate()); evaluationContext.node = 0; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time. if (type != XPathResult::ANY_TYPE) { diff --git a/WebCore/xml/XPathExpression.h b/WebCore/xml/XPathExpression.h index a2b75d7..430e3c9 100644 --- a/WebCore/xml/XPathExpression.h +++ b/WebCore/xml/XPathExpression.h @@ -30,7 +30,7 @@ #if ENABLE(XPATH) #include <wtf/RefCounted.h> -#include <wtf/PassRefPtr.h> +#include <wtf/Forward.h> namespace WebCore { @@ -47,15 +47,11 @@ namespace WebCore { class XPathExpression : public RefCounted<XPathExpression> { public: - static PassRefPtr<XPathExpression> create() { return adoptRef(new XPathExpression); } ~XPathExpression(); - static PassRefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&); PassRefPtr<XPathResult> evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode&); private: - XPathExpression() { } - XPath::Expression* m_topExpression; }; diff --git a/WebCore/xml/XPathFunctions.cpp b/WebCore/xml/XPathFunctions.cpp index 841b436..9e12d28 100644 --- a/WebCore/xml/XPathFunctions.cpp +++ b/WebCore/xml/XPathFunctions.cpp @@ -326,7 +326,7 @@ Value FunLocalName::evaluate() const if (!node) node = evaluationContext().node.get(); - return node->localName().string(); + return node->localName().domString(); } Value FunNamespaceURI::evaluate() const @@ -345,7 +345,7 @@ Value FunNamespaceURI::evaluate() const if (!node) node = evaluationContext().node.get(); - return node->namespaceURI().string(); + return node->namespaceURI().domString(); } Value FunName::evaluate() const @@ -365,7 +365,7 @@ Value FunName::evaluate() const node = evaluationContext().node.get(); const AtomicString& prefix = node->prefix(); - return prefix.isEmpty() ? node->localName().string() : prefix + ":" + node->localName(); + return prefix.isEmpty() ? node->localName().domString() : prefix + ":" + node->localName(); } Value FunCount::evaluate() const diff --git a/WebCore/xml/XPathNSResolver.h b/WebCore/xml/XPathNSResolver.h index 04b5f80..b6120c1 100644 --- a/WebCore/xml/XPathNSResolver.h +++ b/WebCore/xml/XPathNSResolver.h @@ -39,9 +39,6 @@ namespace WebCore { public: virtual ~XPathNSResolver(); virtual String lookupNamespaceURI(const String& prefix) = 0; - - protected: - XPathNSResolver() { } }; } diff --git a/WebCore/xml/XPathResult.h b/WebCore/xml/XPathResult.h index ecd5cac..356992d 100644 --- a/WebCore/xml/XPathResult.h +++ b/WebCore/xml/XPathResult.h @@ -56,7 +56,7 @@ namespace WebCore { FIRST_ORDERED_NODE_TYPE = 9 }; - static PassRefPtr<XPathResult> create(EventTargetNode* eventTarget, const XPath::Value& value) { return adoptRef(new XPathResult(eventTarget, value)); } + XPathResult(EventTargetNode*, const XPath::Value&); ~XPathResult(); void convertTo(unsigned short type, ExceptionCode&); @@ -76,8 +76,6 @@ namespace WebCore { void invalidateIteratorState(); private: - XPathResult(EventTargetNode*, const XPath::Value&); - XPath::Value m_value; unsigned m_nodeSetPosition; XPath::NodeSet m_nodeSet; // FIXME: why duplicate the node set stored in m_value? diff --git a/WebCore/xml/XPathValue.cpp b/WebCore/xml/XPathValue.cpp index b3cad38..b21942f 100644 --- a/WebCore/xml/XPathValue.cpp +++ b/WebCore/xml/XPathValue.cpp @@ -55,7 +55,7 @@ const NodeSet& Value::toNodeSet() const NodeSet& Value::modifiableNodeSet() { if (!m_data) - m_data = ValueData::create(); + m_data = new ValueData; m_type = NodeSetValue; return m_data->m_nodeSet; diff --git a/WebCore/xml/XPathValue.h b/WebCore/xml/XPathValue.h index 7eae512..b2ad0d6 100644 --- a/WebCore/xml/XPathValue.h +++ b/WebCore/xml/XPathValue.h @@ -37,18 +37,13 @@ namespace WebCore { namespace XPath { class ValueData : public RefCounted<ValueData> { - public: - static PassRefPtr<ValueData> create() { return adoptRef(new ValueData); } - static PassRefPtr<ValueData> create(const NodeSet& nodeSet) { return adoptRef(new ValueData(nodeSet)); } - static PassRefPtr<ValueData> create(const String& string) { return adoptRef(new ValueData(string)); } + public: + ValueData() {} + ValueData(const NodeSet& nodeSet) : m_nodeSet(nodeSet) {} + ValueData(const String& string) : m_string(string) {} NodeSet m_nodeSet; String m_string; - - private: - ValueData() { } - ValueData(const NodeSet& nodeSet) : m_nodeSet(nodeSet) { } - ValueData(const String& string) : m_string(string) { } }; // Copying Value objects makes their data partially shared, so care has to be taken when dealing with copies. @@ -60,16 +55,16 @@ namespace WebCore { Value(unsigned long value) : m_type(NumberValue), m_number(value) {} Value(double value) : m_type(NumberValue), m_number(value) {} - Value(const char* value) : m_type(StringValue), m_data(ValueData::create(value)) {} - Value(const String& value) : m_type(StringValue), m_data(ValueData::create(value)) {} - Value(const NodeSet& value) : m_type(NodeSetValue), m_data(ValueData::create(value)) {} - Value(Node* value) : m_type(NodeSetValue), m_data(ValueData::create()) { m_data->m_nodeSet.append(value); } + Value(const char* value) : m_type(StringValue), m_data(new ValueData(value)) {} + Value(const String& value) : m_type(StringValue), m_data(new ValueData(value)) {} + Value(const NodeSet& value) : m_type(NodeSetValue), m_data(new ValueData(value)) {} + Value(Node* value) : m_type(NodeSetValue), m_data(new ValueData) { m_data->m_nodeSet.append(value); } // This is needed to safely implement constructing from bool - with normal function overloading, any pointer type would match. template<typename T> Value(T); static const struct AdoptTag {} adopt; - Value(NodeSet& value, const AdoptTag&) : m_type(NodeSetValue), m_data(ValueData::create()) { value.swap(m_data->m_nodeSet); } + Value(NodeSet& value, const AdoptTag&) : m_type(NodeSetValue), m_data(new ValueData) { value.swap(m_data->m_nodeSet); } Type type() const { return m_type; } diff --git a/WebCore/xml/XSLImportRule.cpp b/WebCore/xml/XSLImportRule.cpp index 2f28add..bfdec20 100644 --- a/WebCore/xml/XSLImportRule.cpp +++ b/WebCore/xml/XSLImportRule.cpp @@ -1,7 +1,7 @@ -/* +/** * This file is part of the XSL implementation. * - * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -88,7 +88,7 @@ void XSLImportRule::loadSheet() XSLStyleSheet* parentSheet = parentStyleSheet(); if (!parentSheet->href().isNull()) // use parent styleheet's URL as the base URL - absHref = KURL(KURL(parentSheet->href()), m_strHref).string(); + absHref = KURL(parentSheet->href().deprecatedString(), m_strHref.deprecatedString()).string(); // Check for a cycle in our import chain. If we encounter a stylesheet // in our parent chain with the same URL, then just bail. diff --git a/WebCore/xml/XSLStyleSheet.cpp b/WebCore/xml/XSLStyleSheet.cpp index 64c712f..22a0464 100644 --- a/WebCore/xml/XSLStyleSheet.cpp +++ b/WebCore/xml/XSLStyleSheet.cpp @@ -1,7 +1,7 @@ -/* +/** * This file is part of the XSL implementation. * - * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -190,7 +190,7 @@ void XSLStyleSheet::loadChildSheets() } if (IS_XSLT_ELEM(curr) && IS_XSLT_NAME(curr, "import")) { xmlChar* uriRef = xsltGetNsProp(curr, (const xmlChar*)"href", XSLT_NAMESPACE); - loadChildSheet(String::fromUTF8((const char*)uriRef)); + loadChildSheet(DeprecatedString::fromUtf8((const char*)uriRef)); xmlFree(uriRef); } else break; @@ -201,7 +201,7 @@ void XSLStyleSheet::loadChildSheets() while (curr) { if (curr->type == XML_ELEMENT_NODE && IS_XSLT_ELEM(curr) && IS_XSLT_NAME(curr, "include")) { xmlChar* uriRef = xsltGetNsProp(curr, (const xmlChar*)"href", XSLT_NAMESPACE); - loadChildSheet(String::fromUTF8((const char*)uriRef)); + loadChildSheet(DeprecatedString::fromUtf8((const char*)uriRef)); xmlFree(uriRef); } curr = curr->next; @@ -209,7 +209,7 @@ void XSLStyleSheet::loadChildSheets() } } -void XSLStyleSheet::loadChildSheet(const String& href) +void XSLStyleSheet::loadChildSheet(const DeprecatedString& href) { RefPtr<XSLImportRule> childRule = new XSLImportRule(this, href); append(childRule); diff --git a/WebCore/xml/XSLStyleSheet.h b/WebCore/xml/XSLStyleSheet.h index 0509cc0..43c7bed 100644 --- a/WebCore/xml/XSLStyleSheet.h +++ b/WebCore/xml/XSLStyleSheet.h @@ -1,7 +1,7 @@ /* * This file is part of the XSL implementation. * - * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2006 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -51,7 +51,7 @@ public: virtual void checkLoaded(); void loadChildSheets(); - void loadChildSheet(const String& href); + void loadChildSheet(const DeprecatedString& href); xsltStylesheetPtr compileStyleSheet(); diff --git a/WebCore/xml/XSLTProcessor.cpp b/WebCore/xml/XSLTProcessor.cpp index b8ce7f3..07efe75 100644 --- a/WebCore/xml/XSLTProcessor.cpp +++ b/WebCore/xml/XSLTProcessor.cpp @@ -1,7 +1,7 @@ -/* +/** * This file is part of the XSL implementation. * - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007 Apple, Inc. * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org> * * This library is free software; you can redistribute it and/or @@ -37,7 +37,6 @@ #include "HTMLDocument.h" #include "HTMLTokenizer.h" #include "Page.h" -#include "ResourceError.h" #include "ResourceHandle.h" #include "ResourceRequest.h" #include "ResourceResponse.h" @@ -113,7 +112,7 @@ static xmlDocPtr docLoaderFunc(const xmlChar* uri, case XSLT_LOAD_DOCUMENT: { xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); - KURL url(KURL(reinterpret_cast<const char*>(base)), reinterpret_cast<const char*>(uri)); + KURL url((const char*)base, (const char*)uri); xmlFree(base); ResourceError error; ResourceResponse response; @@ -259,6 +258,7 @@ RefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceStr result->setURL(ownerDocument->url()); result->setBaseURL(ownerDocument->baseURL()); } + result->determineParseMode(documentSource); // Make sure we parse in the correct mode. RefPtr<TextResourceDecoder> decoder = new TextResourceDecoder(sourceMIMEType); decoder->setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : TextEncoding(sourceEncoding), TextResourceDecoder::EncodingFromXMLHeader); @@ -293,8 +293,7 @@ static inline RefPtr<DocumentFragment> createFragmentFromSource(String sourceStr static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode) { if (!cachedStylesheet && stylesheetRootNode) { - cachedStylesheet = new XSLStyleSheet(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode, - stylesheetRootNode->document()->url().string()); + cachedStylesheet = new XSLStyleSheet(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode, stylesheetRootNode->document()->url()); cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); } @@ -313,8 +312,7 @@ static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) if (sourceIsDocument) sourceDoc = (xmlDocPtr)ownerDocument->transformSource(); if (!sourceDoc) { - sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->docLoader(), createMarkup(sourceNode), - sourceIsDocument ? ownerDocument->url().string() : String()); + sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->docLoader(), createMarkup(sourceNode), sourceIsDocument ? ownerDocument->url() : DeprecatedString()); shouldDelete = (sourceDoc != 0); } return sourceDoc; diff --git a/WebCore/xml/XSLTProcessor.h b/WebCore/xml/XSLTProcessor.h index f96ad15..3a92a59 100644 --- a/WebCore/xml/XSLTProcessor.h +++ b/WebCore/xml/XSLTProcessor.h @@ -38,10 +38,9 @@ class Node; class Document; class DocumentFragment; -class XSLTProcessor : public RefCounted<XSLTProcessor> { +class XSLTProcessor : public RefCounted<XSLTProcessor> +{ public: - static PassRefPtr<XSLTProcessor> create() { return adoptRef(new XSLTProcessor); } - void setXSLStylesheet(XSLStyleSheet* styleSheet) { m_stylesheet = styleSheet; } bool transformToString(Node* source, String& resultMIMEType, String& resultString, String& resultEncoding); RefPtr<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame); @@ -67,8 +66,6 @@ public: typedef HashMap<String, String> ParameterMap; private: - XSLTProcessor() { } - // Convert a libxml doc ptr to a KHTML DOM Document RefPtr<Document> documentFromXMLDocPtr(xmlDocPtr resultDoc, xsltStylesheetPtr sheet, Document* ownerDocument, bool sourceIsDocument); |