Closed
Bug 209634
Opened 22 years ago
Closed 22 years ago
[FIX]No-op attribute changes can lead to processing and mutation events
Categories
(Core :: DOM: Core & HTML, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla1.5alpha
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
()
Details
Attachments
(4 files, 2 obsolete files)
493 bytes,
text/html
|
Details | |
537 bytes,
text/xml
|
Details | |
12.27 KB,
patch
|
Details | Diff | Splinter Review | |
2.77 KB,
patch
|
Details | Diff | Splinter Review |
We have some code in nsGenericHTMLElement::SetAttr to prevent processing of
attribute changes that don't actually change the attribute. This code is
bypassed if we call out to SetHTMLAttribute, however, and there is no equivalent
check in SetHTMLAttribute. The URL field has an example page where our CPU
usage is ridiculously higher than it should be because of this problem.
In addition, nsGenericElement has no such checks at all; we probably want to add
some. (same for nsSVGElement, and then there is XUL....)
This bug depends on bug 188803; until that's checked in, fixing this bug would
break inline style changes....
Assignee | ||
Comment 1•22 years ago
|
||
Assignee | ||
Comment 2•22 years ago
|
||
Assignee | ||
Comment 3•22 years ago
|
||
Assignee | ||
Comment 4•22 years ago
|
||
Comment on attachment 125802 [details] [diff] [review]
Proposed patch (for generic XML and HTML only)
Thoughts?
Assignee | ||
Comment 5•22 years ago
|
||
Attachment #125802 -
Attachment is obsolete: true
Assignee | ||
Updated•22 years ago
|
Attachment #126086 -
Flags: superreview?(jst)
Attachment #126086 -
Flags: review?(bugmail)
Comment 6•22 years ago
|
||
Comment on attachment 126086 [details] [diff] [review]
Proposed patch including XUL and SVG
- In nsXULElement::SetAttr():
if (tag == nsXULAtoms::window &&
aNodeInfo->Equals(nsXULAtoms::hidechrome)) {
- nsAutoString val;
- val.Assign(aValue);
+ nsAutoString val(aValue);
HideWindowChrome(val.EqualsIgnoreCase("true"));
How about using aValue.Equals("true", nsCaseInsensitiveStringComparator()) and
loosing the nsAutoString?
sr=jst
Attachment #126086 -
Flags: superreview?(jst) → superreview+
Assignee | ||
Comment 7•22 years ago
|
||
> How about using aValue.Equals("true", nsCaseInsensitiveStringComparator()) and
> loosing the nsAutoString?
That may give the wrong result in some locales, because the comparator is
locale-sensitive.... See the problems we had with similar code when determining
input types in HTML (bug number provided on request).
Taking bug.
Assignee: dom_bugs → bzbarsky
Priority: -- → P1
Summary: No-op attribute changes can lead to processing and mutation events → [FIX]No-op attribute changes can lead to processing and mutation events
Target Milestone: --- → mozilla1.5alpha
Assignee | ||
Updated•22 years ago
|
Attachment #126086 -
Flags: review?(bugmail) → review?(caillon)
Comment 8•22 years ago
|
||
Comment on attachment 126086 [details] [diff] [review]
Proposed patch including XUL and SVG
>Index: content/svg/content/src/nsSVGAttributes.cpp
>+ if (index < count) { // found the attr in the list
>+ NS_ASSERTION(attr, "How did we get here with a null attr pointer?");
>+ modification = PR_TRUE;
>+ attr->GetValue()->SetValueString(aValue);
>+ } else { // didn't find it
> if (GetMappedAttribute(aNodeInfo, &attr)) {
> AppendElement(attr);
> attr->GetValue()->SetValueString(aValue);
> }
> else {
> rv = nsSVGAttribute::Create(aNodeInfo, aValue, &attr);
> NS_ENSURE_TRUE(attr, rv);
> AppendElement(attr);
> }
> attr->Release();
Add the comment we talked about, plus only one AppendElement() call.
>Index: content/xul/content/src/nsXULElement.cpp
>+ // Check to see if the STYLE attribute is being set. If so, we need to
>+ // create a new style rule based off the value of this attribute, and we
>+ // need to let the document know about the StyleRule change.
> if (aNodeInfo->Equals(nsXULAtoms::style, kNameSpaceID_None) &&
>- (mDocument != nsnull)) {
>+ mDocument) {
This can fit on one line in under 80 chars now, if you like. I don't care one
way or another.
r=caillon.
Attachment #126086 -
Flags: review?(caillon) → review+
Assignee | ||
Comment 9•22 years ago
|
||
Attachment #126086 -
Attachment is obsolete: true
Assignee | ||
Comment 10•22 years ago
|
||
Assignee | ||
Comment 11•22 years ago
|
||
fixed. This seems to not have affected Tp after all and improved Txul by 3%, Ts
by 1% or so.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 12•22 years ago
|
||
Nice work.
Comment 13•21 years ago
|
||
*** Bug 207054 has been marked as a duplicate of this bug. ***
Comment 14•21 years ago
|
||
The patch for nsXULElement.cpp caused the regression described in bug 212625
(verified by backing it out). Can anyone look at this, please?
You need to log in
before you can comment on or make changes to this bug.
Description
•