mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1181890 - Center children of ruby content frame if necessary after the bidi reposition. r=jfkthame
--HG-- extra : source : db370ccfe5334eae5c4397a8ababab12f0794099
This commit is contained in:
parent
d441030372
commit
33c1455032
@ -1263,7 +1263,7 @@ nsBidiPresUtils::ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
|
||||
aBpd->ResetData();
|
||||
}
|
||||
|
||||
void
|
||||
/* static */ nscoord
|
||||
nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
||||
int32_t aNumFramesOnLine,
|
||||
WritingMode aLineWM,
|
||||
@ -1273,16 +1273,17 @@ nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
||||
// If this line consists of a line frame, reorder the line frame's children.
|
||||
if (aFirstFrameOnLine->GetType() == nsGkAtoms::lineFrame) {
|
||||
aFirstFrameOnLine = aFirstFrameOnLine->GetFirstPrincipalChild();
|
||||
if (!aFirstFrameOnLine)
|
||||
return;
|
||||
if (!aFirstFrameOnLine) {
|
||||
return 0;
|
||||
}
|
||||
// All children of the line frame are on the first line. Setting aNumFramesOnLine
|
||||
// to -1 makes InitLogicalArrayFromLine look at all of them.
|
||||
aNumFramesOnLine = -1;
|
||||
}
|
||||
|
||||
BidiLineData bld(aFirstFrameOnLine, aNumFramesOnLine);
|
||||
RepositionInlineFrames(&bld, aFirstFrameOnLine, aLineWM,
|
||||
aContainerSize, aStart);
|
||||
return RepositionInlineFrames(&bld, aFirstFrameOnLine, aLineWM,
|
||||
aContainerSize, aStart);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
@ -1437,6 +1438,41 @@ nsBidiPresUtils::IsFirstOrLast(nsIFrame* aFrame,
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsBidiPresUtils::RepositionRubyContentFrame(
|
||||
nsIFrame* aFrame, WritingMode aFrameWM, const LogicalMargin& aBorderPadding)
|
||||
{
|
||||
const nsFrameList& childList = aFrame->PrincipalChildList();
|
||||
if (childList.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reorder the children.
|
||||
// XXX It currently doesn't work properly because we do not
|
||||
// resolve frames inside ruby content frames.
|
||||
nscoord isize = ReorderFrames(childList.FirstChild(),
|
||||
childList.GetLength(),
|
||||
aFrameWM, aFrame->GetSize(),
|
||||
aBorderPadding.IStart(aFrameWM));
|
||||
isize += aBorderPadding.IEnd(aFrameWM);
|
||||
|
||||
if (aFrame->StyleText()->mRubyAlign == NS_STYLE_RUBY_ALIGN_START) {
|
||||
return;
|
||||
}
|
||||
nscoord residualISize = aFrame->ISize(aFrameWM) - isize;
|
||||
if (residualISize <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When ruby-align is not "start", if the content does not fill this
|
||||
// frame, we need to center the children.
|
||||
for (nsIFrame* child : childList) {
|
||||
LogicalRect rect = child->GetLogicalRect(aFrameWM, 0);
|
||||
rect.IStart(aFrameWM) += residualISize / 2;
|
||||
child->SetRect(aFrameWM, rect, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ nscoord
|
||||
nsBidiPresUtils::RepositionRubyFrame(
|
||||
nsIFrame* aFrame,
|
||||
@ -1492,14 +1528,7 @@ nsBidiPresUtils::RepositionRubyFrame(
|
||||
} else {
|
||||
if (frameType == nsGkAtoms::rubyBaseFrame ||
|
||||
frameType == nsGkAtoms::rubyTextFrame) {
|
||||
// Reorder the children.
|
||||
// XXX It currently doesn't work properly because we do not
|
||||
// resolve frames inside ruby content frames.
|
||||
const nsFrameList& childList = aFrame->PrincipalChildList();
|
||||
if (childList.NotEmpty()) {
|
||||
ReorderFrames(childList.FirstChild(), childList.GetLength(),
|
||||
frameWM, frameSize, aBorderPadding.IStart(frameWM));
|
||||
}
|
||||
RepositionRubyContentFrame(aFrame, frameWM, aBorderPadding);
|
||||
}
|
||||
// Note that, ruby text container is not present in all conditions
|
||||
// above. It is intended, because the children of rtc are reordered
|
||||
@ -1636,7 +1665,7 @@ nsBidiPresUtils::InitContinuationStates(nsIFrame* aFrame,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
/* static */ nscoord
|
||||
nsBidiPresUtils::RepositionInlineFrames(BidiLineData *aBld,
|
||||
nsIFrame* aFirstChild,
|
||||
WritingMode aLineWM,
|
||||
@ -1673,6 +1702,7 @@ nsBidiPresUtils::RepositionInlineFrames(BidiLineData *aBld,
|
||||
start, &continuationStates,
|
||||
aLineWM, false, aContainerSize);
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -159,14 +159,16 @@ public:
|
||||
/**
|
||||
* Reorder this line using Bidi engine.
|
||||
* Update frame array, following the new visual sequence.
|
||||
*
|
||||
* @return total inline size
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
||||
int32_t aNumFramesOnLine,
|
||||
mozilla::WritingMode aLineWM,
|
||||
const nsSize& aContainerSize,
|
||||
nscoord aStart);
|
||||
static nscoord ReorderFrames(nsIFrame* aFirstFrameOnLine,
|
||||
int32_t aNumFramesOnLine,
|
||||
mozilla::WritingMode aLineWM,
|
||||
const nsSize& aContainerSize,
|
||||
nscoord aStart);
|
||||
|
||||
/**
|
||||
* Format Unicode text, taking into account bidi capabilities
|
||||
@ -397,6 +399,14 @@ private:
|
||||
nsIFrame* aCurrentFrame,
|
||||
BidiParagraphData* aBpd);
|
||||
|
||||
/**
|
||||
* Position ruby content frames (ruby base/text frame).
|
||||
* Called from RepositionRubyFrame.
|
||||
*/
|
||||
static void RepositionRubyContentFrame(
|
||||
nsIFrame* aFrame, mozilla::WritingMode aFrameWM,
|
||||
const mozilla::LogicalMargin& aBorderPadding);
|
||||
|
||||
/*
|
||||
* Position ruby frames. Called from RepositionFrame.
|
||||
*/
|
||||
@ -475,14 +485,15 @@ private:
|
||||
* Adjust frame positions following their visual order
|
||||
*
|
||||
* @param aFirstChild the first kid
|
||||
* @return total inline size
|
||||
*
|
||||
* @lina 04/11/2000
|
||||
*/
|
||||
static void RepositionInlineFrames(BidiLineData* aBld,
|
||||
nsIFrame* aFirstChild,
|
||||
mozilla::WritingMode aLineWM,
|
||||
const nsSize& aContainerSize,
|
||||
nscoord aStart);
|
||||
static nscoord RepositionInlineFrames(BidiLineData* aBld,
|
||||
nsIFrame* aFirstChild,
|
||||
mozilla::WritingMode aLineWM,
|
||||
const nsSize& aContainerSize,
|
||||
nscoord aStart);
|
||||
|
||||
/**
|
||||
* Helper method for Resolve()
|
||||
|
9
layout/reftests/css-ruby/bug1181890-notref.html
Normal file
9
layout/reftests/css-ruby/bug1181890-notref.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<p style="ruby-align: start">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
||||
<p style="ruby-align: start">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
9
layout/reftests/css-ruby/bug1181890-ref.html
Normal file
9
layout/reftests/css-ruby/bug1181890-ref.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<p style="ruby-align: center">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
||||
<p style="ruby-align: space-between">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
10
layout/reftests/css-ruby/bug1181890.html
Normal file
10
layout/reftests/css-ruby/bug1181890.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<p style="ruby-align: center">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
||||
<p style="ruby-align: space-between">
|
||||
<ruby><rb>A</rb><rt>aaaaaaaaaaaa</rt></ruby>
|
||||
<ruby><rb>BBBBB</rb><rt>b</rt></ruby>
|
||||
</p>
|
||||
‎
|
@ -53,3 +53,5 @@ pref(layout.css.vertical-text.enabled,true) == ruby-position-vertical-rl.html ru
|
||||
== 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
|
||||
== bug1181890.html bug1181890-ref.html
|
||||
!= bug1181890.html bug1181890-notref.html
|
||||
|
Loading…
Reference in New Issue
Block a user