From 726e1c5c1c79eafed7ab1ebc52cb55d380015c5b Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 22 Sep 2016 19:55:38 +1000 Subject: [PATCH 01/86] Bug 1302573: [MSE] P1. Add mochitest. r=gerald MozReview-Commit-ID: 9zAZ8x3kwQ7 --HG-- extra : rebase_source : caf5853d097beeb57e87e6dee692cc445b2c9c29 --- dom/media/mediasource/test/mochitest.ini | 10 ++- .../mediasource/test/test_Eviction_mp4.html | 82 +++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 dom/media/mediasource/test/test_Eviction_mp4.html diff --git a/dom/media/mediasource/test/mochitest.ini b/dom/media/mediasource/test/mochitest.ini index 8c6290ef4afd..5e4196ce6eff 100644 --- a/dom/media/mediasource/test/mochitest.ini +++ b/dom/media/mediasource/test/mochitest.ini @@ -55,14 +55,16 @@ skip-if = toolkit == 'android' #timeout android bug 1199531 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3 [test_DrainOnMissingData_mp4.html] skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3 -[test_EndOfStream.html] -skip-if = (true || toolkit == 'android' || buildapp == 'mulet') #timeout android/mulet only bug 1101187 and bug 1182946 -[test_EndOfStream_mp4.html] -skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android' || buildapp == 'mulet')) # Not supported on xp and android 2.3 [test_DurationChange.html] [test_DurationUpdated.html] [test_DurationUpdated_mp4.html] skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3 +[test_EndOfStream.html] +skip-if = (true || toolkit == 'android' || buildapp == 'mulet') #timeout android/mulet only bug 1101187 and bug 1182946 +[test_EndOfStream_mp4.html] +skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android' || buildapp == 'mulet')) # Not supported on xp and android 2.3 +[test_Eviction_mp4.html] +skip-if = (os == "win" && os_version == "5.1") # Not supported on xp. [test_FrameSelection.html] [test_FrameSelection_mp4.html] skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3 diff --git a/dom/media/mediasource/test/test_Eviction_mp4.html b/dom/media/mediasource/test/test_Eviction_mp4.html new file mode 100644 index 000000000000..c702cc3bb262 --- /dev/null +++ b/dom/media/mediasource/test/test_Eviction_mp4.html @@ -0,0 +1,82 @@ + + + + MSE: QuotaExceededError when source buffer is full + + + + + +

