OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 m_toggleClosedCaptionsButton->show(); | 353 m_toggleClosedCaptionsButton->show(); |
354 else | 354 else |
355 m_toggleClosedCaptionsButton->hide(); | 355 m_toggleClosedCaptionsButton->hide(); |
356 } | 356 } |
357 | 357 |
358 void MediaControls::textTracksChanged() | 358 void MediaControls::textTracksChanged() |
359 { | 359 { |
360 refreshClosedCaptionsButtonVisibility(); | 360 refreshClosedCaptionsButtonVisibility(); |
361 } | 361 } |
362 | 362 |
363 void MediaControls::timelineKnobDragged() | |
364 { | |
365 resetHideMediaControlsTimer(); | |
366 } | |
367 | |
363 static Element* elementFromCenter(Element& element) | 368 static Element* elementFromCenter(Element& element) |
364 { | 369 { |
365 RefPtrWillBeRawPtr<ClientRect> clientRect = element.getBoundingClientRect(); | 370 RefPtrWillBeRawPtr<ClientRect> clientRect = element.getBoundingClientRect(); |
366 int centerX = static_cast<int>((clientRect->left() + clientRect->right()) / 2); | 371 int centerX = static_cast<int>((clientRect->left() + clientRect->right()) / 2); |
367 int centerY = static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); | 372 int centerY = static_cast<int>((clientRect->top() + clientRect->bottom()) / 2); |
368 | 373 |
369 return element.document().elementFromPoint(centerX , centerY); | 374 return element.document().elementFromPoint(centerX , centerY); |
370 } | 375 } |
371 | 376 |
372 void MediaControls::tryShowOverlayCastButton() | 377 void MediaControls::tryShowOverlayCastButton() |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 m_castButton->setIsPlayingRemotely(true); | 433 m_castButton->setIsPlayingRemotely(true); |
429 m_overlayCastButton->setIsPlayingRemotely(true); | 434 m_overlayCastButton->setIsPlayingRemotely(true); |
430 } | 435 } |
431 | 436 |
432 void MediaControls::stoppedCasting() | 437 void MediaControls::stoppedCasting() |
433 { | 438 { |
434 m_castButton->setIsPlayingRemotely(false); | 439 m_castButton->setIsPlayingRemotely(false); |
435 m_overlayCastButton->setIsPlayingRemotely(false); | 440 m_overlayCastButton->setIsPlayingRemotely(false); |
436 } | 441 } |
437 | 442 |
443 bool MediaControls::isInactiveElement(Node* node) const | |
philipj_slow
2015/02/16 10:45:19
If isn't mate moot by other changes, would willRes
| |
444 { | |
445 if (node == m_mediaElement | |
446 || node == m_textDisplayContainer | |
447 || node == m_overlayEnclosure | |
448 || node == m_enclosure) | |
449 return true; | |
450 | |
451 return false; | |
452 } | |
453 | |
438 void MediaControls::defaultEventHandler(Event* event) | 454 void MediaControls::defaultEventHandler(Event* event) |
439 { | 455 { |
440 HTMLDivElement::defaultEventHandler(event); | 456 HTMLDivElement::defaultEventHandler(event); |
441 | 457 |
442 // Add IgnoreControlsHover to m_hideTimerBehaviorFlags when we see a touch e vent, | 458 // Add IgnoreControlsHover to m_hideTimerBehaviorFlags when we see a touch e vent, |
443 // to allow the hide-timer to do the right thing when it fires. | 459 // to allow the hide-timer to do the right thing when it fires. |
444 // FIXME: Preferably we would only do this when we're actually handling the event | 460 // FIXME: Preferably we would only do this when we're actually handling the event |
445 // here ourselves. | 461 // here ourselves. |
462 bool mouseIsSynthetic = event->isMouseEvent() && toMouseEvent(event)->fromTo uch(); | |
philipj_slow
2015/02/16 10:45:19
Perhaps isMouseEventFromTouch will make sound less
| |
446 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() | 463 bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() |
philipj_slow
2015/02/16 10:45:18
I just renamed this, but actually isTouchEvent wou
| |
447 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); | 464 || mouseIsSynthetic; |
465 | |
448 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore None; | 466 m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : Ignore None; |
449 | 467 |
450 if (event->type() == EventTypeNames::mouseover) { | 468 // Separate tap gestures from mouse clicks unless the tap |
469 // is intended for an input element like a button. | |
470 if (event->type() == EventTypeNames::gesturetap) { | |
philipj_slow
2015/02/16 10:45:19
Did you first try using the touchstart and click e
Tima Vaisburd
2015/02/16 20:32:11
No, I must admit I haven't tried the touchstart ev
philipj_slow
2015/02/17 02:37:24
Overriding Node::willRespondToTouchEvents() ought
Tima Vaisburd
2015/02/19 19:32:28
I was wrong: whether touch events propagate or not
| |
471 Node * targetNode = event->target() ? event->target()->toNode() : nullpt r; | |
472 if (!targetNode || isInactiveElement(targetNode)) { | |
473 // Do not generate mouse events from this tap, | |
474 // otherwise a tap to show controls might also | |
475 // trigger some unexpected action like stop or seek. | |
476 event->preventDefault(); | |
philipj_slow
2015/02/16 10:45:19
This will be observable to Web content. An alterna
| |
477 | |
478 if (!m_panel->isOpaque()) { | |
479 makeOpaque(); | |
480 startHideMediaControlsTimer(); | |
481 // Prevent immediate hiding by playbackProgressed() | |
482 m_isMouseOverControls = true; | |
philipj_slow
2015/02/16 10:45:19
This seems like an abuse of this state variable, a
| |
483 } else { | |
484 stopHideMediaControlsTimer(); | |
485 makeTransparent(); | |
486 } | |
487 } else { | |
488 // Prevent the controls from disappearing while we are working with them | |
489 if (m_panel->isOpaque()) | |
490 resetHideMediaControlsTimer(); | |
491 } | |
492 return; | |
493 } | |
494 | |
495 if (event->type() == EventTypeNames::mouseover && !mouseIsSynthetic) { | |
451 if (!containsRelatedTarget(event)) { | 496 if (!containsRelatedTarget(event)) { |
452 m_isMouseOverControls = true; | 497 m_isMouseOverControls = true; |
453 if (!mediaElement().togglePlayStateWillPlay()) { | 498 if (!mediaElement().togglePlayStateWillPlay()) { |
454 makeOpaque(); | 499 makeOpaque(); |
455 if (shouldHideMediaControls()) | 500 if (shouldHideMediaControls()) |
456 startHideMediaControlsTimer(); | 501 startHideMediaControlsTimer(); |
457 } | 502 } |
458 } | 503 } |
459 return; | 504 return; |
460 } | 505 } |
461 | 506 |
462 if (event->type() == EventTypeNames::mouseout) { | 507 if (event->type() == EventTypeNames::mouseout && !mouseIsSynthetic) { |
463 if (!containsRelatedTarget(event)) { | 508 if (!containsRelatedTarget(event)) { |
464 m_isMouseOverControls = false; | 509 m_isMouseOverControls = false; |
465 stopHideMediaControlsTimer(); | 510 stopHideMediaControlsTimer(); |
466 } | 511 } |
467 return; | 512 return; |
468 } | 513 } |
469 | 514 |
470 if (event->type() == EventTypeNames::mousemove) { | 515 if (event->type() == EventTypeNames::mousemove && !mouseIsSynthetic) { |
471 // When we get a mouse move, show the media controls, and start a timer | 516 // When we get a mouse move, show the media controls, and start a timer |
472 // that will hide the media controls after a 3 seconds without a mouse m ove. | 517 // that will hide the media controls after a 3 seconds without a mouse m ove. |
473 makeOpaque(); | 518 makeOpaque(); |
474 refreshCastButtonVisibility(); | 519 refreshCastButtonVisibility(); |
475 if (shouldHideMediaControls(IgnoreVideoHover)) | 520 if (shouldHideMediaControls(IgnoreVideoHover)) |
476 startHideMediaControlsTimer(); | 521 startHideMediaControlsTimer(); |
477 return; | 522 return; |
478 } | 523 } |
479 } | 524 } |
480 | 525 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 visitor->trace(m_toggleClosedCaptionsButton); | 615 visitor->trace(m_toggleClosedCaptionsButton); |
571 visitor->trace(m_fullScreenButton); | 616 visitor->trace(m_fullScreenButton); |
572 visitor->trace(m_durationDisplay); | 617 visitor->trace(m_durationDisplay); |
573 visitor->trace(m_enclosure); | 618 visitor->trace(m_enclosure); |
574 visitor->trace(m_castButton); | 619 visitor->trace(m_castButton); |
575 visitor->trace(m_overlayCastButton); | 620 visitor->trace(m_overlayCastButton); |
576 HTMLDivElement::trace(visitor); | 621 HTMLDivElement::trace(visitor); |
577 } | 622 } |
578 | 623 |
579 } | 624 } |
OLD | NEW |