[webkit-changes] cvs commit: WebCore/khtml/xml dom_elementimpl.h
Darin
darin at opensource.apple.com
Sat Dec 10 10:56:01 PST 2005
darin 05/12/10 10:56:01
Modified: . ChangeLog
. ChangeLog
khtml/html htmlparser.cpp
khtml/xml dom_elementimpl.h
Added: fast/parser duplicate-html-body-element-IDs-expected.txt
duplicate-html-body-element-IDs.html
Log:
LayoutTests:
New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5784
* fast/parser/duplicate-html-body-element-IDs-expected.txt: Added.
* fast/parser/duplicate-html-body-element-IDs.html: Added.
WebCore:
Reviewed and landed by Darin.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5784
Assertion failure in DocumentImpl::removeElementById() (idCount > 0)
Another symptom is that getElementById doesn't work when the ID is on a duplicate
<html> or <body> element.
Added a new layout test that checks for at least one symptom of the bug.
* khtml/html/htmlparser.cpp: (HTMLParser::handleError): Use setAttribute here instead
of using insertAttribute and calling recalcStyle explicitly. That's because setAttribute
does other things that are needed to change an attribute in an attribute map that's
already connected to an element, including updating the ID map if the attribute is
the ID attribute.
* khtml/xml/dom_elementimpl.h: (DOM::NamedAttrMapImpl::insertAttribute):
Assert that this parser-only function is only used on attribute maps that aren't yet
attached to elements.
Revision Changes Path
1.133 +7 -0 LayoutTests/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/LayoutTests/ChangeLog,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- ChangeLog 10 Dec 2005 02:59:11 -0000 1.132
+++ ChangeLog 10 Dec 2005 18:55:55 -0000 1.133
@@ -1,3 +1,10 @@
+2005-12-10 Darin Adler <darin at apple.com>
+
+ New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5784
+
+ * fast/parser/duplicate-html-body-element-IDs-expected.txt: Added.
+ * fast/parser/duplicate-html-body-element-IDs.html: Added.
+
2005-12-09 Justin Garcia <justin.garcia at apple.com>
New layout tests for:
1.1 LayoutTests/fast/parser/duplicate-html-body-element-IDs-expected.txt
Index: duplicate-html-body-element-IDs-expected.txt
===================================================================
Hooray, it worked! Since getElementById found the HTML element, its ID presumably was added to the ID map correctly.
Hooray, it worked! Since getElementById found the body element, its ID presumably was added to the ID map correctly.
1.1 LayoutTests/fast/parser/duplicate-html-body-element-IDs.html
Index: duplicate-html-body-element-IDs.html
===================================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" id="html">
<body>
<body id="body">
<script type="text/javascript">
if (window.layoutTestController)
layoutTestController.dumpAsText();
if (document.getElementById("html") == document.documentElement)
document.write("<p>Hooray, it worked! Since getElementById found the HTML element, its ID presumably was added to the ID map correctly.</p>");
if (document.getElementById("body").parentNode == document.documentElement)
document.write("<p>Hooray, it worked! Since getElementById found the body element, its ID presumably was added to the ID map correctly.</p>");
</script>
</body>
</html>
1.499 +21 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.498
retrieving revision 1.499
diff -u -r1.498 -r1.499
--- ChangeLog 10 Dec 2005 17:14:32 -0000 1.498
+++ ChangeLog 10 Dec 2005 18:55:56 -0000 1.499
@@ -1,3 +1,24 @@
+2005-12-10 Mitz Pettel <opendarwin.org at mitzpettel.com>
+
+ Reviewed and landed by Darin.
+
+ - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5784
+ Assertion failure in DocumentImpl::removeElementById() (idCount > 0)
+ Another symptom is that getElementById doesn't work when the ID is on a duplicate
+ <html> or <body> element.
+
+ Added a new layout test that checks for at least one symptom of the bug.
+
+ * khtml/html/htmlparser.cpp: (HTMLParser::handleError): Use setAttribute here instead
+ of using insertAttribute and calling recalcStyle explicitly. That's because setAttribute
+ does other things that are needed to change an attribute in an attribute map that's
+ already connected to an element, including updating the ID map if the attribute is
+ the ID attribute.
+
+ * khtml/xml/dom_elementimpl.h: (DOM::NamedAttrMapImpl::insertAttribute):
+ Assert that this parser-only function is only used on attribute maps that aren't yet
+ attached to elements.
+
2005-12-10 Darin Adler <darin at apple.com>
Reviewed by Eric and Tim Omernick.
1.124 +8 -12 WebCore/khtml/html/htmlparser.cpp
Index: htmlparser.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/htmlparser.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- htmlparser.cpp 1 Dec 2005 10:32:19 -0000 1.123
+++ htmlparser.cpp 10 Dec 2005 18:56:00 -0000 1.124
@@ -339,15 +339,13 @@
// we have another <HTML> element.... apply attributes to existing one
// make sure we don't overwrite already existing attributes
NamedAttrMapImpl *map = static_cast<ElementImpl*>(n)->attributes(true);
- NamedAttrMapImpl *bmap = static_cast<ElementImpl*>(doc()->firstChild())->attributes(false);
- bool changed = false;
+ ElementImpl *existingHTML = static_cast<ElementImpl*>(doc()->firstChild());
+ NamedAttrMapImpl *bmap = existingHTML->attributes(false);
for (unsigned l = 0; map && l < map->length(); ++l) {
AttributeImpl* it = map->attributeItem(l);
- changed = !bmap->getAttributeItem(it->name());
- bmap->insertAttribute(it->clone(false));
+ if (!bmap->getAttributeItem(it->name()))
+ existingHTML->setAttribute(it->name(), it->value());
}
- if (changed)
- doc()->recalcStyle(NodeImpl::Inherit);
}
return false;
}
@@ -376,15 +374,13 @@
// make sure we don't overwrite already existing attributes
// some sites use <body bgcolor=rightcolor>...<body bgcolor=wrongcolor>
NamedAttrMapImpl *map = static_cast<ElementImpl*>(n)->attributes(true);
- NamedAttrMapImpl *bmap = doc()->body()->attributes(false);
- bool changed = false;
+ ElementImpl *existingBody = doc()->body();
+ NamedAttrMapImpl *bmap = existingBody->attributes(false);
for (unsigned l = 0; map && l < map->length(); ++l) {
AttributeImpl* it = map->attributeItem(l);
- changed = !bmap->getAttributeItem(it->name());
- bmap->insertAttribute(it->clone(false));
+ if (!bmap->getAttributeItem(it->name()))
+ existingBody->setAttribute(it->name(), it->value());
}
- if (changed)
- doc()->recalcStyle(NodeImpl::Inherit);
return false;
}
else if (!current->isDocumentNode())
1.65 +1 -0 WebCore/khtml/xml/dom_elementimpl.h
Index: dom_elementimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_elementimpl.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- dom_elementimpl.h 1 Dec 2005 10:32:27 -0000 1.64
+++ dom_elementimpl.h 10 Dec 2005 18:56:00 -0000 1.65
@@ -316,6 +316,7 @@
// used during parsing: only inserts if not already there
// no error checking!
void insertAttribute(AttributeImpl* newAttribute) {
+ assert(!element);
if (!getAttributeItem(newAttribute->name()))
addAttribute(newAttribute);
else
More information about the webkit-changes
mailing list