| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 392 } |
| 393 | 393 |
| 394 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 394 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
| 395 { | 395 { |
| 396 if (name == srcAttr) { | 396 if (name == srcAttr) { |
| 397 // Trigger a reload, as long as the 'src' attribute is present. | 397 // Trigger a reload, as long as the 'src' attribute is present. |
| 398 if (!value.isNull()) { | 398 if (!value.isNull()) { |
| 399 clearMediaPlayer(LoadMediaResource); | 399 clearMediaPlayer(LoadMediaResource); |
| 400 scheduleDelayedAction(LoadMediaResource); | 400 scheduleDelayedAction(LoadMediaResource); |
| 401 } | 401 } |
| 402 } else if (name == controlsAttr) | 402 } else if (name == controlsAttr) { |
| 403 configureMediaControls(); | 403 configureMediaControls(); |
| 404 else if (name == preloadAttr) { | 404 } else if (name == preloadAttr) { |
| 405 if (equalIgnoringCase(value, "none")) | 405 if (equalIgnoringCase(value, "none")) |
| 406 m_preload = MediaPlayer::None; | 406 m_preload = MediaPlayer::None; |
| 407 else if (equalIgnoringCase(value, "metadata")) | 407 else if (equalIgnoringCase(value, "metadata")) |
| 408 m_preload = MediaPlayer::MetaData; | 408 m_preload = MediaPlayer::MetaData; |
| 409 else { | 409 else { |
| 410 // The spec does not define an "invalid value default" but "auto" is
suggested as the | 410 // The spec does not define an "invalid value default" but "auto" is
suggested as the |
| 411 // "missing value default", so use it for everything except "none" a
nd "metadata" | 411 // "missing value default", so use it for everything except "none" a
nd "metadata" |
| 412 m_preload = MediaPlayer::Auto; | 412 m_preload = MediaPlayer::Auto; |
| 413 } | 413 } |
| 414 | 414 |
| 415 // The attribute must be ignored if the autoplay attribute is present | 415 // The attribute must be ignored if the autoplay attribute is present |
| 416 if (!autoplay() && m_player) | 416 if (!autoplay() && m_player) |
| 417 setPlayerPreload(); | 417 setPlayerPreload(); |
| 418 | 418 |
| 419 } else if (name == mediagroupAttr) | 419 } else if (name == mediagroupAttr) { |
| 420 setMediaGroup(value); | 420 setMediaGroup(value); |
| 421 else if (name == onbeforeloadAttr) | 421 } else { |
| 422 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve
ntListener(this, name, value)); | |
| 423 else | |
| 424 HTMLElement::parseAttribute(name, value); | 422 HTMLElement::parseAttribute(name, value); |
| 423 } |
| 425 } | 424 } |
| 426 | 425 |
| 427 void HTMLMediaElement::finishParsingChildren() | 426 void HTMLMediaElement::finishParsingChildren() |
| 428 { | 427 { |
| 429 HTMLElement::finishParsingChildren(); | 428 HTMLElement::finishParsingChildren(); |
| 430 | 429 |
| 431 if (!RuntimeEnabledFeatures::videoTrackEnabled()) | 430 if (!RuntimeEnabledFeatures::videoTrackEnabled()) |
| 432 return; | 431 return; |
| 433 | 432 |
| 434 if (Traversal<HTMLTrackElement>::firstChild(*this)) | 433 if (Traversal<HTMLTrackElement>::firstChild(*this)) |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 // The spec doesn't say to block the load event until we actually run the as
ynchronous section | 696 // The spec doesn't say to block the load event until we actually run the as
ynchronous section |
| 698 // algorithm, but do it now because we won't start that until after the time
r fires and the | 697 // algorithm, but do it now because we won't start that until after the time
r fires and the |
| 699 // event may have already fired by then. | 698 // event may have already fired by then. |
| 700 setShouldDelayLoadEvent(true); | 699 setShouldDelayLoadEvent(true); |
| 701 | 700 |
| 702 configureMediaControls(); | 701 configureMediaControls(); |
| 703 } | 702 } |
| 704 | 703 |
| 705 void HTMLMediaElement::loadInternal() | 704 void HTMLMediaElement::loadInternal() |
| 706 { | 705 { |
| 707 // Some of the code paths below this function dispatch the BeforeLoad event.
This ASSERT helps | 706 // FIXME: Now that we don't have beforeload events we should make this ASSER
T the opposite. |
| 708 // us catch those bugs more quickly without needing all the branches to alig
n to actually | |
| 709 // trigger the event. | |
| 710 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 707 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
| 711 | 708 |
| 712 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the | 709 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the |
| 713 // disabled state when the element's resource selection algorithm last start
ed". | 710 // disabled state when the element's resource selection algorithm last start
ed". |
| 714 if (RuntimeEnabledFeatures::videoTrackEnabled()) { | 711 if (RuntimeEnabledFeatures::videoTrackEnabled()) { |
| 715 m_textTracksWhenResourceSelectionBegan.clear(); | 712 m_textTracksWhenResourceSelectionBegan.clear(); |
| 716 if (m_textTracks) { | 713 if (m_textTracks) { |
| 717 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 714 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
| 718 TextTrack* track = m_textTracks->item(i); | 715 TextTrack* track = m_textTracks->item(i); |
| 719 if (track->mode() != TextTrack::disabledKeyword()) | 716 if (track->mode() != TextTrack::disabledKeyword()) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 m_loadState = LoadingFromSrcAttr; | 764 m_loadState = LoadingFromSrcAttr; |
| 768 | 765 |
| 769 // If the src attribute's value is the empty string ... jump down to the
failed step below | 766 // If the src attribute's value is the empty string ... jump down to the
failed step below |
| 770 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); | 767 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); |
| 771 if (mediaURL.isEmpty()) { | 768 if (mediaURL.isEmpty()) { |
| 772 mediaLoadingFailed(MediaPlayer::FormatError); | 769 mediaLoadingFailed(MediaPlayer::FormatError); |
| 773 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, empty 'src'")
; | 770 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, empty 'src'")
; |
| 774 return; | 771 return; |
| 775 } | 772 } |
| 776 | 773 |
| 777 if (!isSafeToLoadURL(mediaURL, Complain) || !dispatchBeforeLoadEvent(med
iaURL.string())) { | 774 if (!isSafeToLoadURL(mediaURL, Complain)) { |
| 778 mediaLoadingFailed(MediaPlayer::FormatError); | 775 mediaLoadingFailed(MediaPlayer::FormatError); |
| 779 return; | 776 return; |
| 780 } | 777 } |
| 781 | 778 |
| 782 // No type or key system information is available when the url comes | 779 // No type or key system information is available when the url comes |
| 783 // from the 'src' attribute so MediaPlayer | 780 // from the 'src' attribute so MediaPlayer |
| 784 // will have to pick a media engine based on the file extension. | 781 // will have to pick a media engine based on the file extension. |
| 785 ContentType contentType((String())); | 782 ContentType contentType((String())); |
| 786 loadResource(mediaURL, contentType, String()); | 783 loadResource(mediaURL, contentType, String()); |
| 787 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'src' attri
bute url"); | 784 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'src' attri
bute url"); |
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 return KURL(); | 2591 return KURL(); |
| 2595 } | 2592 } |
| 2596 | 2593 |
| 2597 KURL mediaURL; | 2594 KURL mediaURL; |
| 2598 Node* node; | 2595 Node* node; |
| 2599 HTMLSourceElement* source = 0; | 2596 HTMLSourceElement* source = 0; |
| 2600 String type; | 2597 String type; |
| 2601 String system; | 2598 String system; |
| 2602 bool lookingForStartNode = m_nextChildNodeToConsider; | 2599 bool lookingForStartNode = m_nextChildNodeToConsider; |
| 2603 bool canUseSourceElement = false; | 2600 bool canUseSourceElement = false; |
| 2604 bool okToLoadSourceURL; | |
| 2605 | 2601 |
| 2606 NodeVector potentialSourceNodes; | 2602 NodeVector potentialSourceNodes; |
| 2607 getChildNodes(*this, potentialSourceNodes); | 2603 getChildNodes(*this, potentialSourceNodes); |
| 2608 | 2604 |
| 2609 for (unsigned i = 0; !canUseSourceElement && i < potentialSourceNodes.size()
; ++i) { | 2605 for (unsigned i = 0; !canUseSourceElement && i < potentialSourceNodes.size()
; ++i) { |
| 2610 node = potentialSourceNodes[i].get(); | 2606 node = potentialSourceNodes[i].get(); |
| 2611 if (lookingForStartNode && m_nextChildNodeToConsider != node) | 2607 if (lookingForStartNode && m_nextChildNodeToConsider != node) |
| 2612 continue; | 2608 continue; |
| 2613 lookingForStartNode = false; | 2609 lookingForStartNode = false; |
| 2614 | 2610 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2635 if (!type.isEmpty() || !system.isEmpty()) { | 2631 if (!type.isEmpty() || !system.isEmpty()) { |
| 2636 #if !LOG_DISABLED | 2632 #if !LOG_DISABLED |
| 2637 if (shouldLog) | 2633 if (shouldLog) |
| 2638 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type'
is '%s' - key system is '%s'", type.utf8().data(), system.utf8().data()); | 2634 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type'
is '%s' - key system is '%s'", type.utf8().data(), system.utf8().data()); |
| 2639 #endif | 2635 #endif |
| 2640 if (!supportsType(ContentType(type), system)) | 2636 if (!supportsType(ContentType(type), system)) |
| 2641 goto check_again; | 2637 goto check_again; |
| 2642 } | 2638 } |
| 2643 | 2639 |
| 2644 // Is it safe to load this url? | 2640 // Is it safe to load this url? |
| 2645 okToLoadSourceURL = isSafeToLoadURL(mediaURL, actionIfInvalid) && dispat
chBeforeLoadEvent(mediaURL.string()); | 2641 if (!isSafeToLoadURL(mediaURL, actionIfInvalid)) |
| 2646 | |
| 2647 // A 'beforeload' event handler can mutate the DOM, so check to see if t
he source element is still a child node. | |
| 2648 if (node->parentNode() != this) { | |
| 2649 WTF_LOG(Media, "HTMLMediaElement::selectNextSourceChild : 'beforeloa
d' removed current element"); | |
| 2650 source = 0; | |
| 2651 goto check_again; | |
| 2652 } | |
| 2653 | |
| 2654 if (!okToLoadSourceURL) | |
| 2655 goto check_again; | 2642 goto check_again; |
| 2656 | 2643 |
| 2657 // Making it this far means the <source> looks reasonable. | 2644 // Making it this far means the <source> looks reasonable. |
| 2658 canUseSourceElement = true; | 2645 canUseSourceElement = true; |
| 2659 | 2646 |
| 2660 check_again: | 2647 check_again: |
| 2661 if (!canUseSourceElement && actionIfInvalid == Complain && source) | 2648 if (!canUseSourceElement && actionIfInvalid == Complain && source) |
| 2662 source->scheduleErrorEvent(); | 2649 source->scheduleErrorEvent(); |
| 2663 } | 2650 } |
| 2664 | 2651 |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 { | 3645 { |
| 3659 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3646 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3660 } | 3647 } |
| 3661 | 3648 |
| 3662 bool HTMLMediaElement::isInteractiveContent() const | 3649 bool HTMLMediaElement::isInteractiveContent() const |
| 3663 { | 3650 { |
| 3664 return fastHasAttribute(controlsAttr); | 3651 return fastHasAttribute(controlsAttr); |
| 3665 } | 3652 } |
| 3666 | 3653 |
| 3667 } | 3654 } |
| OLD | NEW |