diff options
author | Steve Block <steveblock@google.com> | 2010-09-29 17:32:26 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-09-29 17:35:08 +0100 |
commit | 68513a70bcd92384395513322f1b801e7bf9c729 (patch) | |
tree | 161b50f75a5921d61731bb25e730005994fcec85 /WebCore/dom/XMLDocumentParserLibxml2.cpp | |
parent | fd5c6425ce58eb75211be7718d5dee960842a37e (diff) | |
download | external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.zip external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.gz external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.bz2 |
Merge WebKit at r67908: Initial merge by Git
Change-Id: I43a553e7b3299b28cb6ee8aa035ed70fe342b972
Diffstat (limited to 'WebCore/dom/XMLDocumentParserLibxml2.cpp')
-rw-r--r-- | WebCore/dom/XMLDocumentParserLibxml2.cpp | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp index 927fbbe..5539072 100644 --- a/WebCore/dom/XMLDocumentParserLibxml2.cpp +++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp @@ -1,11 +1,12 @@ /* - * Copyright (C) 2000 Peter Kelly (pmk@post.com) + * Copyright (C) 2000 Peter Kelly <pmk@post.com> * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) + * Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> + * Copyright (C) 2007 Samuel Weinig <sam@webkit.org> * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2008 Holger Hans Peter Freyther * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -671,17 +672,26 @@ void XMLDocumentParser::doWrite(const String& parseString) } } -static inline String toString(const xmlChar* str, unsigned len) +static inline String toString(const xmlChar* string, size_t size) { - return UTF8Encoding().decode(reinterpret_cast<const char*>(str), len); + return String::fromUTF8(reinterpret_cast<const char*>(string), size); } -static inline String toString(const xmlChar* str) +static inline String toString(const xmlChar* string) { - if (!str) - return String(); + return String::fromUTF8(reinterpret_cast<const char*>(string)); +} - return UTF8Encoding().decode(reinterpret_cast<const char*>(str), strlen(reinterpret_cast<const char*>(str))); +static inline AtomicString toAtomicString(const xmlChar* string, size_t size) +{ + // FIXME: Use AtomicString::fromUTF8. + return AtomicString(toString(string, size)); +} + +static inline AtomicString toAtomicString(const xmlChar* string) +{ + // FIXME: Use AtomicString::fromUTF8. + return AtomicString(toString(string)); } struct _xmlSAX2Namespace { @@ -695,7 +705,7 @@ static inline void handleElementNamespaces(Element* newElement, const xmlChar** xmlSAX2Namespace* namespaces = reinterpret_cast<xmlSAX2Namespace*>(libxmlNamespaces); for (int i = 0; i < nb_namespaces; i++) { AtomicString namespaceQName = xmlnsAtom; - String namespaceURI = toString(namespaces[i].uri); + AtomicString namespaceURI = toAtomicString(namespaces[i].uri); if (namespaces[i].prefix) namespaceQName = "xmlns:" + toString(namespaces[i].prefix); newElement->setAttributeNS(XMLNSNames::xmlnsNamespaceURI, namespaceQName, namespaceURI, ec, scriptingPermission); @@ -717,12 +727,11 @@ static inline void handleElementAttributes(Element* newElement, const xmlChar** { xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlAttributes); for (int i = 0; i < nb_attributes; i++) { - String attrLocalName = toString(attributes[i].localname); - int valueLength = (int) (attributes[i].end - attributes[i].value); - String attrValue = toString(attributes[i].value, valueLength); + int valueLength = static_cast<int>(attributes[i].end - attributes[i].value); + AtomicString attrValue = toAtomicString(attributes[i].value, valueLength); String attrPrefix = toString(attributes[i].prefix); - String attrURI = attrPrefix.isEmpty() ? String() : toString(attributes[i].uri); - String attrQName = attrPrefix.isEmpty() ? attrLocalName : attrPrefix + ":" + attrLocalName; + AtomicString attrURI = attrPrefix.isEmpty() ? AtomicString() : toAtomicString(attributes[i].uri); + AtomicString attrQName = attrPrefix.isEmpty() ? toAtomicString(attributes[i].localname) : AtomicString(attrPrefix + ":" + toString(attributes[i].localname)); newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingPermission); if (ec) // exception setting attributes @@ -752,9 +761,9 @@ void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlCha exitText(); - String localName = toString(xmlLocalName); - String uri = toString(xmlURI); - String prefix = toString(xmlPrefix); + AtomicString localName = toAtomicString(xmlLocalName); + AtomicString uri = toAtomicString(xmlURI); + AtomicString prefix = toAtomicString(xmlPrefix); if (m_parsingFragment && uri.isNull()) { if (!prefix.isNull()) |