From 81b341a9b37acae2b60e0334a9b0846bc5be8445 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 29 Sep 2018 23:20:36 +0200 Subject: Clean up a number of unused variables. Tag #21. --- layout/base/nsLayoutUtils.cpp | 1 - layout/base/nsPresShell.cpp | 5 ----- 2 files changed, 6 deletions(-) (limited to 'layout') diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d0f790a0b..c1f4ad372 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3423,7 +3423,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram return NS_OK; } - TimeStamp startBuildDisplayList = TimeStamp::Now(); nsDisplayListBuilder builder(aFrame, aBuilderMode, !(aFlags & PaintFrameFlags::PAINT_HIDE_CARET)); if (aFlags & PaintFrameFlags::PAINT_IN_TRANSFORM) { diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 88539dc4a..340042b46 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1111,10 +1111,6 @@ PresShell::Destroy() LogTextPerfStats(tp, this, tp->cumulative, 0.0, eLog_totals, nullptr); } } - if (mPresContext) { - const bool mayFlushUserFontSet = false; - gfxUserFontSet* fs = mPresContext->GetUserFontSet(mayFlushUserFontSet); - } #ifdef MOZ_REFLOW_PERF DumpReflows(); @@ -9409,7 +9405,6 @@ PresShell::ProcessReflowCommands(bool aInterruptible) return true; } - mozilla::TimeStamp timerStart = mozilla::TimeStamp::Now(); bool interrupted = false; if (!mDirtyRoots.IsEmpty()) { -- cgit v1.2.3 From 6e48f5e1406913ea87756a971048009e83b46f26 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 7 Oct 2018 19:46:00 +0200 Subject: Make caret width normal/thick behind CJK char configurable. Fixes #820 (regression). --- layout/base/nsCaret.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'layout') diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 8ad435950..eca22f3ba 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -117,6 +117,12 @@ IsBidiUI() return Preferences::GetBool("bidi.browser.ui"); } +static bool +CjkThickCaret() +{ + return Preferences::GetBool("layout.cjkthickcaret"); +} + nsCaret::nsCaret() : mOverrideOffset(0) , mBlinkCount(-1) @@ -190,7 +196,7 @@ nsCaret::ComputeMetrics(nsIFrame* aFrame, int32_t aOffset, nscoord aCaretHeight) nsPresContext::CSSPixelsToAppUnits( LookAndFeel::GetInt(LookAndFeel::eIntID_CaretWidth, 1)); - if (DrawCJKCaret(aFrame, aOffset)) { + if (DrawCJKCaret(aFrame, aOffset) && CjkThickCaret()) { caretWidth += nsPresContext::CSSPixelsToAppUnits(1); } nscoord bidiIndicatorSize = nsPresContext::CSSPixelsToAppUnits(kMinBidiIndicatorPixels); -- cgit v1.2.3 From 26ec82f16d9381b920bed7d60cf76643883ab4eb Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 7 Oct 2018 20:35:37 +0200 Subject: Use device pixels instead of CSS pixels for table borders. This resolves #821 (regression). --- layout/tables/nsTableFrame.cpp | 79 ++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'layout') diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 5030804ed..4c11d2704 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -2681,14 +2681,14 @@ nsTableFrame::GetOuterBCBorder(const WritingMode aWM) const const_cast(this)->CalcBCBorders(); } - int32_t p2t = nsPresContext::AppUnitsPerCSSPixel(); + int32_t d2a = PresContext()->AppUnitsPerDevPixel(); BCPropertyData* propData = GetBCProperty(); if (propData) { return LogicalMargin(aWM, - BC_BORDER_START_HALF_COORD(p2t, propData->mBStartBorderWidth), - BC_BORDER_END_HALF_COORD(p2t, propData->mIEndBorderWidth), - BC_BORDER_END_HALF_COORD(p2t, propData->mBEndBorderWidth), - BC_BORDER_START_HALF_COORD(p2t, propData->mIStartBorderWidth)); + BC_BORDER_START_HALF_COORD(d2a, propData->mBStartBorderWidth), + BC_BORDER_END_HALF_COORD(d2a, propData->mIEndBorderWidth), + BC_BORDER_END_HALF_COORD(d2a, propData->mBEndBorderWidth), + BC_BORDER_START_HALF_COORD(d2a, propData->mIStartBorderWidth)); } return LogicalMargin(aWM); } @@ -2700,14 +2700,14 @@ nsTableFrame::GetIncludedOuterBCBorder(const WritingMode aWM) const const_cast(this)->CalcBCBorders(); } - int32_t p2t = nsPresContext::AppUnitsPerCSSPixel(); + int32_t d2a = PresContext()->AppUnitsPerDevPixel(); BCPropertyData* propData = GetBCProperty(); if (propData) { return LogicalMargin(aWM, - BC_BORDER_START_HALF_COORD(p2t, propData->mBStartBorderWidth), - BC_BORDER_END_HALF_COORD(p2t, propData->mIEndCellBorderWidth), - BC_BORDER_END_HALF_COORD(p2t, propData->mBEndBorderWidth), - BC_BORDER_START_HALF_COORD(p2t, propData->mIStartCellBorderWidth)); + BC_BORDER_START_HALF_COORD(d2a, propData->mBStartBorderWidth), + BC_BORDER_END_HALF_COORD(d2a, propData->mIEndCellBorderWidth), + BC_BORDER_END_HALF_COORD(d2a, propData->mBEndBorderWidth), + BC_BORDER_START_HALF_COORD(d2a, propData->mIStartCellBorderWidth)); } return LogicalMargin(aWM); } @@ -4791,7 +4791,7 @@ GetColorAndStyle(const nsIFrame* aFrame, if (aWidth) { nscoord width = styleData->GetComputedBorderWidth(physicalSide); - *aWidth = nsPresContext::AppUnitsToIntCSSPixels(width); + *aWidth = aFrame->PresContext()->AppUnitsToDevPixels(width); } } @@ -6476,8 +6476,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) nscoord rowBSize = rowFrame->BSize(mTableWM); if (haveIntersect) { // conservatively estimate the half border widths outside the row - nscoord borderHalf = mTable->GetPrevInFlow() ? 0 : nsPresContext:: - CSSPixelsToAppUnits(rowFrame->GetBStartBCBorderWidth() + 1); + nscoord borderHalf = mTable->GetPrevInFlow() ? 0 : + mTable->PresContext()->DevPixelsToAppUnits(rowFrame->GetBStartBCBorderWidth() + 1); if (dirtyRect.BEnd(mTableWM) >= rowB - borderHalf) { nsTableRowFrame* fifRow = static_cast(rowFrame->FirstInFlow()); @@ -6487,8 +6487,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) } else { // conservatively estimate the half border widths outside the row - nscoord borderHalf = mTable->GetNextInFlow() ? 0 : nsPresContext:: - CSSPixelsToAppUnits(rowFrame->GetBEndBCBorderWidth() + 1); + nscoord borderHalf = mTable->GetNextInFlow() ? 0 : + mTable->PresContext()->DevPixelsToAppUnits(rowFrame->GetBEndBCBorderWidth() + 1); if (rowB + rowBSize + borderHalf >= dirtyRect.BStart(mTableWM)) { mStartRg = rgFrame; mStartRow = rowFrame; @@ -6532,8 +6532,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) nscoord colISize = colFrame->ISize(mTableWM); if (haveIntersect) { // conservatively estimate the iStart half border width outside the col - nscoord iStartBorderHalf = nsPresContext:: - CSSPixelsToAppUnits(colFrame->GetIStartBorderWidth() + 1); + nscoord iStartBorderHalf = + mTable->PresContext()->DevPixelsToAppUnits(colFrame->GetIStartBorderWidth() + 1); if (dirtyRect.IEnd(mTableWM) >= x - iStartBorderHalf) { endColIndex = colIdx; } @@ -6541,8 +6541,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) } else { // conservatively estimate the iEnd half border width outside the col - nscoord iEndBorderHalf = nsPresContext:: - CSSPixelsToAppUnits(colFrame->GetIEndBorderWidth() + 1); + nscoord iEndBorderHalf = + mTable->PresContext()->DevPixelsToAppUnits(colFrame->GetIEndBorderWidth() + 1); if (x + colISize + iEndBorderHalf >= dirtyRect.IStart(mTableWM)) { startColIndex = endColIndex = colIdx; haveIntersect = true; @@ -6785,7 +6785,8 @@ CalcVerCornerOffset(LogicalSide aCornerOwnerSide, BCPixelSize aCornerSubWidth, BCPixelSize aHorWidth, bool aIsStartOfSeg, - bool aIsBevel) + bool aIsBevel, + nsPresContext* aPresContext) { nscoord offset = 0; // XXX These should be replaced with appropriate side-specific macros (which?) @@ -6808,7 +6809,7 @@ CalcVerCornerOffset(LogicalSide aCornerOwnerSide, offset = (aIsStartOfSeg) ? smallHalf : -largeHalf; } } - return nsPresContext::CSSPixelsToAppUnits(offset); + return aPresContext->DevPixelsToAppUnits(offset); } /** Compute the horizontal offset of a horizontal border segment @@ -6824,7 +6825,8 @@ CalcHorCornerOffset(LogicalSide aCornerOwnerSide, BCPixelSize aCornerSubWidth, BCPixelSize aVerWidth, bool aIsStartOfSeg, - bool aIsBevel) + bool aIsBevel, + nsPresContext* aPresContext) { nscoord offset = 0; // XXX These should be replaced with appropriate side-specific macros (which?) @@ -6847,7 +6849,7 @@ CalcHorCornerOffset(LogicalSide aCornerOwnerSide, offset = (aIsStartOfSeg) ? smallHalf : -largeHalf; } } - return nsPresContext::CSSPixelsToAppUnits(offset); + return aPresContext->DevPixelsToAppUnits(offset); } BCBlockDirSeg::BCBlockDirSeg() @@ -6883,10 +6885,10 @@ BCBlockDirSeg::Start(BCPaintBorderIterator& aIter, BCPixelSize maxInlineSegBSize = std::max(aIter.mPrevInlineSegBSize, aInlineSegBSize); nscoord offset = CalcVerCornerOffset(ownerSide, cornerSubWidth, maxInlineSegBSize, true, - bStartBevel); + bStartBevel, aIter.mTable->PresContext()); mBStartBevelOffset = bStartBevel ? - nsPresContext::CSSPixelsToAppUnits(maxInlineSegBSize): 0; + aIter.mTable->PresContext()->DevPixelsToAppUnits(maxInlineSegBSize): 0; // XXX this assumes that only corners where 2 segments join can be beveled mBStartBevelSide = (aInlineSegBSize > 0) ? eLogicalSideIEnd : eLogicalSideIStart; mOffsetB += offset; @@ -6944,8 +6946,8 @@ BCBlockDirSeg::GetBEndCorner(BCPaintBorderIterator& aIter, mIsBEndBevel = (mWidth > 0) ? bevel : false; mBEndInlineSegBSize = std::max(aIter.mPrevInlineSegBSize, aInlineSegBSize); mBEndOffset = CalcVerCornerOffset(ownerSide, cornerSubWidth, - mBEndInlineSegBSize, - false, mIsBEndBevel); + mBEndInlineSegBSize, false, + mIsBEndBevel, aIter.mTable->PresContext()); mLength += mBEndOffset; } @@ -7029,11 +7031,11 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter, BCPixelSize smallHalf, largeHalf; DivideBCBorderSize(mWidth, smallHalf, largeHalf); LogicalRect segRect(aIter.mTableWM, - mOffsetI - nsPresContext::CSSPixelsToAppUnits(largeHalf), + mOffsetI - aIter.mTable->PresContext()->DevPixelsToAppUnits(largeHalf), mOffsetB, - nsPresContext::CSSPixelsToAppUnits(mWidth), mLength); + aIter.mTable->PresContext()->DevPixelsToAppUnits(mWidth), mLength); nscoord bEndBevelOffset = (mIsBEndBevel) ? - nsPresContext::CSSPixelsToAppUnits(mBEndInlineSegBSize) : 0; + aIter.mTable->PresContext()->DevPixelsToAppUnits(mBEndInlineSegBSize) : 0; LogicalSide bEndBevelSide = (aInlineSegBSize > 0) ? eLogicalSideIEnd : eLogicalSideIStart; @@ -7067,7 +7069,7 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter, nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color, aIter.mTableBgColor, physicalRect, appUnitsPerDevPixel, - nsPresContext::AppUnitsPerCSSPixel(), + aIter.mTable->PresContext()->AppUnitsPerDevPixel(), startBevelSide, startBevelOffset, endBevelSide, endBevelOffset); } @@ -7123,7 +7125,8 @@ BCInlineDirSeg::Start(BCPaintBorderIterator& aIter, nscoord maxBlockSegISize = std::max(aIter.mBlockDirInfo[relColIndex].mWidth, aBEndBlockSegISize); nscoord offset = CalcHorCornerOffset(cornerOwnerSide, cornerSubWidth, - maxBlockSegISize, true, iStartBevel); + maxBlockSegISize, true, iStartBevel, + aIter.mTable->PresContext()); mIStartBevelOffset = (iStartBevel && (aInlineSegBSize > 0)) ? maxBlockSegISize : 0; // XXX this assumes that only corners where 2 segments join can be beveled mIStartBevelSide = (aBEndBlockSegISize > 0) ? eLogicalSideBEnd : eLogicalSideBStart; @@ -7157,10 +7160,10 @@ BCInlineDirSeg::GetIEndCorner(BCPaintBorderIterator& aIter, nscoord verWidth = std::max(aIter.mBlockDirInfo[relColIndex].mWidth, aIStartSegISize); mEndOffset = CalcHorCornerOffset(ownerSide, cornerSubWidth, verWidth, - false, mIsIEndBevel); + false, mIsIEndBevel, aIter.mTable->PresContext()); mLength += mEndOffset; mIEndBevelOffset = (mIsIEndBevel) ? - nsPresContext::CSSPixelsToAppUnits(verWidth) : 0; + aIter.mTable->PresContext()->DevPixelsToAppUnits(verWidth) : 0; mIEndBevelSide = (aIStartSegISize > 0) ? eLogicalSideBEnd : eLogicalSideBStart; } @@ -7240,9 +7243,9 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget) BCPixelSize smallHalf, largeHalf; DivideBCBorderSize(mWidth, smallHalf, largeHalf); LogicalRect segRect(aIter.mTableWM, mOffsetI, - mOffsetB - nsPresContext::CSSPixelsToAppUnits(largeHalf), + mOffsetB - aIter.mTable->PresContext()->DevPixelsToAppUnits(largeHalf), mLength, - nsPresContext::CSSPixelsToAppUnits(mWidth)); + aIter.mTable->PresContext()->DevPixelsToAppUnits(mWidth)); // Convert logical to physical sides/coordinates for DrawTableBorderSegment. nsRect physicalRect = segRect.GetPhysicalRect(aIter.mTableWM, @@ -7250,7 +7253,7 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget) uint8_t startBevelSide = aIter.mTableWM.PhysicalSide(mIStartBevelSide); uint8_t endBevelSide = aIter.mTableWM.PhysicalSide(mIEndBevelSide); nscoord startBevelOffset = - nsPresContext::CSSPixelsToAppUnits(mIStartBevelOffset); + aIter.mTable->PresContext()->DevPixelsToAppUnits(mIStartBevelOffset); nscoord endBevelOffset = mIEndBevelOffset; // With inline-RTL directionality, the 'start' and 'end' of the inline-dir // border segment need to be swapped because DrawTableBorderSegment will @@ -7271,7 +7274,7 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget) nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color, aIter.mTableBgColor, physicalRect, appUnitsPerDevPixel, - nsPresContext::AppUnitsPerCSSPixel(), + aIter.mTable->PresContext()->AppUnitsPerDevPixel(), startBevelSide, startBevelOffset, endBevelSide, endBevelOffset); } -- cgit v1.2.3 From 88671bcc3633af5a5e34715518e0804ca892fac7 Mon Sep 17 00:00:00 2001 From: JustOff Date: Sat, 20 Oct 2018 16:25:28 +0300 Subject: [css-grid] Don't shrink-wrap the inline size when we have an available size when measuring block size --- layout/generic/nsGridContainerFrame.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'layout') diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 8f117b5ab..fbd61f783 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -3714,8 +3714,11 @@ MeasuringReflow(nsIFrame* aChild, parent->Properties().Set( nsContainerFrame::DebugReflowingWithInfiniteISize(), true); #endif - uint32_t riFlags = ReflowInput::COMPUTE_SIZE_SHRINK_WRAP | - ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE; + auto wm = aChild->GetWritingMode(); + uint32_t riFlags = ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE; + if (aAvailableSize.ISize(wm) == INFINITE_ISIZE_COORD) { + riFlags |= ReflowInput::COMPUTE_SIZE_SHRINK_WRAP; + } if (aIMinSizeClamp != NS_MAXSIZE) { riFlags |= ReflowInput::I_CLAMP_MARGIN_BOX_MIN_SIZE; } @@ -3730,7 +3733,6 @@ MeasuringReflow(nsIFrame* aChild, ReflowOutput childSize(childRI); nsReflowStatus childStatus; const uint32_t flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_SIZE_VIEW; - WritingMode wm = childRI.GetWritingMode(); parent->ReflowChild(aChild, pc, childSize, childRI, wm, LogicalPoint(wm), nsSize(), flags, childStatus); parent->FinishReflowChild(aChild, pc, childSize, &childRI, wm, -- cgit v1.2.3 From 7110f93fb1345577a6f156935e720a741bccb50a Mon Sep 17 00:00:00 2001 From: JustOff Date: Sat, 20 Oct 2018 16:27:57 +0300 Subject: [css-grid] Reftests for 88671bcc3633af5a5e34715518e0804ca892fac7 --- layout/reftests/css-grid/bug1349571-ref.html | 90 ++++++++++++++++++++++++++ layout/reftests/css-grid/bug1349571.html | 94 ++++++++++++++++++++++++++++ layout/reftests/css-grid/bug1356820-ref.html | 81 ++++++++++++++++++++++++ layout/reftests/css-grid/bug1356820.html | 81 ++++++++++++++++++++++++ layout/reftests/css-grid/reftest.list | 2 + 5 files changed, 348 insertions(+) create mode 100644 layout/reftests/css-grid/bug1349571-ref.html create mode 100644 layout/reftests/css-grid/bug1349571.html create mode 100644 layout/reftests/css-grid/bug1356820-ref.html create mode 100644 layout/reftests/css-grid/bug1356820.html (limited to 'layout') diff --git a/layout/reftests/css-grid/bug1349571-ref.html b/layout/reftests/css-grid/bug1349571-ref.html new file mode 100644 index 000000000..42efd731a --- /dev/null +++ b/layout/reftests/css-grid/bug1349571-ref.html @@ -0,0 +1,90 @@ + + + + + + Testcase for bug 1349571 + + + + +
+
+
+ + + + \ No newline at end of file diff --git a/layout/reftests/css-grid/bug1349571.html b/layout/reftests/css-grid/bug1349571.html new file mode 100644 index 000000000..f836fe36e --- /dev/null +++ b/layout/reftests/css-grid/bug1349571.html @@ -0,0 +1,94 @@ + + + + + + Testcase for bug 1349571 + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/layout/reftests/css-grid/bug1356820-ref.html b/layout/reftests/css-grid/bug1356820-ref.html new file mode 100644 index 000000000..b203ba203 --- /dev/null +++ b/layout/reftests/css-grid/bug1356820-ref.html @@ -0,0 +1,81 @@ + + +
+
+ first item with a longlonglongword +
+
+ second item +
+
+
+
+ first item with a longlonglongword +
+
+ second item +
+
+
+
+ first item with a longlonglongword +
+
+ second item +
+
+ \ No newline at end of file diff --git a/layout/reftests/css-grid/bug1356820.html b/layout/reftests/css-grid/bug1356820.html new file mode 100644 index 000000000..2f2f36014 --- /dev/null +++ b/layout/reftests/css-grid/bug1356820.html @@ -0,0 +1,81 @@ + + +
+
+ first item with a longlonglongword +
+
+ second item +
+
+
+
+ first item with a longlonglongword +
+
+ second item +
+
+
+
+ first item with a longlonglongword +
+
+ second item +
+
+ \ No newline at end of file diff --git a/layout/reftests/css-grid/reftest.list b/layout/reftests/css-grid/reftest.list index c2ee57c1a..3087ca49b 100644 --- a/layout/reftests/css-grid/reftest.list +++ b/layout/reftests/css-grid/reftest.list @@ -280,3 +280,5 @@ asserts(1-10) == grid-fragmentation-dyn4-021.html grid-fragmentation-021-ref.htm == grid-fragmentation-dyn2-031.html grid-fragmentation-031-ref.html == bug1306106.html bug1306106-ref.html == grid-percent-intrinsic-sizing-001.html grid-percent-intrinsic-sizing-001-ref.html +== bug1349571.html bug1349571-ref.html +== bug1356820.html bug1356820-ref.html -- cgit v1.2.3 From fdbac095968bc952fec6a03765a7156940ae4733 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 31 Oct 2018 18:47:29 +0100 Subject: Ensure that the scroll frame deregisters its refresh driver observers (mAsyncScroll & mAsyncSmoothMSDScroll) before it's destroyed. Tag #345 --- layout/generic/nsGfxScrollFrame.cpp | 52 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'layout') diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index ccdc3a0ce..cfa366aa3 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1774,6 +1774,18 @@ public: return true; } + /** + * The mCallee holds a strong ref to us since the refresh driver doesn't. + * Our dtor and mCallee's Destroy() method both call RemoveObserver() - + * whichever comes first removes us from the refresh driver. + */ + void RemoveObserver() { + if (mCallee) { + RefreshDriver(mCallee)->RemoveRefreshObserver(this, Flush_Style); + mCallee = nullptr; + } + } + private: // Private destructor, to discourage deletion outside of Release(): ~AsyncSmoothMSDScroll() { @@ -1786,17 +1798,6 @@ private: return aCallee->mOuter->PresContext()->RefreshDriver(); } - /* - * The refresh driver doesn't hold a reference to its observers, - * so releasing this object can (and is) used to remove the observer on DTOR. - * Currently, this object is released once the scrolling ends. - */ - void RemoveObserver() { - if (mCallee) { - RefreshDriver(mCallee)->RemoveRefreshObserver(this, Flush_Style); - } - } - mozilla::layers::AxisPhysicsMSDModel mXAxisModel, mYAxisModel; nsRect mRange; mozilla::TimeStamp mLastRefreshTime; @@ -1875,24 +1876,25 @@ public: ScrollFrameHelper::AsyncScrollCallback(mCallee, aTime); } -private: - ScrollFrameHelper *mCallee; - - nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) { - return aCallee->mOuter->PresContext()->RefreshDriver(); - } - - /* - * The refresh driver doesn't hold a reference to its observers, - * so releasing this object can (and is) used to remove the observer on DTOR. - * Currently, this object is released once the scrolling ends. + /** + * The mCallee holds a strong ref to us since the refresh driver doesn't. + * Our dtor and mCallee's Destroy() method both call RemoveObserver() - + * whichever comes first removes us from the refresh driver. */ void RemoveObserver() { if (mCallee) { RefreshDriver(mCallee)->RemoveRefreshObserver(this, Flush_Style); APZCCallbackHelper::SuppressDisplayport(false, mCallee->mOuter->PresContext()->PresShell()); + mCallee = nullptr; } } + +private: + ScrollFrameHelper *mCallee; + + nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) { + return aCallee->mOuter->PresContext()->RefreshDriver(); + } }; /* @@ -4586,6 +4588,12 @@ ScrollFrameHelper::Destroy() mScrollActivityTimer->Cancel(); mScrollActivityTimer = nullptr; } + if (mAsyncScroll) { + mAsyncScroll->RemoveObserver(); + } + if (mAsyncSmoothMSDScroll) { + mAsyncSmoothMSDScroll->RemoveObserver(); + } } /** -- cgit v1.2.3 From 3b2c342f3879705b0cc9919198b984f92aec5e62 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 2 Nov 2018 10:47:05 +0100 Subject: Make sure we remove our RefreshDriver observers in CompleteAsyncScroll. Follow-up to fdbac095968bc952fec6a03765a7156940ae4733 --- layout/generic/nsGfxScrollFrame.cpp | 11 +++++++++-- layout/generic/nsGfxScrollFrame.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'layout') diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index cfa366aa3..3ed3b0bb3 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2152,8 +2152,7 @@ void ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin) { // Apply desired destination range since this is the last step of scrolling. - mAsyncSmoothMSDScroll = nullptr; - mAsyncScroll = nullptr; + RemoveObservers(); nsWeakFrame weakFrame(mOuter); ScrollToImpl(mDestination, aRange, aOrigin); if (!weakFrame.IsAlive()) { @@ -4588,11 +4587,19 @@ ScrollFrameHelper::Destroy() mScrollActivityTimer->Cancel(); mScrollActivityTimer = nullptr; } + RemoveObservers(); +} + +void +ScrollFrameHelper::RemoveObservers() +{ if (mAsyncScroll) { mAsyncScroll->RemoveObserver(); + mAsyncScroll = nullptr; } if (mAsyncSmoothMSDScroll) { mAsyncSmoothMSDScroll->RemoveObserver(); + mAsyncSmoothMSDScroll = nullptr; } } diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index f1ef44ae8..81bbb358f 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -638,6 +638,9 @@ protected: bool HasBgAttachmentLocal() const; uint8_t GetScrolledFrameDir() const; + // Removes any RefreshDriver observers we might have registered. + void RemoveObservers(); + static void EnsureFrameVisPrefsCached(); static bool sFrameVisPrefsCached; // The number of scrollports wide/high to expand when tracking frame visibility. -- cgit v1.2.3