Closed Bug 1160342 Opened 10 years ago Closed 9 years ago

Implement <marquee> using mutation observers

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox40 --- affected
firefox47 --- fixed

People

(Reporter: cvan, Assigned: martijn.martijn)

References

Details

Attachments

(2 files, 5 obsolete files)

Attached file test case
1. Load a page with a <marquee> tag. 2. Notice a JS warning appears in the Console: > Use of Mutation Events is deprecated. Use MutationObserver instead. – The <marquee> tag should likely be reimplemented using mutation observers.
Martijn, want to fix this?
(though, it is not clear to me MutationObservers are synchronous enough for this.)
I'll take a look at it later, if someone doesn't beat me to it.
Assignee: nobody → martijn.martijn
Attached file 1160342_marquee.html (obsolete) —
It looks like MutationObservers are slow, something like this returns 'scrollalternate' with DOMAttrModified (which is correct) and 'scrollscroll' with MutationObservers for marquees, which is incorrect. I'm not really sure if this would be an issue with real pages on real sites. There is no way to speed up MutationObservers, is there? Or we could overload setAttribute/removeAttribute et all, but that was shot down in bug 239919.
Flags: needinfo?(bugs)
Attached patch all.diff (obsolete) — Splinter Review
Fwiw, I have something like this for now.
Ok, it might be that .behavior should just reflect the behavior attribute or I need to fix the behavior property.
Flags: needinfo?(bugs)
(In reply to Martijn Wargers [:mwargers] (QA) from comment #4) > It looks like MutationObservers are slow, something like this returns > 'scrollalternate' with DOMAttrModified (which is correct) and 'scrollscroll' > with MutationObservers for marquees, which is incorrect. > I'm not really sure if this would be an issue with real pages on real sites. > There is no way to speed up MutationObservers, is there? MutationObservers are, last time I checked, 7x faster than MutationEvents ;) But they aren't synchronous. The callback is called at the end of a microtask. See comment 2.
Attached patch 1160342.diff (obsolete) — Splinter Review
Something like this, I guess. The mochitest handles various cases, the todo_is is basically what IE is doing, but what Mozilla currently isn't doing with the patch. Although, I'm wondering if it's really worth the effort to mimick IE in all cases here. Does this need to go through mozreview or something?
Attachment #8717719 - Attachment is obsolete: true
Attachment #8719322 - Flags: review?(bugs)
(nothing _needs_ to go through mozreview. Some people prefer it, so people prefer the old style.)
Comment on attachment 8719322 [details] [diff] [review] 1160342.diff > <setter> >- this.setAttribute("scrollamount", val); >+ if (isNaN(val) || val == null) >+ val = 0; >+ if (!this._set_scrollAmount(val)) { >+ throw new Error("Invalid argument for Marquee::scrollAmount"); >+ } else { >+ this.setAttribute("scrollamount", val); >+ } > </setter> Making web exposed setters to throw is backwards incompatible change and should be done in a separate bug. (and please test what other browsers do) So waiting to see a patch which has just the minimal MutationObserver related changes.
Attachment #8719322 - Flags: review?(bugs) → review-
(In reply to Olli Pettay [:smaug] (high review load) from comment #10) > Making web exposed setters to throw is backwards incompatible change and > should be done in a separate bug. > (and please test what other browsers do) I think this got broken with the fix for bug 848939, but you're right, this is currently not working, so I guess it's bettor to remove it for now. I did test what happens in Internet Explorer. Internet Explorer is passing all the tests in the mochitest. Google Chrome is failing in 21 of the tests. > So waiting to see a patch which has just the minimal MutationObserver > related changes. Ok, will do, I'll just make the tests todo_is() for the cases where it's not doing the same as Internet Explorer. Ok, will do.
(In reply to Martijn Wargers [:mwargers] (QA) from comment #11) > I think this got broken with the fix for bug 848939, but you're right, this > is currently not working, so I guess it's bettor to remove it for now. > I did test what happens in Internet Explorer. Internet Explorer is passing > all the tests in the mochitest. > Google Chrome is failing in 21 of the tests. Here is an online version of the mochitest, btw: http://people.mozilla.org/~mwargers/mochitestjs2/test_bug1160342_marquee.html
Attached patch 1160342_marquee.diff (obsolete) — Splinter Review
Updated patch with the throwing error part removed. Also added a fix and some tests for the direction property. What is still needed is more testing of direction=up/down, onbounce, onstart, onfinish. Also, if the actual properties work as advertised. Also, the mutationObserver could also listen for the relevant attributes in question (although I don't know how that works regarding case sensitivity). Or perhaps you only want to have this handle the minimal MutationObserver changes?
Attachment #8719322 - Attachment is obsolete: true
Attachment #8720041 - Flags: review?(bugs)
If we can keep the existing behavior with the uploaded patch, great. Changes to behavior could be implemented in followup bugs.
So looks like the patch does add plenty of non-mutationobserver related fixes too. I really would like to have first just the change to start using mutationobserver.
Comment on attachment 8720041 [details] [diff] [review] 1160342_marquee.diff So could you split the non-mutationobserver related stuff to a separate patch/bug. I'm talking about the changes to various getters and setters and so. And change to _set_scrollDelay. So I would expect to see a patch which has just those couple of this._mutationActor(this._mutationObserver.takeRecords()); calls and <method name="_mutationActor">...</method> and the change to constructor. (or is there a reason to have all the other changes in this bug?) Sorry being a bit difficult here, but this all mainly to ease tracking possible regressions.
Attachment #8720041 - Flags: review?(bugs) → review-
Attached patch 1160342_marquee.diff (obsolete) — Splinter Review
Ok, this keeps existing attribute/property handling of marquees. Wit this patch, the results are the same in the mochitest as we have currently (which is not correct in many ways). Pushed to try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2a33e0f1020e
Attachment #8720242 - Flags: review?(bugs)
Comment on attachment 8720242 [details] [diff] [review] 1160342_marquee.diff Still don't know why we need those two parseInt calls, which seem like unrelated changes. But fine.
Attachment #8720242 - Flags: review?(bugs) → review+
Because I would otherwise get differences in results in the mochitest.
Attachment #8717716 - Attachment is obsolete: true
Attachment #8720041 - Attachment is obsolete: true
Attachment #8720242 - Attachment is obsolete: true
Keywords: checkin-needed
Depends on: 1249061
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: