Bug 68034 - Update media-controls.js so it can find the timeline slider
Summary: Update media-controls.js so it can find the timeline slider
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks: 68038
  Show dependency treegraph
 
Reported: 2011-09-13 15:06 PDT by Eric Carlson
Modified: 2011-09-14 12:27 PDT (History)
1 user (show)

See Also:


Attachments
Proposed patch. (2.31 KB, patch)
2011-09-13 15:12 PDT, Eric Carlson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2011-09-13 15:06:49 PDT
The mediaControlsButtonCoordinates() function in LayoutTests/media/media-controls.js returns the center point of an element in the media controller so it is possible to write cross-platform tests that use the controls. It doesn't work with the timeline slider or volume slider because it assumes that all of the elements in the controller are siblings.
Comment 1 Eric Carlson 2011-09-13 15:12:53 PDT
Created attachment 107239 [details]
Proposed patch.
Comment 2 Darin Adler 2011-09-13 16:45:08 PDT
Comment on attachment 107239 [details]
Proposed patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=107239&action=review

r=me -- this code seems like it will work but there are some things worth fixing

> LayoutTests/media/media-controls.js:2
> +function mediaConrolsElement(parent, id)

Typo here: "conrols".

Not sure that naming this argument “parent” is good; the code iterates the siblings of what’s passed in, not its children.

> LayoutTests/media/media-controls.js:5
> +    if (parent.nodeType !== Node.ELEMENT_NODE)
> +        return null;

I don’t think this is needed. Not sure why you are checking the type of the first element in a sibling list but not the types of the rest. As far as I can tell no checking is needed.

> LayoutTests/media/media-controls.js:7
> +    controlID = "-webkit-media-controls-" + id;

Should use var here.

> LayoutTests/media/media-controls.js:13
> +            var childElement = mediaConrolsElement(element.firstChild, id);

This will work, but there are also non-recursive ways to walk an entire hierarchy.

> LayoutTests/media/media-controls.js:25
> +    var controlsShadow = internals.shadowRoot(element).firstChild.firstChild;

Would be nice to have a why comment here explaining why we are descending two levels deep with firstChild.
Comment 3 Eric Carlson 2011-09-13 18:03:16 PDT
(In reply to comment #2)
> (From update of attachment 107239 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=107239&action=review
> 
> r=me -- this code seems like it will work but there are some things worth fixing
> 
> > LayoutTests/media/media-controls.js:2
> > +function mediaConrolsElement(parent, id)
> 
> Typo here: "conrols".
> 
> Not sure that naming this argument “parent” is good; the code iterates the siblings of what’s passed in, not its children.
> 
  Fixed both, thanks.

> > LayoutTests/media/media-controls.js:5
> > +    if (parent.nodeType !== Node.ELEMENT_NODE)
> > +        return null;
> 
> I don’t think this is needed. Not sure why you are checking the type of the first element in a sibling list but not the types of the rest. As far as I can tell no checking is needed.
> 
  It was there because internals.shadowPseudoId() throws an exception if called for an element that doesn't have a shadow ID and the TEXT_NODE nodes don't, but a better way to deal with that is with a comment and a try block. Fixed.

> > LayoutTests/media/media-controls.js:7
> > +    controlID = "-webkit-media-controls-" + id;
> 
> Should use var here.
> 
  Thanks, fixed.

> > LayoutTests/media/media-controls.js:13
> > +            var childElement = mediaConrolsElement(element.firstChild, id);
> 
> This will work, but there are also non-recursive ways to walk an entire hierarchy.
> 
  The media controls hierarchy is small and shallow, so I left this as is for now.

> > LayoutTests/media/media-controls.js:25
> > +    var controlsShadow = internals.shadowRoot(element).firstChild.firstChild;
> 
> Would be nice to have a why comment here explaining why we are descending two levels deep with firstChild.
>
  Good point, there isn't any reason to hard code it at two levels deep. Fixed.

Thanks!
Comment 4 Radar WebKit Bug Importer 2011-09-13 19:10:56 PDT
<rdar://problem/10120776>
Comment 5 Eric Carlson 2011-09-14 12:27:27 PDT
http://trac.webkit.org/changeset/95111