From cd8f0da1f4c470a9eda31c9a7cf8a5e5bb829065 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 8 Jan 2015 23:20:16 +1100 Subject: [PATCH] Bug 1055658 part 4 - Revert RubyReflowState. r=dbaron --HG-- extra : source : 4ee892ec7dde8957aa733401bfd7746a97ebcf7e --- layout/generic/RubyReflowState.cpp | 24 -------- layout/generic/RubyReflowState.h | 68 --------------------- layout/generic/moz.build | 1 - layout/generic/nsHTMLReflowState.cpp | 2 - layout/generic/nsHTMLReflowState.h | 7 --- layout/generic/nsLineLayout.cpp | 5 -- layout/generic/nsLineLayout.h | 15 ----- layout/generic/nsRubyBaseContainerFrame.cpp | 3 +- layout/generic/nsRubyBaseContainerFrame.h | 3 +- layout/generic/nsRubyFrame.cpp | 6 -- layout/generic/nsRubyTextContainerFrame.cpp | 7 +-- layout/generic/nsRubyTextContainerFrame.h | 10 ++- 12 files changed, 12 insertions(+), 139 deletions(-) delete mode 100644 layout/generic/RubyReflowState.cpp delete mode 100644 layout/generic/RubyReflowState.h diff --git a/layout/generic/RubyReflowState.cpp b/layout/generic/RubyReflowState.cpp deleted file mode 100644 index 8cade0c415ee..000000000000 --- a/layout/generic/RubyReflowState.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/* states and methods used while laying out a ruby segment */ - -#include "RubyReflowState.h" - -using namespace mozilla; - -RubyReflowState::RubyReflowState( - WritingMode aLineWM, - const nsTArray& aTextContainers) - : mCurrentContainerIndex(kBaseContainerIndex) -{ - uint32_t rtcCount = aTextContainers.Length(); - mTextContainers.SetCapacity(rtcCount); - for (uint32_t i = 0; i < rtcCount; i++) { - mTextContainers.AppendElement( - TextContainerInfo(aLineWM, aTextContainers[i])); - } -} diff --git a/layout/generic/RubyReflowState.h b/layout/generic/RubyReflowState.h deleted file mode 100644 index 212317b3f73e..000000000000 --- a/layout/generic/RubyReflowState.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -/* states and methods used while laying out a ruby segment */ - -#ifndef mozilla_RubyReflowState_h_ -#define mozilla_RubyReflowState_h_ - -#include "mozilla/Attributes.h" -#include "WritingModes.h" -#include "nsTArray.h" - -#define RTC_ARRAY_SIZE 1 - -class nsRubyTextContainerFrame; - -namespace mozilla { - -class MOZ_STACK_CLASS RubyReflowState MOZ_FINAL -{ -public: - explicit RubyReflowState( - WritingMode aLineWM, - const nsTArray& aTextContainers); - - struct TextContainerInfo - { - nsRubyTextContainerFrame* mFrame; - LogicalSize mLineSize; - - TextContainerInfo(WritingMode aLineWM, nsRubyTextContainerFrame* aFrame) - : mFrame(aFrame) - , mLineSize(aLineWM) { } - }; - - void AdvanceCurrentContainerIndex() { mCurrentContainerIndex++; } - - void SetTextContainerInfo(int32_t aIndex, - nsRubyTextContainerFrame* aContainer, - const LogicalSize& aLineSize) - { - MOZ_ASSERT(mTextContainers[aIndex].mFrame == aContainer); - mTextContainers[aIndex].mLineSize = aLineSize; - } - - const TextContainerInfo& - GetCurrentTextContainerInfo(nsRubyTextContainerFrame* aFrame) const - { - MOZ_ASSERT(mTextContainers[mCurrentContainerIndex].mFrame == aFrame); - return mTextContainers[mCurrentContainerIndex]; - } - -private: - static MOZ_CONSTEXPR_VAR int32_t kBaseContainerIndex = -1; - // The index of the current reflowing container. When it equals to - // kBaseContainerIndex, we are reflowing ruby base. Otherwise, it - // stands for the index of text containers in the ruby segment. - int32_t mCurrentContainerIndex; - - nsAutoTArray mTextContainers; -}; - -} - -#endif // mozilla_RubyReflowState_h_ diff --git a/layout/generic/moz.build b/layout/generic/moz.build index be752630b8a0..0d413496e088 100644 --- a/layout/generic/moz.build +++ b/layout/generic/moz.build @@ -95,7 +95,6 @@ UNIFIED_SOURCES += [ 'nsTextRunTransformations.cpp', 'nsVideoFrame.cpp', 'nsViewportFrame.cpp', - 'RubyReflowState.cpp', 'RubyUtils.cpp', 'ScrollbarActivity.cpp', 'StickyScrollContainer.cpp', diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 53a9e43c2caf..34446aea1660 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -72,7 +72,6 @@ nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext, AvailableBSize() = aAvailableSpace.BSize(mWritingMode); mFloatManager = nullptr; mLineLayout = nullptr; - mRubyReflowState = nullptr; memset(&mFlags, 0, sizeof(mFlags)); mDiscoveredClearance = nullptr; mPercentHeightObserver = nullptr; @@ -208,7 +207,6 @@ nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext, mLineLayout = aParentReflowState.mLineLayout; else mLineLayout = nullptr; - mRubyReflowState = nullptr; // Note: mFlags was initialized as a copy of aParentReflowState.mFlags up in // this constructor's init list, so the only flags that we need to explicitly diff --git a/layout/generic/nsHTMLReflowState.h b/layout/generic/nsHTMLReflowState.h index 7c6751e632f6..da282f702bd6 100644 --- a/layout/generic/nsHTMLReflowState.h +++ b/layout/generic/nsHTMLReflowState.h @@ -21,10 +21,6 @@ class nsLineLayout; class nsIPercentHeightObserver; struct nsHypotheticalBox; -namespace mozilla { -class RubyReflowState; -} - /** * @return aValue clamped to [aMinValue, aMaxValue]. * @@ -262,9 +258,6 @@ struct nsHTMLReflowState : public nsCSSOffsetState { // LineLayout object (only for inline reflow; set to nullptr otherwise) nsLineLayout* mLineLayout; - // RubyReflowState object (only for ruby reflow; set to nullptr otherwise) - mozilla::RubyReflowState* mRubyReflowState; - // The appropriate reflow state for the containing block (for // percentage widths, etc.) of this reflow state's frame. const nsHTMLReflowState *mCBReflowState; diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 676f49eeff5f..3bb43cea7b56 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -67,7 +67,6 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext, mForceBreakFrameOffset(-1), mMinLineBSize(0), mTextIndent(0), - mRubyReflowState(nullptr), mFirstLetterStyleOK(false), mIsTopOfPage(false), mImpactedByFloats(false), @@ -886,10 +885,6 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, aFrame, availSize); nsHTMLReflowState& reflowState = *reflowStateHolder; reflowState.mLineLayout = this; - if (mRubyReflowState) { - reflowState.mRubyReflowState = mRubyReflowState; - mRubyReflowState = nullptr; - } reflowState.mFlags.mIsTopOfPage = mIsTopOfPage; if (reflowState.ComputedISize() == NS_UNCONSTRAINEDSIZE) { reflowState.AvailableISize() = availableSpaceOnLine; diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index 44bf7286aa75..64beb5fe7000 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -27,10 +27,6 @@ class nsFloatManager; struct nsStyleText; -namespace mozilla { -class RubyReflowState; -} - class nsLineLayout { public: /** @@ -102,13 +98,6 @@ public: bool IsZeroBSize(); - // The ruby layout will be passed to the next frame to be reflowed - // via the HTML reflow state. - void SetRubyReflowState(mozilla::RubyReflowState* aRubyReflowState) - { - mRubyReflowState = aRubyReflowState; - } - // Reflows the frame and returns the reflow status. aPushedFrame is true // if the frame is pushed to the next line because it doesn't fit. void ReflowFrame(nsIFrame* aFrame, @@ -565,10 +554,6 @@ protected: int32_t mLineNumber; mozilla::JustificationInfo mJustificationInfo; - // The ruby layout for the next frame to be reflowed. - // It is reset every time it is used. - mozilla::RubyReflowState* mRubyReflowState; - int32_t mTotalPlacedFrames; nscoord mBStartEdge; diff --git a/layout/generic/nsRubyBaseContainerFrame.cpp b/layout/generic/nsRubyBaseContainerFrame.cpp index 0a613310b852..0a280ea3c720 100644 --- a/layout/generic/nsRubyBaseContainerFrame.cpp +++ b/layout/generic/nsRubyBaseContainerFrame.cpp @@ -341,7 +341,6 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext, "No line layout provided to RubyBaseContainerFrame reflow method."); return; } - MOZ_ASSERT(aReflowState.mRubyReflowState, "No ruby reflow state provided"); AutoTextContainerArray textContainers; GetTextContainers(textContainers); @@ -494,7 +493,7 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext, lineLayout->VerticalAlignLine(); LogicalSize lineSize(lineWM, rtcISize, lineLayout->GetFinalLineBSize()); - aReflowState.mRubyReflowState->SetTextContainerInfo(i, textContainer, lineSize); + textContainer->SetLineSize(lineSize); lineLayout->EndLineReflow(); } diff --git a/layout/generic/nsRubyBaseContainerFrame.h b/layout/generic/nsRubyBaseContainerFrame.h index 526a861d58be..530acc6c2a61 100644 --- a/layout/generic/nsRubyBaseContainerFrame.h +++ b/layout/generic/nsRubyBaseContainerFrame.h @@ -13,7 +13,8 @@ #include "nsRubyTextContainerFrame.h" #include "nsRubyBaseFrame.h" #include "nsRubyTextFrame.h" -#include "RubyReflowState.h" + +#define RTC_ARRAY_SIZE 1 /** * Factory function. diff --git a/layout/generic/nsRubyFrame.cpp b/layout/generic/nsRubyFrame.cpp index c9b059cf139d..68eabe110b53 100644 --- a/layout/generic/nsRubyFrame.cpp +++ b/layout/generic/nsRubyFrame.cpp @@ -11,7 +11,6 @@ #include "nsStyleContext.h" #include "WritingModes.h" #include "RubyUtils.h" -#include "RubyReflowState.h" #include "nsRubyBaseContainerFrame.h" #include "nsRubyTextContainerFrame.h" @@ -241,11 +240,9 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext, textContainers.AppendElement(iter.GetTextContainer()); } const uint32_t rtcCount = textContainers.Length(); - RubyReflowState rubyReflowState(lineWM, textContainers); nsHTMLReflowMetrics baseMetrics(aReflowState); bool pushedFrame; - aReflowState.mLineLayout->SetRubyReflowState(&rubyReflowState); aReflowState.mLineLayout->ReflowFrame(aBaseContainer, aStatus, &baseMetrics, pushedFrame); @@ -330,13 +327,10 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext, nsRect offsetRect = baseRect; for (uint32_t i = 0; i < rtcCount; i++) { nsRubyTextContainerFrame* textContainer = textContainers[i]; - rubyReflowState.AdvanceCurrentContainerIndex(); - nsReflowStatus textReflowStatus; nsHTMLReflowMetrics textMetrics(aReflowState); nsHTMLReflowState textReflowState(aPresContext, aReflowState, textContainer, availSize); - textReflowState.mRubyReflowState = &rubyReflowState; // FIXME We probably shouldn't be using the same nsLineLayout for // the text containers. But it should be fine now as we are // not actually using this line layout to reflow something, diff --git a/layout/generic/nsRubyTextContainerFrame.cpp b/layout/generic/nsRubyTextContainerFrame.cpp index 2c75e8a738ca..4721ba0813cc 100644 --- a/layout/generic/nsRubyTextContainerFrame.cpp +++ b/layout/generic/nsRubyTextContainerFrame.cpp @@ -10,7 +10,6 @@ #include "nsPresContext.h" #include "nsStyleContext.h" #include "WritingModes.h" -#include "RubyReflowState.h" #include "mozilla/UniquePtr.h" using namespace mozilla; @@ -125,8 +124,6 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsRubyTextContainerFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); - MOZ_ASSERT(aReflowState.mRubyReflowState, "No ruby reflow state provided"); - // All rt children have already been reflowed. All we need to do is // to report complete and return the desired size provided by the // ruby base container. @@ -137,7 +134,5 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext, // will take care of our continuations. aStatus = NS_FRAME_COMPLETE; WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode(); - const RubyReflowState::TextContainerInfo& info = - aReflowState.mRubyReflowState->GetCurrentTextContainerInfo(this); - aDesiredSize.SetSize(lineWM, info.mLineSize); + aDesiredSize.SetSize(lineWM, mLineSize); } diff --git a/layout/generic/nsRubyTextContainerFrame.h b/layout/generic/nsRubyTextContainerFrame.h index b2588f5048a0..ce79f6242f4c 100644 --- a/layout/generic/nsRubyTextContainerFrame.h +++ b/layout/generic/nsRubyTextContainerFrame.h @@ -62,12 +62,18 @@ protected: NS_NewRubyTextContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); explicit nsRubyTextContainerFrame(nsStyleContext* aContext) - : nsRubyTextContainerFrameSuper(aContext) {} + : nsRubyTextContainerFrameSuper(aContext) + , mLineSize(mozilla::WritingMode(aContext)) {} void UpdateSpanFlag(); - // For MoveOverflowToChildList friend class nsRubyBaseContainerFrame; + void SetLineSize(const mozilla::LogicalSize& aSize) { mLineSize = aSize; } + + // The intended dimensions of the ruby text container. It is set by + // the corresponding ruby base container when the segment is reflowed, + // and used when the ruby text container is reflowed by its parent. + mozilla::LogicalSize mLineSize; }; #endif /* nsRubyTextContainerFrame_h___ */