Changeset 31231 for trunk/WebCore/dom/DOMImplementation.cpp
- Timestamp:
- 03/22/08 02:50:54 (8 months ago)
- Files:
-
- 1 modified
-
trunk/WebCore/dom/DOMImplementation.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }