| 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, 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2005, 2006, 2008, 2014 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. | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 const String& chunk, | 486 const String& chunk, |
| 487 DocumentFragment* fragment, | 487 DocumentFragment* fragment, |
| 488 Element* contextElement, | 488 Element* contextElement, |
| 489 ParserContentPolicy parserContentPolicy) { | 489 ParserContentPolicy parserContentPolicy) { |
| 490 if (!chunk.length()) | 490 if (!chunk.length()) |
| 491 return true; | 491 return true; |
| 492 | 492 |
| 493 // FIXME: We need to implement the HTML5 XML Fragment parsing algorithm: | 493 // FIXME: We need to implement the HTML5 XML Fragment parsing algorithm: |
| 494 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-synta
x.html#xml-fragment-parsing-algorithm | 494 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-synta
x.html#xml-fragment-parsing-algorithm |
| 495 // For now we have a hack for script/style innerHTML support: | 495 // For now we have a hack for script/style innerHTML support: |
| 496 if (contextElement && (contextElement->hasLocalName(scriptTag.localName()) || | 496 if (contextElement && |
| 497 contextElement->hasLocalName(styleTag.localName()))) { | 497 (contextElement->hasLocalName(scriptTag.localName()) || |
| 498 contextElement->hasLocalName(styleTag.localName()))) { |
| 498 fragment->parserAppendChild(fragment->document().createTextNode(chunk)); | 499 fragment->parserAppendChild(fragment->document().createTextNode(chunk)); |
| 499 return true; | 500 return true; |
| 500 } | 501 } |
| 501 | 502 |
| 502 XMLDocumentParser* parser = | 503 XMLDocumentParser* parser = |
| 503 XMLDocumentParser::create(fragment, contextElement, parserContentPolicy); | 504 XMLDocumentParser::create(fragment, contextElement, parserContentPolicy); |
| 504 bool wellFormed = parser->appendFragmentSource(chunk); | 505 bool wellFormed = parser->appendFragmentSource(chunk); |
| 505 | 506 |
| 506 // Do not call finish(). Current finish() and doEnd() implementations touch | 507 // Do not call finish(). Current finish() and doEnd() implementations touch |
| 507 // the main Document/loader and can cause crashes in the fragment case. | 508 // the main Document/loader and can cause crashes in the fragment case. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks and | 542 // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks and |
| 542 // switch encodings, causing the parse to fail. | 543 // switch encodings, causing the parse to fail. |
| 543 if (is8Bit) { | 544 if (is8Bit) { |
| 544 xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1); | 545 xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1); |
| 545 return; | 546 return; |
| 546 } | 547 } |
| 547 | 548 |
| 548 const UChar BOM = 0xFEFF; | 549 const UChar BOM = 0xFEFF; |
| 549 const unsigned char BOMHighByte = | 550 const unsigned char BOMHighByte = |
| 550 *reinterpret_cast<const unsigned char*>(&BOM); | 551 *reinterpret_cast<const unsigned char*>(&BOM); |
| 551 xmlSwitchEncoding(ctxt, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE | 552 xmlSwitchEncoding(ctxt, |
| 552 : XML_CHAR_ENCODING_UTF16BE); | 553 BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE |
| 554 : XML_CHAR_ENCODING_UTF16BE); |
| 553 } | 555 } |
| 554 | 556 |
| 555 static void parseChunk(xmlParserCtxtPtr ctxt, const String& chunk) { | 557 static void parseChunk(xmlParserCtxtPtr ctxt, const String& chunk) { |
| 556 bool is8Bit = chunk.is8Bit(); | 558 bool is8Bit = chunk.is8Bit(); |
| 557 switchEncoding(ctxt, is8Bit); | 559 switchEncoding(ctxt, is8Bit); |
| 558 if (is8Bit) | 560 if (is8Bit) |
| 559 xmlParseChunk(ctxt, reinterpret_cast<const char*>(chunk.characters8()), | 561 xmlParseChunk(ctxt, reinterpret_cast<const char*>(chunk.characters8()), |
| 560 sizeof(LChar) * chunk.length(), 0); | 562 sizeof(LChar) * chunk.length(), 0); |
| 561 else | 563 else |
| 562 xmlParseChunk(ctxt, reinterpret_cast<const char*>(chunk.characters16()), | 564 xmlParseChunk(ctxt, reinterpret_cast<const char*>(chunk.characters16()), |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 RefPtr<XMLParserContext> parser = | 1711 RefPtr<XMLParserContext> parser = |
| 1710 XMLParserContext::createStringParser(&sax, &state); | 1712 XMLParserContext::createStringParser(&sax, &state); |
| 1711 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1713 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1712 parseChunk(parser->context(), parseString); | 1714 parseChunk(parser->context(), parseString); |
| 1713 finishParsing(parser->context()); | 1715 finishParsing(parser->context()); |
| 1714 attrsOK = state.gotAttributes; | 1716 attrsOK = state.gotAttributes; |
| 1715 return state.attributes; | 1717 return state.attributes; |
| 1716 } | 1718 } |
| 1717 | 1719 |
| 1718 } // namespace blink | 1720 } // namespace blink |
| OLD | NEW |