| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 static inline AtomicString toAtomicString(const xmlChar* string, size_t length) | 90 static inline AtomicString toAtomicString(const xmlChar* string, size_t length) |
| 91 { | 91 { |
| 92 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string), length)
; | 92 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string), length)
; |
| 93 } | 93 } |
| 94 | 94 |
| 95 static inline AtomicString toAtomicString(const xmlChar* string) | 95 static inline AtomicString toAtomicString(const xmlChar* string) |
| 96 { | 96 { |
| 97 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string)); | 97 return AtomicString::fromUTF8(reinterpret_cast<const char*>(string)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 static inline bool hasNoStyleInformation(Document* document) |
| 101 { |
| 102 if (document->sawElementsInKnownNamespaces() || document->transformSourceDoc
ument()) |
| 103 return false; |
| 104 |
| 105 if (!document->frame() || !document->frame()->page()) |
| 106 return false; |
| 107 |
| 108 if (document->frame()->tree()->parent()) |
| 109 return false; // This document is not in a top frame |
| 110 |
| 111 return true; |
| 112 } |
| 113 |
| 100 class PendingStartElementNSCallback FINAL : public XMLDocumentParser::PendingCal
lback { | 114 class PendingStartElementNSCallback FINAL : public XMLDocumentParser::PendingCal
lback { |
| 101 public: | 115 public: |
| 102 PendingStartElementNSCallback(const AtomicString& localName, const AtomicStr
ing& prefix, const AtomicString& uri, | 116 PendingStartElementNSCallback(const AtomicString& localName, const AtomicStr
ing& prefix, const AtomicString& uri, |
| 103 int namespaceCount, const xmlChar** namespaces, int attributeCount, int
defaultedCount, const xmlChar** attributes) | 117 int namespaceCount, const xmlChar** namespaces, int attributeCount, int
defaultedCount, const xmlChar** attributes) |
| 104 : m_localName(localName) | 118 : m_localName(localName) |
| 105 , m_prefix(prefix) | 119 , m_prefix(prefix) |
| 106 , m_uri(uri) | 120 , m_uri(uri) |
| 107 , m_namespaceCount(namespaceCount) | 121 , m_namespaceCount(namespaceCount) |
| 108 , m_attributeCount(attributeCount) | 122 , m_attributeCount(attributeCount) |
| 109 , m_defaultedCount(defaultedCount) | 123 , m_defaultedCount(defaultedCount) |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 // Tell libxml we're done. | 1446 // Tell libxml we're done. |
| 1433 { | 1447 { |
| 1434 XMLDocumentParserScope scope(document()->fetcher()); | 1448 XMLDocumentParserScope scope(document()->fetcher()); |
| 1435 finishParsing(context()); | 1449 finishParsing(context()); |
| 1436 } | 1450 } |
| 1437 | 1451 |
| 1438 m_context = 0; | 1452 m_context = 0; |
| 1439 } | 1453 } |
| 1440 } | 1454 } |
| 1441 | 1455 |
| 1442 XMLTreeViewer xmlTreeViewer(document()); | 1456 bool xmlViewerMode = !m_sawError && !m_sawCSS && !m_sawXSLTransform && hasNo
StyleInformation(document()); |
| 1443 bool xmlViewerMode = !m_sawError && !m_sawCSS && !m_sawXSLTransform && xmlTr
eeViewer.hasNoStyleInformation(); | |
| 1444 if (xmlViewerMode) { | 1457 if (xmlViewerMode) { |
| 1458 XMLTreeViewer xmlTreeViewer(document()); |
| 1445 xmlTreeViewer.transformDocumentToTreeView(); | 1459 xmlTreeViewer.transformDocumentToTreeView(); |
| 1446 } else if (m_sawXSLTransform) { | 1460 } else if (m_sawXSLTransform) { |
| 1447 xmlDocPtr doc = xmlDocPtrForString(document()->fetcher(), m_originalSour
ceForTransform.toString(), document()->url().string()); | 1461 xmlDocPtr doc = xmlDocPtrForString(document()->fetcher(), m_originalSour
ceForTransform.toString(), document()->url().string()); |
| 1448 document()->setTransformSource(adoptPtr(new TransformSource(doc))); | 1462 document()->setTransformSource(adoptPtr(new TransformSource(doc))); |
| 1449 | 1463 |
| 1450 document()->setParsing(false); // Make the document think it's done, so
it will apply XSL stylesheets. | 1464 document()->setParsing(false); // Make the document think it's done, so
it will apply XSL stylesheets. |
| 1451 document()->styleResolverChanged(RecalcStyleImmediately); | 1465 document()->styleResolverChanged(RecalcStyleImmediately); |
| 1452 | 1466 |
| 1453 // styleResolverChanged() call can detach the parser and null out its do
cument. | 1467 // styleResolverChanged() call can detach the parser and null out its do
cument. |
| 1454 // In that case, we just bail out. | 1468 // In that case, we just bail out. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 sax.initialized = XML_SAX2_MAGIC; | 1615 sax.initialized = XML_SAX2_MAGIC; |
| 1602 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); | 1616 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax,
&state); |
| 1603 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1617 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1604 parseChunk(parser->context(), parseString); | 1618 parseChunk(parser->context(), parseString); |
| 1605 finishParsing(parser->context()); | 1619 finishParsing(parser->context()); |
| 1606 attrsOK = state.gotAttributes; | 1620 attrsOK = state.gotAttributes; |
| 1607 return state.attributes; | 1621 return state.attributes; |
| 1608 } | 1622 } |
| 1609 | 1623 |
| 1610 } // namespace WebCore | 1624 } // namespace WebCore |
| OLD | NEW |