Changeset 43842 in webkit for trunk/WebCore/dom/XMLTokenizerLibxml2.cpp
- Timestamp:
- May 18, 2009, 4:48:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/dom/XMLTokenizerLibxml2.cpp
r43663 r43842 6 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 7 * Copyright (C) 2008 Holger Hans Peter Freyther 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 9 9 * 10 10 * This library is free software; you can redistribute it and/or … … 64 64 #endif 65 65 66 #if ENABLE(XHTMLMP) 67 #include "HTMLNames.h" 68 #include "HTMLScriptElement.h" 69 #endif 70 66 71 using namespace std; 67 72 … … 527 532 , m_sawFirstElement(false) 528 533 , m_isXHTMLDocument(false) 534 #if ENABLE(XHTMLMP) 535 , m_isXHTMLMPDocument(false) 536 , m_hasDocTypeDeclaration(false) 537 #endif 529 538 , m_parserPaused(false) 530 539 , m_requestingScript(false) … … 550 559 , m_sawFirstElement(false) 551 560 , m_isXHTMLDocument(false) 561 #if ENABLE(XHTMLMP) 562 , m_isXHTMLMPDocument(false) 563 , m_hasDocTypeDeclaration(false) 564 #endif 552 565 , m_parserPaused(false) 553 566 , m_requestingScript(false) … … 705 718 } 706 719 707 bool isFirstElement = !m_sawFirstElement; 708 m_sawFirstElement = true; 720 #if ENABLE(XHTMLMP) 721 // check if the DOCTYPE Declaration of XHTMLMP document exists 722 if (!m_hasDocTypeDeclaration && m_doc->isXHTMLMPDocument()) { 723 handleError(fatal, "DOCTYPE declaration lost.", lineNumber(), columnNumber()); 724 return; 725 } 726 #endif 709 727 710 728 exitText(); … … 721 739 } 722 740 741 #if ENABLE(XHTMLMP) 742 if (!m_sawFirstElement && isXHTMLMPDocument()) { 743 // As per the section 7.1 of OMA-WAP-XHTMLMP-V1_1-20061020-A.pdf, 744 // we should make sure that the root element MUST be 'html' and 745 // ensure the name of the default namespace on the root elment 'html' 746 // MUST be 'http://www.w3.org/1999/xhtml' 747 if (localName != HTMLNames::htmlTag.localName()) { 748 handleError(fatal, "XHTMLMP document expects 'html' as root element.", lineNumber(), columnNumber()); 749 return; 750 } 751 752 if (uri.isNull()) { 753 m_defaultNamespaceURI = HTMLNames::xhtmlNamespaceURI; 754 uri = m_defaultNamespaceURI; 755 } 756 } 757 #endif 758 759 bool isFirstElement = !m_sawFirstElement; 760 m_sawFirstElement = true; 761 723 762 QualifiedName qName(prefix, localName, uri); 724 763 RefPtr<Element> newElement = m_doc->createElement(qName, true); … … 799 838 m_requestingScript = true; 800 839 801 String scriptHref = scriptElement->sourceAttributeValue(); 802 if (!scriptHref.isEmpty()) { 803 // we have a src attribute 804 String scriptCharset = scriptElement->scriptCharset(); 805 if ((m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { 806 m_scriptElement = element; 807 m_pendingScript->addClient(this); 808 809 // m_pendingScript will be 0 if script was already loaded and ref() executed it 810 if (m_pendingScript) 811 pauseParsing(); 812 } else 813 m_scriptElement = 0; 814 } else 815 m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 816 840 #if ENABLE(XHTMLMP) 841 if (!scriptElement->shouldExecuteAsJavaScript()) 842 m_doc->setShouldProcessNoscriptElement(true); 843 else 844 #endif 845 { 846 String scriptHref = scriptElement->sourceAttributeValue(); 847 if (!scriptHref.isEmpty()) { 848 // we have a src attribute 849 String scriptCharset = scriptElement->scriptCharset(); 850 if ((m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { 851 m_scriptElement = element; 852 m_pendingScript->addClient(this); 853 854 // m_pendingScript will be 0 if script was already loaded and ref() executed it 855 if (m_pendingScript) 856 pauseParsing(); 857 } else 858 m_scriptElement = 0; 859 } else 860 m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 861 } 817 862 m_requestingScript = false; 818 863 setCurrentNode(parent.get()); … … 943 988 { 944 989 exitText(); 990 #if ENABLE(XHTMLMP) 991 m_hasDocTypeDeclaration = false; 992 #endif 945 993 } 946 994 … … 956 1004 957 1005 if (m_doc) { 1006 #if ENABLE(WML) || ENABLE(XHTMLMP) 1007 String extId = toString(externalID); 1008 #endif 958 1009 #if ENABLE(WML) 959 String extId = toString(externalID);960 1010 if (isWMLDocument() 961 1011 && extId != "-//WAPFORUM//DTD WML 1.3//EN" … … 965 1015 handleError(fatal, "Invalid DTD Public ID", lineNumber(), columnNumber()); 966 1016 #endif 967 1017 #if ENABLE(XHTMLMP) 1018 String dtdName = toString(name); 1019 if (extId == "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" 1020 || extId == "-//WAPFORUM//DTD XHTML Mobile 1.1//EN") { 1021 if (dtdName != HTMLNames::htmlTag.localName()) { 1022 handleError(fatal, "Invalid DOCTYPE declaration, expected 'html' as root element.", lineNumber(), columnNumber()); 1023 return; 1024 } 1025 1026 if (m_doc->isXHTMLMPDocument()) 1027 setIsXHTMLMPDocument(true); 1028 else 1029 setIsXHTMLDocument(true); 1030 1031 m_hasDocTypeDeclaration = true; 1032 } 1033 #endif 1034 1035 #if ENABLE(XHTMLMP) 1036 m_doc->addChild(DocumentType::create(m_doc, dtdName, extId, toString(systemID))); 1037 #elif ENABLE(WML) 1038 m_doc->addChild(DocumentType::create(m_doc, toString(name), extId, toString(systemID))); 1039 #else 968 1040 m_doc->addChild(DocumentType::create(m_doc, toString(name), toString(externalID), toString(systemID))); 1041 #endif 969 1042 } 970 1043 } … … 1109 1182 ent = xmlGetDocEntity(ctxt->myDoc, name); 1110 1183 if (!ent && (getTokenizer(closure)->isXHTMLDocument() 1184 #if ENABLE(XHTMLMP) 1185 || getTokenizer(closure)->isXHTMLMPDocument() 1186 #endif 1111 1187 #if ENABLE(WML) 1112 1188 || getTokenizer(closure)->isWMLDocument() … … 1150 1226 || (extId == "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN") 1151 1227 || (extId == "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN") 1152 || (extId == "-//WAPFORUM//DTD XHTML Mobile 1.0//EN")) 1228 #if !ENABLE(XHTMLMP) 1229 || (extId == "-//WAPFORUM//DTD XHTML Mobile 1.0//EN") 1230 #endif 1231 ) 1153 1232 getTokenizer(closure)->setIsXHTMLDocument(true); // controls if we replace entities or not. 1154 1233 }
Note:
See TracChangeset
for help on using the changeset viewer.