void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion) { if (!prpRegion) return; RefPtr<VTTRegion> region = prpRegion; VTTRegionList* regionList = ensureVTTRegionList(); // 1. If the given region is in a text track list of regions, then remove // region from that text track list of regions. TextTrack* regionTrack = region->track(); if (regionTrack && regionTrack != this) regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION); // 2. If the method's TextTrack object's text track list of regions contains // a region with the same identifier as region replace the values of that // region's width, height, anchor point, viewport anchor point and scroll // attributes with those of region. VTTRegion* existingRegion = regionList->getRegionById(region->id()); if (existingRegion) { existingRegion->updateParametersFromRegion(region.get()); return; } // Otherwise: add region to the method's TextTrack object's text track // list of regions. region->setTrack(this); regionList->add(region); }
VTTRegionList* TextTrack::regions() { // If the text track mode of the text track that the TextTrack object // represents is not the text track disabled mode, then the regions // attribute must return a live VTTRegionList object that represents // the text track list of regions of the text track. Otherwise, it must // return null. When an object is returned, the same object must be returned // each time. if (m_mode == Mode::Disabled) return nullptr; return &ensureVTTRegionList(); }
VTTRegionList* TextTrack::regions() { // If the text track mode of the text track that the TextTrack object // represents is not the text track disabled mode, then the regions // attribute must return a live VTTRegionList object that represents // the text track list of regions of the text track. Otherwise, it must // return null. When an object is returned, the same object must be returned // each time. if (RuntimeEnabledFeatures::webVTTRegionsEnabled() && m_mode != disabledKeyword()) return ensureVTTRegionList(); return 0; }