2009-03-23 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2009 20:39:40 +0000 (20:39 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2009 20:39:40 +0000 (20:39 +0000)
        Reviewed by Antti Koivisto

        https://bugs.webkit.org/show_bug.cgi?id=24733

        Fix media controller with full-page zoom. Previously, the media controller
        shadow nodes never saw style changes on the RenderMedia, so did not respond
        to zooming at all. Now, we update the style on the shadow renderers
        whenever RenderMedia gets a style change. Also fix the video thumb in
        the theme to be scaled properly.

        Test: media/video-controls-zoomed.html

        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlShadowRootElement::updateStyle):
        (WebCore::MediaTextDisplayElement::MediaTextDisplayElement):
        (WebCore::MediaTextDisplayElement::updateStyle):
        (WebCore::MediaControlInputElement::MediaControlInputElement):
        (WebCore::MediaControlInputElement::updateStyle):
        * rendering/MediaControlElements.h:
        * rendering/RenderMedia.cpp:
        (WebCore::RenderMedia::styleDidChange):
        * rendering/RenderMedia.h:
        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::adjustSliderThumbSize):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41918 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/video-controls-zoomed-expected.txt [new file with mode: 0644]
LayoutTests/media/video-controls-zoomed.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/MediaControlElements.cpp
WebCore/rendering/MediaControlElements.h
WebCore/rendering/RenderMedia.cpp
WebCore/rendering/RenderMedia.h
WebCore/rendering/RenderThemeMac.mm

index 396598c..188adff 100644 (file)
@@ -1,5 +1,16 @@
 2009-03-23  Simon Fraser  <simon.fraser@apple.com>
 
+        Reviewed by Antti Koivisto
+
+        https://bugs.webkit.org/show_bug.cgi?id=24733
+        
+        Test events on the play button after zooming.
+
+        * media/video-controls-zoomed-expected.txt: Added.
+        * media/video-controls-zoomed.html: Added.
+
+2009-03-23  Simon Fraser  <simon.fraser@apple.com>
+
         Reviewed by Darin Adler
 
         https://bugs.webkit.org/show_bug.cgi?id=24736
diff --git a/LayoutTests/media/video-controls-zoomed-expected.txt b/LayoutTests/media/video-controls-zoomed-expected.txt
new file mode 100644 (file)
index 0000000..7ab5ddf
--- /dev/null
@@ -0,0 +1,9 @@
+Test controls on zoomed video.
+
+This test only runs in DRT!
+
+EXPECTED (video.controls != 'null') OK
+EVENT(load)
+EXPECTED (video.paused == 'false') OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-controls-zoomed.html b/LayoutTests/media/video-controls-zoomed.html
new file mode 100644 (file)
index 0000000..66406dc
--- /dev/null
@@ -0,0 +1,41 @@
+<html>
+<head>
+  <title>Test controls with zooming</title>
+  <style type="text/css" media="screen">
+    video {
+      margin: 50px;
+    }
+  </style>
+  <script type="text/javascript" charset="utf-8">
+    function runTest()
+    {
+      window.setTimeout(function() {
+        document.documentElement.style.zoom = '150%';
+        if (window.eventSender) 
+        {
+            eventSender.mouseMoveTo(120,432); // over play button
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+        }
+        testExpected("video.paused", false);
+        endTest();
+      }, 50);
+    }
+  </script>
+</head>
+<body>
+    <video controls></video>
+    <p>Test controls on zoomed video.</p>
+    <p>This test only runs in DRT!</p>
+    <script src=video-test.js></script>
+    <script>
+        testExpected("video.controls", null, '!=');
+        waitForEvent('load', function() {
+            runTest();
+        } );
+        video.src = 'content/test.mp4';
+    </script>
+</body>
+</html>
+
+
index 462e3c6..a3a9e0c 100644 (file)
@@ -1,3 +1,30 @@
+2009-03-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Antti Koivisto
+        
+        https://bugs.webkit.org/show_bug.cgi?id=24733
+        
+        Fix media controller with full-page zoom. Previously, the media controller
+        shadow nodes never saw style changes on the RenderMedia, so did not respond
+        to zooming at all. Now, we update the style on the shadow renderers
+        whenever RenderMedia gets a style change. Also fix the video thumb in
+        the theme to be scaled properly.
+
+        Test: media/video-controls-zoomed.html
+
+        * rendering/MediaControlElements.cpp:
+        (WebCore::MediaControlShadowRootElement::updateStyle):
+        (WebCore::MediaTextDisplayElement::MediaTextDisplayElement):
+        (WebCore::MediaTextDisplayElement::updateStyle):
+        (WebCore::MediaControlInputElement::MediaControlInputElement):
+        (WebCore::MediaControlInputElement::updateStyle):
+        * rendering/MediaControlElements.h:
+        * rendering/RenderMedia.cpp:
+        (WebCore::RenderMedia::styleDidChange):
+        * rendering/RenderMedia.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::adjustSliderThumbSize):
+
 2009-03-23  Mike Belshe  <mike@belshe.com>
 
         Reviewed by Darin Adler.
index 1ae3f15..d84e9ad 100644 (file)
@@ -68,13 +68,22 @@ MediaControlShadowRootElement::MediaControlShadowRootElement(Document* doc, HTML
     setInDocument(true);
 }
 
