Bug 1028716 part 2 - Handle the new orient values in <progress> and <meter> layout. r=smontagu

This commit is contained in:
Jonathan Kew 2014-06-27 11:25:11 +01:00
parent ba44c76dce
commit b68965af5a
4 changed files with 40 additions and 16 deletions

View File

@ -135,7 +135,7 @@ nsMeterFrame::ReflowBarFrame(nsIFrame* aBarFrame,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = StyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL;
bool vertical = ResolvedOrientationIsVertical();
WritingMode wm = aBarFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
@ -158,7 +158,7 @@ nsMeterFrame::ReflowBarFrame(nsIFrame* aBarFrame,
size = NSToCoordRound(size * position);
if (!vertical && StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
if (!vertical && (wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR())) {
xoffset += aReflowState.ComputedWidth() - size;
}
@ -230,7 +230,7 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
LogicalSize autoSize(wm);
autoSize.BSize(wm) = autoSize.ISize(wm) = fontMet->Font().size; // 1em
if (StyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL) {
if (ResolvedOrientationIsVertical()) {
autoSize.Height(wm) *= 5; // 5em
} else {
autoSize.Width(wm) *= 5; // 5em
@ -246,14 +246,14 @@ nsMeterFrame::GetMinISize(nsRenderingContext *aRenderingContext)
NS_ENSURE_SUCCESS(
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0);
nscoord minWidth = fontMet->Font().size; // 1em
nscoord minISize = fontMet->Font().size; // 1em
if (StyleDisplay()->mOrient == NS_STYLE_ORIENT_HORIZONTAL) {
// The orientation is horizontal
minWidth *= 5; // 5em
if (ResolvedOrientationIsVertical() == GetWritingMode().IsVertical()) {
// The orientation is inline
minISize *= 5; // 5em
}
return minWidth;
return minISize;
}
nscoord

View File

@ -139,7 +139,7 @@ nsProgressFrame::ReflowBarFrame(nsIFrame* aBarFrame,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = StyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL;
bool vertical = ResolvedOrientationIsVertical();
WritingMode wm = aBarFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
@ -158,7 +158,7 @@ nsProgressFrame::ReflowBarFrame(nsIFrame* aBarFrame,
size *= position;
}
if (!vertical && StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
if (!vertical && (wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR())) {
xoffset += aReflowState.ComputedWidth() - size;
}
@ -236,7 +236,7 @@ nsProgressFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
NSToCoordRound(StyleFont()->mFont.size *
nsLayoutUtils::FontSizeInflationFor(this)); // 1em
if (StyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL) {
if (ResolvedOrientationIsVertical()) {
autoSize.Height(wm) *= 10; // 10em
} else {
autoSize.Width(wm) *= 10; // 10em
@ -252,14 +252,14 @@ nsProgressFrame::GetMinISize(nsRenderingContext *aRenderingContext)
NS_ENSURE_SUCCESS(
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0);
nscoord minWidth = fontMet->Font().size; // 1em
nscoord minISize = fontMet->Font().size; // 1em
if (StyleDisplay()->mOrient == NS_STYLE_ORIENT_HORIZONTAL) {
// The orientation is horizontal
minWidth *= 10; // 10em
if (ResolvedOrientationIsVertical() == GetWritingMode().IsVertical()) {
// The orientation is inline
minISize *= 10; // 10em
}
return minWidth;
return minISize;
}
nscoord

View File

@ -1679,6 +1679,24 @@ nsContainerFrame::PullNextInFlowChild(ContinuationTraversingState& aState)
return frame;
}
bool
nsContainerFrame::ResolvedOrientationIsVertical()
{
uint8_t orient = StyleDisplay()->mOrient;
switch (orient) {
case NS_STYLE_ORIENT_HORIZONTAL:
return false;
case NS_STYLE_ORIENT_VERTICAL:
return true;
case NS_STYLE_ORIENT_INLINE:
return GetWritingMode().IsVertical();
case NS_STYLE_ORIENT_BLOCK:
return !GetWritingMode().IsVertical();
}
NS_NOTREACHED("unexpected -moz-orient value");
return false;
}
nsOverflowContinuationTracker::nsOverflowContinuationTracker(nsContainerFrame* aFrame,
bool aWalkOOFFrames,
bool aSkipOverflowContainerChildren)

View File

@ -613,6 +613,12 @@ protected:
// ==========================================================================
// Helper used by Progress and Meter frames. Returns true if the bar should
// be rendered vertically, based on writing-mode and -moz-orient properties.
bool ResolvedOrientationIsVertical();
// ==========================================================================
nsFrameList mFrames;
};