Closed Bug 233643 Opened 21 years ago Closed 17 years ago

XUL needs to clone inline-style rule before modifying it

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha5

People

(Reporter: sicking, Assigned: Gavin)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

Currently the prototype and contentnode share stylerule. When that stylerule is
changed through .style we need to clone the rule before modifying it's
declaration. Otherwise we end up modifying the declaration used by the prototype.
sicking, any chance you could just do this?
This might be another case where doing the RightThing might be too costly. I'm
not sure if we should clone the rule just because nsXULElement::GetStyle is
called, but anything later then that will be too late.

One solution is to let the stylerule clone the declaration if it notices that it
has more then one reference to it. Or some such...
Blocks: 236697
Do we need to make a lighter-weight thing to clone?  Or is the style rule as
light as it can get for the needs of a fix for this bug?

/be
Frankly, we should just clone in GetStyle.  If someone does that to a XUL
element, they're up to no good anyway and deserve the perf hit.
Flags: blocking1.8b3?
Flags: blocking1.8b4?
Flags: blocking1.8b3?
Flags: blocking1.8b3-
Whiteboard: [no l10n impact]
Flags: blocking1.8b4? → blocking1.8b4-
Attached file testcase
Assignee: hyatt → gavin.sharp
Status: NEW → ASSIGNED
QA Contact: shrir → xptoolkit.xul
Whiteboard: [no l10n impact]
Target Milestone: --- → mozilla1.9alpha4
Attached patch patch (obsolete) — Splinter Review
This fixes the testcase in this bug, but I'm not sure that I've done everything correctly. The MakeHeavyweight change is an unrelated correctness fix that Boris requested over IRC (though I'm not sure that this is what he meant).

Cloning the CSSStyleRuleValue on any given element's first GetStyle() seems rather expensive (unless there's some simpler way that I'm unaware of). People calling GetStyle on a XUL element may be "up to no good", but the fact is we seem to do it quite a bit in Firefox/Toolkit chrome (see e.g. http://lxr.mozilla.org/seamonkey/search?string=.style. ), though maybe none of those are in any critical paths.
That patch looks like about what I was thinking...

As for it being expensive... yes.  It is.  The problem is that after that point we can't easily detect attempts to set.

If that change actually causes a noticeable Txul/Ts/memory-use hit, we can worry about it then.  I rather doubt it will.
Attachment #260310 - Flags: superreview?(jonas)
Attachment #260310 - Flags: review?(jonas)
Comment on attachment 260310 [details] [diff] [review]
patch

Looks good. I assume that you tested that this test fails on trunk, but passes with this test?
Attachment #260310 - Flags: superreview?(jonas)
Attachment #260310 - Flags: superreview+
Attachment #260310 - Flags: review?(jonas)
Attachment #260310 - Flags: review+
(In reply to comment #8)
> (From update of attachment 260310 [details] [diff] [review])
> Looks good. I assume that you tested that this test fails on trunk, but passes
> with this test?

I did, but I'll test again before landing.
Whiteboard: [checkin needed]
Attached patch updated patchSplinter Review
This is the same patch, with the test updated to deal with the test issue found in bug 377295.
Attachment #260310 - Attachment is obsolete: true
Comment on attachment 263175 [details] [diff] [review]
updated patch

> _TEST_FILES = 	test_bug330705-2.xul \
>+								test_bug233643.xul \
> 		$(NULL)

Something's wrong with the indentation here.
(In reply to comment #11)
> Something's wrong with the indentation here.

Thanks, I noticed that too but forgot to fix it before uploading the patch. I've fixed this locally.
For some reason the "r+sr=sicking" part of my commit message got cut off, but I've landed this on the trunk.

mozilla/content/xul/content/src/nsXULElement.cpp 	1.696
mozilla/content/xul/content/test/Makefile.in 	1.2
mozilla/content/xul/content/test/test_bug233643.xul 	1.1
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: mozilla1.9alpha4 → mozilla1.9alpha5
Flags: in-testsuite+
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.xul → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: