| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/track/AutomaticTrackSelection.h" | 5 #include "core/html/track/AutomaticTrackSelection.h" |
| 6 | 6 |
| 7 #include "core/html/track/TextTrack.h" | 7 #include "core/html/track/TextTrack.h" |
| 8 #include "core/html/track/TextTrackList.h" | 8 #include "core/html/track/TextTrackList.h" |
| 9 #include "platform/Language.h" | 9 #include "platform/Language.h" |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 HeapVector<Member<TextTrack>> currentlyEnabledTracks; | 71 HeapVector<Member<TextTrack>> currentlyEnabledTracks; |
| 72 TextTrack* trackToEnable = nullptr; | 72 TextTrack* trackToEnable = nullptr; |
| 73 TextTrack* defaultTrack = nullptr; | 73 TextTrack* defaultTrack = nullptr; |
| 74 TextTrack* preferredTrack = nullptr; | 74 TextTrack* preferredTrack = nullptr; |
| 75 TextTrack* fallbackTrack = nullptr; | 75 TextTrack* fallbackTrack = nullptr; |
| 76 int highestTrackScore = 0; | 76 int highestTrackScore = 0; |
| 77 | 77 |
| 78 for (const auto& textTrack : group.tracks) { | 78 for (const auto& textTrack : group.tracks) { |
| 79 if (m_configuration.disableCurrentlyEnabledTracks && | 79 if (m_configuration.disableCurrentlyEnabledTracks && |
| 80 textTrack->mode() == TextTrack::showingKeyword()) | 80 textTrack->mode() == TextTrack::showingKeyword()) |
| 81 currentlyEnabledTracks.append(textTrack); | 81 currentlyEnabledTracks.push_back(textTrack); |
| 82 | 82 |
| 83 int trackScore = textTrackSelectionScore(*textTrack); | 83 int trackScore = textTrackSelectionScore(*textTrack); |
| 84 | 84 |
| 85 if (textTrack->kind() == preferredTrackKind()) | 85 if (textTrack->kind() == preferredTrackKind()) |
| 86 trackScore += 1; | 86 trackScore += 1; |
| 87 if (trackScore) { | 87 if (trackScore) { |
| 88 // * If the text track kind is subtitles or captions and the user has | 88 // * If the text track kind is subtitles or captions and the user has |
| 89 // indicated an interest in having a track with this text track kind, text | 89 // indicated an interest in having a track with this text track kind, text |
| 90 // track language, and text track label enabled, and there is no other | 90 // track language, and text track label enabled, and there is no other |
| 91 // text track in the media element's list of text tracks with a text track | 91 // text track in the media element's list of text tracks with a text track |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // adding another track after the initial configuration doesn't reconfigure | 190 // adding another track after the initial configuration doesn't reconfigure |
| 191 // every track - only those that should be changed by the new addition. For | 191 // every track - only those that should be changed by the new addition. For |
| 192 // example all metadata tracks are disabled by default, and we don't want a | 192 // example all metadata tracks are disabled by default, and we don't want a |
| 193 // track that has been enabled by script to be disabled automatically when a | 193 // track that has been enabled by script to be disabled automatically when a |
| 194 // new metadata track is added later. | 194 // new metadata track is added later. |
| 195 if (textTrack->hasBeenConfigured()) | 195 if (textTrack->hasBeenConfigured()) |
| 196 continue; | 196 continue; |
| 197 | 197 |
| 198 if (textTrack->language().length()) | 198 if (textTrack->language().length()) |
| 199 currentGroup->hasSrcLang = true; | 199 currentGroup->hasSrcLang = true; |
| 200 currentGroup->tracks.append(textTrack); | 200 currentGroup->tracks.push_back(textTrack); |
| 201 } | 201 } |
| 202 | 202 |
| 203 if (captionAndSubtitleTracks.tracks.size()) | 203 if (captionAndSubtitleTracks.tracks.size()) |
| 204 performAutomaticTextTrackSelection(captionAndSubtitleTracks); | 204 performAutomaticTextTrackSelection(captionAndSubtitleTracks); |
| 205 if (descriptionTracks.tracks.size()) | 205 if (descriptionTracks.tracks.size()) |
| 206 performAutomaticTextTrackSelection(descriptionTracks); | 206 performAutomaticTextTrackSelection(descriptionTracks); |
| 207 if (chapterTracks.tracks.size()) | 207 if (chapterTracks.tracks.size()) |
| 208 performAutomaticTextTrackSelection(chapterTracks); | 208 performAutomaticTextTrackSelection(chapterTracks); |
| 209 if (metadataTracks.tracks.size()) | 209 if (metadataTracks.tracks.size()) |
| 210 enableDefaultMetadataTextTracks(metadataTracks); | 210 enableDefaultMetadataTextTracks(metadataTracks); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace blink | 213 } // namespace blink |
| OLD | NEW |