Changeset 20997 in webkit
- Timestamp:
- Apr 21, 2007, 2:38:59 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r20996 r20997 1 2007-04-21 Lamar Goddard <lamargoddard@gmail.com> 2 3 Reviewed by Darin. 4 5 http://bugs.webkit.org/show_bug.cgi?id=5262 6 <rdar://problem/5018778> 7 XMLSerializer drops Namespace information 8 9 * fast/dom/serialize-nodes-expected.txt: Added. 10 * fast/dom/serialize-nodes.xhtml: Added. 11 * dom/xhtml/level3/core/nodeisequalnode14-expected.txt: This test fails because 12 createAttribute is supposed to create an Attr with localName of null. 13 * dom/xhtml/level3/core/nodeisequalnode15-expected.txt: Now succeeds. 14 * fast/innerHTML/004-expected.txt: Added namespace information to head and body nodes 15 as xhtml nodes now serialize with namespace information. 16 1 17 2007-04-21 Alexey Proskuryakov <ap@webkit.org> 2 18 -
trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode14-expected.txt
r11962 r20997 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode14 2 Status Success 2 Status failure 3 Message nodeisequalnode14: assertTrue failed -
trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode15-expected.txt
r13297 r20997 1 1 Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode15 2 Status failure 3 Message nodeisequalnode15: assertTrue failed 2 Status Success -
trunk/LayoutTests/fast/innerHTML/004-expected.txt
r14948 r20997 1 1 Content: 2 2 3 <head >3 <head xmlns="http://www.w3.org/1999/xhtml"> 4 4 <meta name="description" content="This tests singular elements too" /> 5 5 <title>xhtml innerHTML test</title> 6 6 </head> 7 <body >7 <body xmlns="http://www.w3.org/1999/xhtml"> 8 8 <span>Content:</span> 9 9 <pre id="content">placeholder</pre> -
trunk/WebCore/ChangeLog
r20996 r20997 1 2007-04-21 Lamar Goddard <lamargoddard@gmail.com> 2 3 Reviewed by Darin. 4 5 Fix for http://bugs.webkit.org/show_bug.cgi?id=5262 6 <rdar://problem/5018778> 7 XMLSerializer drops Namespace information 8 9 Updated WebCore::markup to output namespace information for elements/attributes whose namespace information 10 doesn't appear in its scope in the output. 11 12 Added test case: fast/dom/serialize-nodes.xhtml 13 14 * WebCore/editing/markup.cpp: 15 (WebCore::createMarkup(const Node*, ...)): Changed call to WebCore::markup to match parameters 16 (WebCore::markup): Changed recursive call to match tree structure, removed ASSERT and no longer needed includeSiblings parameter. 17 (WebCore::startMarkup): Added optional parameter to track namespaces in the current scope. 18 (WebCore::addNamespace): Function to add namespace information to markup. 19 (WebCore::shouldAddNamespaceAttr): 20 (WebCore::shouldAddNamespaceElem): Functions that test whether namespace information should be added for a given node. 21 * WebCore/dom/Document.idl: 22 (createElementNS): 23 (createAttributeNS): 24 (getElementsByTagNameNS): Added [ConvertNullToNullString] to namespaceURI parameter. 25 * WebCore/dom/Node.cpp: 26 (Node::getElementsByTagNameNS): removed test for namespaceURI being null as null can be a valid namespace. 27 1 28 2007-04-21 Alexey Proskuryakov <ap@webkit.org> 2 29 -
trunk/WebCore/dom/Document.idl
r20948 r20997 50 50 in boolean deep) 51 51 raises (DOMException); 52 [OldStyleObjC] Element createElementNS(in DOMString namespaceURI,52 [OldStyleObjC] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI, 53 53 in DOMString qualifiedName) 54 54 raises (DOMException); 55 [OldStyleObjC] Attr createAttributeNS(in DOMString namespaceURI,55 [OldStyleObjC] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI, 56 56 in DOMString qualifiedName) 57 57 raises (DOMException); 58 [OldStyleObjC] NodeList getElementsByTagNameNS(in DOMString namespaceURI,58 [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI, 59 59 in DOMString localName); 60 60 Element getElementById(in DOMString elementId); -
trunk/WebCore/dom/Node.cpp
r20495 r20997 1195 1195 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const String &namespaceURI, const String &localName) 1196 1196 { 1197 if ( namespaceURI.isNull() ||localName.isNull())1197 if (localName.isNull()) 1198 1198 return 0; // FIXME: Who relies on getting 0 instead of a node list in this case? 1199 1199 -
trunk/WebCore/editing/markup.cpp
r20912 r20997 49 49 #include "Logging.h" 50 50 #include "ProcessingInstruction.h" 51 #include "QualifiedName.h" 51 52 #include "Range.h" 52 53 #include "Selection.h" … … 155 156 } 156 157 157 static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false) 158 static bool shouldAddNamespaceElem(const Element* elem) 159 { 160 // Don't add namespace attribute if it is already defined for this elem. 161 const AtomicString& prefix = elem->prefix(); 162 AtomicString attr = !prefix.isEmpty() ? "xmlns:" + prefix : "xmlns"; 163 return !elem->hasAttribute(attr); 164 } 165 166 static bool shouldAddNamespaceAttr(const Attribute* attr, HashMap<AtomicStringImpl*, AtomicStringImpl*>& namespaces) 167 { 168 // Don't add namespace attributes twice 169 static const AtomicString xmlnsURI = "http://www.w3.org/2000/xmlns/"; 170 static const QualifiedName xmlnsAttr(nullAtom, "xmlns", xmlnsURI); 171 if (attr->name() == xmlnsAttr) { 172 namespaces.set(emptyAtom.impl(), attr->value().impl()); 173 return false; 174 } 175 176 QualifiedName xmlnsPrefixAttr("xmlns", attr->localName(), xmlnsURI); 177 if (attr->name() == xmlnsPrefixAttr) { 178 namespaces.set(attr->localName().impl(), attr->value().impl()); 179 return false; 180 } 181 182 return true; 183 } 184 185 static String addNamespace(const AtomicString& prefix, const AtomicString& ns, HashMap<AtomicStringImpl*, AtomicStringImpl*>& namespaces) 186 { 187 if (ns.isEmpty()) 188 return ""; 189 190 // Use emptyAtoms's impl() for both null and empty strings since the HashMap can't handle 0 as a key 191 AtomicStringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() : prefix.impl(); 192 AtomicStringImpl* foundNS = namespaces.get(pre); 193 if (foundNS != ns.impl()) { 194 namespaces.set(pre, ns.impl()); 195 return " xmlns" + (!prefix.isEmpty() ? ":" + prefix : "") + "=\"" + escapeTextForMarkup(ns.deprecatedString(), true) + "\""; 196 } 197 198 return ""; 199 } 200 201 static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false, HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 158 202 { 159 203 bool documentIsHTML = node->document()->isHTMLDocument(); … … 194 238 NamedAttrMap *attrs = el->attributes(); 195 239 unsigned length = attrs->length(); 240 if (!documentIsHTML && namespaces && shouldAddNamespaceElem(el)) 241 markup += addNamespace(el->prefix(), el->namespaceURI(), *namespaces).deprecatedString(); 196 242 197 243 for (unsigned int i = 0; i < length; i++) { … … 207 253 markup += " " + attr->name().toString().deprecatedString(); 208 254 markup += "=\"" + escapeTextForMarkup(value.deprecatedString(), true) + "\""; 255 256 if (!documentIsHTML && namespaces && shouldAddNamespaceAttr(attr, *namespaces)) 257 markup += addNamespace(attr->prefix(), attr->namespaceURI(), *namespaces).deprecatedString(); 209 258 } 210 259 … … 275 324 } 276 325 277 static DeprecatedString markup(Node* startNode, bool onlyIncludeChildren, bool includeSiblings, Vector<Node*> *nodes) 278 { 279 // Doesn't make sense to only include children and include siblings. 280 ASSERT(!(onlyIncludeChildren && includeSiblings)); 326 static DeprecatedString markup(Node* startNode, bool onlyIncludeChildren, Vector<Node*>* nodes, const HashMap<AtomicStringImpl*, AtomicStringImpl*>* namespaces = 0) 327 { 328 HashMap<AtomicStringImpl*, AtomicStringImpl*> namespaceHash; 329 if (namespaces) 330 namespaceHash = *namespaces; 331 281 332 DeprecatedString me = ""; 282 for (Node* current = startNode; current != NULL; current = includeSiblings ? current->nextSibling() : NULL) { 283 if (!onlyIncludeChildren) { 284 if (nodes) 285 nodes->append(current); 286 me += startMarkup(current, 0, DoNotAnnotateForInterchange); 287 } 288 // print children 289 if (Node *n = current->firstChild()) 290 if (!(n->document()->isHTMLDocument() && doesHTMLForbidEndTag(current))) 291 me += markup(n, false, true, nodes); 292 293 // Print my ending tag 294 if (!onlyIncludeChildren) 295 me += endMarkup(current); 296 } 333 if (!onlyIncludeChildren) { 334 if (nodes) 335 nodes->append(startNode); 336 me += startMarkup(startNode, 0, DoNotAnnotateForInterchange, false, &namespaceHash); 337 } 338 // print children 339 if (!(startNode->document()->isHTMLDocument() && doesHTMLForbidEndTag(startNode))) 340 for (Node* current = startNode->firstChild(); current; current = current->nextSibling()) 341 me += markup(current, false, nodes, &namespaceHash); 342 343 // Print my ending tag 344 if (!onlyIncludeChildren) 345 me += endMarkup(startNode); 346 297 347 return me; 298 348 } … … 586 636 node->document()->frame()->editor()->deleteButtonController()->disable(); 587 637 node->document()->updateLayoutIgnorePendingStylesheets(); 588 DeprecatedString result(markup(const_cast<Node*>(node), includeChildren, false,nodes));638 DeprecatedString result(markup(const_cast<Node*>(node), includeChildren, nodes)); 589 639 if (node->document()->frame()) 590 640 node->document()->frame()->editor()->deleteButtonController()->enable();
Note:
See TracChangeset
for help on using the changeset viewer.