зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1116037 part 1 - Move TextContainerIterator to RubyUtils. r=dbaron
--HG-- extra : source : 2953b34d3cc05a3f34edb3d775821e81c798b77b
This commit is contained in:
Родитель
122e7b1bfe
Коммит
7368bd2654
|
@ -5,7 +5,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "RubyUtils.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -42,3 +41,20 @@ RubyUtils::GetReservedISize(nsIFrame* aFrame)
|
|||
value.mPointer = aFrame->Properties().Get(ReservedISize());
|
||||
return value.mCoord;
|
||||
}
|
||||
|
||||
RubyTextContainerIterator::RubyTextContainerIterator(
|
||||
nsRubyBaseContainerFrame* aBaseContainer)
|
||||
{
|
||||
mFrame = aBaseContainer;
|
||||
Next();
|
||||
}
|
||||
|
||||
void
|
||||
RubyTextContainerIterator::Next()
|
||||
{
|
||||
MOZ_ASSERT(mFrame, "Should have checked AtEnd()");
|
||||
mFrame = mFrame->GetNextSibling();
|
||||
if (mFrame && mFrame->GetType() != nsGkAtoms::rubyTextContainerFrame) {
|
||||
mFrame = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#define mozilla_RubyUtils_h_
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsRubyBaseContainerFrame.h"
|
||||
#include "nsRubyTextContainerFrame.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -58,6 +59,26 @@ public:
|
|||
static nscoord GetReservedISize(nsIFrame* aFrame);
|
||||
};
|
||||
|
||||
/**
|
||||
* This class iterates all ruby text containers paired with
|
||||
* the given ruby base container.
|
||||
*/
|
||||
class MOZ_STACK_CLASS RubyTextContainerIterator
|
||||
{
|
||||
public:
|
||||
explicit RubyTextContainerIterator(nsRubyBaseContainerFrame* aBaseContainer);
|
||||
|
||||
void Next();
|
||||
bool AtEnd() const { return !mFrame; }
|
||||
nsRubyTextContainerFrame* GetTextContainer() const
|
||||
{
|
||||
return static_cast<nsRubyTextContainerFrame*>(mFrame);
|
||||
}
|
||||
|
||||
private:
|
||||
nsIFrame* mFrame;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* !defined(mozilla_RubyUtils_h_) */
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsPresContext.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "WritingModes.h"
|
||||
#include "RubyUtils.h"
|
||||
#include "nsRubyBaseContainerFrame.h"
|
||||
#include "nsRubyTextContainerFrame.h"
|
||||
|
||||
|
@ -59,39 +60,6 @@ nsRubyFrame::GetFrameName(nsAString& aResult) const
|
|||
}
|
||||
#endif
|
||||
|
||||
class MOZ_STACK_CLASS TextContainerIterator
|
||||
{
|
||||
public:
|
||||
explicit TextContainerIterator(nsRubyBaseContainerFrame* aBaseContainer);
|
||||
void Next();
|
||||
bool AtEnd() const { return !mFrame; }
|
||||
nsRubyTextContainerFrame* GetTextContainer() const
|
||||
{
|
||||
return static_cast<nsRubyTextContainerFrame*>(mFrame);
|
||||
}
|
||||
|
||||
private:
|
||||
nsIFrame* mFrame;
|
||||
};
|
||||
|
||||
TextContainerIterator::TextContainerIterator(
|
||||
nsRubyBaseContainerFrame* aBaseContainer)
|
||||
{
|
||||
mFrame = aBaseContainer;
|
||||
Next();
|
||||
}
|
||||
|
||||
void
|
||||
TextContainerIterator::Next()
|
||||
{
|
||||
if (mFrame) {
|
||||
mFrame = mFrame->GetNextSibling();
|
||||
if (mFrame && mFrame->GetType() != nsGkAtoms::rubyTextContainerFrame) {
|
||||
mFrame = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is responsible for appending and clearing
|
||||
* text container list of the base container.
|
||||
|
@ -113,7 +81,7 @@ AutoSetTextContainers::AutoSetTextContainers(
|
|||
#ifdef DEBUG
|
||||
aBaseContainer->AssertTextContainersEmpty();
|
||||
#endif
|
||||
for (TextContainerIterator iter(aBaseContainer);
|
||||
for (RubyTextContainerIterator iter(aBaseContainer);
|
||||
!iter.AtEnd(); iter.Next()) {
|
||||
aBaseContainer->AppendTextContainer(iter.GetTextContainer());
|
||||
}
|
||||
|
@ -300,7 +268,7 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext,
|
|||
aReflowState.AvailableBSize());
|
||||
|
||||
nsAutoTArray<nsRubyTextContainerFrame*, RTC_ARRAY_SIZE> textContainers;
|
||||
for (TextContainerIterator iter(aBaseContainer); !iter.AtEnd(); iter.Next()) {
|
||||
for (RubyTextContainerIterator iter(aBaseContainer); !iter.AtEnd(); iter.Next()) {
|
||||
textContainers.AppendElement(iter.GetTextContainer());
|
||||
}
|
||||
const uint32_t rtcCount = textContainers.Length();
|
||||
|
|
Загрузка…
Ссылка в новой задаче