Backed out 4 changesets (bug 1055658) for M5 bustage on a CLOSED TREE

Backed out changeset 3cbd9323c896 (bug 1055658)
Backed out changeset 99e071295c42 (bug 1055658)
Backed out changeset 55119d19e4c5 (bug 1055658)
Backed out changeset e82f640cb53f (bug 1055658)
This commit is contained in:
Nigel Babu 2015-01-12 10:43:11 +05:30
parent 89d65e0f17
commit 053a7d3408
17 changed files with 149 additions and 199 deletions

View File

@ -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]));
}
}

View File

@ -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_

View File

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

View File

@ -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

View File

@ -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;

View File

@ -67,6 +67,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mForceBreakFrameOffset(-1),
mMinLineBSize(0),
mTextIndent(0),
mRubyReflowState(nullptr),
mFirstLetterStyleOK(false),
mIsTopOfPage(false),
mImpactedByFloats(false),
@ -252,21 +253,6 @@ nsLineLayout::BeginLineReflow(nscoord aICoord, nscoord aBCoord,
pfd->mAscent = 0;
pfd->mSpan = psd;
psd->mFrame = pfd;
nsIFrame* frame = mBlockReflowState->frame;
if (frame->GetType() == nsGkAtoms::rubyTextContainerFrame) {
// Ruby text container won't be reflowed via ReflowFrame, hence the
// relative positioning information should be recorded here.
MOZ_ASSERT(mBaseLineLayout != this);
pfd->mRelativePos =
mBlockReflowState->mStyleDisplay->IsRelativelyPositionedStyle();
if (pfd->mRelativePos) {
MOZ_ASSERT(
mBlockReflowState->GetWritingMode() == frame->GetWritingMode(),
"mBlockReflowState->frame == frame, "
"hence they should have identical writing mode");
pfd->mOffsets = mBlockReflowState->ComputedLogicalOffsets();
}
}
}
void
@ -689,7 +675,6 @@ nsLineLayout::NewPerFrameData(nsIFrame* aFrame)
WritingMode frameWM = aFrame->GetWritingMode();
WritingMode lineWM = mRootSpan->mWritingMode;
pfd->mBounds = LogicalRect(lineWM);
pfd->mOverflowAreas.Clear();
pfd->mMargin = LogicalMargin(lineWM);
pfd->mBorderPadding = LogicalMargin(lineWM);
pfd->mOffsets = LogicalMargin(frameWM);
@ -885,6 +870,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;
@ -3032,45 +3021,6 @@ nsLineLayout::RelativePositionFrames(nsOverflowAreas& aOverflowAreas)
RelativePositionFrames(mRootSpan, aOverflowAreas);
}
// This method applies any relative positioning to the given frame.
void
nsLineLayout::ApplyRelativePositioning(PerFrameData* aPFD)
{
if (!aPFD->mRelativePos) {
return;
}
nsIFrame* frame = aPFD->mFrame;
WritingMode frameWM = frame->GetWritingMode();
LogicalPoint origin = frame->GetLogicalPosition(mContainerWidth);
// right and bottom are handled by
// nsHTMLReflowState::ComputeRelativeOffsets
nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
aPFD->mOffsets, &origin,
mContainerWidth);
frame->SetPosition(frameWM, origin, mContainerWidth);
}
// This method do relative positioning for ruby annotations.
void
nsLineLayout::RelativePositionAnnotations(PerSpanData* aRubyPSD,
nsOverflowAreas& aOverflowAreas)
{
MOZ_ASSERT(aRubyPSD->mFrame->mFrame->GetType() == nsGkAtoms::rubyFrame);
for (PerFrameData* pfd = aRubyPSD->mFirstFrame; pfd; pfd = pfd->mNext) {
MOZ_ASSERT(pfd->mFrame->GetType() == nsGkAtoms::rubyBaseContainerFrame);
for (PerFrameData* rtc = pfd->mNextAnnotation;
rtc; rtc = rtc->mNextAnnotation) {
nsIFrame* rtcFrame = rtc->mFrame;
MOZ_ASSERT(rtcFrame->GetType() == nsGkAtoms::rubyTextContainerFrame);
ApplyRelativePositioning(rtc);
nsOverflowAreas rtcOverflowAreas;
RelativePositionFrames(rtc->mSpan, rtcOverflowAreas);
aOverflowAreas.UnionWith(rtcOverflowAreas + rtcFrame->GetPosition());
}
}
}
void
nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas)
{
@ -3109,7 +3059,16 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
nsIFrame* frame = pfd->mFrame;
// Adjust the origin of the frame
ApplyRelativePositioning(pfd);
if (pfd->mRelativePos) {
WritingMode frameWM = frame->GetWritingMode();
LogicalPoint origin = frame->GetLogicalPosition(mContainerWidth);
// right and bottom are handled by
// nsHTMLReflowState::ComputeRelativeOffsets
nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
pfd->mOffsets, &origin,
mContainerWidth);
frame->SetPosition(frameWM, origin, mContainerWidth);
}
// We must position the view correctly before positioning its
// descendants so that widgets are positioned properly (since only
@ -3165,11 +3124,6 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
overflowAreas.UnionWith(r + frame->GetPosition());
}
// Also compute relative position in the annotations.
if (psd->mFrame->mFrame->GetType() == nsGkAtoms::rubyFrame) {
RelativePositionAnnotations(psd, overflowAreas);
}
// If we just computed a spans combined area, we need to update its
// overflow rect...
if (psd != mRootSpan) {

View File

@ -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;
@ -650,11 +665,6 @@ protected:
nscoord aDistanceFromStart,
nscoord aLineBSize);
void ApplyRelativePositioning(PerFrameData* aPFD);
void RelativePositionAnnotations(PerSpanData* aRubyPSD,
nsOverflowAreas& aOverflowAreas);
void RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas);
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaISize);

