Changeset 88546 in webkit


Ignore:
Timestamp:
Jun 10, 2011 10:05:31 AM (13 years ago)
Author:
Darin Adler
Message:

2011-06-10 Darin Adler <Darin Adler>

Reviewed by Eric Carlson.

REGRESSION: Fullscreen video controller can't be dragged
https://bugs.webkit.org/show_bug.cgi?id=62462

No regression test because we don't have machinery for testing the fullscreen
mode. We may find a way to add this in the future.

  • html/shadow/MediaControlElements.cpp: (WebCore::MediaControlPanelElement::MediaControlPanelElement): Initialize new booleans related to dragging. (WebCore::MediaControlPanelElement::startDrag): Added. Starts drag if dragging is allowed and a drag isn't already in progress. (WebCore::MediaControlPanelElement::continueDrag): Added. Moves the window if dragging is already in progress. (WebCore::MediaControlPanelElement::endDrag): Added. Ends the capture that is done during the dragging process. (WebCore::MediaControlPanelElement::setPosition): Added. Positions the panel using explicit top/left. (WebCore::MediaControlPanelElement::resetPosition): Added. Removes the positioning done by setPosition. (WebCore::MediaControlPanelElement::defaultEventHandler): Added. Calls startDrag, continueDrag, and endDrag in response to mouse events. (WebCore::MediaControlPanelElement::setCanBeDragged): Added.
  • html/shadow/MediaControlElements.h: Added new function and data members as mentioned above.
  • html/shadow/MediaControlRootElement.cpp: (WebCore::MediaControlRootElement::enteredFullscreen): Call setCanBeDragged(true) so you can drag the panel while in fullscreen. (WebCore::MediaControlRootElement::exitedFullscreen): Call setCanBeDragged(false) so you can't drag the panel while not in fullscreen. Also call resetPosition so position changes from dragging don't affect the panel in other contexts.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88544 r88546  
     12011-06-10  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Eric Carlson.
     4
     5        REGRESSION: Fullscreen video controller can't be dragged
     6        https://bugs.webkit.org/show_bug.cgi?id=62462
     7
     8        No regression test because we don't have machinery for testing the fullscreen
     9        mode. We may find a way to add this in the future.
     10
     11        * html/shadow/MediaControlElements.cpp:
     12        (WebCore::MediaControlPanelElement::MediaControlPanelElement): Initialize new
     13        booleans related to dragging.
     14        (WebCore::MediaControlPanelElement::startDrag): Added. Starts drag if dragging
     15        is allowed and a drag isn't already in progress.
     16        (WebCore::MediaControlPanelElement::continueDrag): Added. Moves the window if
     17        dragging is already in progress.
     18        (WebCore::MediaControlPanelElement::endDrag): Added. Ends the capture that is
     19        done during the dragging process.
     20        (WebCore::MediaControlPanelElement::setPosition): Added. Positions the panel
     21        using explicit top/left.
     22        (WebCore::MediaControlPanelElement::resetPosition): Added. Removes the positioning
     23        done by setPosition.
     24        (WebCore::MediaControlPanelElement::defaultEventHandler): Added. Calls startDrag,
     25        continueDrag, and endDrag in response to mouse events.
     26        (WebCore::MediaControlPanelElement::setCanBeDragged): Added.
     27        * html/shadow/MediaControlElements.h: Added new function and data members
     28        as mentioned above.
     29
     30        * html/shadow/MediaControlRootElement.cpp:
     31        (WebCore::MediaControlRootElement::enteredFullscreen): Call setCanBeDragged(true)
     32        so you can drag the panel while in fullscreen.
     33        (WebCore::MediaControlRootElement::exitedFullscreen): Call setCanBeDragged(false)
     34        so you can't drag the panel while not in fullscreen. Also call resetPosition so
     35        position changes from dragging don't affect the panel in other contexts.
     36
    1372011-06-10  Darin Adler  <darin@apple.com>
    238
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r88415 r88546  
    3434
    3535#include "CSSStyleSelector.h"
     36#include "CSSValueKeywords.h"
    3637#include "EventNames.h"
    3738#include "FloatConversion.h"
     
    100101inline MediaControlPanelElement::MediaControlPanelElement(HTMLMediaElement* mediaElement)
    101102    : MediaControlElement(mediaElement)
     103    , m_canBeDragged(false)
     104    , m_isBeingDragged(false)
    102105{
    103106}
     
    117120    DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-panel"));
    118121    return id;
     122}
     123
     124void MediaControlPanelElement::startDrag(const IntPoint& eventLocation)
     125{
     126    if (!m_canBeDragged)
     127        return;
     128
     129    if (m_isBeingDragged)
     130        return;
     131
     132    RenderObject* renderer = this->renderer();
     133    if (!renderer || !renderer->isBox())
     134        return;
     135
     136    Frame* frame = document()->frame();
     137    if (!frame)
     138        return;
     139
     140    m_dragStartPosition = toRenderBox(renderer)->location();
     141    m_dragStartEventLocation = eventLocation;
     142
     143    frame->eventHandler()->setCapturingMouseEventsNode(this);
     144
     145    m_isBeingDragged = true;
     146}
     147
     148void MediaControlPanelElement::continueDrag(const IntPoint& eventLocation)
     149{
     150    if (!m_isBeingDragged)
     151        return;
     152
     153    IntSize distanceDragged = eventLocation - m_dragStartEventLocation;
     154    setPosition(m_dragStartPosition + distanceDragged);
     155}
     156
     157void MediaControlPanelElement::endDrag()
     158{
     159    if (!m_isBeingDragged)
     160        return;
     161
     162    m_isBeingDragged = false;
     163
     164    Frame* frame = document()->frame();
     165    if (!frame)
     166        return;
     167
     168    frame->eventHandler()->setCapturingMouseEventsNode(0);
     169}
     170
     171void MediaControlPanelElement::setPosition(const IntPoint& position)
     172{
     173    CSSMutableStyleDeclaration* style = getInlineStyleDecl();
     174
     175    double left = position.x();
     176    double top = position.y();
     177
     178    // Set the left and top to control the panel's position; this depends on it being absolute positioned.
     179    // Set the margin to zero since the position passed in will already include the effect of the margin.
     180    style->setProperty(CSSPropertyLeft, left, CSSPrimitiveValue::CSS_PX);
     181    style->setProperty(CSSPropertyTop, top, CSSPrimitiveValue::CSS_PX);
     182    style->setProperty(CSSPropertyMarginLeft, 0.0, CSSPrimitiveValue::CSS_PX);
     183    style->setProperty(CSSPropertyMarginTop, 0.0, CSSPrimitiveValue::CSS_PX);
     184}
     185
     186void MediaControlPanelElement::resetPosition()
     187{
     188    CSSMutableStyleDeclaration* style = getInlineStyleDecl();
     189
     190    style->removeProperty(CSSPropertyLeft);
     191    style->removeProperty(CSSPropertyTop);
     192    style->removeProperty(CSSPropertyMarginLeft);
     193    style->removeProperty(CSSPropertyMarginTop);
     194}
     195
     196void MediaControlPanelElement::defaultEventHandler(Event* event)
     197{
     198    MediaControlElement::defaultEventHandler(event);
     199
     200    if (event->isMouseEvent()) {
     201        IntPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
     202        if (event->type() == eventNames().mousedownEvent) {
     203            startDrag(location);
     204            event->setDefaultHandled();
     205        } else if (event->type() == eventNames().mousemoveEvent)
     206            continueDrag(location);
     207        else if (event->type() == eventNames().mouseupEvent) {
     208            continueDrag(location);
     209            endDrag();
     210            event->setDefaultHandled();
     211        }
     212    }
     213}
     214
     215void MediaControlPanelElement::setCanBeDragged(bool canBeDragged)
     216{
     217    if (m_canBeDragged == canBeDragged)
     218        return;
     219
     220    m_canBeDragged = canBeDragged;
     221
     222    if (!canBeDragged)
     223        endDrag();
    119224}
    120225
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r88415 r88546  
    100100    static PassRefPtr<MediaControlPanelElement> create(HTMLMediaElement*);
    101101
     102    void setCanBeDragged(bool);
     103    void resetPosition();
     104
    102105private:
    103106    MediaControlPanelElement(HTMLMediaElement*);
    104107    virtual MediaControlElementType displayType() const;
    105108    virtual const AtomicString& shadowPseudoId() const;
     109    virtual void defaultEventHandler(Event*);
     110
     111    void startDrag(const IntPoint& eventLocation);
     112    void continueDrag(const IntPoint& eventLocation);
     113    void endDrag();
     114
     115    void setPosition(const IntPoint&);
     116
     117    bool m_canBeDragged;
     118    bool m_isBeingDragged;
     119    IntPoint m_dragStartPosition;
     120    IntPoint m_dragStartEventLocation;
    106121};
    107122
  • trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp

    r87703 r88546  
    452452    }
    453453
     454    m_panel->setCanBeDragged(true);
     455
    454456    startHideFullscreenControlsTimer();
    455457}
     
    464466    m_seekForwardButton->show();
    465467    m_returnToRealTimeButton->show();
     468
     469    m_panel->setCanBeDragged(false);
     470
     471    // We will keep using the panel, but we want it to go back to the standard position.
     472    // This will matter right away because we use the panel even when not fullscreen.
     473    // And if we reenter fullscreen we also want the panel in the standard position.
     474    m_panel->resetPosition();
    466475
    467476    stopHideFullscreenControlsTimer();   
Note: See TracChangeset for help on using the changeset viewer.