Bug 1172450 - Size and position the dropdown arrow properly in vertical writing modes. r=smontagu

This commit is contained in:
Jonathan Kew 2015-07-27 16:52:12 +01:00
parent ec0223aadb
commit 8008a0cf86
4 changed files with 25 additions and 18 deletions

View File

@ -733,7 +733,7 @@ nsComboboxControlFrame::GetIntrinsicISize(nsRenderingContext* aRenderingContext,
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
scrollbarWidth = scrollable->GetNondisappearingScrollbarWidth(
presContext, aRenderingContext);
presContext, aRenderingContext, GetWritingMode());
}
nscoord displayISize = 0;
@ -848,6 +848,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
// Get the width of the vertical scrollbar. That will be the inline
// size of the dropdown button.
WritingMode wm = aReflowState.GetWritingMode();
nscoord buttonISize;
const nsStyleDisplay *disp = StyleDisplay();
if ((IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) ||
@ -858,7 +859,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
buttonISize = scrollable->GetNondisappearingScrollbarWidth(
PresContext(), aReflowState.rendContext);
PresContext(), aReflowState.rendContext, wm);
if (buttonISize > aReflowState.ComputedISize()) {
buttonISize = 0;
}
@ -869,8 +870,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// The button should occupy the same space as a scrollbar
WritingMode wm = aReflowState.GetWritingMode();
nsSize containerSize = aReflowState.ComputedSizeAsContainerIfConstrained();
nsSize containerSize = aDesiredSize.PhysicalSize();
LogicalRect buttonRect = mButtonFrame->GetLogicalRect(containerSize);
buttonRect.IStart(wm) =

View File

@ -1042,34 +1042,38 @@ ScrollFrameHelper::GetDesiredScrollbarSizes(nsBoxLayoutState* aState)
}
nscoord
ScrollFrameHelper::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState)
ScrollFrameHelper::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
WritingMode aWM)
{
NS_ASSERTION(aState && aState->GetRenderingContext(),
"Must have rendering context in layout state for size "
"computations");
bool verticalWM = aWM.IsVertical();
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
// We're using overlay scrollbars, so we need to get the width that
// non-disappearing scrollbars would have.
nsITheme* theme = aState->PresContext()->GetTheme();
if (theme &&
theme->ThemeSupportsWidget(aState->PresContext(),
mVScrollbarBox,
verticalWM ? mHScrollbarBox
: mVScrollbarBox,
NS_THEME_SCROLLBAR_NON_DISAPPEARING)) {
LayoutDeviceIntSize size;
bool canOverride = true;
theme->GetMinimumWidgetSize(aState->PresContext(),
mVScrollbarBox,
verticalWM ? mHScrollbarBox
: mVScrollbarBox,
NS_THEME_SCROLLBAR_NON_DISAPPEARING,
&size,
&canOverride);
if (size.width) {
return aState->PresContext()->DevPixelsToAppUnits(size.width);
}
return aState->PresContext()->
DevPixelsToAppUnits(verticalWM ? size.height : size.width);
}
}
return GetDesiredScrollbarSizes(aState).LeftRight();
nsMargin sizes(GetDesiredScrollbarSizes(aState));
return verticalWM ? sizes.TopBottom() : sizes.LeftRight();
}
void

View File

@ -304,7 +304,8 @@ public:
}
nsMargin GetActualScrollbarSizes() const;
nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState);
nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
mozilla::WritingMode aVerticalWM);
bool IsLTR() const;
bool IsScrollbarOnRight() const;
bool IsScrollingActive(nsDisplayListBuilder* aBuilder) const;
@ -691,9 +692,9 @@ public:
return GetDesiredScrollbarSizes(&bls);
}
virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC) override {
nsRenderingContext* aRC, mozilla::WritingMode aWM) override {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();
@ -1095,9 +1096,9 @@ public:
return GetDesiredScrollbarSizes(&bls);
}
virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC) override {
nsRenderingContext* aRC, mozilla::WritingMode aWM) override {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();

View File

@ -107,8 +107,10 @@ public:
/**
* Return the width for non-disappearing scrollbars.
*/
virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC) = 0;
virtual nscoord
GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC,
mozilla::WritingMode aWM) = 0;
/**
* GetScrolledRect is designed to encapsulate deciding which
* directions of overflow should be reachable by scrolling and which