Commit 13c792d0 authored by philipj@opera.com's avatar philipj@opera.com

Remove dead code for dragging MediaControlPanelElement

Because setCanBeDragged(true) is never called, all the rest of the
dragging code becomes unreachable. The feature as such looks useful, but
it would require fixing and above all testing to interact well with text
track rendering.

BUG=341813
TEST=LayoutTests/media/ still passes, i.e. there were none!

Review URL: https://codereview.chromium.org/196533020

git-svn-id: svn://svn.chromium.org/blink/trunk@169606 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cd00ae88
......@@ -60,8 +60,6 @@ static const double fadeOutDuration = 0.3;
MediaControlPanelElement::MediaControlPanelElement(MediaControls& mediaControls)
: MediaControlDivElement(mediaControls, MediaControlsPanel)
, m_canBeDragged(false)
, m_isBeingDragged(false)
, m_isDisplayed(false)
, m_opaque(true)
, m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired)
......@@ -79,54 +77,6 @@ const AtomicString& MediaControlPanelElement::shadowPseudoId() const
return id;
}
void MediaControlPanelElement::startDrag(const LayoutPoint& eventLocation)
{
if (!m_canBeDragged)
return;
if (m_isBeingDragged)
return;
RenderObject* renderer = this->renderer();
if (!renderer || !renderer->isBox())
return;
LocalFrame* frame = document().frame();
if (!frame)
return;
m_lastDragEventLocation = eventLocation;
frame->eventHandler().setCapturingMouseEventsNode(this);
m_isBeingDragged = true;
}
void MediaControlPanelElement::continueDrag(const LayoutPoint& eventLocation)
{
if (!m_isBeingDragged)
return;
LayoutSize distanceDragged = eventLocation - m_lastDragEventLocation;
m_cumulativeDragOffset.move(distanceDragged);
m_lastDragEventLocation = eventLocation;
setPosition(m_cumulativeDragOffset);
}
void MediaControlPanelElement::endDrag()
{
if (!m_isBeingDragged)
return;
m_isBeingDragged = false;
LocalFrame* frame = document().frame();
if (!frame)
return;
frame->eventHandler().setCapturingMouseEventsNode(nullptr);
}
void MediaControlPanelElement::startTimer()
{
stopTimer();
......@@ -152,35 +102,6 @@ void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelEleme
stopTimer();
}
void MediaControlPanelElement::setPosition(const LayoutPoint& position)
{
// FIXME: Do we really want to up-convert these to doubles and not round? crbug.com/350474
double left = position.x().toFloat();
double top = position.y().toFloat();
// Set the left and top to control the panel's position; this depends on it being absolute positioned.
// Set the margin to zero since the position passed in will already include the effect of the margin.
setInlineStyleProperty(CSSPropertyLeft, left, CSSPrimitiveValue::CSS_PX);
setInlineStyleProperty(CSSPropertyTop, top, CSSPrimitiveValue::CSS_PX);
setInlineStyleProperty(CSSPropertyMarginLeft, 0.0, CSSPrimitiveValue::CSS_PX);
setInlineStyleProperty(CSSPropertyMarginTop, 0.0, CSSPrimitiveValue::CSS_PX);
classList().add("dragged", IGNORE_EXCEPTION);
}
void MediaControlPanelElement::resetPosition()
{
removeInlineStyleProperty(CSSPropertyLeft);
removeInlineStyleProperty(CSSPropertyTop);
removeInlineStyleProperty(CSSPropertyMarginLeft);
removeInlineStyleProperty(CSSPropertyMarginTop);
classList().remove("dragged", IGNORE_EXCEPTION);
m_cumulativeDragOffset.setX(0);
m_cumulativeDragOffset.setY(0);
}
void MediaControlPanelElement::makeOpaque()
{
if (m_opaque)
......@@ -209,36 +130,6 @@ void MediaControlPanelElement::makeTransparent()
startTimer();
}
void MediaControlPanelElement::defaultEventHandler(Event* event)
{
MediaControlDivElement::defaultEventHandler(event);
if (event->isMouseEvent()) {
LayoutPoint location = toMouseEvent(event)->absoluteLocation();
if (event->type() == EventTypeNames::mousedown && event->target() == this) {
startDrag(location);
event->setDefaultHandled();
} else if (event->type() == EventTypeNames::mousemove && m_isBeingDragged)
continueDrag(location);
else if (event->type() == EventTypeNames::mouseup && m_isBeingDragged) {
continueDrag(location);
endDrag();
event->setDefaultHandled();
}
}
}
void MediaControlPanelElement::setCanBeDragged(bool canBeDragged)
{
if (m_canBeDragged == canBeDragged)
return;
m_canBeDragged = canBeDragged;
if (!canBeDragged)
endDrag();
}
void MediaControlPanelElement::setIsDisplayed(bool isDisplayed)
{
m_isDisplayed = isDisplayed;
......
......@@ -40,38 +40,22 @@ class MediaControlPanelElement FINAL : public MediaControlDivElement {
public:
static PassRefPtr<MediaControlPanelElement> create(MediaControls&);
void setCanBeDragged(bool);
void setIsDisplayed(bool);
void resetPosition();
void makeOpaque();
void makeTransparent();
virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
virtual bool willRespondToMouseClickEvents() OVERRIDE { return true; }
private:
explicit MediaControlPanelElement(MediaControls&);
virtual const AtomicString& shadowPseudoId() const OVERRIDE;
virtual void defaultEventHandler(Event*) OVERRIDE;
void startDrag(const LayoutPoint& eventLocation);
void continueDrag(const LayoutPoint& eventLocation);
void endDrag();
void startTimer();
void stopTimer();
void transitionTimerFired(Timer<MediaControlPanelElement>*);
void setPosition(const LayoutPoint&);
bool m_canBeDragged;
bool m_isBeingDragged;
bool m_isDisplayed;
bool m_opaque;
LayoutPoint m_lastDragEventLocation;
LayoutPoint m_cumulativeDragOffset;
Timer<MediaControlPanelElement> m_transitionTimer;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment