Changeset 31231 in webkit
- Timestamp:
- Mar 22, 2008 2:50:54 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r31230 r31231 1 2008-03-22 Eric Seidel <eric@webkit.org> 2 3 Reviewed by mjs. 4 5 Unify handling of NAMESPACE_ERR and fix Acid3 test 25 6 http://bugs.webkit.org/show_bug.cgi?id=16693 7 8 * fast/dom/DOMImplementation/createDocumentType-err-expected.txt: Added. 9 * fast/dom/DOMImplementation/createDocumentType-err.html: Copied from LayoutTests/fast/dom/DOMException/EventException.html. 10 * fast/dom/DOMImplementation/resources/TEMPLATE.html: Copied from LayoutTests/fast/dom/Document/resources/TEMPLATE.html. 11 * fast/dom/DOMImplementation/resources/createDocumentType-err.js: Added. 12 * fast/dom/Document/createAttributeNS-namespace-err-expected.txt: 13 * fast/dom/Document/createElementNS-namespace-err-expected.txt: 14 1 15 2008-03-22 Eric Seidel <eric@webkit.org> 2 16 -
trunk/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err-expected.txt
r31230 r31231 29 29 PASS createAttributeNS("http://example.com/", "div:"); threw NAMESPACE_ERR 30 30 PASS createAttributeNS(null, "d:iv"); threw NAMESPACE_ERR 31 FAIL createAttributeNS(null, "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR32 FAIL createAttributeNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR33 FAIL createAttributeNS(null, "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR34 FAIL createAttributeNS("http://example.com/", "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR31 PASS createAttributeNS(null, "a:b:c"); valid XML name, invalid QName; threw NAMESPACE_ERR 32 PASS createAttributeNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; threw NAMESPACE_ERR 33 PASS createAttributeNS(null, "a::c"); valid XML name, invalid QName; threw NAMESPACE_ERR 34 PASS createAttributeNS("http://example.com/", "a::c"); valid XML name, invalid QName; threw NAMESPACE_ERR 35 35 PASS createAttributeNS("http://example.com/", "a:0"); valid XML name, not a valid QName; threw INVALID_CHARACTER_ERR 36 36 PASS createAttributeNS("http://example.com/", "0:a"); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR -
trunk/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt
r31230 r31231 30 30 PASS createElementNS("http://example.com/", "div:"); threw NAMESPACE_ERR 31 31 PASS createElementNS(null, "d:iv"); threw NAMESPACE_ERR 32 FAIL createElementNS(null, "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR33 FAIL createElementNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR34 FAIL createElementNS(null, "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR35 FAIL createElementNS("http://example.com/", "a::c"); valid XML name, invalid QName; expected NAMESPACE_ERR, threw INVALID_CHARACTER_ERR32 PASS createElementNS(null, "a:b:c"); valid XML name, invalid QName; threw NAMESPACE_ERR 33 PASS createElementNS("http://example.com/", "a:b:c"); valid XML name, invalid QName; threw NAMESPACE_ERR 34 PASS createElementNS(null, "a::c"); valid XML name, invalid QName; threw NAMESPACE_ERR 35 PASS createElementNS("http://example.com/", "a::c"); valid XML name, invalid QName; threw NAMESPACE_ERR 36 36 PASS createElementNS("http://example.com/", "a:0"); valid XML name, not a valid QName; threw INVALID_CHARACTER_ERR 37 37 PASS createElementNS("http://example.com/", "0:a"); 0 at start makes it not a valid XML name; threw INVALID_CHARACTER_ERR -
trunk/WebCore/ChangeLog
r31230 r31231 1 2008-03-22 Eric Seidel <eric@webkit.org> 2 3 Reviewed by mjs. 4 5 Unify handling of NAMESPACE_ERR and fix Acid3 test 25 6 http://bugs.webkit.org/show_bug.cgi?id=16693 7 8 Test: fast/dom/DOMImplementation/createDocumentType-err.html 9 10 * dom/DOMImplementation.cpp: 11 (WebCore::DOMImplementation::createDocumentType): 12 (WebCore::DOMImplementation::createDocument): 13 * dom/DOMImplementation.idl: 14 * dom/Document.cpp: 15 (WebCore::Document::hasPrefixNamespaceMismatch): 16 (WebCore::Document::createElementNS): 17 (WebCore::Document::parseQualifiedName): 18 (WebCore::Document::createAttributeNS): 19 * dom/Document.h: 20 * dom/Element.cpp: 21 (WebCore::Element::setAttributeNS): 22 * editing/FormatBlockCommand.cpp: 23 (WebCore::FormatBlockCommand::doApply): 24 1 25 2008-03-22 Eric Seidel <eric@webkit.org> 2 26 -
trunk/WebCore/dom/DOMImplementation.cpp
r30923 r31231 52 52 53 53 namespace WebCore { 54 55 // FIXME: An implementation of this is still waiting for me to understand the distinction between56 // a "malformed" qualified name and one with bad characters in it. For example, is a second colon57 // an illegal character or a malformed qualified name? This will determine both what parameters58 // this function needs to take and exactly what it will do. Should also be exported so that59 // Element can use it too.60 static bool qualifiedNameIsMalformed(const String&)61 {62 return false;63 }64 54 65 55 #if ENABLE(SVG) … … 207 197 const String& publicId, const String& systemId, ExceptionCode& ec) 208 198 { 209 // Not mentioned in spec: throw NAMESPACE_ERR if no qualifiedName supplied 210 if (qualifiedName.isNull()) { 211 ec = NAMESPACE_ERR; 199 String prefix, localName; 200 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec)) 212 201 return 0; 213 } 214 215 // INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. 216 String prefix, localName; 217 if (!Document::parseQualifiedName(qualifiedName, prefix, localName)) { 218 ec = INVALID_CHARACTER_ERR; 219 return 0; 220 } 221 222 // NAMESPACE_ERR: Raised if the qualifiedName is malformed. 223 if (qualifiedNameIsMalformed(qualifiedName)) { 224 ec = NAMESPACE_ERR; 225 return 0; 226 } 227 228 ec = 0; 202 229 203 return new DocumentType(this, 0, qualifiedName, publicId, systemId); 230 204 } … … 239 213 const String& qualifiedName, DocumentType* doctype, ExceptionCode& ec) 240 214 { 241 if (!qualifiedName.isEmpty()) {242 // INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.243 String prefix, localName;244 if (!Document::parseQualifiedName(qualifiedName, prefix, localName)) {245 ec = INVALID_CHARACTER_ERR;246 return 0;247 }248 249 // NAMESPACE_ERR:250 // - Raised if the qualifiedName is malformed,251 // - if the qualifiedName has a prefix and the namespaceURI is null, or252 // - if the qualifiedName has a prefix that is "xml" and the namespaceURI is different253 // from "http://www.w3.org/XML/1998/namespace" [Namespaces].254 int colonpos = qualifiedName.find(':');255 if (qualifiedNameIsMalformed(qualifiedName) ||256 (colonpos >= 0 && namespaceURI.isNull()) ||257 (colonpos == 3 && qualifiedName[0] == 'x' && qualifiedName[1] == 'm' && qualifiedName[2] == 'l' &&258 #if ENABLE(SVG)259 namespaceURI != SVGNames::svgNamespaceURI &&260 #endif261 namespaceURI != XMLNames::xmlNamespaceURI)) {262 263 ec = NAMESPACE_ERR;264 return 0;265 }266 }267 268 215 // WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was 269 216 // created from a different implementation. 270 if (doctype && (doctype->document() || doctype->implementation() != this)) { 271 ec = WRONG_DOCUMENT_ERR; 272 return 0; 273 } 217 bool shouldThrowWrongDocErr = false; 218 if (doctype && (doctype->document() || doctype->implementation() != this)) 219 shouldThrowWrongDocErr = true; 274 220 275 221 RefPtr<Document> doc; … … 288 234 doc->addChild(doctype); 289 235 290 if (!qualifiedName.isEmpty()) 236 if (!qualifiedName.isEmpty()) { 291 237 doc->addChild(doc->createElementNS(namespaceURI, qualifiedName, ec)); 292 293 ec = 0; 238 if (ec != 0) 239 return 0; 240 } 241 242 // Hixie's interpretation of the DOM Core spec suggests we should prefer 243 // other exceptions to WRONG_DOCUMENT_ERR (based on order mentioned in spec) 244 if (shouldThrowWrongDocErr) { 245 ec = WRONG_DOCUMENT_ERR; 246 return 0; 247 } 248 294 249 return doc.release(); 295 250 } -
trunk/WebCore/dom/DOMImplementation.idl
r27276 r31231 34 34 // DOM Level 2 35 35 36 [OldStyleObjC] DocumentType createDocumentType(in DOMString qualifiedName,37 in DOMString publicId,38 in DOMString systemId)36 [OldStyleObjC] DocumentType createDocumentType(in [ConvertUndefinedOrNullToNullString] DOMString qualifiedName, 37 in [ConvertUndefinedOrNullToNullString] DOMString publicId, 38 in [ConvertUndefinedOrNullToNullString] DOMString systemId) 39 39 raises(DOMException); 40 40 [OldStyleObjC] Document createDocument(in [ConvertNullToNullString] DOMString namespaceURI, -
trunk/WebCore/dom/Document.cpp
r31230 r31231 718 718 } 719 719 720 static bool hasNamespaceError(const QualifiedName& qName)721 { 722 static const AtomicString xmlnsNamespaceURI = "http://www.w3.org/2000/xmlns/";723 static const AtomicString xmlns = "xmlns";724 static const AtomicString xml = "xml";720 bool Document::hasPrefixNamespaceMismatch(const QualifiedName& qName) 721 { 722 static const AtomicString xmlnsNamespaceURI("http://www.w3.org/2000/xmlns/"); 723 static const AtomicString xmlns("xmlns"); 724 static const AtomicString xml("xml"); 725 725 726 726 // These checks are from DOM Core Level 2, createElementNS 727 727 // http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrElNS 728 if (qName.prefix() == emptyAtom) // createElementNS(null, ":div")729 return true;730 if (qName.localName().isEmpty()) // createElementNS(null, ""), createElementNS(null, null), createElementNS()731 return true;732 728 if (!qName.prefix().isEmpty() && qName.namespaceURI().isNull()) // createElementNS(null, "html:div") 733 729 return true; … … 778 774 { 779 775 String prefix, localName; 780 if (!parseQualifiedName(qualifiedName, prefix, localName)) { 781 ec = INVALID_CHARACTER_ERR; 776 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 782 777 return 0; 783 }784 778 785 779 QualifiedName qName(prefix, localName, namespaceURI); 786 if (has NamespaceError(qName)) {780 if (hasPrefixNamespaceMismatch(qName)) { 787 781 ec = NAMESPACE_ERR; 788 782 return 0; … … 2820 2814 } 2821 2815 2822 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName )2816 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode& ec) 2823 2817 { 2824 2818 unsigned length = qualifiedName.length(); 2825 2819 2826 if (length == 0) 2820 if (length == 0) { 2821 ec = INVALID_CHARACTER_ERR; 2827 2822 return false; 2823 } 2828 2824 2829 2825 bool nameStart = true; … … 2836 2832 U16_NEXT(s, i, length, c) 2837 2833 if (c == ':') { 2838 if (sawColon) 2834 if (sawColon) { 2835 ec = NAMESPACE_ERR; 2839 2836 return false; // multiple colons: not allowed 2837 } 2840 2838 nameStart = true; 2841 2839 sawColon = true; 2842 2840 colonPos = i - 1; 2843 2841 } else if (nameStart) { 2844 if (!isValidNameStart(c)) 2842 if (!isValidNameStart(c)) { 2843 ec = INVALID_CHARACTER_ERR; 2845 2844 return false; 2845 } 2846 2846 nameStart = false; 2847 2847 } else { 2848 if (!isValidNamePart(c)) 2848 if (!isValidNamePart(c)) { 2849 ec = INVALID_CHARACTER_ERR; 2849 2850 return false; 2851 } 2850 2852 } 2851 2853 } … … 2856 2858 } else { 2857 2859 prefix = qualifiedName.substring(0, colonPos); 2860 if (prefix.isEmpty()) { 2861 ec = NAMESPACE_ERR; 2862 return false; 2863 } 2858 2864 localName = qualifiedName.substring(colonPos + 1); 2865 } 2866 2867 if (localName.isEmpty()) { 2868 ec = NAMESPACE_ERR; 2869 return false; 2859 2870 } 2860 2871 … … 3528 3539 { 3529 3540 String prefix, localName; 3530 if (!parseQualifiedName(qualifiedName, prefix, localName)) { 3531 ec = INVALID_CHARACTER_ERR; 3541 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 3532 3542 return 0; 3533 }3534 3543 3535 3544 QualifiedName qName(prefix, localName, namespaceURI); 3536 if (has NamespaceError(qName)) {3545 if (hasPrefixNamespaceMismatch(qName)) { 3537 3546 ec = NAMESPACE_ERR; 3538 3547 return 0; -
trunk/WebCore/dom/Document.h
r31144 r31231 593 593 594 594 // The following breaks a qualified name into a prefix and a local name. 595 // It also does a validity check, and returns false if the qualified name is invalid 596 // (empty string or invalid characters). 597 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName); 595 // It also does a validity check, and returns false if the qualified name 596 // is invalid. It also sets ExceptionCode when name is invalid. 597 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&); 598 599 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3) 600 static bool hasPrefixNamespaceMismatch(const QualifiedName&); 598 601 599 602 void addElementById(const AtomicString& elementId, Element *element); -
trunk/WebCore/dom/Element.cpp
r31181 r31231 1055 1055 { 1056 1056 String prefix, localName; 1057 if (!Document::parseQualifiedName(qualifiedName, prefix, localName )) {1058 ec = INVALID_CHARACTER_ERR;1059 return; 1060 }1061 setAttribute( QualifiedName(prefix, localName, namespaceURI), value.impl(), ec);1057 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec)) 1058 return; 1059 1060 QualifiedName qName(prefix, localName, namespaceURI); 1061 setAttribute(qName, value.impl(), ec); 1062 1062 } 1063 1063 -
trunk/WebCore/editing/FormatBlockCommand.cpp
r29877 r31231 92 92 if (endingSelection().isRange() && modifyRange()) 93 93 return; 94 94 95 ExceptionCode ec; 95 96 String localName, prefix; 96 if (!Document::parseQualifiedName(m_tagName, prefix, localName ))97 if (!Document::parseQualifiedName(m_tagName, prefix, localName, ec)) 97 98 return; 98 QualifiedName qTypeOfBlock = QualifiedName(AtomicString(prefix), AtomicString(localName), xhtmlNamespaceURI);99 99 QualifiedName qTypeOfBlock(prefix, localName, xhtmlNamespaceURI); 100 100 101 Node* refNode = enclosingBlockFlowElement(endingSelection().visibleStart()); 101 102 if (refNode->hasTagName(qTypeOfBlock))
Note: See TracChangeset
for help on using the changeset viewer.