Title: [105185] branches/safari-534.54-branch/Source/WebCore

Diff

Modified: branches/safari-534.54-branch/Source/WebCore/ChangeLog (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/ChangeLog	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/ChangeLog	2012-01-17 20:44:49 UTC (rev 105185)
@@ -1,5 +1,43 @@
 2012-01-17  Mark Rowe  <[email protected]>
 
+        Merge r100408.
+
+    2011-11-15  Darin Adler  <[email protected]>
+
+        Incorrect type checks in RenderTheme media code
+        https://bugs.webkit.org/show_bug.cgi?id=72184
+
+        Reviewed by Eric Carlson.
+
+        No tests added. Ideally this patch should be revised to add tests!
+
+        * accessibility/AccessibilityMediaControls.cpp:
+        (WebCore::AccessibilityMediaControl::create): Use mediaControlElementType.
+        (WebCore::AccessibilityMediaControl::controlType): Ditto.
+        (WebCore::AccessibilityMediaTimeline::valueDescription): Use early return
+        rather than an assertion to check type of input element.
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::mediaControlElementType): Added. A type-safe way to get the
+        media control element type after checking isMediaControlElement but with
+        no other assumptions.
+        * html/shadow/MediaControlElements.h: Added mediaControlElementType.
+
+        * platform/efl/RenderThemeEfl.cpp:
+        (WebCore::RenderThemeEfl::paintMediaPlayButton): Use mediaControlElementType.
+        (WebCore::RenderThemeEfl::paintMediaSeekBackButton): Use mediaControlElementType.
+        (WebCore::RenderThemeEfl::paintMediaSeekForwardButton): Use mediaControlElementType.
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::paintMediaPlayButton): Check isMediaControlElement and
+        use mediaControlElementType.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMediaMuteButton): Ditto. Also remove uneeded
+        redundant null check.
+        (WebCore::RenderThemeMac::paintMediaPlayButton): Ditto.
+        (WebCore::RenderThemeMac::paintMediaToggleClosedCaptionsButton): Ditto.
+
+2012-01-17  Mark Rowe  <[email protected]>
+
         Merge r101543.
 
     2011-11-30  James Simonsen  <[email protected]>

