mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
Bug 1140264 part 2 - Move and merge line breaking code in rbc reflow to reduce useless computation and fix undesired break point. r=dbaron
--HG-- extra : rebase_source : 16081f365a95f7ca2abaf9e42abb70cc37193a90 extra : source : 9b63131b3248015451e9fd12f18da327d5a7267c
This commit is contained in:
parent
8d078dffee
commit
b5e5ccaa5b
@ -700,22 +700,38 @@ nsRubyBaseContainerFrame::ReflowOneColumn(const ReflowState& aReflowState,
|
|||||||
{
|
{
|
||||||
const nsHTMLReflowState& baseReflowState = aReflowState.mBaseReflowState;
|
const nsHTMLReflowState& baseReflowState = aReflowState.mBaseReflowState;
|
||||||
const auto& textReflowStates = aReflowState.mTextReflowStates;
|
const auto& textReflowStates = aReflowState.mTextReflowStates;
|
||||||
|
nscoord istart = baseReflowState.mLineLayout->GetCurrentICoord();
|
||||||
|
|
||||||
if (aColumn.mBaseFrame) {
|
if (aColumn.mBaseFrame) {
|
||||||
int32_t pos = baseReflowState.mLineLayout->
|
bool allowBreakBefore = aColumnIndex ?
|
||||||
GetForcedBreakPosition(aColumn.mBaseFrame);
|
aReflowState.mAllowLineBreak : aReflowState.mAllowInitialLineBreak;
|
||||||
MOZ_ASSERT(pos == -1 || pos == 0,
|
if (allowBreakBefore) {
|
||||||
"It should either break before, or not break at all.");
|
gfxBreakPriority breakPriority = LineBreakBefore(
|
||||||
if (pos >= 0) {
|
aColumn.mBaseFrame, baseReflowState.rendContext,
|
||||||
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
baseReflowState.mLineLayout->LineContainerFrame(),
|
||||||
return 0;
|
baseReflowState.mLineLayout->GetLine());
|
||||||
|
if (breakPriority != gfxBreakPriority::eNoBreak) {
|
||||||
|
int32_t offset;
|
||||||
|
gfxBreakPriority lastBreakPriority;
|
||||||
|
baseReflowState.mLineLayout->
|
||||||
|
GetLastOptionalBreakPosition(&offset, &lastBreakPriority);
|
||||||
|
if (breakPriority >= lastBreakPriority) {
|
||||||
|
// Either we have been overflow, or we are forced
|
||||||
|
// to break here, do break before.
|
||||||
|
if (istart > baseReflowState.AvailableISize() ||
|
||||||
|
baseReflowState.mLineLayout->NotifyOptionalBreakPosition(
|
||||||
|
aColumn.mBaseFrame, 0, true, breakPriority)) {
|
||||||
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t rtcCount = aReflowState.mTextContainers.Length();
|
const uint32_t rtcCount = aReflowState.mTextContainers.Length();
|
||||||
MOZ_ASSERT(aColumn.mTextFrames.Length() == rtcCount);
|
MOZ_ASSERT(aColumn.mTextFrames.Length() == rtcCount);
|
||||||
MOZ_ASSERT(textReflowStates.Length() == rtcCount);
|
MOZ_ASSERT(textReflowStates.Length() == rtcCount);
|
||||||
nscoord istart = baseReflowState.mLineLayout->GetCurrentICoord();
|
|
||||||
nscoord columnISize = 0;
|
nscoord columnISize = 0;
|
||||||
|
|
||||||
nsAutoString baseText;
|
nsAutoString baseText;
|
||||||
@ -773,42 +789,10 @@ nsRubyBaseContainerFrame::ReflowOneColumn(const ReflowState& aReflowState,
|
|||||||
"Any line break inside ruby box should has been suppressed");
|
"Any line break inside ruby box should has been suppressed");
|
||||||
nscoord baseISize = lineLayout->GetCurrentICoord() - baseIStart;
|
nscoord baseISize = lineLayout->GetCurrentICoord() - baseIStart;
|
||||||
columnISize = std::max(columnISize, baseISize);
|
columnISize = std::max(columnISize, baseISize);
|
||||||
|
|
||||||
bool allowBreakBefore = aColumnIndex ?
|
|
||||||
aReflowState.mAllowLineBreak : aReflowState.mAllowInitialLineBreak;
|
|
||||||
if (allowBreakBefore) {
|
|
||||||
bool shouldBreakBefore = false;
|
|
||||||
gfxBreakPriority breakPriority = LineBreakBefore(
|
|
||||||
aColumn.mBaseFrame, baseReflowState.rendContext,
|
|
||||||
baseReflowState.mLineLayout->LineContainerFrame(),
|
|
||||||
baseReflowState.mLineLayout->GetLine());
|
|
||||||
if (breakPriority != gfxBreakPriority::eNoBreak) {
|
|
||||||
int32_t offset;
|
|
||||||
gfxBreakPriority lastBreakPriority;
|
|
||||||
baseReflowState.mLineLayout->
|
|
||||||
GetLastOptionalBreakPosition(&offset, &lastBreakPriority);
|
|
||||||
shouldBreakBefore = breakPriority >= lastBreakPriority;
|
|
||||||
}
|
|
||||||
if (shouldBreakBefore) {
|
|
||||||
bool fits = istart <= baseReflowState.AvailableISize();
|
|
||||||
DebugOnly<bool> breakBefore =
|
|
||||||
baseReflowState.mLineLayout->NotifyOptionalBreakPosition(
|
|
||||||
aColumn.mBaseFrame, 0, fits, breakPriority);
|
|
||||||
MOZ_ASSERT(!breakBefore, "The break notified here should have "
|
|
||||||
"triggered at the start of this method.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nscoord icoord = istart + columnISize;
|
|
||||||
// If we can break here, do it now.
|
|
||||||
if (icoord > baseReflowState.AvailableISize() &&
|
|
||||||
baseReflowState.mLineLayout->HasOptionalBreakPosition()) {
|
|
||||||
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Align all the line layout to the new coordinate.
|
// Align all the line layout to the new coordinate.
|
||||||
|
nscoord icoord = istart + columnISize;
|
||||||
nscoord deltaISize = icoord - baseReflowState.mLineLayout->GetCurrentICoord();
|
nscoord deltaISize = icoord - baseReflowState.mLineLayout->GetCurrentICoord();
|
||||||
if (deltaISize > 0) {
|
if (deltaISize > 0) {
|
||||||
baseReflowState.mLineLayout->AdvanceICoord(deltaISize);
|
baseReflowState.mLineLayout->AdvanceICoord(deltaISize);
|
||||||
|
Loading…
Reference in New Issue
Block a user