+void MediaControlShadowRootElement::updateStyle()
+{
+    if (renderer()) {
+        RenderStyle* timelineContainerStyle = m_mediaElement->renderer()->getCachedPseudoStyle(MEDIA_CONTROLS_TIMELINE_CONTAINER);
+        renderer()->setStyle(timelineContainerStyle);
+    }
+}
+
 // ----------------------------
 
 MediaTextDisplayElement::MediaTextDisplayElement(Document* doc, PseudoId pseudo, HTMLMediaElement* mediaElement) 
     : HTMLDivElement(divTag, doc)
     , m_mediaElement(mediaElement)
+    , m_pseudoStyleId(pseudo)
 {
-    RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(pseudo);
+    RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
     RenderObject* renderer = createRenderer(m_mediaElement->renderer()->renderArena(), style);
     if (renderer) {
         setRenderer(renderer);
@@ -97,6 +106,14 @@ void MediaTextDisplayElement::update()
         renderer()->updateFromElement();
 }
 
+void MediaTextDisplayElement::updateStyle()
+{
+    if (renderer() && m_mediaElement->renderer()) {
+        RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
+        renderer()->setStyle(style);
+    }
+}
+
 MediaTimeDisplayElement::MediaTimeDisplayElement(Document* doc, HTMLMediaElement* element, bool currentTime)
     : MediaTextDisplayElement(doc, currentTime ? MEDIA_CONTROLS_CURRENT_TIME_DISPLAY : MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, element)
 {
@@ -107,9 +124,10 @@ MediaTimeDisplayElement::MediaTimeDisplayElement(Document* doc, HTMLMediaElement
 MediaControlInputElement::MediaControlInputElement(Document* doc, PseudoId pseudo, const String& type, HTMLMediaElement* mediaElement) 
     : HTMLInputElement(inputTag, doc)
     , m_mediaElement(mediaElement)
+    , m_pseudoStyleId(pseudo)
 {
     setInputType(type);
-    RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(pseudo);
+    RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
     RenderObject* renderer = createRenderer(m_mediaElement->renderer()->renderArena(), style);
     if (renderer) {
         setRenderer(renderer);
@@ -131,6 +149,14 @@ void MediaControlInputElement::update()
         renderer()->updateFromElement();
 }
 
+void MediaControlInputElement::updateStyle()
+{
+    if (renderer() && m_mediaElement->renderer()) {
+        RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
+        renderer()->setStyle(style);
+    }
+}
+
 bool MediaControlInputElement::hitTest(const IntPoint& absPoint)
 {
     if (renderer() && renderer()->style()->hasAppearance())
index 9eeb113..fa0fb30 100644 (file)
@@ -56,6 +56,8 @@ public:
     
     virtual bool isShadowNode() const { return true; }
     virtual Node* shadowParentNode() { return m_mediaElement; }
+
+    void updateStyle();
     
 private:
     HTMLMediaElement* m_mediaElement;    
@@ -69,8 +71,10 @@ public:
     MediaTextDisplayElement(Document*, PseudoId, HTMLMediaElement*);
     void attachToParent(Element*);
     void update();
+    void updateStyle();
 protected:
     HTMLMediaElement* m_mediaElement;   
+    PseudoId m_pseudoStyleId;
 };
 
 // ----------------------------
@@ -87,9 +91,11 @@ public:
     MediaControlInputElement(Document*, PseudoId, const String& type, HTMLMediaElement*);
     void attachToParent(Element*);
     void update();
+    void updateStyle();
     bool hitTest(const IntPoint& absPoint);
 protected:
     HTMLMediaElement* m_mediaElement;   
+    PseudoId m_pseudoStyleId;
 };
 
 // ----------------------------
index 51d88c6..42cd709 100644 (file)
@@ -103,6 +103,28 @@ MediaPlayer* RenderMedia::player() const
     return mediaElement()->player();
 }
 
+void RenderMedia::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
+{
+    RenderReplaced::styleDidChange(diff, oldStyle);
+
+    if (m_controlsShadowRoot) {
+        if (m_panel->renderer())
+            m_panel->renderer()->setStyle(getCachedPseudoStyle(MEDIA_CONTROLS_PANEL));
+
+        if (m_timelineContainer->renderer())
+            m_timelineContainer->renderer()->setStyle(getCachedPseudoStyle(MEDIA_CONTROLS_TIMELINE_CONTAINER));
+        
+        m_muteButton->updateStyle();
+        m_playButton->updateStyle();
+        m_seekBackButton->updateStyle();
+        m_seekForwardButton->updateStyle();
+        m_timeline->updateStyle();
+        m_fullscreenButton->updateStyle();
+        m_currentTimeDisplay->updateStyle();
+        m_timeRemainingDisplay->updateStyle();
+    }
+}
+
 void RenderMedia::layout()
 {
     IntSize oldSize = contentBoxRect().size();
index ff2cdb3..0e56dab 100644 (file)
@@ -98,6 +98,8 @@ private:
     void changeOpacity(HTMLElement*, float opacity);
     void opacityAnimationTimerFired(Timer<RenderMedia>*);
 
+    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
+
     RefPtr<HTMLElement> m_controlsShadowRoot;
     RefPtr<HTMLElement> m_panel;
     RefPtr<MediaControlMuteButtonElement> m_muteButton;
index 0c12b62..7d1a60e 100644 (file)
@@ -1455,8 +1455,8 @@ void RenderThemeMac::adjustSliderThumbSize(RenderObject* o) const
             height = size.height;
         }
 
-        o->style()->setWidth(Length(width, Fixed));
-        o->style()->setHeight(Length(height, Fixed));
+        o->style()->setWidth(Length(static_cast<int>(width * zoomLevel), Fixed));
+        o->style()->setHeight(Length(static_cast<int>(height * zoomLevel), Fixed));
     }
 #endif
 }