+
+ + From 93fe7f08f6b2fc1733fd16d00a7d3204e55dd41a Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 22 Sep 2016 20:03:13 +1000 Subject: [PATCH 02/86] Bug 1302573: [MSE] P2. Keep track of how much data can be evicted prior to current demuxing position. r=gerald The MSE specs require a synchronous step which would evict data prior to an appendBuffer. This is however, fundamentally incompatible with our multi-threaded, almost lock-free architecture. So instead, we keep track of how much data we have prior to currentTime, and check that value before appending new data. MozReview-Commit-ID: Fl58R7dZsig --HG-- extra : rebase_source : 41ea607249f94d1e1034055789160fab79616990 --- dom/media/mediasource/TrackBuffersManager.cpp | 98 +++++++++++++++++-- dom/media/mediasource/TrackBuffersManager.h | 25 ++++- 2 files changed, 113 insertions(+), 10 deletions(-) diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 219a279a13e5..b8dfacf116e9 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -274,8 +274,20 @@ TrackBuffersManager::EvictData(const TimeUnit& aPlaybackTime, int64_t aSize) } const int64_t toEvict = GetSize() + aSize - EvictionThreshold(); - MSE_DEBUG("buffered=%lldkb, eviction threshold=%ukb, evict=%lldkb", - GetSize() / 1024, EvictionThreshold() / 1024, toEvict / 1024); + uint32_t canEvict; + { + MonitorAutoLock mon(mMonitor); + if (HasVideo()) { + canEvict = mVideoTracks.mEvictionIndex.mEvictable; + } else { + canEvict = mAudioTracks.mEvictionIndex.mEvictable; + } + } + + MSE_DEBUG( + "buffered=%lldkB, eviction threshold=%ukB, evict=%lldkB canevict=%ukB", + GetSize() / 1024, EvictionThreshold() / 1024, toEvict / 1024, + canEvict / 1024); if (toEvict <= 0) { mEvictionState = EvictionState::NO_EVICTION_NEEDED; @@ -289,7 +301,8 @@ TrackBuffersManager::EvictData(const TimeUnit& aPlaybackTime, int64_t aSize) EvictDataResult result; - if (mBufferFull && mEvictionState == EvictionState::EVICTION_COMPLETED) { + if (mBufferFull && mEvictionState == EvictionState::EVICTION_COMPLETED && + canEvict < uint32_t(toEvict)) { // Our buffer is currently full. We will make another eviction attempt. // However, the current appendBuffer will fail as we can't know ahead of // time if the eviction will later succeed. @@ -422,7 +435,7 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime, mEvictionState = EvictionState::EVICTION_COMPLETED; // Video is what takes the most space, only evict there if we have video. - const auto& track = HasVideo() ? mVideoTracks : mAudioTracks; + auto& track = HasVideo() ? mVideoTracks : mAudioTracks; const auto& buffer = track.mBuffers.LastElement(); // Remove any data we've already played, or before the next sample to be // demuxed whichever is lowest. @@ -1706,8 +1719,15 @@ TrackBuffersManager::InsertFrames(TrackBuffer& aSamples, aIntervals.GetEnd() >= trackBuffer.mNextSampleTime) { MSE_DEBUG("Next sample to be played got overwritten"); trackBuffer.mNextGetSampleIndex.reset(); + ResetEvictionIndex(trackBuffer); } else if (trackBuffer.mNextInsertionIndex.ref() <= trackBuffer.mNextGetSampleIndex.ref()) { trackBuffer.mNextGetSampleIndex.ref() += aSamples.Length(); + // We could adjust the eviction index so that the new data gets added to + // the evictable amount (as it is prior currentTime). However, considering + // new data is being added prior the current playback, it's likely that + // this data will be played next, and as such we probably don't want to + // have it evicted too early. So instead reset the eviction index instead. + ResetEvictionIndex(trackBuffer); } } @@ -1783,6 +1803,7 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals, } int64_t maxSampleDuration = 0; + uint32_t sizeRemoved = 0; TimeIntervals removedIntervals; for (uint32_t i = firstRemovedIndex.ref(); i <= lastRemovedIndex; i++) { const RefPtr sample = data[i]; @@ -1793,8 +1814,9 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals, if (sample->mDuration > maxSampleDuration) { maxSampleDuration = sample->mDuration; } - aTrackData.mSizeBuffer -= sample->ComputedSizeOfIncludingThis(); + sizeRemoved += sample->ComputedSizeOfIncludingThis(); } + aTrackData.mSizeBuffer -= sizeRemoved; MSE_DEBUG("Removing frames from:%u (frames:%u) ([%f, %f))", firstRemovedIndex.ref(), @@ -1807,9 +1829,21 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals, aTrackData.mNextGetSampleIndex.ref() <= lastRemovedIndex) { MSE_DEBUG("Next sample to be played got evicted"); aTrackData.mNextGetSampleIndex.reset(); + ResetEvictionIndex(aTrackData); } else if (aTrackData.mNextGetSampleIndex.ref() > lastRemovedIndex) { - aTrackData.mNextGetSampleIndex.ref() -= - lastRemovedIndex - firstRemovedIndex.ref() + 1; + uint32_t samplesRemoved = lastRemovedIndex - firstRemovedIndex.ref() + 1; + aTrackData.mNextGetSampleIndex.ref() -= samplesRemoved; + if (aTrackData.mEvictionIndex.mLastIndex > lastRemovedIndex) { + MOZ_DIAGNOSTIC_ASSERT( + aTrackData.mEvictionIndex.mLastIndex >= samplesRemoved && + aTrackData.mEvictionIndex.mEvictable >= sizeRemoved, + "Invalid eviction index"); + MonitorAutoLock mon(mMonitor); + aTrackData.mEvictionIndex.mLastIndex -= samplesRemoved; + aTrackData.mEvictionIndex.mEvictable -= sizeRemoved; + } else { + ResetEvictionIndex(aTrackData); + } } } @@ -1951,6 +1985,33 @@ TrackBuffersManager::HighestEndTime() return highestEndTime; } +void +TrackBuffersManager::ResetEvictionIndex(TrackData& aTrackData) +{ + MonitorAutoLock mon(mMonitor); + aTrackData.mEvictionIndex.Reset(); +} + +void +TrackBuffersManager::UpdateEvictionIndex(TrackData& aTrackData, + uint32_t currentIndex) +{ + uint32_t evictable = 0; + TrackBuffer& data = aTrackData.mBuffers.LastElement(); + MOZ_DIAGNOSTIC_ASSERT(currentIndex >= aTrackData.mEvictionIndex.mLastIndex, + "Invalid call"); + MOZ_DIAGNOSTIC_ASSERT(currentIndex == data.Length() || + data[currentIndex]->mKeyframe,"Must stop at keyframe"); + + for (uint32_t i = aTrackData.mEvictionIndex.mLastIndex; i < currentIndex; + i++) { + evictable += data[i]->ComputedSizeOfIncludingThis(); + } + aTrackData.mEvictionIndex.mLastIndex = currentIndex; + MonitorAutoLock mon(mMonitor); + aTrackData.mEvictionIndex.mEvictable += evictable; +} + const TrackBuffersManager::TrackBuffer& TrackBuffersManager::GetTrackBuffer(TrackInfo::TrackType aTrack) { @@ -1989,6 +2050,7 @@ TrackBuffersManager::Seek(TrackInfo::TrackType aTrack, trackBuffer.mNextGetSampleIndex = Some(uint32_t(0)); trackBuffer.mNextSampleTimecode = TimeUnit(); trackBuffer.mNextSampleTime = TimeUnit(); + ResetEvictionIndex(trackBuffer); return TimeUnit(); } @@ -2027,13 +2089,16 @@ TrackBuffersManager::Seek(TrackInfo::TrackType aTrack, break; } } - MSE_DEBUG("Keyframe %s found at %lld", + MSE_DEBUG("Keyframe %s found at %lld @ %u", lastKeyFrameTime.isSome() ? "" : "not", - lastKeyFrameTime.refOr(TimeUnit()).ToMicroseconds()); + lastKeyFrameTime.refOr(TimeUnit()).ToMicroseconds(), + lastKeyFrameIndex); trackBuffer.mNextGetSampleIndex = Some(lastKeyFrameIndex); trackBuffer.mNextSampleTimecode = lastKeyFrameTimecode; trackBuffer.mNextSampleTime = lastKeyFrameTime.refOr(TimeUnit()); + ResetEvictionIndex(trackBuffer); + UpdateEvictionIndex(trackBuffer, lastKeyFrameIndex); return lastKeyFrameTime.refOr(TimeUnit()); } @@ -2121,6 +2186,11 @@ TrackBuffersManager::SkipToNextRandomAccessPoint(TrackInfo::TrackType aTrack, parsed--; } } + + if (aFound) { + UpdateEvictionIndex(trackData, trackData.mNextGetSampleIndex.ref()); + } + return parsed; } @@ -2193,6 +2263,9 @@ TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack, aResult = MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__); return nullptr; } + if (p->mKeyframe) { + UpdateEvictionIndex(trackData, trackData.mNextGetSampleIndex.ref()); + } trackData.mNextGetSampleIndex.ref()++; // Estimate decode timestamp and timestamp of the next sample. TimeUnit nextSampleTimecode = @@ -2244,6 +2317,13 @@ TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack, aResult = MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__); return nullptr; } + + // Find the previous keyframe to calculate the evictable amount. + int32_t i = pos; + for (; !track[i]->mKeyframe; i--) { + } + UpdateEvictionIndex(trackData, i); + trackData.mNextGetSampleIndex = Some(uint32_t(pos)+1); trackData.mNextSampleTimecode = TimeUnit::FromMicroseconds(sample->mTimecode + sample->mDuration); diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 0bec46a47052..8bbeaf0dd41d 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -334,6 +334,26 @@ private: // Approximation of the next sample's presentation timestamp. media::TimeUnit mNextSampleTime; + struct EvictionIndex + { + EvictionIndex() { Reset(); } + void Reset() + { + mEvictable = 0; + mLastIndex = 0; + } + uint32_t mEvictable; + uint32_t mLastIndex; + }; + // Size of data that can be safely evicted during the next eviction + // cycle. + // We consider as evictable all frames up to the last keyframe prior to + // mNextGetSampleIndex. If mNextGetSampleIndex isn't set, then we assume + // that we can't yet evict data. + // Protected by global monitor, except when reading on the task queue as it + // is only written there. + EvictionIndex mEvictionIndex; + void ResetAppendState() { mLastDecodeTimestamp.reset(); @@ -363,6 +383,9 @@ private: size_t RemoveFrames(const media::TimeIntervals& aIntervals, TrackData& aTrackData, uint32_t aStartIndex); + // Recalculate track's evictable amount. + void ResetEvictionIndex(TrackData& aTrackData); + void UpdateEvictionIndex(TrackData& aTrackData, uint32_t aCurrentIndex); // Find index of sample. Return a negative value if not found. uint32_t FindSampleIndex(const TrackBuffer& aTrackBuffer, const media::TimeInterval& aInterval); @@ -436,7 +459,7 @@ private: }; Atomic mEvictionState; - // Monitor to protect following objects accessed across multipple threads. + // Monitor to protect following objects accessed across multiple threads. mutable Monitor mMonitor; // Stable audio and video track time ranges. media::TimeIntervals mVideoBufferedRanges; From 35a0f6dbcf0c4522cf713f87239e306bc80898b4 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sat, 24 Sep 2016 16:38:14 +1000 Subject: [PATCH 03/86] Bug 1302573: [MSE] P3. Display evictable amount in about:media output. r=gerald MozReview-Commit-ID: 1cs2aAxSH4A --HG-- extra : rebase_source : cad708cb139aff03d91f338827f579c18551c99a --- dom/media/mediasource/MediaSourceDemuxer.cpp | 6 ++++-- dom/media/mediasource/TrackBuffersManager.cpp | 18 +++++++++--------- dom/media/mediasource/TrackBuffersManager.h | 11 +++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dom/media/mediasource/MediaSourceDemuxer.cpp b/dom/media/mediasource/MediaSourceDemuxer.cpp index 385f1bc2a36b..73950e1a874e 100644 --- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -258,11 +258,12 @@ MediaSourceDemuxer::GetMozDebugReaderData(nsAString& aString) result += nsPrintfCString("Dumping data for demuxer %p:\n", this); if (mAudioTrack) { result += nsPrintfCString("\tDumping Audio Track Buffer(%s): - mLastAudioTime: %f\n" - "\t\tNumSamples:%u Size:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n", + "\t\tNumSamples:%u Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n", mAudioTrack->mAudioTracks.mInfo->mMimeType.get(), mAudioTrack->mAudioTracks.mNextSampleTime.ToSeconds(), mAudioTrack->mAudioTracks.mBuffers[0].Length(), mAudioTrack->mAudioTracks.mSizeBuffer, + mAudioTrack->Evictable(TrackInfo::kAudioTrack), mAudioTrack->mAudioTracks.mNextGetSampleIndex.valueOr(-1), mAudioTrack->mAudioTracks.mNextInsertionIndex.valueOr(-1)); @@ -271,11 +272,12 @@ MediaSourceDemuxer::GetMozDebugReaderData(nsAString& aString) } if (mVideoTrack) { result += nsPrintfCString("\tDumping Video Track Buffer(%s) - mLastVideoTime: %f\n" - "\t\tNumSamples:%u Size:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n", + "\t\tNumSamples:%u Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n", mVideoTrack->mVideoTracks.mInfo->mMimeType.get(), mVideoTrack->mVideoTracks.mNextSampleTime.ToSeconds(), mVideoTrack->mVideoTracks.mBuffers[0].Length(), mVideoTrack->mVideoTracks.mSizeBuffer, + mVideoTrack->Evictable(TrackInfo::kVideoTrack), mVideoTrack->mVideoTracks.mNextGetSampleIndex.valueOr(-1), mVideoTrack->mVideoTracks.mNextInsertionIndex.valueOr(-1)); diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index b8dfacf116e9..b4a7c2e20667 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -274,15 +274,8 @@ TrackBuffersManager::EvictData(const TimeUnit& aPlaybackTime, int64_t aSize) } const int64_t toEvict = GetSize() + aSize - EvictionThreshold(); - uint32_t canEvict; - { - MonitorAutoLock mon(mMonitor); - if (HasVideo()) { - canEvict = mVideoTracks.mEvictionIndex.mEvictable; - } else { - canEvict = mAudioTracks.mEvictionIndex.mEvictable; - } - } + const uint32_t canEvict = + Evictable(HasVideo() ? TrackInfo::kVideoTrack : TrackInfo::kAudioTrack); MSE_DEBUG( "buffered=%lldkB, eviction threshold=%ukB, evict=%lldkB canevict=%ukB", @@ -2393,6 +2386,13 @@ TrackBuffersManager::FindCurrentPosition(TrackInfo::TrackType aTrack, return -1; } +uint32_t +TrackBuffersManager::Evictable(TrackInfo::TrackType aTrack) const +{ + MonitorAutoLock mon(mMonitor); + return GetTracksData(aTrack).mEvictionIndex.mEvictable; +} + TimeUnit TrackBuffersManager::GetNextRandomAccessPoint(TrackInfo::TrackType aTrack, const TimeUnit& aFuzz) diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 8bbeaf0dd41d..3fea12b26f10 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -147,6 +147,7 @@ public: { return mEnded; } + uint32_t Evictable(TrackInfo::TrackType aTrack) const; media::TimeUnit Seek(TrackInfo::TrackType aTrack, const media::TimeUnit& aTime, const media::TimeUnit& aFuzz); @@ -412,6 +413,16 @@ private: return mAudioTracks; } } + const TrackData& GetTracksData(TrackType aTrack) const + { + switch(aTrack) { + case TrackType::kVideoTrack: + return mVideoTracks; + case TrackType::kAudioTrack: + default: + return mAudioTracks; + } + } TrackData mVideoTracks; TrackData mAudioTracks; From 46aeb460fb146f820a8f1093dec5e080f3bc4851 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sat, 24 Sep 2016 20:43:32 +1000 Subject: [PATCH 04/86] Bug 1302573: [MSE] P4. Be consistent in datatype being used. r=gerald When using gcc on linux, about:media shows incorrect content due to incorrect printf formatter. MozReview-Commit-ID: IWtl6cX1OFA --HG-- extra : rebase_source : 392143e1f5a3af3b9353a6824487c328ab9a3878 --- dom/media/mediasource/TrackBuffersManager.cpp | 12 ++++++------ dom/media/mediasource/TrackBuffersManager.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index b4a7c2e20667..11ae07d0d836 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -1609,7 +1609,7 @@ TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData, TrackBuffer& data = aTrackData.mBuffers.LastElement(); if (data.IsEmpty() || aSampleTime < aTrackData.mBufferedRanges.GetStart()) { - aTrackData.mNextInsertionIndex = Some(size_t(0)); + aTrackData.mNextInsertionIndex = Some(0u); return true; } @@ -1623,7 +1623,7 @@ TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData, } if (target.IsEmpty()) { // No target found, it will be added at the end of the track buffer. - aTrackData.mNextInsertionIndex = Some(data.Length()); + aTrackData.mNextInsertionIndex = Some(uint32_t(data.Length())); return true; } // We now need to find the first frame of the searched interval. @@ -1632,7 +1632,7 @@ TrackBuffersManager::CheckNextInsertionIndex(TrackData& aTrackData, const RefPtr& sample = data[i]; if (sample->mTime >= target.mStart.ToMicroseconds() || sample->GetEndTime() > target.mStart.ToMicroseconds()) { - aTrackData.mNextInsertionIndex = Some(size_t(i)); + aTrackData.mNextInsertionIndex = Some(i); return true; } } @@ -1692,7 +1692,7 @@ TrackBuffersManager::InsertFrames(TrackBuffer& aSamples, // to overlap the following frame. trackBuffer.mNextInsertionIndex.reset(); } - size_t index = + uint32_t index = RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0)); if (index) { trackBuffer.mNextInsertionIndex = Some(index); @@ -1750,7 +1750,7 @@ TrackBuffersManager::UpdateHighestTimestamp(TrackData& aTrackData, } } -size_t +uint32_t TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals, TrackData& aTrackData, uint32_t aStartIndex) @@ -2189,7 +2189,7 @@ TrackBuffersManager::SkipToNextRandomAccessPoint(TrackInfo::TrackType aTrack, const MediaRawData* TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack, - size_t aIndex, + uint32_t aIndex, const TimeUnit& aExpectedDts, const TimeUnit& aExpectedPts, const TimeUnit& aFuzz) diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 3fea12b26f10..455e20288268 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -308,7 +308,7 @@ private: // If set, position where the next contiguous frame will be inserted. // If a discontinuity is detected, it will be unset and recalculated upon // the next insertion. - Maybe mNextInsertionIndex; + Maybe mNextInsertionIndex; // Samples just demuxed, but not yet parsed. TrackBuffer mQueuedSamples; // We only manage a single track of each type at this time. @@ -381,9 +381,9 @@ private: // Remove all frames and their dependencies contained in aIntervals. // Return the index at which frames were first removed or 0 if no frames // removed. - size_t RemoveFrames(const media::TimeIntervals& aIntervals, - TrackData& aTrackData, - uint32_t aStartIndex); + uint32_t RemoveFrames(const media::TimeIntervals& aIntervals, + TrackData& aTrackData, + uint32_t aStartIndex); // Recalculate track's evictable amount. void ResetEvictionIndex(TrackData& aTrackData); void UpdateEvictionIndex(TrackData& aTrackData, uint32_t aCurrentIndex); @@ -391,7 +391,7 @@ private: uint32_t FindSampleIndex(const TrackBuffer& aTrackBuffer, const media::TimeInterval& aInterval); const MediaRawData* GetSample(TrackInfo::TrackType aTrack, - size_t aIndex, + uint32_t aIndex, const media::TimeUnit& aExpectedDts, const media::TimeUnit& aExpectedPts, const media::TimeUnit& aFuzz); From 05df96f1aaf6ca0b6742c9eaa7cb52cb66f374f2 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Sun, 25 Sep 2016 21:55:26 +1000 Subject: [PATCH 05/86] Bug 1302573: [MSE] P5. Always evict data as soon as we can. r=gerald While never evicting less than 512kB saves CPU cycles, it reduces the chances to evict data when we actually need to and requires currentTime to advance much further. MozReview-Commit-ID: LcQFFtarbbi --HG-- extra : rebase_source : 381de3d926bbb12377f4332eb87c08b52a56551a --- dom/media/mediasource/TrackBuffersManager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 11ae07d0d836..32b84c8bc33f 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -286,11 +286,6 @@ TrackBuffersManager::EvictData(const TimeUnit& aPlaybackTime, int64_t aSize) mEvictionState = EvictionState::NO_EVICTION_NEEDED; return EvictDataResult::NO_DATA_EVICTED; } - if (toEvict <= 512*1024) { - // Don't bother evicting less than 512KB. - mEvictionState = EvictionState::NO_EVICTION_NEEDED; - return EvictDataResult::CANT_EVICT; - } EvictDataResult result; From dd2a72e7ccec72d1fcdf4a58869cc15d3a00c3d2 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 26 Sep 2016 12:28:07 +1000 Subject: [PATCH 06/86] Bug 1297311: P1. Always recreate a decoder when SPS changes. r=cpearce This allow consistency between platforms. A decoder will now always be shutdown and another one created if the video configuration changes. MozReview-Commit-ID: 1SPzhVuBrip --HG-- extra : rebase_source : f4d0347c4686d2f3ec0e4cf065a6c3fa36b7ea06 --- dom/media/ipc/RemoteVideoDecoder.h | 1 - dom/media/platforms/PlatformDecoderModule.h | 8 ------- .../platforms/wmf/WMFMediaDataDecoder.cpp | 21 ------------------- dom/media/platforms/wmf/WMFMediaDataDecoder.h | 8 ------- .../platforms/wmf/WMFVideoMFTManager.cpp | 9 -------- dom/media/platforms/wmf/WMFVideoMFTManager.h | 2 -- .../platforms/wrappers/FuzzingWrapper.cpp | 9 -------- dom/media/platforms/wrappers/FuzzingWrapper.h | 1 - .../platforms/wrappers/H264Converter.cpp | 18 +++------------- dom/media/platforms/wrappers/H264Converter.h | 1 - 10 files changed, 3 insertions(+), 75 deletions(-) diff --git a/dom/media/ipc/RemoteVideoDecoder.h b/dom/media/ipc/RemoteVideoDecoder.h index 29d508b2d012..6ebacf099329 100644 --- a/dom/media/ipc/RemoteVideoDecoder.h +++ b/dom/media/ipc/RemoteVideoDecoder.h @@ -32,7 +32,6 @@ public: void Flush() override; void Drain() override; void Shutdown() override; - void ConfigurationChanged(const TrackInfo& aConfig) override { MOZ_ASSERT(false); } const char* GetDescriptionName() const override { return "RemoteVideoDecoder"; } diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h index 7d94f94e10d4..0f3877204c3c 100644 --- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -266,14 +266,6 @@ public: // after creating. It doesn't need to call Init() before calling this function. virtual bool IsHardwareAccelerated(nsACString& aFailureReason) const { return false; } - // ConfigurationChanged will be called to inform the video or audio decoder - // that the format of the next input sample is about to change. - // If video decoder, aConfig will be a VideoInfo object. - // If audio decoder, aConfig will be a AudioInfo object. - // It is not safe to store a reference to this object and the decoder must - // make a copy. - virtual void ConfigurationChanged(const TrackInfo& aConfig) {} - // Return the name of the MediaDataDecoder, only used for decoding. // Only return a static const string, as the information may be accessed // in a non thread-safe fashion. diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index 86fa3a4d6ce5..d2c13eac75e1 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -209,27 +209,6 @@ WMFMediaDataDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const { return mMFTManager && mMFTManager->IsHardwareAccelerated(aFailureReason); } -void -WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig) -{ - MOZ_ASSERT(mCallback->OnReaderTaskQueue()); - - nsCOMPtr runnable = - NewRunnableMethod&&>( - this, - &WMFMediaDataDecoder::ProcessConfigurationChanged, - aConfig.Clone()); - mTaskQueue->Dispatch(runnable.forget()); -} - -void -WMFMediaDataDecoder::ProcessConfigurationChanged(UniquePtr&& aConfig) -{ - if (mMFTManager) { - mMFTManager->ConfigurationChanged(*aConfig); - } -} - void WMFMediaDataDecoder::SetSeekThreshold(const media::TimeUnit& aTime) { diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.h b/dom/media/platforms/wmf/WMFMediaDataDecoder.h index 664de31a9f75..a4dd49f56fe7 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h @@ -57,8 +57,6 @@ public: virtual TrackInfo::TrackType GetType() = 0; - virtual void ConfigurationChanged(const TrackInfo& aConfig) {} - virtual const char* GetDescriptionName() const = 0; virtual void SetSeekThreshold(const media::TimeUnit& aTime) { @@ -96,8 +94,6 @@ public: bool IsHardwareAccelerated(nsACString& aFailureReason) const override; - void ConfigurationChanged(const TrackInfo& aConfig) override; - const char* GetDescriptionName() const override { return mMFTManager ? mMFTManager->GetDescriptionName() : ""; @@ -125,10 +121,6 @@ private: void ProcessShutdown(); - // Called on the task queue. Tell the MFT that the next Input will have a - // different configuration (typically resolution change). - void ProcessConfigurationChanged(UniquePtr&& aConfig); - const RefPtr mTaskQueue; MediaDataDecoderCallback* mCallback; diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 202068655236..81592eb16295 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -963,13 +963,4 @@ WMFVideoMFTManager::IsHardwareAccelerated(nsACString& aFailureReason) const return mDecoder && mUseHwAccel; } -void -WMFVideoMFTManager::ConfigurationChanged(const TrackInfo& aConfig) -{ - MOZ_ASSERT(aConfig.GetAsVideoInfo()); - mVideoInfo = *aConfig.GetAsVideoInfo(); - mImageSize = mVideoInfo.mImage; - ValidateVideoInfo(); -} - } // namespace mozilla diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.h b/dom/media/platforms/wmf/WMFVideoMFTManager.h index 799e97e243f1..8e8455e58f73 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.h +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h @@ -40,8 +40,6 @@ public: return TrackInfo::kVideoTrack; } - void ConfigurationChanged(const TrackInfo& aConfig) override; - const char* GetDescriptionName() const override { nsCString failureReason; diff --git a/dom/media/platforms/wrappers/FuzzingWrapper.cpp b/dom/media/platforms/wrappers/FuzzingWrapper.cpp index bf5a5f68b7af..7df020f4639d 100644 --- a/dom/media/platforms/wrappers/FuzzingWrapper.cpp +++ b/dom/media/platforms/wrappers/FuzzingWrapper.cpp @@ -88,15 +88,6 @@ DecoderFuzzingWrapper::IsHardwareAccelerated(nsACString& aFailureReason) const return mDecoder->IsHardwareAccelerated(aFailureReason); } -void -DecoderFuzzingWrapper::ConfigurationChanged(const TrackInfo& aConfig) -{ - DFW_LOGV(""); - MOZ_ASSERT(mDecoder); - mDecoder->ConfigurationChanged(aConfig); -} - - DecoderCallbackFuzzingWrapper::DecoderCallbackFuzzingWrapper(MediaDataDecoderCallback* aCallback) : mCallback(aCallback) , mDontDelayInputExhausted(false) diff --git a/dom/media/platforms/wrappers/FuzzingWrapper.h b/dom/media/platforms/wrappers/FuzzingWrapper.h index d2898a50f51c..c2b737520761 100644 --- a/dom/media/platforms/wrappers/FuzzingWrapper.h +++ b/dom/media/platforms/wrappers/FuzzingWrapper.h @@ -108,7 +108,6 @@ public: void Drain() override; void Shutdown() override; bool IsHardwareAccelerated(nsACString& aFailureReason) const override; - void ConfigurationChanged(const TrackInfo& aConfig) override; const char* GetDescriptionName() const override { return mDecoder->GetDescriptionName(); diff --git a/dom/media/platforms/wrappers/H264Converter.cpp b/dom/media/platforms/wrappers/H264Converter.cpp index d449c60cc3ec..41db4f6be723 100644 --- a/dom/media/platforms/wrappers/H264Converter.cpp +++ b/dom/media/platforms/wrappers/H264Converter.cpp @@ -18,7 +18,6 @@ namespace mozilla H264Converter::H264Converter(PlatformDecoderModule* aPDM, const CreateDecoderParams& aParams) : mPDM(aPDM) - , mOriginalConfig(aParams.VideoConfig()) , mCurrentConfig(aParams.VideoConfig()) , mLayersBackend(aParams.mLayersBackend) , mImageContainer(aParams.mImageContainer) @@ -166,7 +165,7 @@ H264Converter::SetSeekThreshold(const media::TimeUnit& aTime) nsresult H264Converter::CreateDecoder(DecoderDoctorDiagnostics* aDiagnostics) { - if (mNeedAVCC && !mp4_demuxer::AnnexB::HasSPS(mCurrentConfig.mExtraData)) { + if (!mp4_demuxer::AnnexB::HasSPS(mCurrentConfig.mExtraData)) { // nothing found yet, will try again later return NS_ERROR_NOT_INITIALIZED; } @@ -183,20 +182,14 @@ H264Converter::CreateDecoder(DecoderDoctorDiagnostics* aDiagnostics) } return NS_ERROR_FAILURE; } - } else if (mNeedAVCC) { + } else { // SPS was invalid. mLastError = NS_ERROR_FAILURE; return NS_ERROR_FAILURE; } - if (!mNeedAVCC) { - // When using a decoder handling AnnexB, we get here only once from the - // constructor. We do want to get the dimensions extracted from the SPS. - mOriginalConfig = mCurrentConfig; - } - mDecoder = mPDM->CreateVideoDecoder({ - mNeedAVCC ? mCurrentConfig : mOriginalConfig, + mCurrentConfig, mTaskQueue, mCallback, aDiagnostics, @@ -281,11 +274,6 @@ H264Converter::CheckForSPSChange(MediaRawData* aSample) mCurrentConfig.mExtraData)) { return NS_OK; } - if (!mNeedAVCC) { - UpdateConfigFromExtraData(extra_data); - mDecoder->ConfigurationChanged(mCurrentConfig); - return NS_OK; - } // The SPS has changed, signal to flush the current decoder and create a // new one. mDecoder->Flush(); diff --git a/dom/media/platforms/wrappers/H264Converter.h b/dom/media/platforms/wrappers/H264Converter.h index bbeae9a539dc..bda2fb0480de 100644 --- a/dom/media/platforms/wrappers/H264Converter.h +++ b/dom/media/platforms/wrappers/H264Converter.h @@ -55,7 +55,6 @@ private: void OnDecoderInitFailed(MediaResult aError); RefPtr mPDM; - VideoInfo mOriginalConfig; VideoInfo mCurrentConfig; layers::LayersBackend mLayersBackend; RefPtr mImageContainer; From c169e0a2d237c27d2eefd3357cde19ada398fe1d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 26 Sep 2016 12:33:49 +1000 Subject: [PATCH 07/86] Bug 1297311: P2. Remove redundant virtual keyword. r=mattwoodrow MozReview-Commit-ID: D78jszKQrev --HG-- extra : rebase_source : 6459fcb09401b0c4fa45304664671de636c18d5b --- dom/media/ipc/RemoteVideoDecoder.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dom/media/ipc/RemoteVideoDecoder.h b/dom/media/ipc/RemoteVideoDecoder.h index 6ebacf099329..62cffc25faf3 100644 --- a/dom/media/ipc/RemoteVideoDecoder.h +++ b/dom/media/ipc/RemoteVideoDecoder.h @@ -61,18 +61,22 @@ public: : mWrapped(aWrapped) {} - virtual nsresult Startup() override; + nsresult Startup() override; - virtual bool SupportsMimeType(const nsACString& aMimeType, - DecoderDoctorDiagnostics* aDiagnostics) const override; + bool SupportsMimeType(const nsACString& aMimeType, + DecoderDoctorDiagnostics* aDiagnostics) const override; - virtual ConversionRequired DecoderNeedsConversion(const TrackInfo& aConfig) const override; + ConversionRequired DecoderNeedsConversion( + const TrackInfo& aConfig) const override; - virtual already_AddRefed - CreateVideoDecoder(const CreateDecoderParams& aParams) override; + already_AddRefed CreateVideoDecoder( + const CreateDecoderParams& aParams) override; - virtual already_AddRefed - CreateAudioDecoder(const CreateDecoderParams& aParams) override { return nullptr; } + already_AddRefed CreateAudioDecoder( + const CreateDecoderParams& aParams) override + { + return nullptr; + } private: RefPtr mWrapped; From 3870ec0b0182ec5be4f45a935f2ebdeac84fa31f Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 26 Sep 2016 10:48:07 +0800 Subject: [PATCH 08/86] Bug 1305336. Part 1 - extract some code to a function. r=pehrsons MozReview-Commit-ID: Lr4NeNPXIhc --HG-- extra : rebase_source : 0618d02624607539ad245f17f7768ec05d05929e --- dom/media/test/test_streams_autoplay.html | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/dom/media/test/test_streams_autoplay.html b/dom/media/test/test_streams_autoplay.html index 5a2825d77c75..45aea6f7adc5 100644 --- a/dom/media/test/test_streams_autoplay.html +++ b/dom/media/test/test_streams_autoplay.html @@ -19,21 +19,25 @@ if (media == null) { todo(false, "No media supported."); SimpleTest.finish(); } else { - v1.src = media.name; - v1.preload = 'metadata'; - v1.onloadedmetadata = function() { - v2.srcObject = v1.mozCaptureStream(); - v1.play(); - }; - var onPlayingEventFired = false; + function startTest() { + v1.src = media.name; + v1.preload = 'metadata'; + v1.onloadedmetadata = function() { + v2.srcObject = v1.mozCaptureStream(); + v1.play(); + }; + var onPlayingEventFired = false; - v2.onplaying = function() { - if(!onPlayingEventFired) { - onPlayingEventFired = true; - ok(true, "playback started"); - SimpleTest.finish(); + v2.onplaying = function() { + if(!onPlayingEventFired) { + onPlayingEventFired = true; + ok(true, "playback started"); + SimpleTest.finish(); + } } } + + startTest(); } From 3c425238ca037a1b4b242a00feed02dbf47a2d02 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 26 Sep 2016 10:54:27 +0800 Subject: [PATCH 09/86] Bug 1305336. Part 2 - use 'once' handler to remove onPlayingEventFired. r=pehrsons MozReview-Commit-ID: 9wosr7kOnJx --HG-- extra : rebase_source : b7211282084d54a242f190daeae3a6754577f0d2 --- dom/media/test/test_streams_autoplay.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dom/media/test/test_streams_autoplay.html b/dom/media/test/test_streams_autoplay.html index 45aea6f7adc5..b089b7819077 100644 --- a/dom/media/test/test_streams_autoplay.html +++ b/dom/media/test/test_streams_autoplay.html @@ -26,19 +26,16 @@ if (media == null) { v2.srcObject = v1.mozCaptureStream(); v1.play(); }; - var onPlayingEventFired = false; - v2.onplaying = function() { - if(!onPlayingEventFired) { - onPlayingEventFired = true; - ok(true, "playback started"); - SimpleTest.finish(); - } - } + v2.addEventListener('playing', function() { + ok(true, "playback started"); + SimpleTest.finish(); + }, {once: true}); } startTest(); } + From 291103574887f206796ff58f2e29468366271cd8 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 26 Sep 2016 10:58:58 +0800 Subject: [PATCH 10/86] Bug 1305336. Part 3 - set prefs before running tests. r=pehrsons MozReview-Commit-ID: 4nJ4xsR0kE2 --HG-- extra : rebase_source : 28e87ba11a471404434000c963515128bc259d5a --- dom/media/test/test_streams_autoplay.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/media/test/test_streams_autoplay.html b/dom/media/test/test_streams_autoplay.html index b089b7819077..7846a815f8b0 100644 --- a/dom/media/test/test_streams_autoplay.html +++ b/dom/media/test/test_streams_autoplay.html @@ -33,7 +33,7 @@ if (media == null) { }, {once: true}); } - startTest(); + setMediaTestsPrefs(startTest); } From 7d431b82f14699d2ac61ab97c4cdddf2c790502b Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 26 Sep 2016 11:18:09 +0800 Subject: [PATCH 11/86] Bug 1305336. Part 4 - create elements dynamically because pref changes only take effect for those elements that are created later. r=pehrsons MozReview-Commit-ID: IvzSrnVQV5F --HG-- extra : rebase_source : 2830517544272f47138ebfaa7595c5f3457c0dfe --- dom/media/test/test_streams_autoplay.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dom/media/test/test_streams_autoplay.html b/dom/media/test/test_streams_autoplay.html index 7846a815f8b0..a24fb64ac8c7 100644 --- a/dom/media/test/test_streams_autoplay.html +++ b/dom/media/test/test_streams_autoplay.html @@ -7,8 +7,6 @@ - -
 
diff --git a/toolkit/modules/FinderHighlighter.jsm b/toolkit/modules/FinderHighlighter.jsm
index 01148f11ba58..768001f4927d 100644
--- a/toolkit/modules/FinderHighlighter.jsm
+++ b/toolkit/modules/FinderHighlighter.jsm
@@ -233,12 +233,12 @@ FinderHighlighter.prototype = {
     this._found = true;
   },
 
-  onIteratorReset() {
+  onIteratorReset() {},
+
+  onIteratorRestart() {
     this.clear(this.finder._getWindow());
   },
 
-  onIteratorRestart() {},
-
   onIteratorStart(params) {
     let window = this.finder._getWindow();
     let dict = this.getForWindow(window);
@@ -511,8 +511,11 @@ FinderHighlighter.prototype = {
   onHighlightAllChange(highlightAll) {
     this._highlightAll = highlightAll;
     if (!highlightAll) {
-      this.clear();
-      this._scheduleRepaintOfMask(this.finder._getWindow());
+      let window = this.finder._getWindow();
+      if (!this._modal)
+        this.hide(window);
+      this.clear(window);
+      this._scheduleRepaintOfMask(window);
     }
   },
 
diff --git a/toolkit/modules/tests/browser/browser_FinderHighlighter.js b/toolkit/modules/tests/browser/browser_FinderHighlighter.js
index 1bc12462ea84..65b4219cdd3f 100644
--- a/toolkit/modules/tests/browser/browser_FinderHighlighter.js
+++ b/toolkit/modules/tests/browser/browser_FinderHighlighter.js
@@ -358,7 +358,7 @@ add_task(function* testHighlightAllToggle() {
 
     // For posterity, let's switch back.
     expectedResult = {
-      rectCount: 2,
+      rectCount: 1,
       insertCalls: [1, 3],
       removeCalls: [0, 1]
     };

From c19bea65a75809fea6b2ed7bc407154e858c2ef3 Mon Sep 17 00:00:00 2001
From: Henrik Skupin 
Date: Mon, 26 Sep 2016 15:35:59 +0200
Subject: [PATCH 21/86] Bug 1305370 - Bump firefox-puppeteer 52.0.0. r=maja_zf

MozReview-Commit-ID: IdVUoenRYMh

--HG--
extra : rebase_source : f0ef6a7125144d012f2c8631b0ea0239c677f702
---
 dom/media/test/external/requirements.txt                | 2 +-
 testing/firefox-ui/harness/requirements.txt             | 2 +-
 testing/puppeteer/firefox/firefox_puppeteer/__init__.py | 4 +---
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/dom/media/test/external/requirements.txt b/dom/media/test/external/requirements.txt
index 8857e8a9c7a2..dc36b05f788a 100644
--- a/dom/media/test/external/requirements.txt
+++ b/dom/media/test/external/requirements.txt
@@ -17,4 +17,4 @@ mozversion==1.4
 wptserve==1.3.0
 marionette-client==3.1.0
 marionette-driver==2.0.0
-firefox-puppeteer >= 51.0.0, <52.0.0
+firefox-puppeteer >= 52.0.0, <53.0.0
diff --git a/testing/firefox-ui/harness/requirements.txt b/testing/firefox-ui/harness/requirements.txt
index b4a7e47d6de6..3eebff291c77 100644
--- a/testing/firefox-ui/harness/requirements.txt
+++ b/testing/firefox-ui/harness/requirements.txt
@@ -1,4 +1,4 @@
-firefox-puppeteer >= 51.0.0, <52.0.0
+firefox-puppeteer >= 52.0.0, <53.0.0
 marionette-client >= 2.3.0
 mozfile >= 1.2
 mozinfo >= 0.8
diff --git a/testing/puppeteer/firefox/firefox_puppeteer/__init__.py b/testing/puppeteer/firefox/firefox_puppeteer/__init__.py
index 7b783c170a5c..71110b48d7ac 100644
--- a/testing/puppeteer/firefox/firefox_puppeteer/__init__.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/__init__.py
@@ -2,14 +2,12 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-import os
-
 from marionette_driver.marionette import HTMLElement
 
 from decorators import use_class_as_property
 
 
-__version__ = '51.0.0'
+__version__ = '52.0.0'
 
 
 class Puppeteer(object):

From 34d1a0e09dc87ed2b10574e9bc364fa9310e5d59 Mon Sep 17 00:00:00 2001
From: Robert Helmer 
Date: Mon, 16 May 2016 15:04:09 -0700
Subject: [PATCH 22/86] bug 512479 - make pending crash reports more
 identifiable, r=mconley

MozReview-Commit-ID: H0c1CC4s3Vw

--HG--
extra : rebase_source : 78fadde80b9c6ef037e4aece224ee9ba28df11eb
---
 toolkit/crashreporter/content/crashes.js      |  7 +++-
 toolkit/crashreporter/content/crashes.xhtml   | 37 +++++++++++++------
 .../locales/en-US/crashreporter/crashes.dtd   |  7 +++-
 3 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/toolkit/crashreporter/content/crashes.js b/toolkit/crashreporter/content/crashes.js
index 9020166e0a40..8a489fcf8e6a 100644
--- a/toolkit/crashreporter/content/crashes.js
+++ b/toolkit/crashreporter/content/crashes.js
@@ -80,7 +80,6 @@ function populateReportList() {
 
   var formatter = Cc["@mozilla.org/intl/scriptabledateformat;1"].
                   createInstance(Ci.nsIScriptableDateFormat);
-  var body = document.getElementById("tbody");
   var ios = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService);
   var reportURI = ios.newURI(reportURL, null, null);
@@ -120,7 +119,11 @@ function populateReportList() {
                                        date.getSeconds());
     cell.appendChild(document.createTextNode(timestr));
     row.appendChild(cell);
-    body.appendChild(row);
+    if (reports[i].pending) {
+      document.getElementById("unsubmitted").appendChild(row);
+    } else {
+      document.getElementById("submitted").appendChild(row);
+    }
   }
 }
 
diff --git a/toolkit/crashreporter/content/crashes.xhtml b/toolkit/crashreporter/content/crashes.xhtml
index 13d8d7e5ecee..f78f45067621 100644
--- a/toolkit/crashreporter/content/crashes.xhtml
+++ b/toolkit/crashreporter/content/crashes.xhtml
@@ -89,18 +89,33 @@ td:last-child {
 
 
-

&crashes.title;

- - - - - - - - - -
&id.heading;&date.heading;
+
+

&crashesUnsubmitted.label;

+ + + + + + + + + +
&id.heading;&dateCrashed.heading;
+
+
+

&crashesSubmitted.label;

+ + + + + + + + + +
&id.heading;&dateSubmitted.heading;
+
diff --git a/toolkit/locales/en-US/crashreporter/crashes.dtd b/toolkit/locales/en-US/crashreporter/crashes.dtd index 62da4d55fbb2..c4ab684e31e2 100644 --- a/toolkit/locales/en-US/crashreporter/crashes.dtd +++ b/toolkit/locales/en-US/crashreporter/crashes.dtd @@ -2,9 +2,12 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - + + + - + + breakpad.reportURL must be set."> From 68d9d89340d67315fed2a863a889af45699fbbf2 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 22 Sep 2016 18:19:28 +0200 Subject: [PATCH 23/86] Bug 1300380: Fix undefined behavior under WasmTruncate functions; r=h4writer MozReview-Commit-ID: I3lbWLKHO4g --HG-- extra : rebase_source : 870752aae0022baaf9a9b31ee5e196b022fa4518 extra : histedit_source : 9353b1f4828cfd73a1102c190e090d6726aa3506 --- js/src/asmjs/WasmTypes.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/js/src/asmjs/WasmTypes.cpp b/js/src/asmjs/WasmTypes.cpp index cbbe18987534..4133d034c206 100644 --- a/js/src/asmjs/WasmTypes.cpp +++ b/js/src/asmjs/WasmTypes.cpp @@ -36,6 +36,8 @@ using namespace js; using namespace js::jit; using namespace js::wasm; +using mozilla::IsNaN; + void Val::writePayload(uint8_t* dst) const { @@ -206,11 +208,9 @@ UModI64(uint32_t x_hi, uint32_t x_lo, uint32_t y_hi, uint32_t y_lo) static int64_t TruncateDoubleToInt64(double input) { - // Note: INT64_MAX is not representable in double. It is actually INT64_MAX + 1. - // Therefore also sending the failure value. - if (input >= double(INT64_MAX)) - return 0x8000000000000000; - if (input < double(INT64_MIN)) + // Note: INT64_MAX is not representable in double. It is actually + // INT64_MAX + 1. Therefore also sending the failure value. + if (input >= double(INT64_MAX) || input < double(INT64_MIN) || IsNaN(input)) return 0x8000000000000000; return int64_t(input); } @@ -220,9 +220,7 @@ TruncateDoubleToUint64(double input) { // Note: UINT64_MAX is not representable in double. It is actually UINT64_MAX + 1. // Therefore also sending the failure value. - if (input >= double(UINT64_MAX)) - return 0x8000000000000000; - if (input <= -1.0) + if (input >= double(UINT64_MAX) || input <= -1.0 || IsNaN(input)) return 0x8000000000000000; return uint64_t(input); } From 8bd74b039eb6dd916ef7a1317324a5a161677c77 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 22 Sep 2016 18:21:36 +0200 Subject: [PATCH 24/86] Bug 1300380: Build the ARM simulator under macosx with sse2 too; r=jandem And workaround a small oversight of clang in Simulator::canonicalizeNaN(float), which does a float->double->float conversion messing up with the signal/quiet bit of NaN values. MozReview-Commit-ID: 9izzAfPpP3b --HG-- extra : rebase_source : 646603c182eee90ffa925f08cdfc4d879ab80e71 extra : amend_source : 60ee8d3e5c7053f14193dc60de87530e512e04cd extra : histedit_source : 3977dce49fdc590c6552a086bac598e8ee1e4c37 --- js/src/jit/arm/Simulator-arm.cpp | 10 ++++------ js/src/moz.build | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/js/src/jit/arm/Simulator-arm.cpp b/js/src/jit/arm/Simulator-arm.cpp index 364622790b69..9ea9bfe059ab 100644 --- a/js/src/jit/arm/Simulator-arm.cpp +++ b/js/src/jit/arm/Simulator-arm.cpp @@ -2687,17 +2687,15 @@ Simulator::softwareInterrupt(SimInstruction* instr) void Simulator::canonicalizeNaN(double* value) { - *value = !JitOptions.wasmTestMode && FPSCR_default_NaN_mode_ - ? JS::CanonicalizeNaN(*value) - : *value; + if (!JitOptions.wasmTestMode && FPSCR_default_NaN_mode_) + *value = JS::CanonicalizeNaN(*value); } void Simulator::canonicalizeNaN(float* value) { - *value = !JitOptions.wasmTestMode && FPSCR_default_NaN_mode_ - ? JS::CanonicalizeNaN(*value) - : *value; + if (!JitOptions.wasmTestMode && FPSCR_default_NaN_mode_) + *value = JS::CanonicalizeNaN(*value); } // Stop helper functions. diff --git a/js/src/moz.build b/js/src/moz.build index 6acfcbd47f72..9b36547dc261 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -484,7 +484,7 @@ elif CONFIG['JS_CODEGEN_ARM']: 'jit/arm/Simulator-arm.cpp' ] # Configuration used only for testing. - if CONFIG['OS_ARCH'] == 'Linux': + if CONFIG['OS_ARCH'] == 'Linux' or CONFIG['OS_ARCH'] == 'Darwin': CXXFLAGS += [ '-msse2', '-mfpmath=sse' ] elif CONFIG['OS_ARCH'] == 'Darwin': SOURCES += [ From 31ba17fbcbd678bbab6707fd7499317f9ff66288 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 26 Sep 2016 10:33:06 +0200 Subject: [PATCH 25/86] Bug 1305097: Enhance error reporting from the ToAST transformation; r=luke --- js/src/asmjs/WasmBinary.cpp | 1 + js/src/asmjs/WasmBinary.h | 2 +- js/src/asmjs/WasmBinaryToAST.cpp | 28 +++++++++++-------- js/src/asmjs/WasmBinaryToAST.h | 3 +- js/src/asmjs/WasmBinaryToExperimentalText.cpp | 3 +- .../tests/wasm/to-text-experimental.js | 2 ++ js/src/jit-test/tests/wasm/to-text.js | 2 ++ 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/js/src/asmjs/WasmBinary.cpp b/js/src/asmjs/WasmBinary.cpp index 56e3bfb15dda..a3ece8f23088 100644 --- a/js/src/asmjs/WasmBinary.cpp +++ b/js/src/asmjs/WasmBinary.cpp @@ -40,6 +40,7 @@ Decoder::fail(const char* msg, ...) { bool Decoder::fail(UniqueChars msg) { + MOZ_ASSERT(error_); UniqueChars strWithOffset(JS_smprintf("at offset %zu: %s", currentOffset(), msg.get())); if (!strWithOffset) return false; diff --git a/js/src/asmjs/WasmBinary.h b/js/src/asmjs/WasmBinary.h index 0875fe72084b..b537dccb38f7 100644 --- a/js/src/asmjs/WasmBinary.h +++ b/js/src/asmjs/WasmBinary.h @@ -770,7 +770,7 @@ class Decoder static const size_t ExprLimit = 2 * UINT8_MAX - 1; public: - Decoder(const uint8_t* begin, const uint8_t* end, UniqueChars* error = nullptr) + Decoder(const uint8_t* begin, const uint8_t* end, UniqueChars* error) : beg_(begin), end_(end), cur_(begin), diff --git a/js/src/asmjs/WasmBinaryToAST.cpp b/js/src/asmjs/WasmBinaryToAST.cpp index d1cf1a9f4c86..61f89aa9b538 100644 --- a/js/src/asmjs/WasmBinaryToAST.cpp +++ b/js/src/asmjs/WasmBinaryToAST.cpp @@ -46,16 +46,20 @@ struct AstDecodeStackItem ExprType type; explicit AstDecodeStackItem() - : expr(nullptr), - terminationKind(AstDecodeTerminationKind::Unknown), - type(ExprType::Limit) {} - explicit AstDecodeStackItem(AstDecodeTerminationKind terminationKind, - ExprType type) - : expr(nullptr), terminationKind(terminationKind), type(type) {} + : expr(nullptr), + terminationKind(AstDecodeTerminationKind::Unknown), + type(ExprType::Limit) + {} + explicit AstDecodeStackItem(AstDecodeTerminationKind terminationKind, ExprType type) + : expr(nullptr), + terminationKind(terminationKind), + type(type) + {} explicit AstDecodeStackItem(AstExpr* expr) - : expr(expr), - terminationKind(AstDecodeTerminationKind::Unknown), - type(ExprType::Limit) {} + : expr(expr), + terminationKind(AstDecodeTerminationKind::Unknown), + type(ExprType::Limit) + {} }; // We don't define a Value type because ExprIter doesn't push void values, which @@ -97,7 +101,8 @@ class AstDecodeContext ExprType retType_; public: - AstDecodeContext(JSContext* cx, LifoAlloc& lifo, Decoder& d, AstModule& module, bool generateNames) + AstDecodeContext(JSContext* cx, LifoAlloc& lifo, Decoder& d, AstModule& module, + bool generateNames) : cx(cx), lifo(lifo), d(d), @@ -1469,7 +1474,6 @@ AstDecodeFunctionSection(AstDecodeContext& c) if (numDecls > MaxFuncs) return c.d.fail("too many functions"); - if (!c.funcSigs().resize(numDecls)) return false; @@ -2147,6 +2151,8 @@ wasm::BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length, return false; } + MOZ_ASSERT(!error, "unreported error in decoding"); + *module = result; return true; } diff --git a/js/src/asmjs/WasmBinaryToAST.h b/js/src/asmjs/WasmBinaryToAST.h index 8994f1c30b7d..79607d97ba33 100644 --- a/js/src/asmjs/WasmBinaryToAST.h +++ b/js/src/asmjs/WasmBinaryToAST.h @@ -28,7 +28,8 @@ namespace js { namespace wasm { bool -BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length, LifoAlloc& lifo, AstModule** module); +BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length, LifoAlloc& lifo, + AstModule** module); } // end wasm namespace } // end js namespace diff --git a/js/src/asmjs/WasmBinaryToExperimentalText.cpp b/js/src/asmjs/WasmBinaryToExperimentalText.cpp index a78aa51dbcf2..07083ee6153e 100644 --- a/js/src/asmjs/WasmBinaryToExperimentalText.cpp +++ b/js/src/asmjs/WasmBinaryToExperimentalText.cpp @@ -129,7 +129,8 @@ struct WasmPrintContext uint32_t currentFuncIndex; PrintOperatorPrecedence currentPrecedence; - WasmPrintContext(JSContext* cx, AstModule* module, WasmPrintBuffer& buffer, const ExperimentalTextFormatting& f, GeneratedSourceMap* wasmSourceMap_) + WasmPrintContext(JSContext* cx, AstModule* module, WasmPrintBuffer& buffer, + const ExperimentalTextFormatting& f, GeneratedSourceMap* wasmSourceMap_) : cx(cx), module(module), buffer(buffer), diff --git a/js/src/jit-test/tests/wasm/to-text-experimental.js b/js/src/jit-test/tests/wasm/to-text-experimental.js index 06967bfc819c..6b90435659d8 100644 --- a/js/src/jit-test/tests/wasm/to-text-experimental.js +++ b/js/src/jit-test/tests/wasm/to-text-experimental.js @@ -1,6 +1,8 @@ // |jit-test| test-also-wasm-baseline load(libdir + "wasm.js"); +assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`(module (func (result i32) (f32.const 13.37)))`), 'experimental'), WebAssembly.CompileError, /type mismatch/); + function runTest(code, expected) { var binary = wasmTextToBinary(code); var s = wasmBinaryToText(binary, "experimental"); diff --git a/js/src/jit-test/tests/wasm/to-text.js b/js/src/jit-test/tests/wasm/to-text.js index 0caa61ca44e1..706ed1900383 100644 --- a/js/src/jit-test/tests/wasm/to-text.js +++ b/js/src/jit-test/tests/wasm/to-text.js @@ -9,6 +9,8 @@ try { } assertEq(caught, true); +assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`(module (func (result i32) (f32.const 13.37)))`)), WebAssembly.CompileError, /type mismatch/); + function runTest(code) { var expected = wasmTextToBinary(code); var s = wasmBinaryToText(expected); From 2c4a3e97687e421d651a8ec5f3a4bf250fb275b6 Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Mon, 26 Sep 2016 09:54:13 +0100 Subject: [PATCH 26/86] Bug 1304704 - Add fudge factor to asserts in ClampColorStops() - r=mstange --- layout/base/nsCSSRendering.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index a05631e0e531..586e07f74dbb 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2583,8 +2583,8 @@ ClampColorStops(nsTArray& aStops) } } - MOZ_ASSERT(aStops[0].mPosition >= 0); - MOZ_ASSERT(aStops.LastElement().mPosition <= 1); + MOZ_ASSERT(aStops[0].mPosition >= -1e6); + MOZ_ASSERT(aStops.LastElement().mPosition - 1 <= 1e6); // The end points won't exist yet if they don't fall in the original range of // |aStops|. Create them if needed. From e8488364fed15f02c9a62f005196da182d395f12 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 26 Sep 2016 22:03:25 +1000 Subject: [PATCH 27/86] Bug 1304302 part 1 - Add const version of AsGecko/AsServo to StyleSheet. r=heycam MozReview-Commit-ID: LGQQjmkTWsO --HG-- extra : source : 337342b3376bdaff444ed1c3887d8eee80cfa9ee --- layout/style/StyleSheet.h | 2 ++ layout/style/StyleSheetInlines.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 53fe13fefd24..d7955998ee30 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -72,6 +72,8 @@ public: inline CSSStyleSheet& AsGecko(); inline ServoStyleSheet& AsServo(); inline StyleSheetHandle AsHandle(); + inline const CSSStyleSheet& AsGecko() const; + inline const ServoStyleSheet& AsServo() const; protected: nsIDocument* mDocument; // weak ref; parents maintain this for their children diff --git a/layout/style/StyleSheetInlines.h b/layout/style/StyleSheetInlines.h index 417ea6bd5888..08f95999841e 100644 --- a/layout/style/StyleSheetInlines.h +++ b/layout/style/StyleSheetInlines.h @@ -35,6 +35,20 @@ StyleSheet::AsHandle() return &AsGecko(); } +const CSSStyleSheet& +StyleSheet::AsGecko() const +{ + MOZ_ASSERT(IsGecko()); + return *static_cast(this); +} + +const ServoStyleSheet& +StyleSheet::AsServo() const +{ + MOZ_ASSERT(IsServo()); + return *static_cast(this); +} + } #endif // mozilla_StyleSheetInlines_h From e981c7e9be0258c803a01ac10ec6a878d7de34bc Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 26 Sep 2016 22:03:25 +1000 Subject: [PATCH 28/86] Bug 1304302 part 2 - Some small fixes. r=heycam MozReview-Commit-ID: 7rnl4wkMorC --HG-- extra : source : d3319119916b7ca8e36627cc086150f799481d97 --- layout/style/Loader.cpp | 2 +- layout/style/ServoStyleSheet.cpp | 2 +- layout/style/StyleSheetHandleInlines.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 1240a29daf16..9e956768f15f 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1121,7 +1121,7 @@ Loader::CreateSheet(nsIURI* aURI, // Then our per-document complete sheets. URIPrincipalReferrerPolicyAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode, aReferrerPolicy); - StyleSheetHandle completeSheet; + StyleSheetHandle completeSheet = nullptr; mSheets->mCompleteSheets.Get(&key, &completeSheet); sheet = completeSheet; LOG((" From completed: %p", sheet->AsVoidPtr())); diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index 852d406e7718..ddbf93b80dcd 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -32,7 +32,7 @@ ServoStyleSheet::IsApplicable() const bool ServoStyleSheet::HasRules() const { - return Servo_StyleSheet_HasRules(RawSheet()); + return mSheet && Servo_StyleSheet_HasRules(mSheet); } nsIDocument* diff --git a/layout/style/StyleSheetHandleInlines.h b/layout/style/StyleSheetHandleInlines.h index b6339a92356f..6515c0e3f384 100644 --- a/layout/style/StyleSheetHandleInlines.h +++ b/layout/style/StyleSheetHandleInlines.h @@ -171,6 +171,7 @@ StyleSheetHandle::Ptr::List(FILE* aOut, int32_t aIndex) const #endif #undef FORWARD +#undef FORWARD_CONCRETE inline void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, From 17e476532e17fc84dd7f2e8dc7256be39b5b7eba Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 26 Sep 2016 22:03:25 +1000 Subject: [PATCH 29/86] Bug 1304302 part 3 - Use ServoStyleSheet* instead of Handle in ServoStyleSheet. r=heycam MozReview-Commit-ID: WV8eRxSOnp --HG-- extra : source : 1d1c23f2cf6dbc2a3fbfa8a74b401c8464e113cf --- layout/style/ServoStyleSheet.cpp | 4 ++-- layout/style/ServoStyleSheet.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index ddbf93b80dcd..07d39e19ae15 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -50,7 +50,7 @@ ServoStyleSheet::SetOwningDocument(nsIDocument* aDocument) mDocument = aDocument; } -StyleSheetHandle +ServoStyleSheet* ServoStyleSheet::GetParentSheet() const { // XXXheycam: When we implement support for child sheets, we'll have @@ -60,7 +60,7 @@ ServoStyleSheet::GetParentSheet() const } void -ServoStyleSheet::AppendStyleSheet(StyleSheetHandle aSheet) +ServoStyleSheet::AppendStyleSheet(ServoStyleSheet* aSheet) { // XXXheycam: When we implement support for child sheets, we'll have // to fix SetOwningDocument to propagate the owning document down diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index 04e7ce47ed6c..a32e1f111834 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -11,7 +11,6 @@ #include "mozilla/RefPtr.h" #include "mozilla/ServoBindingHelpers.h" #include "mozilla/StyleSheet.h" -#include "mozilla/StyleSheetHandle.h" #include "mozilla/StyleSheetInfo.h" #include "nsStringFwd.h" @@ -37,8 +36,8 @@ public: nsIDocument* GetOwningDocument() const; void SetOwningDocument(nsIDocument* aDocument); - StyleSheetHandle GetParentSheet() const; - void AppendStyleSheet(StyleSheetHandle aSheet); + ServoStyleSheet* GetParentSheet() const; + void AppendStyleSheet(ServoStyleSheet* aSheet); MOZ_MUST_USE nsresult ParseSheet(const nsAString& aInput, nsIURI* aSheetURI, From 4d65721d5983f7d2309e834dfcb478e6cd4ea905 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 26 Sep 2016 22:03:25 +1000 Subject: [PATCH 30/86] Bug 1304302 part 4 - Add all methods StyleSheetHandle needs to StyleSheet. r=heycam The methods are written in the same order as in StyleSheetHandle::Ptr. MozReview-Commit-ID: 6b4311ailNj --HG-- extra : source : 9cea4a56fc487dd21a8739d4d9be8f01d5fdc93c --- layout/style/CSSStyleSheet.cpp | 39 -------- layout/style/CSSStyleSheet.h | 46 +--------- layout/style/ServoStyleSheet.cpp | 12 --- layout/style/ServoStyleSheet.h | 2 - layout/style/StyleSheet.h | 59 +++++++++++- layout/style/StyleSheetInfo.cpp | 25 ------ layout/style/StyleSheetInfo.h | 18 +--- layout/style/StyleSheetInlines.h | 148 +++++++++++++++++++++++++++++++ 8 files changed, 208 insertions(+), 141 deletions(-) diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index 8acbc4f3c6b9..391d13105397 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -1323,33 +1323,6 @@ CSSStyleSheet::DropStyleSet(nsStyleSet* aStyleSet) NS_ASSERTION(found, "didn't find style set"); } -void -CSSStyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, - nsIURI* aBaseURI) -{ - NS_ASSERTION(mInner->mOrderedRules.Count() == 0 && !mInner->mComplete, - "Can't call SetURIs on sheets that are complete or have rules"); - mInner->SetURIs(aSheetURI, aOriginalSheetURI, aBaseURI); -} - -void -CSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal) -{ - mInner->SetPrincipal(aPrincipal); -} - -nsIURI* -CSSStyleSheet::GetSheetURI() const -{ - return mInner->mSheetURI; -} - -nsIURI* -CSSStyleSheet::GetBaseURI() const -{ - return mInner->mBaseURI; -} - void CSSStyleSheet::GetType(nsString& aType) const { @@ -1379,12 +1352,6 @@ CSSStyleSheet::HasRules() const return StyleRuleCount() != 0; } -bool -CSSStyleSheet::IsApplicable() const -{ - return !mDisabled && mInner->mComplete; -} - void CSSStyleSheet::SetEnabled(bool aEnabled) { @@ -1407,12 +1374,6 @@ CSSStyleSheet::GetParentSheet() const return mParent; } -nsIDocument* -CSSStyleSheet::GetOwningDocument() const -{ - return mDocument; -} - void CSSStyleSheet::SetOwningDocument(nsIDocument* aDocument) { // not ref counted diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index 14a308c0e44e..24e68f4ed35a 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -125,20 +125,10 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID) - nsIURI* GetSheetURI() const; - nsIURI* GetBaseURI() const; void GetTitle(nsString& aTitle) const; void GetType(nsString& aType) const; bool HasRules() const; - /** - * Whether the sheet is applicable. A sheet that is not applicable - * should never be inserted into a style set. A sheet may not be - * applicable for a variety of reasons including being disabled and - * being incomplete. - */ - bool IsApplicable() const; - /** * Set the stylesheet to be enabled. This may or may not make it * applicable. Note that this WILL inform the sheet's document of @@ -152,7 +142,6 @@ public: // style sheet owner info CSSStyleSheet* GetParentSheet() const; // may be null - nsIDocument* GetOwningDocument() const; // may be null void SetOwningDocument(nsIDocument* aDocument); // Find the ID of the owner inner window. @@ -172,23 +161,6 @@ public: nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex); nsresult InsertRuleIntoGroup(const nsAString& aRule, css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval); - /** - * SetURIs must be called on all sheets before parsing into them. - * SetURIs may only be called while the sheet is 1) incomplete and 2) - * has no rules in it - */ - void SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, nsIURI* aBaseURI); - - /** - * SetPrincipal should be called on all sheets before parsing into them. - * This can only be called once with a non-null principal. Calling this with - * a null pointer is allowed and is treated as a no-op. - */ - void SetPrincipal(nsIPrincipal* aPrincipal); - - // Principal() never returns a null pointer. - nsIPrincipal* Principal() const { return mInner->mPrincipal; } - void SetTitle(const nsAString& aTitle) { mTitle = aTitle; } void SetMedia(nsMediaList* aMedia); @@ -222,13 +194,6 @@ public: nsresult InsertRuleInternal(const nsAString& aRule, uint32_t aIndex, uint32_t* aReturn); - /* Get the URI this sheet was originally loaded from, if any. Can - return null */ - nsIURI* GetOriginalURI() const { return mInner->mOriginalSheetURI; } - - // Whether the sheet is for an inline