From 8008a0cf863bfd7b0779f1991603d51b23187494 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Mon, 27 Jul 2015 16:52:12 +0100 Subject: [PATCH] Bug 1172450 - Size and position the dropdown arrow properly in vertical writing modes. r=smontagu --- layout/forms/nsComboboxControlFrame.cpp | 8 ++++---- layout/generic/nsGfxScrollFrame.cpp | 18 +++++++++++------- layout/generic/nsGfxScrollFrame.h | 11 ++++++----- layout/generic/nsIScrollableFrame.h | 6 ++++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index e998213d058..6be4b78483a 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -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) = diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 58074312017..3dbdb238ab5 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -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 diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 47fb0a475bb..d7b06b89500 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -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(); diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 035f8632c09..eb7f611fbe0 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -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