| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2008 Holger Hans Peter Freyther | 7 * Copyright (C) 2008 Holger Hans Peter Freyther |
| 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 handleError(XMLErrors::fatal, "Encoding error", position); | 891 handleError(XMLErrors::fatal, "Encoding error", position); |
| 892 } | 892 } |
| 893 } | 893 } |
| 894 | 894 |
| 895 struct _xmlSAX2Namespace { | 895 struct _xmlSAX2Namespace { |
| 896 const xmlChar* prefix; | 896 const xmlChar* prefix; |
| 897 const xmlChar* uri; | 897 const xmlChar* uri; |
| 898 }; | 898 }; |
| 899 typedef struct _xmlSAX2Namespace xmlSAX2Namespace; | 899 typedef struct _xmlSAX2Namespace xmlSAX2Namespace; |
| 900 | 900 |
| 901 static inline void handleNamespaceAttributes(Vector<Attribute>& prefixedAttribut
es, const xmlChar** libxmlNamespaces, int nbNamespaces, ExceptionState& es) | 901 static inline void handleNamespaceAttributes(Vector<Attribute>& prefixedAttribut
es, const xmlChar** libxmlNamespaces, int nbNamespaces, ExceptionState& exceptio
nState) |
| 902 { | 902 { |
| 903 xmlSAX2Namespace* namespaces = reinterpret_cast<xmlSAX2Namespace*>(libxmlNam
espaces); | 903 xmlSAX2Namespace* namespaces = reinterpret_cast<xmlSAX2Namespace*>(libxmlNam
espaces); |
| 904 for (int i = 0; i < nbNamespaces; i++) { | 904 for (int i = 0; i < nbNamespaces; i++) { |
| 905 AtomicString namespaceQName = xmlnsAtom; | 905 AtomicString namespaceQName = xmlnsAtom; |
| 906 AtomicString namespaceURI = toAtomicString(namespaces[i].uri); | 906 AtomicString namespaceURI = toAtomicString(namespaces[i].uri); |
| 907 if (namespaces[i].prefix) | 907 if (namespaces[i].prefix) |
| 908 namespaceQName = "xmlns:" + toString(namespaces[i].prefix); | 908 namespaceQName = "xmlns:" + toString(namespaces[i].prefix); |
| 909 | 909 |
| 910 QualifiedName parsedName = anyName; | 910 QualifiedName parsedName = anyName; |
| 911 if (!Element::parseAttributeName(parsedName, XMLNSNames::xmlnsNamespaceU
RI, namespaceQName, es)) | 911 if (!Element::parseAttributeName(parsedName, XMLNSNames::xmlnsNamespaceU
RI, namespaceQName, exceptionState)) |
| 912 return; | 912 return; |
| 913 | 913 |
| 914 prefixedAttributes.append(Attribute(parsedName, namespaceURI)); | 914 prefixedAttributes.append(Attribute(parsedName, namespaceURI)); |
| 915 } | 915 } |
| 916 } | 916 } |
| 917 | 917 |
| 918 struct _xmlSAX2Attributes { | 918 struct _xmlSAX2Attributes { |
| 919 const xmlChar* localname; | 919 const xmlChar* localname; |
| 920 const xmlChar* prefix; | 920 const xmlChar* prefix; |
| 921 const xmlChar* uri; | 921 const xmlChar* uri; |
| 922 const xmlChar* value; | 922 const xmlChar* value; |
| 923 const xmlChar* end; | 923 const xmlChar* end; |
| 924 }; | 924 }; |
| 925 typedef struct _xmlSAX2Attributes xmlSAX2Attributes; | 925 typedef struct _xmlSAX2Attributes xmlSAX2Attributes; |
| 926 | 926 |
| 927 static inline void handleElementAttributes(Vector<Attribute>& prefixedAttributes
, const xmlChar** libxmlAttributes, int nbAttributes, ExceptionState& es) | 927 static inline void handleElementAttributes(Vector<Attribute>& prefixedAttributes
, const xmlChar** libxmlAttributes, int nbAttributes, ExceptionState& exceptionS
tate) |
| 928 { | 928 { |
| 929 xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlA
ttributes); | 929 xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlA
ttributes); |
| 930 for (int i = 0; i < nbAttributes; i++) { | 930 for (int i = 0; i < nbAttributes; i++) { |
| 931 int valueLength = static_cast<int>(attributes[i].end - attributes[i].val
ue); | 931 int valueLength = static_cast<int>(attributes[i].end - attributes[i].val
ue); |
| 932 AtomicString attrValue = toAtomicString(attributes[i].value, valueLength
); | 932 AtomicString attrValue = toAtomicString(attributes[i].value, valueLength
); |
| 933 String attrPrefix = toString(attributes[i].prefix); | 933 String attrPrefix = toString(attributes[i].prefix); |
| 934 AtomicString attrURI = attrPrefix.isEmpty() ? AtomicString() : toAtomicS
tring(attributes[i].uri); | 934 AtomicString attrURI = attrPrefix.isEmpty() ? AtomicString() : toAtomicS
tring(attributes[i].uri); |
| 935 AtomicString attrQName = attrPrefix.isEmpty() ? toAtomicString(attribute
s[i].localname) : attrPrefix + ":" + toString(attributes[i].localname); | 935 AtomicString attrQName = attrPrefix.isEmpty() ? toAtomicString(attribute
s[i].localname) : attrPrefix + ":" + toString(attributes[i].localname); |
| 936 | 936 |
| 937 QualifiedName parsedName = anyName; | 937 QualifiedName parsedName = anyName; |
| 938 if (!Element::parseAttributeName(parsedName, attrURI, attrQName, es)) | 938 if (!Element::parseAttributeName(parsedName, attrURI, attrQName, excepti
onState)) |
| 939 return; | 939 return; |
| 940 | 940 |
| 941 prefixedAttributes.append(Attribute(parsedName, attrValue)); | 941 prefixedAttributes.append(Attribute(parsedName, attrValue)); |
| 942 } | 942 } |
| 943 } | 943 } |
| 944 | 944 |
| 945 void XMLDocumentParser::startElementNs(const AtomicString& localName, const Atom
icString& prefix, const AtomicString& uri, int nbNamespaces, | 945 void XMLDocumentParser::startElementNs(const AtomicString& localName, const Atom
icString& prefix, const AtomicString& uri, int nbNamespaces, |
| 946 const xmlChar** libxmlNamespaces, int nbAttributes, int nbDefaulted, const x
mlChar** libxmlAttributes) | 946 const xmlChar** libxmlNamespaces, int nbAttributes, int nbDefaulted, const x
mlChar** libxmlAttributes) |
| 947 { | 947 { |
| 948 if (isStopped()) | 948 if (isStopped()) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 968 m_sawFirstElement = true; | 968 m_sawFirstElement = true; |
| 969 | 969 |
| 970 QualifiedName qName(prefix, localName, adjustedURI); | 970 QualifiedName qName(prefix, localName, adjustedURI); |
| 971 RefPtr<Element> newElement = m_currentNode->document().createElement(qName,
true); | 971 RefPtr<Element> newElement = m_currentNode->document().createElement(qName,
true); |
| 972 if (!newElement) { | 972 if (!newElement) { |
| 973 stopParsing(); | 973 stopParsing(); |
| 974 return; | 974 return; |
| 975 } | 975 } |
| 976 | 976 |
| 977 Vector<Attribute> prefixedAttributes; | 977 Vector<Attribute> prefixedAttributes; |
| 978 TrackExceptionState es; | 978 TrackExceptionState exceptionState; |
| 979 handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, nbNamespaces
, es); | 979 handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, nbNamespaces
, exceptionState); |
| 980 if (es.hadException()) { | 980 if (exceptionState.hadException()) { |
| 981 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy(
)); | 981 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy(
)); |
| 982 stopParsing(); | 982 stopParsing(); |
| 983 return; | 983 return; |
| 984 } | 984 } |
| 985 | 985 |
| 986 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes,
es); | 986 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes,
exceptionState); |
| 987 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy()); | 987 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy()); |
| 988 if (es.hadException()) { | 988 if (exceptionState.hadException()) { |
| 989 stopParsing(); | 989 stopParsing(); |
| 990 return; | 990 return; |
| 991 } | 991 } |
| 992 | 992 |
| 993 newElement->beginParsingChildren(); | 993 newElement->beginParsingChildren(); |
| 994 | 994 |
| 995 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(newElement.get()); | 995 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(newElement.get()); |
| 996 if (scriptLoader) | 996 if (scriptLoader) |
| 997 m_scriptStartPosition = textPosition(); | 997 m_scriptStartPosition = textPosition(); |
| 998 | 998 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 return; | 1135 return; |
| 1136 | 1136 |
| 1137 if (m_parserPaused) { | 1137 if (m_parserPaused) { |
| 1138 m_pendingCallbacks.append(adoptPtr(new PendingProcessingInstructionCallb
ack(target ,data))); | 1138 m_pendingCallbacks.append(adoptPtr(new PendingProcessingInstructionCallb
ack(target ,data))); |
| 1139 return; | 1139 return; |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 exitText(); | 1142 exitText(); |
| 1143 | 1143 |
| 1144 // ### handle exceptions | 1144 // ### handle exceptions |
| 1145 TrackExceptionState es; | 1145 TrackExceptionState exceptionState; |
| 1146 RefPtr<ProcessingInstruction> pi = m_currentNode->document().createProcessin
gInstruction(target, data, es); | 1146 RefPtr<ProcessingInstruction> pi = m_currentNode->document().createProcessin
gInstruction(target, data, exceptionState); |
| 1147 if (es.hadException()) | 1147 if (exceptionState.hadException()) |
| 1148 return; | 1148 return; |
| 1149 | 1149 |
| 1150 pi->setCreatedByParser(true); | 1150 pi->setCreatedByParser(true); |
| 1151 | 1151 |
| 1152 m_currentNode->parserAppendChild(pi.get()); | 1152 m_currentNode->parserAppendChild(pi.get()); |
| 1153 | 1153 |
| 1154 pi->finishParsingChildren(); | 1154 pi->finishParsingChildren(); |
| 1155 | 1155 |
| 1156 if (pi->isCSS()) | 1156 if (pi->isCSS()) |
| 1157 m_sawCSS = true; | 1157 m_sawCSS = true; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 sax.initialized = XML_SAX2_MAGIC; | 1634 sax.initialized = XML_SAX2_MAGIC; |
| 1635 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); | 1635 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); |
| 1636 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1636 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1637 parseChunk(parser->context(), parseString); | 1637 parseChunk(parser->context(), parseString); |
| 1638 finishParsing(parser->context()); | 1638 finishParsing(parser->context()); |
| 1639 attrsOK = state.gotAttributes; | 1639 attrsOK = state.gotAttributes; |
| 1640 return state.attributes; | 1640 return state.attributes; |
| 1641 } | 1641 } |
| 1642 | 1642 |
| 1643 } // namespace WebCore | 1643 } // namespace WebCore |
| OLD | NEW |