[webkit-reviews] review requested: [Bug 15960] View source mode
displays the attributes after an attribute with an empty
value incorrectly. : [Attachment 18245] Proposed patch v4
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Jan 2 16:40:20 PST 2008
Anyang Ren <anyang.ren at gmail.com> has asked for review:
Bug 15960: View source mode displays the attributes after an attribute with an
empty value incorrectly.
http://bugs.webkit.org/show_bug.cgi?id=15960
Attachment 18245: Proposed patch v4
http://bugs.webkit.org/attachment.cgi?id=18245&action=edit
------- Additional Comments from Anyang Ren <anyang.ren at gmail.com>
Mitz, thanks a lot for the review. I made your suggested changes in this
patch.
Note that I set attr to NULL if (token->attrs && currAttr <
token->attrs->length())
is false, and test for a non-NULL attr to match the behavior of the original
code as
much as possible. I considered making the simpler change below, but am not
sure
if it's safe:
Index: HTMLViewSourceDocument.cpp
===================================================================
--- HTMLViewSourceDocument.cpp (revision 29095)
+++ HTMLViewSourceDocument.cpp (working copy)
@@ -128,6 +128,7 @@
unsigned size = guide->size();
unsigned begin = 0;
unsigned currAttr = 0;
+ Attribute* attr = NULL;
for (unsigned i = 0; i < size; i++) {
if (guide->at(i) == 'a' || guide->at(i) == 'x' || guide->at(i)
== 'v') {
// Add in the string.
@@ -135,9 +136,8 @@
begin = i + 1;
- if (token->attrs && currAttr < token->attrs->length()) {
if (guide->at(i) == 'a') {
- Attribute* attr =
token->attrs->attributeItem(currAttr);
+ attr = token->attrs->attributeItem(currAttr++);
String name = attr->name().toString();
if (doctype)
addText(name, "webkit-html-doctype");
@@ -147,10 +147,7 @@
if (m_current != m_tbody)
m_current =
static_cast<Element*>(m_current->parent());
}
- if (attr->value().isNull() ||
attr->value().isEmpty())
- currAttr++;
} else {
- Attribute* attr =
token->attrs->attributeItem(currAttr);
String value = attr->value().domString();
if (doctype)
addText(value, "webkit-html-doctype");
@@ -164,9 +161,7 @@
if (m_current != m_tbody)
m_current =
static_cast<Element*>(m_current->parent());
}
- currAttr++;
}
- }
}
}
More information about the webkit-reviews
mailing list