View File

@ -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();
}

View File

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

View File

@ -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,

View File

@ -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);
}

View File

@ -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___ */

View File

@ -28,8 +28,6 @@ fuzzy-if(winWidget,35,1) == dynamic-removal-3.html dynamic-removal-3-ref.html #
== line-height-1.html line-height-1-ref.html
== line-height-2.html line-height-2-ref.html
== line-height-3.html line-height-3-ref.html
fails-if(cocoaWidget) == relative-positioning-1.html relative-positioning-1-ref.html # bug 1120280
== relative-positioning-2.html relative-positioning-2-ref.html
== ruby-span-1.html ruby-span-1-ref.html
== ruby-whitespace-1.html ruby-whitespace-1-ref.html
== ruby-whitespace-2.html ruby-whitespace-2-ref.html

View File

@ -1,29 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1055658 - Relative positioning for ruby</title>
<style>
.wrapper {
width: 50px;
text-align: center;
}
.annotation, .annotation > div {
position: absolute;
line-height: 1;
}
</style>
</head>
<body>
<div style="height: 80px; line-height: 80px;">
<div class="wrapper" style="display: inline-block; line-height: normal; position: relative;">
<div class="annotation" style="top: 0;">
<div class="wrapper" style="top: -100%;">a<span style="position: relative; top: -10px;">b</span>c</div>
&nbsp; <!-- to give container a nonzero size for
percent values to resolve against -->
</div>
base
</div>
</div>
</body>
</html>

View File

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1055658 - Relative positioning for ruby</title>
<link rel="stylesheet" href="common.css">
<style>
body {
line-height: 80px;
}
rtc, rt {
font-size: 100% !important;
line-height: 1 !important;
}
</style>
</head>
<body>
<ruby style="position: relative;">
<rb>base</rb>
<rtc><rt>a<span style="position: relative; top: -10px;">b</span>c</rt></rtc>
<rtc><div style="width: 50px; height: 0;"></div></rtc>
</ruby>
</body>
</html>

View File

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1055658 - Relative positioning for ruby</title>
<style>
body {
font-family: monospace;
}
.annotation, .annotation > div {
position: absolute;
line-height: 1;
}
</style>
</head>
<body>
<div style="height: 80px; line-height: 80px;">
before
<div style="display: inline-block; line-height: normal; position: relative; top: 20px;">
<div class="annotation" style="top: 0; width: 100%;">
<div style="top: -100%;">
text1
<span style="position: relative; top: -20px;">text2</span>
<span style="position: relative; right: 10px;">text3</span>
</div>
&nbsp; <!-- to give container a nonzero size for
percent values to resolve against -->
</div>
base1
<span style="position: relative; left: 10px;">base2</span>
<span style="position: relative; bottom: -20px;">base3</span>
</div>
after
</div>
</body>
</html>

View File

@ -1,30 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1055658 - Relative positioning for ruby</title>
<link rel="stylesheet" href="common.css">
<style>
body {
font-family: monospace;
line-height: 80px;
}
rtc, rt {
font-size: 100% !important;
line-height: 1 !important;
}
</style>
</head>
<body>
before
<ruby style="position: relative; top: 20px;">
<rb>base1</rb>
<rtc>text1</rtc>
<rb style="position: relative; left: 10px;">base2</rb>
<rtc style="position: relative; top: -20px;">text2</rtc>
<rbc style="position: relative; bottom: -20px;"><rb>base3</rb></rbc>
<rtc><rt style="position: relative; right: 10px;">text3</rt></rtc>
</ruby>
after
</body>
</html>