Show
Ignore:
Timestamp:
03/22/08 02:50:54 (8 months ago)
Author:
eric@webkit.org
Message:

Reviewed by mjs.

Unify handling of NAMESPACE_ERR and fix Acid3 test 25
http://bugs.webkit.org/show_bug.cgi?id=16693

Test: fast/dom/DOMImplementation/createDocumentType-err.html

  • dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocumentType): (WebCore::DOMImplementation::createDocument):
  • dom/DOMImplementation.idl:
  • dom/Document.cpp: (WebCore::Document::hasPrefixNamespaceMismatch): (WebCore::Document::createElementNS): (WebCore::Document::parseQualifiedName): (WebCore::Document::createAttributeNS):
  • dom/Document.h:
  • dom/Element.cpp: (WebCore::Element::setAttributeNS):
  • editing/FormatBlockCommand.cpp: (WebCore::FormatBlockCommand::doApply):
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/dom/Document.cpp

    r31230 r31231  
    718718} 
    719719 
    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"; 
     720bool 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"); 
    725725 
    726726    // These checks are from DOM Core Level 2, createElementNS 
    727727    // 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; 
    732728    if (!qName.prefix().isEmpty() && qName.namespaceURI().isNull()) // createElementNS(null, "html:div") 
    733729        return true; 
     
    778774{ 
    779775    String prefix, localName; 
    780     if (!parseQualifiedName(qualifiedName, prefix, localName)) { 
    781         ec = INVALID_CHARACTER_ERR; 
     776    if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 
    782777        return 0; 
    783     } 
    784778 
    785779    QualifiedName qName(prefix, localName, namespaceURI); 
    786     if (hasNamespaceError(qName)) { 
     780    if (hasPrefixNamespaceMismatch(qName)) { 
    787781        ec = NAMESPACE_ERR; 
    788782        return 0; 
     
    28202814} 
    28212815 
    2822 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName) 
     2816bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode& ec) 
    28232817{ 
    28242818    unsigned length = qualifiedName.length(); 
    28252819 
    2826     if (length == 0) 
     2820    if (length == 0) { 
     2821        ec = INVALID_CHARACTER_ERR; 
    28272822        return false; 
     2823    } 
    28282824 
    28292825    bool nameStart = true; 
     
    28362832        U16_NEXT(s, i, length, c) 
    28372833        if (c == ':') { 
    2838             if (sawColon) 
     2834            if (sawColon) { 
     2835                ec = NAMESPACE_ERR; 
    28392836                return false; // multiple colons: not allowed 
     2837            } 
    28402838            nameStart = true; 
    28412839            sawColon = true; 
    28422840            colonPos = i - 1; 
    28432841        } else if (nameStart) { 
    2844             if (!isValidNameStart(c)) 
     2842            if (!isValidNameStart(c)) { 
     2843                ec = INVALID_CHARACTER_ERR; 
    28452844                return false; 
     2845            } 
    28462846            nameStart = false; 
    28472847        } else { 
    2848             if (!isValidNamePart(c)) 
     2848            if (!isValidNamePart(c)) { 
     2849                ec = INVALID_CHARACTER_ERR; 
    28492850                return false; 
     2851            } 
    28502852        } 
    28512853    } 
     
    28562858    } else { 
    28572859        prefix = qualifiedName.substring(0, colonPos); 
     2860        if (prefix.isEmpty()) { 
     2861            ec = NAMESPACE_ERR; 
     2862            return false; 
     2863        } 
    28582864        localName = qualifiedName.substring(colonPos + 1); 
     2865    } 
     2866 
     2867    if (localName.isEmpty()) { 
     2868        ec = NAMESPACE_ERR; 
     2869        return false; 
    28592870    } 
    28602871 
     
    35283539{ 
    35293540    String prefix, localName; 
    3530     if (!parseQualifiedName(qualifiedName, prefix, localName)) { 
    3531         ec = INVALID_CHARACTER_ERR; 
     3541    if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) 
    35323542        return 0; 
    3533     } 
    35343543 
    35353544    QualifiedName qName(prefix, localName, namespaceURI); 
    3536     if (hasNamespaceError(qName)) { 
     3545    if (hasPrefixNamespaceMismatch(qName)) { 
    35373546        ec = NAMESPACE_ERR; 
    35383547        return 0;