Backed out changeset 2ee5068037f2 (bug 1055658)

This commit is contained in:
Carsten "Tomcat" Book 2015-01-08 16:08:33 +01:00
Родитель ee0769840f
Коммит 9b09e9d3fb
12 изменённых файлов: 139 добавлений и 12 удалений

Просмотреть файл

@ -0,0 +1,24 @@
/* -*- 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<nsRubyTextContainerFrame*>& 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]));
}
}

Просмотреть файл

@ -0,0 +1,68 @@
/* -*- 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<nsRubyTextContainerFrame*>& 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<TextContainerInfo, RTC_ARRAY_SIZE> mTextContainers;
};
}
#endif // mozilla_RubyReflowState_h_

Просмотреть файл

@ -95,6 +95,7 @@ UNIFIED_SOURCES += [
'nsTextRunTransformations.cpp',
'nsVideoFrame.cpp',
'nsViewportFrame.cpp',
'RubyReflowState.cpp',
'RubyUtils.cpp',
'ScrollbarActivity.cpp',
'StickyScrollContainer.cpp',

Просмотреть файл

@ -72,6 +72,7 @@ nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext,
AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
mFloatManager = nullptr;
mLineLayout = nullptr;
mRubyReflowState = nullptr;
memset(&mFlags, 0, sizeof(mFlags));
mDiscoveredClearance = nullptr;
mPercentHeightObserver = nullptr;
@ -207,6 +208,7 @@ 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

Просмотреть файл

@ -21,6 +21,10 @@ class nsLineLayout;
class nsIPercentHeightObserver;
struct nsHypotheticalBox;
namespace mozilla {
class RubyReflowState;
}
/**
* @return aValue clamped to [aMinValue, aMaxValue].
*
@ -258,6 +262,9 @@ 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;

Просмотреть файл

@ -67,6 +67,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mForceBreakFrameOffset(-1),
mMinLineBSize(0),
mTextIndent(0),
mRubyReflowState(nullptr),
mFirstLetterStyleOK(false),
mIsTopOfPage(false),
mImpactedByFloats(false),
@ -885,6 +886,10 @@ 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;

Просмотреть файл

@ -27,6 +27,10 @@
class nsFloatManager;
struct nsStyleText;
namespace mozilla {
class RubyReflowState;
}
class nsLineLayout {
public:
/**
@ -98,6 +102,13 @@ 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,
@ -554,6 +565,10 @@ 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;

Просмотреть файл

@ -341,6 +341,7 @@ 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);
@ -493,7 +494,7 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
lineLayout->VerticalAlignLine();
LogicalSize lineSize(lineWM, rtcISize, lineLayout->GetFinalLineBSize());
textContainer->SetLineSize(lineSize);
aReflowState.mRubyReflowState->SetTextContainerInfo(i, textContainer, lineSize);
lineLayout->EndLineReflow();
}

Просмотреть файл

@ -13,8 +13,7 @@
#include "nsRubyTextContainerFrame.h"
#include "nsRubyBaseFrame.h"
#include "nsRubyTextFrame.h"
#define RTC_ARRAY_SIZE 1
#include "RubyReflowState.h"
/**
* Factory function.

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsStyleContext.h"
#include "WritingModes.h"
#include "RubyUtils.h"
#include "RubyReflowState.h"
#include "nsRubyBaseContainerFrame.h"
#include "nsRubyTextContainerFrame.h"
@ -240,9 +241,11 @@ 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);
@ -327,10 +330,13 @@ 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,

Просмотреть файл

@ -10,6 +10,7 @@
#include "nsPresContext.h"
#include "nsStyleContext.h"
#include "WritingModes.h"
#include "RubyReflowState.h"
#include "mozilla/UniquePtr.h"
using namespace mozilla;
@ -124,6 +125,8 @@ 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.
@ -134,5 +137,7 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext,
// will take care of our continuations.
aStatus = NS_FRAME_COMPLETE;
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
aDesiredSize.SetSize(lineWM, mLineSize);
const RubyReflowState::TextContainerInfo& info =
aReflowState.mRubyReflowState->GetCurrentTextContainerInfo(this);
aDesiredSize.SetSize(lineWM, info.mLineSize);
}

Просмотреть файл

@ -62,18 +62,12 @@ protected:
NS_NewRubyTextContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
explicit nsRubyTextContainerFrame(nsStyleContext* aContext)
: nsRubyTextContainerFrameSuper(aContext)
, mLineSize(mozilla::WritingMode(aContext)) {}
: nsRubyTextContainerFrameSuper(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___ */