diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index bcce3c17c88b..49a8a620cf3c 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10408,7 +10408,7 @@ nsSize nsFrame::GetXULMinSize(nsBoxLayoutState& aState) { // get our size in CSS. bool widthSet, heightSet; bool completelyRedefined = - nsIFrame::AddXULMinSize(this, size, widthSet, heightSet); + nsIFrame::AddXULMinSize(aState, this, size, widthSet, heightSet); // Refresh our caches with new sizes. if (!completelyRedefined) { diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index becd5b51d4f6..18aad0692620 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1665,7 +1665,7 @@ nsSize nsXULScrollFrame::GetXULMinSize(nsBoxLayoutState& aState) { AddBorderAndPadding(min); bool widthSet, heightSet; - nsIFrame::AddXULMinSize(this, min, widthSet, heightSet); + nsIFrame::AddXULMinSize(aState, this, min, widthSet, heightSet); return min; } diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index ca7afd4ae012..402030fd3412 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -3848,8 +3848,8 @@ class nsIFrame : public nsQueryFrame { static bool AddXULPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet); - static bool AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, - bool& aHeightSet); + static bool AddXULMinSize(nsBoxLayoutState& aState, nsIFrame* aBox, + nsSize& aSize, bool& aWidth, bool& aHeightSet); static bool AddXULMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet); static bool AddXULFlex(nsIFrame* aBox, nscoord& aFlex); diff --git a/layout/xul/grid/nsGrid.cpp b/layout/xul/grid/nsGrid.cpp index ebcc35aa36c6..95a9a8012a03 100644 --- a/layout/xul/grid/nsGrid.cpp +++ b/layout/xul/grid/nsGrid.cpp @@ -796,7 +796,7 @@ nscoord nsGrid::GetMinRowHeight(nsBoxLayoutState& aState, int32_t aIndex, if (box) { bool widthSet, heightSet; nsSize cssSize(-1, -1); - nsIFrame::AddXULMinSize(box, cssSize, widthSet, heightSet); + nsIFrame::AddXULMinSize(aState, box, cssSize, widthSet, heightSet); row->mMin = GET_HEIGHT(cssSize, aIsHorizontal); diff --git a/layout/xul/nsBox.cpp b/layout/xul/nsBox.cpp index 675cba7f9ece..ab3a807c40e6 100644 --- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -229,7 +229,7 @@ nsSize nsBox::GetXULMinSize(nsBoxLayoutState& aState) { AddBorderAndPadding(min); bool widthSet, heightSet; - nsIFrame::AddXULMinSize(this, min, widthSet, heightSet); + nsIFrame::AddXULMinSize(aState, this, min, widthSet, heightSet); return min; } @@ -421,30 +421,28 @@ static nscoord GetScrollbarWidthNoTheme(nsIFrame* aBox) { } } -bool nsIFrame::AddXULMinSize(nsIFrame* aBox, +bool nsIFrame::AddXULMinSize(nsBoxLayoutState& aState, nsIFrame* aBox, nsSize& aSize, bool& aWidthSet, bool& aHeightSet) { aWidthSet = false; aHeightSet = false; bool canOverride = true; - nsPresContext* pc = aBox->PresContext(); - // See if a native theme wants to supply a minimum size. const nsStyleDisplay* display = aBox->StyleDisplay(); if (display->HasAppearance()) { - nsITheme* theme = pc->GetTheme(); - if (theme && theme->ThemeSupportsWidget(pc, aBox, + nsITheme* theme = aState.PresContext()->GetTheme(); + if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) { LayoutDeviceIntSize size; - theme->GetMinimumWidgetSize(pc, aBox, + theme->GetMinimumWidgetSize(aState.PresContext(), aBox, display->mAppearance, &size, &canOverride); if (size.width) { - aSize.width = pc->DevPixelsToAppUnits(size.width); + aSize.width = aState.PresContext()->DevPixelsToAppUnits(size.width); aWidthSet = true; } if (size.height) { - aSize.height = pc->DevPixelsToAppUnits(size.height); + aSize.height = aState.PresContext()->DevPixelsToAppUnits(size.height); aHeightSet = true; } } else { diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index eb119cd35d6a..b55f55a11fa3 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -606,7 +606,8 @@ nsSize nsBoxFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) { // if the size was not completely redefined in CSS then ask our children bool widthSet, heightSet; - if (!nsIFrame::AddXULMinSize(this, size, widthSet, heightSet)) { + if (!nsIFrame::AddXULMinSize(aBoxLayoutState, this, size, widthSet, + heightSet)) { if (mLayoutManager) { nsSize layoutSize = mLayoutManager->GetXULMinSize(this, aBoxLayoutState); if (!widthSet) size.width = layoutSize.width; diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 8d3df8718a64..ceb9753ec6b8 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -736,7 +736,7 @@ nsSize nsImageBoxFrame::GetXULMinSize(nsBoxLayoutState& aState) { DISPLAY_MIN_SIZE(this, size); AddBorderAndPadding(size); bool widthSet, heightSet; - nsIFrame::AddXULMinSize(this, size, widthSet, heightSet); + nsIFrame::AddXULMinSize(aState, this, size, widthSet, heightSet); return size; } diff --git a/layout/xul/nsScrollbarFrame.cpp b/layout/xul/nsScrollbarFrame.cpp index e1f4e74fb74b..3fdc025a794c 100644 --- a/layout/xul/nsScrollbarFrame.cpp +++ b/layout/xul/nsScrollbarFrame.cpp @@ -163,47 +163,39 @@ nsIScrollbarMediator* nsScrollbarFrame::GetScrollbarMediator() { } nsresult nsScrollbarFrame::GetXULMargin(nsMargin& aMargin) { + nsresult rv = NS_ERROR_FAILURE; aMargin.SizeTo(0, 0, 0, 0); - const bool overlayScrollbars = - !!LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars); - - const bool horizontal = IsXULHorizontal(); - bool didSetMargin = false; - - if (overlayScrollbars) { - nsSize minSize; - bool widthSet = false; - bool heightSet = false; - AddXULMinSize(this, minSize, widthSet, heightSet); - if (horizontal) { - if (heightSet) { - aMargin.top = -minSize.height; - didSetMargin = true; - } - } else { - if (widthSet) { - aMargin.left = -minSize.width; - didSetMargin = true; + if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) { + nsPresContext* presContext = PresContext(); + nsITheme* theme = presContext->GetTheme(); + if (theme && theme->ThemeSupportsWidget(presContext, this, + StyleAppearance::Scrollbar)) { + LayoutDeviceIntSize size; + bool isOverridable; + theme->GetMinimumWidgetSize(presContext, this, StyleAppearance::Scrollbar, + &size, &isOverridable); + if (IsXULHorizontal()) { + aMargin.top = -presContext->DevPixelsToAppUnits(size.height); + } else { + aMargin.left = -presContext->DevPixelsToAppUnits(size.width); } + rv = NS_OK; } } - if (!didSetMargin) { - DebugOnly rv = nsBox::GetXULMargin(aMargin); - // TODO(emilio): Should probably not be fallible, it's not like anybody - // cares about the return value anyway. - MOZ_ASSERT(NS_SUCCEEDED(rv), "nsBox::GetXULMargin can't really fail"); + if (NS_FAILED(rv)) { + rv = nsBox::GetXULMargin(aMargin); } - if (!horizontal) { + if (NS_SUCCEEDED(rv) && !IsXULHorizontal()) { nsIScrollbarMediator* scrollFrame = GetScrollbarMediator(); if (scrollFrame && !scrollFrame->IsScrollbarOnRight()) { std::swap(aMargin.left, aMargin.right); } } - return NS_OK; + return rv; } void nsScrollbarFrame::SetIncrementToLine(int32_t aDirection) { diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index eaba4e730392..cf970d27af36 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -1080,7 +1080,7 @@ nsSize nsTextBoxFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) { AddBorderAndPadding(size); bool widthSet, heightSet; - nsIFrame::AddXULMinSize(this, size, widthSet, heightSet); + nsIFrame::AddXULMinSize(aBoxLayoutState, this, size, widthSet, heightSet); return size; } diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 57e398a88821..f2f9ed7d7fe5 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -192,7 +192,7 @@ nsSize nsTreeBodyFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) { AddBorderAndPadding(min); bool widthSet, heightSet; - nsIFrame::AddXULMinSize(this, min, widthSet, heightSet); + nsIFrame::AddXULMinSize(aBoxLayoutState, this, min, widthSet, heightSet); return min; } diff --git a/toolkit/themes/mobile/global/scrollbars.css b/toolkit/themes/mobile/global/scrollbars.css index b9692f384866..c81421e82d61 100644 --- a/toolkit/themes/mobile/global/scrollbars.css +++ b/toolkit/themes/mobile/global/scrollbars.css @@ -20,7 +20,10 @@ xul|scrollbar { display: block; } +/* Scrollbar code will reset the margin to the correct side depending on + where layout actually puts the scrollbar */ xul|scrollbar[orient="vertical"] { + margin-left: -6px; min-width: 6px; max-width: 6px; } @@ -32,6 +35,7 @@ xul|scrollbar[orient="vertical"] xul|thumb { } xul|scrollbar[orient="horizontal"] { + margin-top: -6px; min-height: 6px; max-height: 6px; }