Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 893c5a47d056c499ee8fa876a8c4604b4aab564d
https://github.com/WebKit/WebKit/commit/893c5a47d056c499ee8fa876a8c4604b4aab564d
Author: Josh Hernandez <[email protected]>
Date: 2026-06-22 (Mon, 22 Jun 2026)
Changed paths:
A LayoutTests/media/track/text-track-find-expected.txt
A LayoutTests/media/track/text-track-find.html
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
A Source/WebCore/page/CueMatch.h
M Source/WebCore/page/Page.cpp
M Source/WebCore/page/Page.h
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
Log Message:
-----------
Add support for searching text track cues for matching text
https://bugs.webkit.org/show_bug.cgi?id=317049
rdar://179530437
Reviewed by Eric Carlson.
It adds Document::findCueMatches, which iterates the document's connected media
elements, and for each showing subtitles, captions, or descriptions track
matches the target string against every VTTCue's plain text, returning a
CueMatch (the media element and the cue's start time) for each hit. Results are
ordered by media element in composed-tree order, then by cue start time within
each element. Cues whose start time is at or beyond the media's duration are
skipped, and tracks that are not currently showing, or whose kind is chapters
or metadata, are ignored.
Page::findCueMatches is a thin walker that visits
frames in document order, mirroring Page::findTextMatches, and aggregates each
document's results. Searching one document at a time keeps cue ordering
consistent with DOM text matches and avoids comparing media elements across
documents.
To support matching, VTTCue::plainText is added to expose a cue's
flattened, markup-stripped text, so searches run against the rendered words
rather than the raw WebVTT payload.
Searching is currently limited to showing
tracks, and this scope is subject to change as the feature evolves.
This does
not yet alter any find UI. The search is exposed to tests via
internals.findCueMatches, and wiring cue matches into the find result list and
seeking the video on navigation will follow in a later patch.
A new layout
test, media/track/text-track-find.html, loads a hundred-cue WebVTT track on a
video and verifies that matching cues are returned with the correct timestamps,
that cues past the media duration are excluded, and that a query with no
matches returns nothing.
Test: media/track/text-track-find.html
* LayoutTests/media/track/text-track-find-expected.txt: Added.
* LayoutTests/media/track/text-track-find.html: Added.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::findCueMatches):
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/CueMatch.h: Added.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::findCueMatches):
* Source/WebCore/page/Page.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::findCueMatches):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
Canonical link: https://commits.webkit.org/315634@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications