Changeset 295185 in webkit
- Timestamp:
- Jun 2, 2022, 11:45:32 PM (4 years ago)
- Location:
- branches/safari-613-branch/Source/WebCore/html/track
- Files:
-
- 6 edited
-
TextTrackCue.cpp (modified) (5 diffs)
-
TextTrackCue.h (modified) (2 diffs)
-
TextTrackCueGeneric.cpp (modified) (2 diffs)
-
TextTrackCueGeneric.h (modified) (1 diff)
-
VTTCue.cpp (modified) (9 diffs)
-
VTTCue.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-613-branch/Source/WebCore/html/track/TextTrackCue.cpp
r284093 r295185 217 217 , m_startTime(start) 218 218 , m_endTime(end) 219 , m_document(document)220 219 , m_cueNode(WTFMove(cueFragment)) 221 220 { … … 226 225 , m_startTime(start) 227 226 , m_endTime(end) 228 , m_document(document)229 227 { 230 228 } … … 232 230 ScriptExecutionContext* TextTrackCue::scriptExecutionContext() const 233 231 { 234 return &m_document; 232 return ActiveDOMObject::scriptExecutionContext(); 233 } 234 235 Document* TextTrackCue::document() const 236 { 237 return downcast<Document>(scriptExecutionContext()); 235 238 } 236 239 … … 437 440 return nullptr; 438 441 439 auto clonedFragment = DocumentFragment::create(ownerDocument()); 442 auto* document = this->document(); 443 if (!document) 444 return nullptr; 445 446 auto clonedFragment = DocumentFragment::create(*document); 440 447 m_cueNode->cloneChildNodes(clonedFragment); 441 448 … … 486 493 return; 487 494 495 RefPtr document = this->document(); 496 if (!document) 497 return; 498 488 499 ScriptDisallowedScope::EventAllowedScope allowedScopeForReferenceTree(*m_cueNode); 489 500 490 501 if (!m_displayTree) { 491 m_displayTree = TextTrackCueBox::create( ownerDocument(), *this);502 m_displayTree = TextTrackCueBox::create(*document, *this); 492 503 m_displayTree->setPseudo(ShadowPseudoIds::webkitGenericCueRoot()); 493 504 } 494 505 495 506 m_displayTree->removeChildren(); 496 auto clonedFragment = DocumentFragment::create( ownerDocument());507 auto clonedFragment = DocumentFragment::create(*document); 497 508 m_cueNode->cloneChildNodes(clonedFragment); 498 509 m_displayTree->appendChild(clonedFragment); 499 510 500 511 if (m_fontSize) { 501 if (auto page = ownerDocument().page()) {502 auto style = HTMLStyleElement::create(HTMLNames::styleTag, ownerDocument(), false);512 if (auto page = document->page()) { 513 auto style = HTMLStyleElement::create(HTMLNames::styleTag, *document, false); 503 514 style->setTextContent(makeString(page->captionUserPreferencesStyleSheet(), 504 515 " ::", ShadowPseudoIds::cue(), "{font-size:", m_fontSize, m_fontSizeIsImportant ? "px !important}" : "px}")); -
branches/safari-613-branch/Source/WebCore/html/track/TextTrackCue.h
r283851 r295185 127 127 TextTrackCue(Document&, const MediaTime& start, const MediaTime& end); 128 128 129 Document & ownerDocument() { return m_document; }129 Document* document() const; 130 130 131 131 virtual bool cueContentsMatch(const TextTrackCue&) const; … … 154 154 155 155 TextTrack* m_track { nullptr }; 156 157 Document& m_document;158 156 159 157 RefPtr<DocumentFragment> m_cueNode; -
branches/safari-613-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp
r280648 r295185 172 172 } 173 173 174 Ref<VTTCueBox> TextTrackCueGeneric::createDisplayTree() 175 { 176 return TextTrackCueGenericBoxElement::create(ownerDocument(), *this); 174 RefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree() 175 { 176 if (auto* document = this->document()) 177 return TextTrackCueGenericBoxElement::create(*document, *this); 178 return nullptr; 177 179 } 178 180 … … 206 208 if (fontSizeMultiplier()) 207 209 size *= fontSizeMultiplier() / 100; 208 displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSUnitType::CSS_PX); 210 if (auto* displayTree = displayTreeInternal()) 211 displayTree->setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSUnitType::CSS_PX); 209 212 } 210 213 -
branches/safari-613-branch/Source/WebCore/html/track/TextTrackCueGeneric.h
r270738 r295185 70 70 bool isPositionedAbove(const TextTrackCue*) const final; 71 71 72 Ref <VTTCueBox> createDisplayTree() final;72 RefPtr<VTTCueBox> createDisplayTree() final; 73 73 74 74 bool cueContentsMatch(const TextTrackCue&) const final; -
branches/safari-613-branch/Source/WebCore/html/track/VTTCue.cpp
r286743 r295185 272 272 , m_originalStartTime(MediaTime::zeroTime()) 273 273 { 274 initialize( );274 initialize(document); 275 275 } 276 276 … … 279 279 , m_originalStartTime(cueData.originalStartTime()) 280 280 { 281 initialize( );281 initialize(document); 282 282 setText(cueData.content()); 283 283 setStartTime(cueData.startTime()); … … 291 291 } 292 292 293 void VTTCue::initialize( )294 { 295 m_cueBackdropBox = HTMLDivElement::create( ownerDocument());296 m_cueHighlightBox = HTMLSpanElement::create(spanTag, ownerDocument());293 void VTTCue::initialize(Document& document) 294 { 295 m_cueBackdropBox = HTMLDivElement::create(document); 296 m_cueHighlightBox = HTMLSpanElement::create(spanTag, document); 297 297 m_snapToLines = true; 298 298 m_displayTreeShouldChange = true; … … 300 300 } 301 301 302 Ref<VTTCueBox> VTTCue::createDisplayTree() 303 { 304 return VTTCueBox::create(ownerDocument(), *this); 305 } 306 307 VTTCueBox& VTTCue::displayTreeInternal() 302 RefPtr<VTTCueBox> VTTCue::createDisplayTree() 303 { 304 if (auto* document = this->document()) 305 return VTTCueBox::create(*document, *this); 306 return nullptr; 307 } 308 309 VTTCueBox* VTTCue::displayTreeInternal() 308 310 { 309 311 if (!m_displayTree) 310 312 m_displayTree = createDisplayTree(); 311 return *m_displayTree;313 return m_displayTree.get(); 312 314 } 313 315 … … 594 596 void VTTCue::createWebVTTNodeTree() 595 597 { 596 if (!m_webVTTNodeTree )597 m_webVTTNodeTree = WebVTTParser::createDocumentFragmentFromCueText( ownerDocument(), m_content);598 if (!m_webVTTNodeTree && document()) 599 m_webVTTNodeTree = WebVTTParser::createDocumentFragmentFromCueText(*document(), m_content); 598 600 } 599 601 … … 618 620 return nullptr; 619 621 620 auto clonedFragment = DocumentFragment::create(ownerDocument()); 622 auto* document = this->document(); 623 if (!document) 624 return nullptr; 625 626 auto clonedFragment = DocumentFragment::create(*document); 621 627 copyWebVTTNodeToDOMTree(*m_webVTTNodeTree, clonedFragment); 622 628 return clonedFragment; … … 629 635 return nullptr; 630 636 631 auto clonedFragment = DocumentFragment::create(ownerDocument()); 637 auto* document = this->document(); 638 if (!document) 639 return nullptr; 640 641 auto clonedFragment = DocumentFragment::create(*document); 632 642 633 643 // The cloned fragment is never exposed to author scripts so it's safe to dispatch events here. … … 967 977 RefPtr<TextTrackCueBox> VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize) 968 978 { 969 Ref <VTTCueBox>displayTree = displayTreeInternal();970 if (! m_displayTreeShouldChange || !track()->isRendered())979 RefPtr displayTree = displayTreeInternal(); 980 if (!displayTree || !m_displayTreeShouldChange || !track()->isRendered()) 971 981 return displayTree; 972 982 … … 1041 1051 } 1042 1052 1053 RefPtr displayTree = displayTreeInternal(); 1054 if (!displayTree) 1055 return; 1056 1043 1057 // The display tree is never exposed to author scripts so it's safe to dispatch events here. 1044 ScriptDisallowedScope::EventAllowedScope allowedScope( displayTreeInternal());1045 displayTree Internal().remove();1058 ScriptDisallowedScope::EventAllowedScope allowedScope(*displayTree); 1059 displayTree->remove(); 1046 1060 } 1047 1061 -
branches/safari-613-branch/Source/WebCore/html/track/VTTCue.h
r286743 r295185 196 196 bool cueContentsMatch(const TextTrackCue&) const override; 197 197 198 virtual Ref <VTTCueBox> createDisplayTree();199 VTTCueBox &displayTreeInternal();198 virtual RefPtr<VTTCueBox> createDisplayTree(); 199 VTTCueBox* displayTreeInternal(); 200 200 201 201 void toJSON(JSON::Object&) const override; … … 204 204 VTTCue(Document&, const WebVTTCueData&); 205 205 206 void initialize( );206 void initialize(Document&); 207 207 void createWebVTTNodeTree(); 208 208
Note:
See TracChangeset
for help on using the changeset viewer.