Changeset 259599 in webkit
- Timestamp:
- Apr 6, 2020, 4:05:06 PM (6 years ago)
- Location:
- branches/safari-609-branch/Source/WebCore
- Files:
-
- 14 edited
-
ChangeLog (modified) (1 diff)
-
Modules/mediacontrols/MediaControlsHost.cpp (modified) (1 diff)
-
Modules/mediacontrols/MediaControlsHost.h (modified) (1 diff)
-
dom/Document.cpp (modified) (1 diff)
-
dom/Document.h (modified) (2 diffs)
-
html/HTMLMediaElement.cpp (modified) (5 diffs)
-
html/HTMLMediaElement.h (modified) (3 diffs)
-
html/shadow/MediaControlElements.cpp (modified) (14 diffs)
-
html/shadow/MediaControlElements.h (modified) (3 diffs)
-
html/shadow/MediaControls.cpp (modified) (2 diffs)
-
html/shadow/MediaControls.h (modified) (1 diff)
-
page/Page.cpp (modified) (1 diff)
-
rendering/RenderMediaControlElements.cpp (modified) (3 diffs)
-
rendering/RenderMediaControlElements.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-609-branch/Source/WebCore/ChangeLog
r259511 r259599 1 2020-04-06 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r258434. rdar://problem/61352465 4 5 Safari sometimes crashes when switch video into PiP mode 6 https://bugs.webkit.org/show_bug.cgi?id=208904 7 8 Reviewed by Simon Fraser. 9 10 With this patch, MediaControlTextTrackContainerElement won't paint its subtree 11 to an image buffer (for the captions in video fullscreen or picture-in-picture mode) 12 when the cues are updated. Instead, it only sets the flag m_needsGenerateTextTrackRepresentation 13 to true after running layout based on the new cues. After that, it paints its subtree 14 to an image buffer if needed at the end of Page::updateRendering() when the layout is clean. 15 TextTrackRepresentationCocoa will use the image buffer to set the content of the layer 16 for captions in video fullscreen or picture-in-picture mode. 17 18 MediaControlTextTrackContainerElement class is responsible for rendering the captions in both: 19 1) a video player in the inline mode. 20 2) a video player in "video fullscreen" or picture-in-picture mode. 21 This patch refactors some functions to make their responsibilities clear. 22 23 * Modules/mediacontrols/MediaControlsHost.cpp: 24 (WebCore::MediaControlsHost::updateTextTrackRepresentationImageIfNeeded): 25 * Modules/mediacontrols/MediaControlsHost.h: 26 * dom/Document.cpp: 27 (WebCore::Document::setMediaElementShowingTextTrack): 28 (WebCore::Document::clearMediaElementShowingTextTrack): 29 (WebCore::Document::updateTextTrackRepresentationImageIfNeeded): 30 * dom/Document.h: 31 32 Functions textTracksAreReady(), textTrackReadyStateChanged() and configureTextTrackDisplay() 33 should be wrapped with "#if ENABLE(VIDEO_TRACK)". 34 * html/HTMLMediaElement.cpp: 35 (WebCore::HTMLMediaElement::setTextTrackRepresentation): 36 (WebCore::HTMLMediaElement::textTracksAreReady const): 37 (WebCore::HTMLMediaElement::textTrackReadyStateChanged): 38 (WebCore::HTMLMediaElement::configureTextTrackDisplay): 39 (WebCore::HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded): 40 * html/HTMLMediaElement.h: 41 42 * html/shadow/MediaControlElements.cpp: 43 (WebCore::MediaControlTextTrackContainerElement::createElementRenderer): 44 (WebCore::MediaControlTextTrackContainerElement::updateDisplay): 45 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationImageIfNeeded): 46 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationIfNeeded): 47 (WebCore::MediaControlTextTrackContainerElement::clearTextTrackRepresentation): 48 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackStyle): 49 (WebCore::MediaControlTextTrackContainerElement::enteredFullscreen): 50 (WebCore::MediaControlTextTrackContainerElement::updateVideoDisplaySize): 51 (WebCore::MediaControlTextTrackContainerElement::updateSizes): 52 (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage): 53 (WebCore::MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged): 54 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentation): Deleted. 55 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle): Deleted. 56 (WebCore::MediaControlTextTrackContainerElement::layoutIfNecessary): Deleted. 57 (WebCore::MediaControlTextTrackContainerElement::updateCueStyles): Deleted. 58 * html/shadow/MediaControlElements.h: 59 * html/shadow/MediaControls.cpp: 60 (WebCore::MediaControls::updateTextTrackRepresentationImageIfNeeded): 61 * html/shadow/MediaControls.h: 62 * page/Page.cpp: 63 (WebCore::Page::updateRendering): 64 * rendering/RenderMediaControlElements.cpp: 65 (WebCore::RenderMediaControlTextTrackContainer::RenderMediaControlTextTrackContainer): 66 (WebCore::RenderMediaControlTextTrackContainer::layout): 67 (WebCore::RenderTextTrackContainerElement::RenderTextTrackContainerElement): Deleted. 68 (WebCore::RenderTextTrackContainerElement::layout): Deleted. 69 * rendering/RenderMediaControlElements.h: 70 71 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258434 268f45cc-cd09-0410-ab3c-d52691b4dbfc 72 73 2020-03-13 Peng Liu <peng.liu6@apple.com> 74 75 Safari sometimes crashes when switch video into PiP mode 76 https://bugs.webkit.org/show_bug.cgi?id=208904 77 78 Reviewed by Simon Fraser. 79 80 With this patch, MediaControlTextTrackContainerElement won't paint its subtree 81 to an image buffer (for the captions in video fullscreen or picture-in-picture mode) 82 when the cues are updated. Instead, it only sets the flag m_needsGenerateTextTrackRepresentation 83 to true after running layout based on the new cues. After that, it paints its subtree 84 to an image buffer if needed at the end of Page::updateRendering() when the layout is clean. 85 TextTrackRepresentationCocoa will use the image buffer to set the content of the layer 86 for captions in video fullscreen or picture-in-picture mode. 87 88 MediaControlTextTrackContainerElement class is responsible for rendering the captions in both: 89 1) a video player in the inline mode. 90 2) a video player in "video fullscreen" or picture-in-picture mode. 91 This patch refactors some functions to make their responsibilities clear. 92 93 * Modules/mediacontrols/MediaControlsHost.cpp: 94 (WebCore::MediaControlsHost::updateTextTrackRepresentationImageIfNeeded): 95 * Modules/mediacontrols/MediaControlsHost.h: 96 * dom/Document.cpp: 97 (WebCore::Document::setMediaElementShowingTextTrack): 98 (WebCore::Document::clearMediaElementShowingTextTrack): 99 (WebCore::Document::updateTextTrackRepresentationImageIfNeeded): 100 * dom/Document.h: 101 102 Functions textTracksAreReady(), textTrackReadyStateChanged() and configureTextTrackDisplay() 103 should be wrapped with "#if ENABLE(VIDEO_TRACK)". 104 * html/HTMLMediaElement.cpp: 105 (WebCore::HTMLMediaElement::setTextTrackRepresentation): 106 (WebCore::HTMLMediaElement::textTracksAreReady const): 107 (WebCore::HTMLMediaElement::textTrackReadyStateChanged): 108 (WebCore::HTMLMediaElement::configureTextTrackDisplay): 109 (WebCore::HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded): 110 * html/HTMLMediaElement.h: 111 112 * html/shadow/MediaControlElements.cpp: 113 (WebCore::MediaControlTextTrackContainerElement::createElementRenderer): 114 (WebCore::MediaControlTextTrackContainerElement::updateDisplay): 115 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationImageIfNeeded): 116 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationIfNeeded): 117 (WebCore::MediaControlTextTrackContainerElement::clearTextTrackRepresentation): 118 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackStyle): 119 (WebCore::MediaControlTextTrackContainerElement::enteredFullscreen): 120 (WebCore::MediaControlTextTrackContainerElement::updateVideoDisplaySize): 121 (WebCore::MediaControlTextTrackContainerElement::updateSizes): 122 (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage): 123 (WebCore::MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged): 124 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentation): Deleted. 125 (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle): Deleted. 126 (WebCore::MediaControlTextTrackContainerElement::layoutIfNecessary): Deleted. 127 (WebCore::MediaControlTextTrackContainerElement::updateCueStyles): Deleted. 128 * html/shadow/MediaControlElements.h: 129 * html/shadow/MediaControls.cpp: 130 (WebCore::MediaControls::updateTextTrackRepresentationImageIfNeeded): 131 * html/shadow/MediaControls.h: 132 * page/Page.cpp: 133 (WebCore::Page::updateRendering): 134 * rendering/RenderMediaControlElements.cpp: 135 (WebCore::RenderMediaControlTextTrackContainer::RenderMediaControlTextTrackContainer): 136 (WebCore::RenderMediaControlTextTrackContainer::layout): 137 (WebCore::RenderTextTrackContainerElement::RenderTextTrackContainerElement): Deleted. 138 (WebCore::RenderTextTrackContainerElement::layout): Deleted. 139 * rendering/RenderMediaControlElements.h: 140 1 141 2020-04-03 Alan Coon <alancoon@apple.com> 2 142 -
branches/safari-609-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
r251950 r259599 166 166 } 167 167 168 void MediaControlsHost::updateTextTrackRepresentationImageIfNeeded() 169 { 170 if (m_textTrackContainer) 171 m_textTrackContainer->updateTextTrackRepresentationImageIfNeeded(); 172 } 173 168 174 void MediaControlsHost::enteredFullscreen() 169 175 { -
branches/safari-609-branch/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
r251950 r259599 75 75 enum class ForceUpdate { Yes, No }; 76 76 void updateCaptionDisplaySizes(ForceUpdate force = ForceUpdate::No); 77 void updateTextTrackRepresentationImageIfNeeded(); 77 78 void enteredFullscreen(); 78 79 void exitedFullscreen(); -
branches/safari-609-branch/Source/WebCore/dom/Document.cpp
r258581 r259599 5458 5458 } 5459 5459 5460 void Document::setMediaElementShowingTextTrack(const HTMLMediaElement& element) 5461 { 5462 m_mediaElementShowingTextTrack = makeWeakPtr(element); 5463 } 5464 5465 void Document::clearMediaElementShowingTextTrack() 5466 { 5467 m_mediaElementShowingTextTrack = nullptr; 5468 } 5469 5470 void Document::updateTextTrackRepresentationImageIfNeeded() 5471 { 5472 if (m_mediaElementShowingTextTrack) 5473 m_mediaElementShowingTextTrack->updateTextTrackRepresentationImageIfNeeded(); 5474 } 5475 5460 5476 #endif 5461 5477 -
branches/safari-609-branch/Source/WebCore/dom/Document.h
r255871 r259599 1111 1111 void unregisterForCaptionPreferencesChangedCallbacks(HTMLMediaElement&); 1112 1112 void captionPreferencesChanged(); 1113 void setMediaElementShowingTextTrack(const HTMLMediaElement&); 1114 void clearMediaElementShowingTextTrack(); 1115 void updateTextTrackRepresentationImageIfNeeded(); 1113 1116 #endif 1114 1117 … … 1792 1795 #if ENABLE(VIDEO_TRACK) 1793 1796 HashSet<HTMLMediaElement*> m_captionPreferencesChangedElements; 1797 WeakPtr<HTMLMediaElement> m_mediaElementShowingTextTrack; 1794 1798 #endif 1795 1799 -
branches/safari-609-branch/Source/WebCore/html/HTMLMediaElement.cpp
r257037 r259599 1876 1876 } 1877 1877 1878 bool HTMLMediaElement::textTracksAreReady() const1879 {1880 // 4.8.10.12.1 Text track model1881 // ...1882 // The text tracks of a media element are ready if all the text tracks whose mode was not1883 // in the disabled state when the element's resource selection algorithm last started now1884 // have a text track readiness state of loaded or failed to load.1885 for (unsigned i = 0; i < m_textTracksWhenResourceSelectionBegan.size(); ++i) {1886 if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading1887 || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded)1888 return false;1889 }1890 1891 return true;1892 }1893 1894 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track)1895 {1896 if (track->readinessState() != TextTrack::Loading1897 && track->mode() != TextTrack::Mode::Disabled) {1898 // The display trees exist as long as the track is active, in this case,1899 // and if the same track is loaded again (for example if the src attribute was changed),1900 // cues can be accumulated with the old ones, that's why they needs to be flushed1901 if (hasMediaControls())1902 mediaControls()->clearTextDisplayContainer();1903 updateTextTrackDisplay();1904 }1905 if (m_player && m_textTracksWhenResourceSelectionBegan.contains(track)) {1906 if (track->readinessState() != TextTrack::Loading)1907 setReadyState(m_player->readyState());1908 } else {1909 // The track readiness state might have changed as a result of the user1910 // clicking the captions button. In this case, a check whether all the1911 // resources have failed loading should be done in order to hide the CC button.1912 if (hasMediaControls() && track->readinessState() == TextTrack::FailedToLoad)1913 mediaControls()->refreshClosedCaptionsButtonVisibility();1914 }1915 }1916 1917 1878 void HTMLMediaElement::audioTrackEnabledChanged(AudioTrack& track) 1918 1879 { … … 5812 5773 if (m_player) 5813 5774 m_player->setTextTrackRepresentation(representation); 5775 5776 if (representation) 5777 document().setMediaElementShowingTextTrack(*this); 5778 else 5779 document().clearMediaElementShowingTextTrack(); 5814 5780 } 5815 5781 … … 6291 6257 #if ENABLE(VIDEO_TRACK) 6292 6258 6259 bool HTMLMediaElement::textTracksAreReady() const 6260 { 6261 // 4.8.10.12.1 Text track model 6262 // ... 6263 // The text tracks of a media element are ready if all the text tracks whose mode was not 6264 // in the disabled state when the element's resource selection algorithm last started now 6265 // have a text track readiness state of loaded or failed to load. 6266 for (unsigned i = 0; i < m_textTracksWhenResourceSelectionBegan.size(); ++i) { 6267 if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading 6268 || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded) 6269 return false; 6270 } 6271 6272 return true; 6273 } 6274 6275 void HTMLMediaElement::textTrackReadyStateChanged(TextTrack* track) 6276 { 6277 if (track->readinessState() != TextTrack::Loading 6278 && track->mode() != TextTrack::Mode::Disabled) { 6279 // The display trees exist as long as the track is active, in this case, 6280 // and if the same track is loaded again (for example if the src attribute was changed), 6281 // cues can be accumulated with the old ones, that's why they needs to be flushed 6282 if (hasMediaControls()) 6283 mediaControls()->clearTextDisplayContainer(); 6284 updateTextTrackDisplay(); 6285 } 6286 if (m_player && m_textTracksWhenResourceSelectionBegan.contains(track)) { 6287 if (track->readinessState() != TextTrack::Loading) 6288 setReadyState(m_player->readyState()); 6289 } else { 6290 // The track readiness state might have changed as a result of the user 6291 // clicking the captions button. In this case, a check whether all the 6292 // resources have failed loading should be done in order to hide the CC button. 6293 if (hasMediaControls() && track->readinessState() == TextTrack::FailedToLoad) 6294 mediaControls()->refreshClosedCaptionsButtonVisibility(); 6295 } 6296 } 6297 6298 void HTMLMediaElement::configureTextTrackDisplay(TextTrackVisibilityCheckType checkType) 6299 { 6300 ALWAYS_LOG(LOGIDENTIFIER, checkType); 6301 ASSERT(m_textTracks); 6302 6303 if (m_processingPreferenceChange) 6304 return; 6305 6306 if (document().activeDOMObjectsAreStopped()) 6307 return; 6308 6309 bool haveVisibleTextTrack = false; 6310 for (unsigned i = 0; i < m_textTracks->length(); ++i) { 6311 if (m_textTracks->item(i)->mode() == TextTrack::Mode::Showing) { 6312 haveVisibleTextTrack = true; 6313 break; 6314 } 6315 } 6316 6317 if (checkType == CheckTextTrackVisibility && m_haveVisibleTextTrack == haveVisibleTextTrack) { 6318 updateActiveTextTrackCues(currentMediaTime()); 6319 return; 6320 } 6321 6322 m_haveVisibleTextTrack = haveVisibleTextTrack; 6323 m_closedCaptionsVisible = m_haveVisibleTextTrack; 6324 6325 #if ENABLE(MEDIA_CONTROLS_SCRIPT) 6326 if (!m_haveVisibleTextTrack) 6327 return; 6328 6329 ensureMediaControlsShadowRoot(); 6330 updateTextTrackDisplay(); 6331 #else 6332 if (!m_haveVisibleTextTrack && !hasMediaControls() && !createMediaControls()) 6333 return; 6334 6335 mediaControls()->changedClosedCaptionsVisibility(); 6336 6337 updateTextTrackDisplay(); 6338 updateActiveTextTrackCues(currentMediaTime()); 6339 #endif 6340 } 6341 6293 6342 void HTMLMediaElement::updateTextTrackDisplay() 6294 6343 { … … 6306 6355 } 6307 6356 6357 void HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded() 6358 { 6359 #if ENABLE(MEDIA_CONTROLS_SCRIPT) 6360 ensureMediaControlsShadowRoot(); 6361 if (!m_mediaControlsHost) 6362 m_mediaControlsHost = MediaControlsHost::create(*this); 6363 m_mediaControlsHost->updateTextTrackRepresentationImageIfNeeded(); 6364 #else 6365 if (!hasMediaControls() && !createMediaControls()) 6366 return; 6367 6368 mediaControls()->updateTextTrackRepresentationImageIfNeeded(); 6369 #endif 6370 } 6371 6308 6372 #endif 6309 6373 … … 6546 6610 6547 6611 #if ENABLE(VIDEO_TRACK) 6548 void HTMLMediaElement::configureTextTrackDisplay(TextTrackVisibilityCheckType checkType)6549 {6550 ALWAYS_LOG(LOGIDENTIFIER, checkType);6551 ASSERT(m_textTracks);6552 6553 if (m_processingPreferenceChange)6554 return;6555 6556 if (document().activeDOMObjectsAreStopped())6557 return;6558 6559 bool haveVisibleTextTrack = false;6560 for (unsigned i = 0; i < m_textTracks->length(); ++i) {6561 if (m_textTracks->item(i)->mode() == TextTrack::Mode::Showing) {6562 haveVisibleTextTrack = true;6563 break;6564 }6565 }6566 6567 if (checkType == CheckTextTrackVisibility && m_haveVisibleTextTrack == haveVisibleTextTrack) {6568 updateActiveTextTrackCues(currentMediaTime());6569 return;6570 }6571 6572 m_haveVisibleTextTrack = haveVisibleTextTrack;6573 m_closedCaptionsVisible = m_haveVisibleTextTrack;6574 6575 #if ENABLE(MEDIA_CONTROLS_SCRIPT)6576 if (!m_haveVisibleTextTrack)6577 return;6578 6579 ensureMediaControlsShadowRoot();6580 updateTextTrackDisplay();6581 #else6582 if (!m_haveVisibleTextTrack && !hasMediaControls())6583 return;6584 if (!hasMediaControls() && !createMediaControls())6585 return;6586 6587 mediaControls()->changedClosedCaptionsVisibility();6588 6589 updateTextTrackDisplay();6590 updateActiveTextTrackCues(currentMediaTime());6591 #endif6592 }6593 6612 6594 6613 void HTMLMediaElement::captionPreferencesChanged() -
branches/safari-609-branch/Source/WebCore/html/HTMLMediaElement.h
r255029 r259599 380 380 void setSelectedTextTrack(TextTrack*); 381 381 382 bool textTracksAreReady() const;383 using HTMLMediaElementEnums::TextTrackVisibilityCheckType;384 void configureTextTrackDisplay(TextTrackVisibilityCheckType checkType = CheckTextTrackVisibility);385 void updateTextTrackDisplay();386 387 382 // AudioTrackClient 388 383 void audioTrackEnabledChanged(AudioTrack&) final; 389 390 void textTrackReadyStateChanged(TextTrack*);391 384 392 385 // TextTrackClient … … 406 399 407 400 void captionPreferencesChanged(); 401 using HTMLMediaElementEnums::TextTrackVisibilityCheckType; 402 void textTrackReadyStateChanged(TextTrack*); 403 void updateTextTrackRepresentationImageIfNeeded(); 408 404 #endif 409 405 … … 804 800 void markCaptionAndSubtitleTracksAsUnconfigured(ReconfigureMode); 805 801 CaptionUserPreferences::CaptionDisplayMode captionDisplayMode(); 802 803 bool textTracksAreReady() const; 804 void configureTextTrackDisplay(TextTrackVisibilityCheckType = CheckTextTrackVisibility); 805 void updateTextTrackDisplay(); 806 806 #endif 807 807 -
branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.cpp
r257037 r259599 1106 1106 RenderPtr<RenderElement> MediaControlTextTrackContainerElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) 1107 1107 { 1108 return createRenderer<Render TextTrackContainerElement>(*this, WTFMove(style));1108 return createRenderer<RenderMediaControlTextTrackContainer>(*this, WTFMove(style)); 1109 1109 } 1110 1110 … … 1184 1184 1185 1185 if (mediaController()->closedCaptionsVisible()) { 1186 // 10. For each text track cue cuein cues that has not yet had1186 // 10. For each text track cue in cues that has not yet had 1187 1187 // corresponding CSS boxes added to output, in text track cue order, run the 1188 1188 // following substeps: … … 1206 1206 hide(); 1207 1207 1208 if (m_textTrackRepresentation || video.requiresTextTrackRepresentation()) 1209 updateTextTrackRepresentation(); 1208 updateTextTrackRepresentationIfNeeded(); 1209 updateTextTrackStyle(); 1210 m_needsGenerateTextTrackRepresentation = true; 1211 } 1212 1213 void MediaControlTextTrackContainerElement::updateTextTrackRepresentationImageIfNeeded() 1214 { 1215 if (!m_needsGenerateTextTrackRepresentation) 1216 return; 1217 1218 m_needsGenerateTextTrackRepresentation = false; 1219 1220 // We should call m_textTrackRepresentation->update() to paint the subtree of 1221 // the RenderTextTrackContainerElement after the layout is clean. 1222 if (m_textTrackRepresentation) 1223 m_textTrackRepresentation->update(); 1210 1224 } 1211 1225 … … 1289 1303 } 1290 1304 1291 void MediaControlTextTrackContainerElement::updateTextTrackRepresentation ()1305 void MediaControlTextTrackContainerElement::updateTextTrackRepresentationIfNeeded() 1292 1306 { 1293 1307 auto mediaElement = parentMediaElement(this); … … 1298 1312 if (!hasChildNodes() || !requiresTextTrackRepresentation) { 1299 1313 if (m_textTrackRepresentation) { 1300 if (!requiresTextTrackRepresentation) {1314 if (!requiresTextTrackRepresentation) 1301 1315 clearTextTrackRepresentation(); 1302 updateSizes(ForceUpdate::Yes); 1303 } else 1316 else 1304 1317 m_textTrackRepresentation->setHidden(true); 1305 1318 } … … 1310 1323 ALWAYS_LOG(LOGIDENTIFIER); 1311 1324 1312 m_waitingForFirstLayout = true;1313 1325 m_textTrackRepresentation = TextTrackRepresentation::create(*this); 1314 1326 if (document().page()) 1315 1327 m_textTrackRepresentation->setContentScale(document().page()->deviceScaleFactor()); 1316 1328 mediaElement->setTextTrackRepresentation(m_textTrackRepresentation.get()); 1317 updateSizes();1318 updateTextTrackRepresentationStyle();1319 1329 } 1320 1330 1321 1331 m_textTrackRepresentation->setHidden(false); 1322 if (!m_waitingForFirstLayout)1323 m_textTrackRepresentation->update();1324 1332 } 1325 1333 … … 1331 1339 ALWAYS_LOG(LOGIDENTIFIER); 1332 1340 1333 m_waitingForFirstLayout = true;1334 1341 m_textTrackRepresentation = nullptr; 1335 1342 if (auto mediaElement = parentMediaElement(this)) 1336 1343 mediaElement->setTextTrackRepresentation(nullptr); 1337 updateTextTrackRepresentationStyle(); 1338 updateActiveCuesFontSize(); 1339 } 1340 1341 void MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle() 1344 } 1345 1346 void MediaControlTextTrackContainerElement::updateTextTrackStyle() 1342 1347 { 1343 1348 if (m_textTrackRepresentation) { 1349 setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute); 1344 1350 setInlineStyleProperty(CSSPropertyWidth, m_videoDisplaySize.size().width(), CSSUnitType::CSS_PX); 1345 1351 setInlineStyleProperty(CSSPropertyHeight, m_videoDisplaySize.size().height(), CSSUnitType::CSS_PX); 1346 setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);1347 1352 setInlineStyleProperty(CSSPropertyLeft, 0, CSSUnitType::CSS_PX); 1348 1353 setInlineStyleProperty(CSSPropertyTop, 0, CSSUnitType::CSS_PX); … … 1359 1364 void MediaControlTextTrackContainerElement::enteredFullscreen() 1360 1365 { 1361 if (hasChildNodes()) 1362 updateTextTrackRepresentation(); 1366 updateTextTrackRepresentationIfNeeded(); 1363 1367 updateSizes(ForceUpdate::Yes); 1364 1368 } … … 1368 1372 clearTextTrackRepresentation(); 1369 1373 updateSizes(ForceUpdate::Yes); 1370 }1371 1372 void MediaControlTextTrackContainerElement::layoutIfNecessary()1373 {1374 m_waitingForFirstLayout = false;1375 1376 auto sizeChanged = updateVideoDisplaySize();1377 if (m_textTrackRepresentation)1378 m_textTrackRepresentation->update();1379 1380 if (!sizeChanged)1381 return;1382 1383 // FIXME (121170): This function is called during layout, and should lay out the text tracks immediately.1384 m_taskQueue.enqueueTask([this] () {1385 updateCueStyles();1386 });1387 1374 } 1388 1375 … … 1412 1399 1413 1400 m_videoDisplaySize = videoBox; 1414 updateTextTrackRepresentationStyle();1415 1416 1401 return true; 1417 1402 } … … 1419 1404 void MediaControlTextTrackContainerElement::updateSizes(ForceUpdate force) 1420 1405 { 1421 if (updateVideoDisplaySize() || force == ForceUpdate::Yes) 1422 updateCueStyles(); 1423 } 1424 1425 void MediaControlTextTrackContainerElement::updateCueStyles() 1426 { 1406 if (!updateVideoDisplaySize() && force != ForceUpdate::Yes) 1407 return; 1408 1427 1409 if (!document().page()) 1428 1410 return; … … 1434 1416 mediaElement->syncTextTrackBounds(); 1435 1417 1418 updateActiveCuesFontSize(); 1419 updateTextStrokeStyle(); 1436 1420 for (auto& activeCue : mediaElement->currentlyActiveCues()) 1437 1421 activeCue.data()->recalculateStyles(); 1438 1422 1439 updateActiveCuesFontSize();1440 updateDisplay();1441 updateTextStrokeStyle();1423 m_taskQueue.enqueueTask([this] () { 1424 updateDisplay(); 1425 }); 1442 1426 } 1443 1427 … … 1473 1457 return nullptr; 1474 1458 1475 layer->paint(buffer->context(), paintingRect, LayoutSize(), { PaintBehavior::FlattenCompositingLayers, PaintBehavior::Snapshotting }, nullptr, RenderLayer::paintLayerPaintingCompositingAllPhasesFlags()); 1459 auto paintFlags = RenderLayer::paintLayerPaintingCompositingAllPhasesFlags(); 1460 paintFlags.add(RenderLayer::PaintLayerTemporaryClipRects); 1461 layer->paint(buffer->context(), paintingRect, LayoutSize(), { PaintBehavior::FlattenCompositingLayers, PaintBehavior::Snapshotting }, nullptr, paintFlags); 1476 1462 1477 1463 return ImageBuffer::sinkIntoImage(WTFMove(buffer)); … … 1480 1466 void MediaControlTextTrackContainerElement::textTrackRepresentationBoundsChanged(const IntRect&) 1481 1467 { 1482 if (hasChildNodes()) 1483 updateTextTrackRepresentation(); 1468 updateTextTrackRepresentationIfNeeded(); 1484 1469 updateSizes(); 1485 1470 } -
branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.h
r257037 r259599 484 484 enum class ForceUpdate { Yes, No }; 485 485 void updateSizes(ForceUpdate force = ForceUpdate::No); 486 void layoutIfNecessary();487 488 486 void updateDisplay(); 487 488 void updateTextTrackRepresentationImageIfNeeded(); 489 489 490 void enteredFullscreen(); 490 491 void exitedFullscreen(); … … 493 494 explicit MediaControlTextTrackContainerElement(Document&); 494 495 496 // Element 497 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; 498 499 // TextTrackRepresentationClient 500 RefPtr<Image> createTextTrackRepresentationImage() override; 501 void textTrackRepresentationBoundsChanged(const IntRect&) override; 502 503 void updateTextTrackRepresentationIfNeeded(); 504 void clearTextTrackRepresentation(); 505 495 506 bool updateVideoDisplaySize(); 496 void updateCueStyles();497 507 void updateActiveCuesFontSize(); 498 508 void updateTextStrokeStyle(); 499 509 void processActiveVTTCue(VTTCue&); 500 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; 501 502 RefPtr<Image> createTextTrackRepresentationImage() override; 503 void textTrackRepresentationBoundsChanged(const IntRect&) override; 504 void updateTextTrackRepresentation(); 505 void clearTextTrackRepresentation(); 506 void updateTextTrackRepresentationStyle(); 510 void updateTextTrackStyle(); 507 511 508 512 #if !RELEASE_LOG_DISABLED … … 521 525 int m_fontSize { 0 }; 522 526 bool m_fontSizeIsImportant { false }; 523 bool m_ waitingForFirstLayout { true };527 bool m_needsGenerateTextTrackRepresentation { false }; 524 528 }; 525 529 -
branches/safari-609-branch/Source/WebCore/html/shadow/MediaControls.cpp
r251950 r259599 406 406 m_textDisplayContainer->updateDisplay(); 407 407 } 408 408 409 409 void MediaControls::textTrackPreferencesChanged() 410 410 { … … 420 420 } 421 421 422 void MediaControls::updateTextTrackRepresentationImageIfNeeded() 423 { 424 if (m_textDisplayContainer) 425 m_textDisplayContainer->updateTextTrackRepresentationImageIfNeeded(); 426 } 427 422 428 #endif 423 429 -
branches/safari-609-branch/Source/WebCore/html/shadow/MediaControls.h
r237266 r259599 104 104 virtual void textTrackPreferencesChanged(); 105 105 virtual void clearTextDisplayContainer(); 106 virtual void updateTextTrackRepresentationImageIfNeeded(); 106 107 #endif 107 108 -
branches/safari-609-branch/Source/WebCore/page/Page.cpp
r256385 r259599 1347 1347 1348 1348 layoutIfNeeded(); 1349 1350 #if ENABLE(VIDEO_TRACK) 1351 forEachDocument([] (Document& document) { 1352 document.updateTextTrackRepresentationImageIfNeeded(); 1353 }); 1354 #endif 1349 1355 } 1350 1356 -
branches/safari-609-branch/Source/WebCore/rendering/RenderMediaControlElements.cpp
r257037 r259599 42 42 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaControlTimelineContainer); 43 43 #if ENABLE(VIDEO_TRACK) 44 WTF_MAKE_ISO_ALLOCATED_IMPL(Render TextTrackContainerElement);44 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaControlTextTrackContainer); 45 45 #endif 46 46 … … 91 91 #if ENABLE(VIDEO_TRACK) 92 92 93 Render TextTrackContainerElement::RenderTextTrackContainerElement(Element& element, RenderStyle&& style)93 RenderMediaControlTextTrackContainer::RenderMediaControlTextTrackContainer(Element& element, RenderStyle&& style) 94 94 : RenderBlockFlow(element, WTFMove(style)) 95 95 { 96 96 } 97 97 98 void Render TextTrackContainerElement::layout()98 void RenderMediaControlTextTrackContainer::layout() 99 99 { 100 100 RenderBlockFlow::layout(); … … 105 105 106 106 LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext()); 107 static_cast<MediaControlTextTrackContainerElement*>(element())->layoutIfNecessary();108 107 } 109 108 -
branches/safari-609-branch/Source/WebCore/rendering/RenderMediaControlElements.h
r224537 r259599 60 60 #if ENABLE(VIDEO_TRACK) 61 61 62 class Render TextTrackContainerElementfinal : public RenderBlockFlow {63 WTF_MAKE_ISO_ALLOCATED(Render TextTrackContainerElement);62 class RenderMediaControlTextTrackContainer final : public RenderBlockFlow { 63 WTF_MAKE_ISO_ALLOCATED(RenderMediaControlTextTrackContainer); 64 64 public: 65 Render TextTrackContainerElement(Element&, RenderStyle&&);65 RenderMediaControlTextTrackContainer(Element&, RenderStyle&&); 66 66 67 67 private:
Note:
See TracChangeset
for help on using the changeset viewer.