Modified: branches/safari-534.54-branch/Source/WebCore/accessibility/AccessibilityMediaControls.cpp (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/accessibility/AccessibilityMediaControls.cpp	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/accessibility/AccessibilityMediaControls.cpp	2012-01-17 20:44:49 UTC (rev 105185)
@@ -53,18 +53,10 @@
 
 PassRefPtr<AccessibilityObject> AccessibilityMediaControl::create(RenderObject* renderer)
 {
-    ASSERT(renderer->node() && renderer->node()->isMediaControlElement());
+    ASSERT(renderer->node());
 
-    Node* node = renderer->node();
-    MediaControlElementType controlType;
-
-    if (node->hasTagName(inputTag))
-        controlType = static_cast<MediaControlInputElement*>(node)->displayType();
-    else
-        controlType = static_cast<MediaControlElement*>(node)->displayType();
-
     PassRefPtr<AccessibilityObject> obj;
-    switch (controlType) {
+    switch (mediaControlElementType(renderer->node())) {
     case MediaSlider:
         obj = AccessibilityMediaTimeline::create(renderer);
         break;
@@ -91,12 +83,7 @@
     if (!renderer() || !renderer()->node())
         return MediaTimelineContainer; // Timeline container is not accessible.
 
-    Node* node = renderer()->node();
-
-    if (node->hasTagName(inputTag))
-        return static_cast<MediaControlInputElement*>(node)->displayType();
-
-    return static_cast<MediaControlElement*>(node)->displayType();
+    return mediaControlElementType(renderer()->node());
 }
 
 String AccessibilityMediaControl::controlTypeName() const
@@ -271,9 +258,11 @@
 
 String AccessibilityMediaTimeline::valueDescription() const
 {
-    ASSERT(m_renderer->node()->hasTagName(inputTag));
+    Node* node = m_renderer->node();
+    if (!node->hasTagName(inputTag))
+        return String();
 
-    float time = static_cast<HTMLInputElement*>(m_renderer->node())->value().toFloat();
+    float time = static_cast<HTMLInputElement*>(node)->value().toFloat();
     return localizedMediaTimeDescription(time);
 }
 

Modified: branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.cpp (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.cpp	2012-01-17 20:44:49 UTC (rev 105185)
@@ -52,6 +52,11 @@
 
 using namespace HTMLNames;
 
+// FIXME: These constants may need to be tweaked to better match the seeking in the QuickTime plug-in.
+static const float cSeekRepeatDelay = 0.1f;
+static const float cStepTime = 0.07f;
+static const float cSeekTime = 0.2f;
+
 HTMLMediaElement* toParentMediaElement(RenderObject* o)
 {
     Node* node = o->node();
@@ -62,10 +67,14 @@
     return static_cast<HTMLMediaElement*>(mediaNode);
 }
 
-// FIXME: These constants may need to be tweaked to better match the seeking in the QuickTime plug-in.
-static const float cSeekRepeatDelay = 0.1f;
-static const float cStepTime = 0.07f;
-static const float cSeekTime = 0.2f;
+MediaControlElementType mediaControlElementType(Node* node)
+{
+    ASSERT(node->isMediaControlElement());
+    HTMLElement* element = toHTMLElement(node);
+    if (element->hasTagName(inputTag))
+        return static_cast<MediaControlInputElement*>(element)->displayType();
+    return static_cast<MediaControlElement*>(element)->displayType();
+}
 
 // ----------------------------
 

Modified: branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.h (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.h	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/html/shadow/MediaControlElements.h	2012-01-17 20:44:49 UTC (rev 105185)
@@ -72,6 +72,8 @@
 
 HTMLMediaElement* toParentMediaElement(RenderObject*);
 
+MediaControlElementType mediaControlElementType(Node*);
+
 // ----------------------------
 
 class MediaControlElement : public HTMLDivElement {

Modified: branches/safari-534.54-branch/Source/WebCore/platform/efl/RenderThemeEfl.cpp (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/platform/efl/RenderThemeEfl.cpp	2012-01-17 20:44:49 UTC (rev 105185)
@@ -1131,8 +1131,7 @@
     if (!node || !node->isMediaControlElement())
         return false;
 
-    MediaControlPlayButtonElement* button = static_cast<MediaControlPlayButtonElement*>(node);
-    if (!emitMediaButtonSignal(PlayPauseButton, button->displayType(), rect))
+    if (!emitMediaButtonSignal(PlayPauseButton, mediaControlElementType(node), rect))
         return false;
 
     return paintThemePart(object, PlayPauseButton, info, rect);
@@ -1144,8 +1143,7 @@
     if (!node || !node->isMediaControlElement())
         return 0;
 
-    MediaControlSeekButtonElement* button = static_cast<MediaControlSeekButtonElement*>(node);
-    if (!emitMediaButtonSignal(SeekBackwardButton, button->displayType(), rect))
+    if (!emitMediaButtonSignal(SeekBackwardButton, mediaControlElementType(node), rect))
         return false;
 
     return paintThemePart(object, SeekBackwardButton, info, rect);
@@ -1157,8 +1155,7 @@
     if (!node || !node->isMediaControlElement())
         return 0;
 
-    MediaControlSeekButtonElement* button = static_cast<MediaControlSeekButtonElement*>(node);
-    if (!emitMediaButtonSignal(SeekForwardButton, button->displayType(), rect))
+    if (!emitMediaButtonSignal(SeekForwardButton, mediaControlElementType(node), rect))
         return false;
 
     return paintThemePart(object, SeekForwardButton, info, rect);

Modified: branches/safari-534.54-branch/Source/WebCore/platform/gtk/RenderThemeGtk.cpp (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/platform/gtk/RenderThemeGtk.cpp	2012-01-17 20:44:49 UTC (rev 105185)
@@ -512,9 +512,10 @@
     Node* node = renderObject->node();
     if (!node)
         return false;
+    if (!node->isMediaControlElement())
+        return false;
 
-    MediaControlPlayButtonElement* button = static_cast<MediaControlPlayButtonElement*>(node);
-    return paintMediaButton(renderObject, paintInfo.context, rect, button->displayType() == MediaPlayButton ? GTK_STOCK_MEDIA_PLAY : GTK_STOCK_MEDIA_PAUSE);
+    return paintMediaButton(renderObject, paintInfo.context, rect, mediaControlElementType(node) == MediaPlayButton ? GTK_STOCK_MEDIA_PLAY : GTK_STOCK_MEDIA_PAUSE);
 }
 
 bool RenderThemeGtk::paintMediaSeekBackButton(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)

Modified: branches/safari-534.54-branch/Source/WebCore/rendering/RenderThemeMac.mm (105184 => 105185)


--- branches/safari-534.54-branch/Source/WebCore/rendering/RenderThemeMac.mm	2012-01-17 20:32:59 UTC (rev 105184)
+++ branches/safari-534.54-branch/Source/WebCore/rendering/RenderThemeMac.mm	2012-01-17 20:44:49 UTC (rev 105185)
@@ -1731,10 +1731,9 @@
     if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))
         return false;
 
-    if (MediaControlMuteButtonElement* btn = static_cast<MediaControlMuteButtonElement*>(node)) {
+    if (node->isMediaControlElement()) {
         LocalCurrentGraphicsContext localContext(paintInfo.context);
-        wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
-
+        wkDrawMediaUIPart(mediaControlElementType(node), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
     }
     return false;
 }
@@ -1746,9 +1745,9 @@
     if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))
         return false;
 
-    if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) {
+    if (node->isMediaControlElement()) {
         LocalCurrentGraphicsContext localContext(paintInfo.context);
-        wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
+        wkDrawMediaUIPart(mediaControlElementType(node), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
     }
     return false;
 }
@@ -1836,16 +1835,14 @@
 
 bool RenderThemeMac::paintMediaToggleClosedCaptionsButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
-    HTMLInputElement* node = static_cast<HTMLInputElement*>(o->node());
+    Node* node = o->node();
     if (!node)
         return false;
-    
-    MediaControlToggleClosedCaptionsButtonElement* btn = static_cast<MediaControlToggleClosedCaptionsButtonElement*>(node);
-    if (!btn)
+    if (!node->isMediaControlElement())
         return false;
 
     LocalCurrentGraphicsContext localContext(paintInfo.context);
-    wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
+    wkDrawMediaUIPart(mediaControlElementType(node), mediaControllerTheme(), paintInfo.context->platformContext(), r, getMediaUIPartStateFlags(node));
 
     return false;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to