Closed
Bug 601881
Opened 14 years ago
Closed 14 years ago
video and audio should never play automatically in editor
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla2.0b8
People
(Reporter: glazou, Assigned: ehsan.akhgari)
References
()
Details
Attachments
(1 file, 4 obsolete files)
10.80 KB,
patch
|
cpearce
:
review+
benjamin
:
approval2.0+
|
Details | Diff | Splinter Review |
<video autoplay> and <audio autoplay> should never autoplay in the editor or Midas. Suppose you need to insert a <video autoplay loop> in your markup... Editing becomes hell.
Assignee | ||
Comment 1•14 years ago
|
||
Indeed! I'll take this, but I'm afraid that I may not get to it before Firefox 4, given the number of remaining blockers...
Component: Video/Audio → Editor
QA Contact: video.audio → editor
Assignee | ||
Updated•14 years ago
|
Assignee: nobody → ehsan
Comment 2•14 years ago
|
||
Does mozAutoplayEnabled (added in bug 478982) help with this?
Assignee | ||
Comment 3•14 years ago
|
||
(In reply to comment #2)
> Does mozAutoplayEnabled (added in bug 478982) help with this?
Possibly. I think what we want to do is to modify nsHTMLMediaElement::GetMozAutoplayEnabled and always return false if the node is editable... In fact, I may write a patch to that effect! :-)
Assignee | ||
Comment 4•14 years ago
|
||
Attachment #481128 -
Flags: review?(jst)
Attachment #481128 -
Flags: approval2.0?
Assignee | ||
Updated•14 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•14 years ago
|
Whiteboard: [has patch][needs review jst]
Assignee | ||
Comment 5•14 years ago
|
||
Comment on attachment 481128 [details] [diff] [review]
Patch (v1)
Boris, is this something which you can review?
Attachment #481128 -
Flags: review?(jst) → review?(bzbarsky)
Comment 6•14 years ago
|
||
Comment on attachment 481128 [details] [diff] [review]
Patch (v1)
Looks good.
Attachment #481128 -
Flags: review?(bzbarsky)
Attachment #481128 -
Flags: review+
Attachment #481128 -
Flags: approval2.0?
Attachment #481128 -
Flags: approval2.0+
Assignee | ||
Updated•14 years ago
|
Whiteboard: [has patch][needs review jst] → [needs landing]
Assignee | ||
Comment 7•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Target Milestone: --- → mozilla2.0b8
Comment 8•14 years ago
|
||
Comment on attachment 481128 [details] [diff] [review]
Patch (v1)
This seems wrong. GetMozAutoplayEnabled isn't what decides whether a video is played or not, it just reflects the mAutoplayEnabled boolean. In BindToTree GetMozAutoplayEnabled is never called. Seems to me like this check really belongs in IsAutoplayEnabled or something, although technically that may be wrong too since autoplay is really enabled, but the video won't autoplay for other reasons.
My .02.
Attachment #481128 -
Flags: review-
Comment 9•14 years ago
|
||
The check should probably go in the same place as (!aDocument || !aDocument->IsStaticDocument()) in BindToTree. Ftr, the test won't catch this since it doesn't check if the video is playing or not (since there is no source anyhow)...
Comment 10•14 years ago
|
||
Ah, I thought the xbl code was what started the autoplay. Do we have some other code actually doing it?
Updated•14 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 11•14 years ago
|
||
(In reply to comment #10)
Nope. Seems like the deciding place is here: http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsHTMLMediaElement.cpp?mark=2179-2192#2171
NotifyAutoplayDataReady is called from different locations (sometimes the decoder) once the video data is ready, and then it is played.
Comment 12•14 years ago
|
||
See the url for a testcase. mozAutoplayEnabled will report false, but the video will still play.
Status: REOPENED → ASSIGNED
Assignee | ||
Comment 13•14 years ago
|
||
Hmm, I'd expect this approach to work, but I'm obviously wrong, as the test fails, and I actually see that the media elements are playing on the screen...
Matthew, do you have any idea what I'm missing here?
Attachment #481128 -
Attachment is obsolete: true
Attachment #483228 -
Flags: feedback?(kinetik)
Comment 14•14 years ago
|
||
In nsHTMLMediaElement::BindToTree() when we set mAutoplayEnabled, IsEditable() is returning PR_FALSE because the video element itself isn't contentEditable, and it's not in the designMode document yet because we call IsEditable() *before* we call to nsGenericHTMLElement::BindToTree() to do the binding.
If you set mAutoplayEnabled after the call to nsGenericHTMLElement::BindToTree(), the video element's in the document, and it seems to work.
You're also calling video.play() in your testcase, that's probably not helping! ;)
Comment 15•14 years ago
|
||
(In reply to comment #14)
> If you set mAutoplayEnabled after the call to
> nsGenericHTMLElement::BindToTree(), the video element's in the document, and it
> seems to work.
The only problem with that is whether the video controls will read the property in time. Video controls is the current consumer for mozAutoplayEnabled.
Comment 16•14 years ago
|
||
(In reply to comment #15)
> (In reply to comment #14)
> > If you set mAutoplayEnabled after the call to
> > nsGenericHTMLElement::BindToTree(), the video element's in the document, and it
> > seems to work.
>
> The only problem with that is whether the video controls will read the property
> in time. Video controls is the current consumer for mozAutoplayEnabled.
Ok, when setting mAutoplayEnabled as well as checking !IsEditable() we could also check if !aDocument->HasFlag(NODE_IS_EDITABLE) then?
With or without this patch, I still don't see video controls being displayed in designMode documents.
Assignee | ||
Comment 17•14 years ago
|
||
(In reply to comment #14)
> In nsHTMLMediaElement::BindToTree() when we set mAutoplayEnabled, IsEditable()
> is returning PR_FALSE because the video element itself isn't contentEditable,
> and it's not in the designMode document yet because we call IsEditable()
> *before* we call to nsGenericHTMLElement::BindToTree() to do the binding.
Ah, right!
> If you set mAutoplayEnabled after the call to
> nsGenericHTMLElement::BindToTree(), the video element's in the document, and it
> seems to work.
Yep!
> You're also calling video.play() in your testcase, that's probably not helping!
> ;)
Indeed, it's not helping at all! So much for hg copy&&paste I guess!
Assignee | ||
Comment 18•14 years ago
|
||
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #14)
> > > If you set mAutoplayEnabled after the call to
> > > nsGenericHTMLElement::BindToTree(), the video element's in the document, and it
> > > seems to work.
> >
> > The only problem with that is whether the video controls will read the property
> > in time. Video controls is the current consumer for mozAutoplayEnabled.
>
> Ok, when setting mAutoplayEnabled as well as checking !IsEditable() we could
> also check if !aDocument->HasFlag(NODE_IS_EDITABLE) then?
Sounds reasonable.
> With or without this patch, I still don't see video controls being displayed in
> designMode documents.
Hmm, does the same thing happen if <body> is contenteditable, for example?
Assignee | ||
Comment 19•14 years ago
|
||
Attachment #483228 -
Attachment is obsolete: true
Attachment #483352 -
Flags: review?(bzbarsky)
Attachment #483352 -
Flags: approval2.0?
Attachment #483228 -
Flags: feedback?(kinetik)
Comment 20•14 years ago
|
||
(In reply to comment #18)
> > With or without this patch, I still don't see video controls being displayed in
> > designMode documents.
>
> Hmm, does the same thing happen if <body> is contenteditable, for example?
The behaviour I see with your patch applied is:
1. Setting document.designMode="on" *before* the video element gets parsed and added to page - controls do not appear.
2. Seting document.designMode="on" *after* the video element gets parsed and added to page - controls do not appear.
3. contentEditable <body> - controls appear.
In all of those cases I see lots of assertion failures when I type, such as:
WARNING: NS_ENSURE_TRUE(outNode && inNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/li
beditor/html/../../../../editor/libeditor/html/nsHTMLEditor.cpp, line 4602
0[1dc680]: WARNING: NS_ENSURE_TRUE(node) failed: file c:/Users/cpearce/src/orange/objdir/editor/libe
ditor/html/../../../../editor/libeditor/html/nsHTMLEditor.cpp, line 4687
WARNING: NS_ENSURE_TRUE(node) failed: file c:/Users/cpearce/src/orange/objdir/editor/libeditor/html/
../../../../editor/libeditor/html/nsHTMLEditor.cpp, line 4687
0[1dc680]: WARNING: NS_ENSURE_TRUE(mListenerEnabled) failed: file c:/Users/cpearce/src/orange/objdir
/editor/libeditor/html/../../../../editor/libeditor/html/nsHTMLEditRules.cpp, line 8518
WARNING: NS_ENSURE_TRUE(mListenerEnabled) failed: file c:/Users/cpearce/src/orange/objdir/editor/lib
editor/html/../../../../editor/libeditor/html/nsHTMLEditRules.cpp, line 8518
0[1dc680]: WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libe
ditor/html/../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libeditor/html/
../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
0[1dc680]: WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libe
ditor/html/../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libeditor/html/
../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
0[1dc680]: WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libe
ditor/html/../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
WARNING: NS_ENSURE_TRUE(elem) failed: file c:/Users/cpearce/src/orange/objdir/editor/libeditor/html/
../../../../editor/libeditor/html/nsHTMLEditUtils.cpp, line 396
0[1dc680]: WARNING: NS_ENSURE_TRUE(mLastNBSPNode) failed: file c:/Users/cpearce/src/orange/objdir/ed
itor/libeditor/html/../../../../editor/libeditor/html/nsWSRunObject.cpp, line 663
WARNING: NS_ENSURE_TRUE(mLastNBSPNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/libedi
tor/html/../../../../editor/libeditor/html/nsWSRunObject.cpp, line 663
0[1dc680]: WARNING: NS_ENSURE_TRUE(mLastNBSPNode) failed: file c:/Users/cpearce/src/orange/objdir/ed
itor/libeditor/html/../../../../editor/libeditor/html/nsWSRunObject.cpp, line 663
WARNING: NS_ENSURE_TRUE(mLastNBSPNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/libedi
tor/html/../../../../editor/libeditor/html/nsWSRunObject.cpp, line 663
0[1dc680]: WARNING: NS_ENSURE_TRUE(*outIsEmptyNode) failed: file c:/Users/cpearce/src/orange/objdir/
editor/libeditor/html/../../../../editor/libeditor/html/nsHTMLEditor.cpp, line 5095
WARNING: NS_ENSURE_TRUE(*outIsEmptyNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/libe
ditor/html/../../../../editor/libeditor/html/nsHTMLEditor.cpp, line 5095
0[1dc680]: WARNING: NS_ENSURE_TRUE(aNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/lib
editor/base/../../../../editor/libeditor/base/nsEditor.cpp, line 3599
WARNING: NS_ENSURE_TRUE(aNode) failed: file c:/Users/cpearce/src/orange/objdir/editor/libeditor/base
/../../../../editor/libeditor/base/nsEditor.cpp, line 3599
Comment 21•14 years ago
|
||
That patch doesn't look right for cases where the document is not editable but the new parent (and hence our node, but only after we finish the bind) is....
Why can't we just do this check after calling the superclass BindToTree?
Assignee | ||
Comment 22•14 years ago
|
||
(In reply to comment #21)
> That patch doesn't look right for cases where the document is not editable but
> the new parent (and hence our node, but only after we finish the bind) is....
Right.
> Why can't we just do this check after calling the superclass BindToTree?
This version of the patch does that.
Attachment #483352 -
Attachment is obsolete: true
Attachment #483546 -
Flags: review?(bzbarsky)
Attachment #483546 -
Flags: approval2.0?
Attachment #483352 -
Flags: review?(bzbarsky)
Attachment #483352 -
Flags: approval2.0?
Comment 23•14 years ago
|
||
If you're already bound, IsEditable() takes aDocument into account.
Why do you need the two separate sets of mAutoplayEnabled? Why not just set after the call to the superclass?
And is it me, or is mIsBindingToTree write-only?
All of which is to say, it looks like that whole block can just move past the superclass bind call....
Assignee | ||
Comment 24•14 years ago
|
||
(In reply to comment #23)
> If you're already bound, IsEditable() takes aDocument into account.
True.
> Why do you need the two separate sets of mAutoplayEnabled? Why not just set
> after the call to the superclass?
Well, I wasn't sure if it's safe to do that... But I guess nsGenericHTMLElement::BindToTree doesn't touch mAutoplayEnabled... ;-)
> And is it me, or is mIsBindingToTree write-only?
Seems like a superfluous variable. Removed it in this version of the patch.
> All of which is to say, it looks like that whole block can just move past the
> superclass bind call....
Done.
Attachment #483546 -
Attachment is obsolete: true
Attachment #483578 -
Flags: review?(bzbarsky)
Attachment #483578 -
Flags: approval2.0?
Attachment #483546 -
Flags: review?(bzbarsky)
Attachment #483546 -
Flags: approval2.0?
Comment 25•14 years ago
|
||
Hmm. Why is the change to CanActivateAutoplay needed?
Assignee | ||
Comment 26•14 years ago
|
||
In case autoplay can get triggered before a node has been bound to a document tree. I;m nit sure if that can happen in practice though.
Comment 27•14 years ago
|
||
It'd be good if someone who understands autoplay can check that part over.
The rest of the patch looks fine to me.
Assignee | ||
Comment 28•14 years ago
|
||
Comment on attachment 483578 [details] [diff] [review]
Patch (v4)
(In reply to comment #27)
> It'd be good if someone who understands autoplay can check that part over.
>
> The rest of the patch looks fine to me.
Requesting review from Chris on that.
Attachment #483578 -
Flags: review?(chris)
Comment 29•14 years ago
|
||
Comment on attachment 483578 [details] [diff] [review]
Patch (v4)
Looks good to me.
It's a shame we need to rely on a timeout for the test, but we don't have a "I didn't play" event. :/
(In reply to comment #26)
> In case autoplay can get triggered before a node has been bound to a document
> tree. I;m nit sure if that can happen in practice though.
According to the description of HAVE_ENOUGH_DATA media readyState, we should only autoplay when a media element is in a document:
http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#the-ready-states
However Firefox, Webkit and Opera do autoplay when not in a document (contrary to the spec). IE9beta does not, but I'm not convinced that's intentional... I've sent a message to the WhatWG list to see if we want to change the spec to match implemented behaviour.
In the meantime, your change to CanActivateAutoplay is needed.
Attachment #483578 -
Flags: review?(chris) → review+
Updated•14 years ago
|
Attachment #483578 -
Flags: approval2.0? → approval2.0+
Assignee | ||
Updated•14 years ago
|
Whiteboard: [needs landing]
Assignee | ||
Comment 30•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing]
Assignee | ||
Updated•14 years ago
|
Attachment #483578 -
Flags: review?(bzbarsky)
You need to log in
before you can comment on or make changes to this bug.
Description
•