Title: [95111] trunk/LayoutTests
Revision
95111
Author
[email protected]
Date
2011-09-14 12:25:46 -0700 (Wed, 14 Sep 2011)

Log Message

Update media-controls.js so it can find the timeline slider
https://bugs.webkit.org/show_bug.cgi?id=68034

Don't assume that all elements in the media controller shadow DOM pseudo
elements are siblings.

Reviewed by Darin Adler.

* media/media-controls.js:
(mediaConrolsElement):
(mediaControlsButtonCoordinates):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95110 => 95111)


--- trunk/LayoutTests/ChangeLog	2011-09-14 19:10:04 UTC (rev 95110)
+++ trunk/LayoutTests/ChangeLog	2011-09-14 19:25:46 UTC (rev 95111)
@@ -1,3 +1,17 @@
+2011-09-14  Eric Carlson  <[email protected]>
+
+        Update media-controls.js so it can find the timeline slider
+        https://bugs.webkit.org/show_bug.cgi?id=68034
+
+        Don't assume that all elements in the media controller shadow DOM pseudo
+        elements are siblings.
+
+        Reviewed by Darin Adler.
+
+        * media/media-controls.js:
+        (mediaConrolsElement):
+        (mediaControlsButtonCoordinates):
+
 2011-09-14  Cary Clark  <[email protected]>
 
         Unreviewed; new baselines (Skia on Mac)

Modified: trunk/LayoutTests/media/media-controls.js (95110 => 95111)


--- trunk/LayoutTests/media/media-controls.js	2011-09-14 19:10:04 UTC (rev 95110)
+++ trunk/LayoutTests/media/media-controls.js	2011-09-14 19:25:46 UTC (rev 95111)
@@ -1,17 +1,31 @@
 
-function mediaControlsButtonCoordinates(element, id)
+function mediaControlsElement(first, id)
 {
-    var button;
-    var controlsShadow = internals.shadowRoot(element).firstChild.firstChild;
-    for (child = controlsShadow.firstChild; child; child = child.nextSibling) {
-        if (internals.shadowPseudoId(child) == "-webkit-media-controls-" + id) {
-            button = child;
-            break;
+    var controlID = "-webkit-media-controls-" + id;
+    for (var element = first; element; element = element.nextSibling) {
+
+        // Not every element in the media controls has a shadow pseudo ID, eg. the
+        // text nodes for the time values, so guard against exceptions.
+        try {
+            if (internals.shadowPseudoId(element) == controlID)
+                return element;
+        } catch (exception) { }
+
+        if (element.firstChild) {
+            var childElement = mediaControlsElement(element.firstChild, id);
+            if (childElement)
+                return childElement;
         }
     }
 
+    return null;
+}
+
+function mediaControlsButtonCoordinates(element, id)
+{
+    var button = mediaControlsElement(internals.shadowRoot(element).firstChild, id);
     if (!button)
-        throw "Failed to find button " + id;
+        throw "Failed to find media control element ID '" + id + "'";
 
     var buttonBoundingRect = button.getBoundingClientRect();
     var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to