@@ -952,11 +952,9 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument, Document& new
952952 ASSERT_WITH_SECURITY_IMPLICATION (&document () == &newDocument);
953953
954954 // Handle lazy loading observer transfer between documents
955- if (newDocument.settings ().lazyMediaLoadingEnabled ()) {
956- oldDocument.lazyLoadMediaObserver ().unobserve (*this , oldDocument);
957- if (isLazyLoadable ())
958- LazyLoadMediaObserver::observe (*this );
959- }
955+ oldDocument.lazyLoadMediaObserver ().unobserve (*this , oldDocument);
956+ if (newDocument.settings ().lazyMediaLoadingEnabled () && isLazyLoadable ())
957+ LazyLoadMediaObserver::observe (*this );
960958
961959 if (m_shouldDelayLoadEvent) {
962960 oldDocument.decrementLoadEventDelayCount ();
@@ -1037,7 +1035,7 @@ void HTMLMediaElement::attributeChanged(const QualifiedName& name, const AtomStr
10371035 // If a src attribute of a media element is set or changed, the user
10381036 // agent must invoke the media element's media element load algorithm.
10391037 if (!newValue.isNull ()) {
1040- if (isLazyLoadable () && document ().settings ().lazyMediaLoadingEnabled () && m_networkState == NETWORK_EMPTY )
1038+ if (m_networkState == NETWORK_EMPTY && document ().settings ().lazyMediaLoadingEnabled () && isLazyLoadable () )
10411039 LazyLoadMediaObserver::observe (*this );
10421040 else
10431041 prepareForLoad ();
@@ -1142,7 +1140,7 @@ void HTMLMediaElement::didFinishInsertingNode()
11421140
11431141 if (m_inActiveDocument && m_networkState == NETWORK_EMPTY) {
11441142 if (!attributeWithoutSynchronization (srcAttr).isEmpty ()) {
1145- if (isLazyLoadable () && document ().settings ().lazyMediaLoadingEnabled ())
1143+ if (document ().settings ().lazyMediaLoadingEnabled () && isLazyLoadable ())
11461144 LazyLoadMediaObserver::observe (*this );
11471145 else
11481146 prepareForLoad ();
@@ -1538,7 +1536,7 @@ bool HTMLMediaElement::hasLazyLoadableAttributeValue(StringView attributeValue)
15381536
15391537bool HTMLMediaElement::isLazyLoadable () const
15401538{
1541- if (!document ().frame () || !document ().frame ()->checkedScript ( )->canExecuteScripts (ReasonForCallingCanExecuteScripts::NotAboutToExecuteScript))
1539+ if (!document ().frame () || !protect ( document ().frame ()->script () )->canExecuteScripts (ReasonForCallingCanExecuteScripts::NotAboutToExecuteScript))
15421540 return false ;
15431541
15441542 if (document ().paginated ())
@@ -5900,7 +5898,7 @@ void HTMLMediaElement::sourceWasAdded(HTMLSourceElement& source)
59005898 // the media element's resource selection algorithm.
59015899 if (m_networkState == NETWORK_EMPTY) {
59025900 m_nextChildNodeToConsider = source;
5903- if (isLazyLoadable () && document ().settings ().lazyMediaLoadingEnabled ()) {
5901+ if (document ().settings ().lazyMediaLoadingEnabled () && isLazyLoadable ()) {
59045902 LazyLoadMediaObserver::observe (*this );
59055903 return ;
59065904 }
0 commit comments