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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "platform/network/ResourceError.h" | 65 #include "platform/network/ResourceError.h" |
66 #include "platform/network/ResourceRequest.h" | 66 #include "platform/network/ResourceRequest.h" |
67 #include "platform/network/ResourceResponse.h" | 67 #include "platform/network/ResourceResponse.h" |
68 #include "platform/weborigin/SecurityOrigin.h" | 68 #include "platform/weborigin/SecurityOrigin.h" |
69 #include "wtf/StringExtras.h" | 69 #include "wtf/StringExtras.h" |
70 #include "wtf/TemporaryChange.h" | 70 #include "wtf/TemporaryChange.h" |
71 #include "wtf/Threading.h" | 71 #include "wtf/Threading.h" |
72 #include "wtf/Vector.h" | 72 #include "wtf/Vector.h" |
73 #include "wtf/unicode/UTF8.h" | 73 #include "wtf/unicode/UTF8.h" |
74 | 74 |
75 using namespace std; | |
76 | |
77 namespace WebCore { | 75 namespace WebCore { |
78 | 76 |
79 using namespace HTMLNames; | 77 using namespace HTMLNames; |
80 | 78 |
81 // FIXME: HTMLConstructionSite has a limit of 512, should these match? | 79 // FIXME: HTMLConstructionSite has a limit of 512, should these match? |
82 static const unsigned maxXMLTreeDepth = 5000; | 80 static const unsigned maxXMLTreeDepth = 5000; |
83 | 81 |
84 static inline String toString(const xmlChar* string, size_t length) | 82 static inline String toString(const xmlChar* string, std::size_t length) |
85 { | 83 { |
86 return String::fromUTF8(reinterpret_cast<const char*>(string), length); | 84 return String::fromUTF8(reinterpret_cast<const char*>(string), length); |
87 } | 85 } |
88 | 86 |
89 static inline String toString(const xmlChar* string) | 87 static inline String toString(const xmlChar* string) |
90 { | 88 { |
91 return String::fromUTF8(reinterpret_cast<const char*>(string)); | 89 return String::fromUTF8(reinterpret_cast<const char*>(string)); |
92 } | 90 } |
93 | 91 |
94 static inline AtomicString toAtomicString(const xmlChar* string, size_t length) | 92 static inline AtomicString toAtomicString(const xmlChar* string, std::size_t len
gth) |
95 { | 93 { |
96 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string), length)
; | 94 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string), length)
; |
97 } | 95 } |
98 | 96 |
99 static inline AtomicString toAtomicString(const xmlChar* string) | 97 static inline AtomicString toAtomicString(const xmlChar* string) |
100 { | 98 { |
101 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string)); | 99 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string)); |
102 } | 100 } |
103 | 101 |
104 static inline bool hasNoStyleInformation(Document* document) | 102 static inline bool hasNoStyleInformation(Document* document) |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 { | 324 { |
327 #if !ENABLE(OILPAN) | 325 #if !ENABLE(OILPAN) |
328 if (m_currentNode && m_currentNode != document()) | 326 if (m_currentNode && m_currentNode != document()) |
329 m_currentNode->deref(); | 327 m_currentNode->deref(); |
330 #endif | 328 #endif |
331 m_currentNode = nullptr; | 329 m_currentNode = nullptr; |
332 m_leafTextNode = nullptr; | 330 m_leafTextNode = nullptr; |
333 | 331 |
334 if (m_currentNodeStack.size()) { // Aborted parsing. | 332 if (m_currentNodeStack.size()) { // Aborted parsing. |
335 #if !ENABLE(OILPAN) | 333 #if !ENABLE(OILPAN) |
336 for (size_t i = m_currentNodeStack.size() - 1; i != 0; --i) | 334 for (std::size_t i = m_currentNodeStack.size() - 1; i != 0; --i) |
337 m_currentNodeStack[i]->deref(); | 335 m_currentNodeStack[i]->deref(); |
338 if (m_currentNodeStack[0] && m_currentNodeStack[0] != document()) | 336 if (m_currentNodeStack[0] && m_currentNodeStack[0] != document()) |
339 m_currentNodeStack[0]->deref(); | 337 m_currentNodeStack[0]->deref(); |
340 #endif | 338 #endif |
341 m_currentNodeStack.clear(); | 339 m_currentNodeStack.clear(); |
342 } | 340 } |
343 } | 341 } |
344 | 342 |
345 void XMLDocumentParser::insert(const SegmentedString&) | 343 void XMLDocumentParser::insert(const SegmentedString&) |
346 { | 344 { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 static xmlEntity entity; | 1300 static xmlEntity entity; |
1303 if (!entity.type) { | 1301 if (!entity.type) { |
1304 entity.type = XML_ENTITY_DECL; | 1302 entity.type = XML_ENTITY_DECL; |
1305 entity.orig = sharedXHTMLEntityResult; | 1303 entity.orig = sharedXHTMLEntityResult; |
1306 entity.content = sharedXHTMLEntityResult; | 1304 entity.content = sharedXHTMLEntityResult; |
1307 entity.etype = XML_INTERNAL_PREDEFINED_ENTITY; | 1305 entity.etype = XML_INTERNAL_PREDEFINED_ENTITY; |
1308 } | 1306 } |
1309 return &entity; | 1307 return &entity; |
1310 } | 1308 } |
1311 | 1309 |
1312 static size_t convertUTF16EntityToUTF8(const UChar* utf16Entity, size_t numberOf
CodeUnits, char* target, size_t targetSize) | 1310 static std::size_t convertUTF16EntityToUTF8(const UChar* utf16Entity, std::size_
t numberOfCodeUnits, char* target, std::size_t targetSize) |
1313 { | 1311 { |
1314 const char* originalTarget = target; | 1312 const char* originalTarget = target; |
1315 WTF::Unicode::ConversionResult conversionResult = WTF::Unicode::convertUTF16
ToUTF8(&utf16Entity, | 1313 WTF::Unicode::ConversionResult conversionResult = WTF::Unicode::convertUTF16
ToUTF8(&utf16Entity, |
1316 utf16Entity + numberOfCodeUnits, &target, target + targetSize); | 1314 utf16Entity + numberOfCodeUnits, &target, target + targetSize); |
1317 if (conversionResult != WTF::Unicode::conversionOK) | 1315 if (conversionResult != WTF::Unicode::conversionOK) |
1318 return 0; | 1316 return 0; |
1319 | 1317 |
1320 // Even though we must pass the length, libxml expects the entity string to
be null terminated. | 1318 // Even though we must pass the length, libxml expects the entity string to
be null terminated. |
1321 ASSERT(target > originalTarget + 1); | 1319 ASSERT(target > originalTarget + 1); |
1322 *target = '\0'; | 1320 *target = '\0'; |
1323 return target - originalTarget; | 1321 return target - originalTarget; |
1324 } | 1322 } |
1325 | 1323 |
1326 static xmlEntityPtr getXHTMLEntity(const xmlChar* name) | 1324 static xmlEntityPtr getXHTMLEntity(const xmlChar* name) |
1327 { | 1325 { |
1328 UChar utf16DecodedEntity[4]; | 1326 UChar utf16DecodedEntity[4]; |
1329 size_t numberOfCodeUnits = decodeNamedEntityToUCharArray(reinterpret_cast<co
nst char*>(name), utf16DecodedEntity); | 1327 std::size_t numberOfCodeUnits = decodeNamedEntityToUCharArray(reinterpret_ca
st<const char*>(name), utf16DecodedEntity); |
1330 if (!numberOfCodeUnits) | 1328 if (!numberOfCodeUnits) |
1331 return 0; | 1329 return 0; |
1332 | 1330 |
1333 ASSERT(numberOfCodeUnits <= 4); | 1331 ASSERT(numberOfCodeUnits <= 4); |
1334 size_t entityLengthInUTF8 = convertUTF16EntityToUTF8(utf16DecodedEntity, num
berOfCodeUnits, | 1332 std::size_t entityLengthInUTF8 = convertUTF16EntityToUTF8(utf16DecodedEntity
, numberOfCodeUnits, |
1335 reinterpret_cast<char*>(sharedXHTMLEntityResult), WTF_ARRAY_LENGTH(share
dXHTMLEntityResult)); | 1333 reinterpret_cast<char*>(sharedXHTMLEntityResult), WTF_ARRAY_LENGTH(share
dXHTMLEntityResult)); |
1336 if (!entityLengthInUTF8) | 1334 if (!entityLengthInUTF8) |
1337 return 0; | 1335 return 0; |
1338 | 1336 |
1339 xmlEntityPtr entity = sharedXHTMLEntity(); | 1337 xmlEntityPtr entity = sharedXHTMLEntity(); |
1340 entity->length = entityLengthInUTF8; | 1338 entity->length = entityLengthInUTF8; |
1341 entity->name = name; | 1339 entity->name = name; |
1342 return entity; | 1340 return entity; |
1343 } | 1341 } |
1344 | 1342 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 sax.initialized = XML_SAX2_MAGIC; | 1616 sax.initialized = XML_SAX2_MAGIC; |
1619 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); | 1617 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); |
1620 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1618 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
1621 parseChunk(parser->context(), parseString); | 1619 parseChunk(parser->context(), parseString); |
1622 finishParsing(parser->context()); | 1620 finishParsing(parser->context()); |
1623 attrsOK = state.gotAttributes; | 1621 attrsOK = state.gotAttributes; |
1624 return state.attributes; | 1622 return state.attributes; |
1625 } | 1623 } |
1626 | 1624 |
1627 } // namespace WebCore | 1625 } // namespace WebCore |
OLD | NEW |