Merge pull request #24328 from ToRaNek/fix/nkwebkit-time-ranges-merge-keeps-added

fix(libSceNKWebKit): keep the added range's times when PlatformTimeRanges merges equal bounds
This commit is contained in:
Dean authored and GitHub committed 2026-11-21 13:08:06 +13:00
commit fc973e0189
2 files changed
+41 -2

No files matched your search

+2 -2
View File
@@ -200,8 +200,8 @@ bool rangeIsContiguousWithRange(const WebCore::PlatformTimeRanges::Range& a, con
WebCore::PlatformTimeRanges::Range rangeUnionWithOverlappingOrContiguousRange(const WebCore::PlatformTimeRanges::Range& a, const WebCore::PlatformTimeRanges::Range& b) {
WebCore::PlatformTimeRanges::Range ret;
ret.start = _ZNK3WTF9MediaTimeltERKS0_(&a.start, b.start) ? a.start : b.start;
ret.end = _ZNK3WTF9MediaTimegtERKS0_(&a.end, b.end) ? a.end : b.end;
ret.start = _ZNK3WTF9MediaTimeltERKS0_(&b.start, a.start) ? b.start : a.start;
ret.end = _ZNK3WTF9MediaTimeltERKS0_(&a.end, b.end) ? b.end : a.end;
return ret;
}
@@ -442,6 +442,45 @@ void TestPlatformTimeRanges() {
Require(_ZNK7WebCore18PlatformTimeRanges6lengthEv(&invalidAddRanges) == 0);
_ZN7WebCore18PlatformTimeRangesD1Ev(&invalidAddRanges);
WebCore::PlatformTimeRanges tieRanges;
_ZN7WebCore18PlatformTimeRangesC1Ev(&tieRanges);
WTF::MediaTime tieStart;
WTF::MediaTime tieEnd;
_ZN3WTF9MediaTimeC1Eljh(&tieStart, 0, 1000, WTF::MediaTime::Valid);
_ZN3WTF9MediaTimeC1Eljh(&tieEnd, 5000, 1000, WTF::MediaTime::Valid);
_ZN7WebCore18PlatformTimeRanges3addERKN3WTF9MediaTimeES4_(&tieRanges, tieStart, tieEnd);
WTF::MediaTime sameStart;
WTF::MediaTime sameEnd;
_ZN3WTF9MediaTimeC1Eljh(&sameStart, 0, 90000, WTF::MediaTime::Valid);
_ZN3WTF9MediaTimeC1Eljh(&sameEnd, 450000, 90000, WTF::MediaTime::Valid);
_ZN7WebCore18PlatformTimeRanges3addERKN3WTF9MediaTimeES4_(&tieRanges, sameStart, sameEnd);
Require(_ZNK7WebCore18PlatformTimeRanges6lengthEv(&tieRanges) == 1);
bool tieValid = false;
WTF::MediaTime mergedStart = _ZNK7WebCore18PlatformTimeRanges5startEjRb(&tieRanges, 0, tieValid);
Require(tieValid && mergedStart.m_timeValue == 0 && mergedStart.m_timeScale == 90000);
WTF::MediaTime mergedEnd = _ZNK7WebCore18PlatformTimeRanges3endEjRb(&tieRanges, 0, tieValid);
Require(tieValid && mergedEnd.m_timeValue == 450000 && mergedEnd.m_timeScale == 90000);
WTF::MediaTime shortStart;
WTF::MediaTime shortEnd;
_ZN3WTF9MediaTimeC1Eljh(&shortStart, 0, 30000, WTF::MediaTime::Valid);
_ZN3WTF9MediaTimeC1Eljh(&shortEnd, 60000, 30000, WTF::MediaTime::Valid);
_ZN7WebCore18PlatformTimeRanges3addERKN3WTF9MediaTimeES4_(&tieRanges, shortStart, shortEnd);
Require(_ZNK7WebCore18PlatformTimeRanges6lengthEv(&tieRanges) == 1);
mergedStart = _ZNK7WebCore18PlatformTimeRanges5startEjRb(&tieRanges, 0, tieValid);
Require(tieValid && mergedStart.m_timeValue == 0 && mergedStart.m_timeScale == 30000);
mergedEnd = _ZNK7WebCore18PlatformTimeRanges3endEjRb(&tieRanges, 0, tieValid);
Require(tieValid && mergedEnd.m_timeValue == 450000 && mergedEnd.m_timeScale == 90000);
WTF::MediaTime doubleStart = _ZN3WTF9MediaTime16createWithDoubleEd(0.0);
WTF::MediaTime doubleEnd = _ZN3WTF9MediaTime16createWithDoubleEd(5.0);
_ZN7WebCore18PlatformTimeRanges3addERKN3WTF9MediaTimeES4_(&tieRanges, doubleStart, doubleEnd);
Require(_ZNK7WebCore18PlatformTimeRanges6lengthEv(&tieRanges) == 1);
mergedStart = _ZNK7WebCore18PlatformTimeRanges5startEjRb(&tieRanges, 0, tieValid);
Require(tieValid && (mergedStart.m_timeFlags & WTF::MediaTime::DoubleValue) != 0);
mergedEnd = _ZNK7WebCore18PlatformTimeRanges3endEjRb(&tieRanges, 0, tieValid);
Require(tieValid && (mergedEnd.m_timeFlags & WTF::MediaTime::DoubleValue) != 0);
Require(_ZNK3WTF9MediaTime8toDoubleEv(&mergedEnd) == 5.0);
_ZN7WebCore18PlatformTimeRangesD1Ev(&tieRanges);
WebCore::PlatformTimeRanges ranges;
_ZN7WebCore18PlatformTimeRangesC1Ev(&ranges);