diff --git a/extensions/xmlterm/base/mozXMLTermStream.cpp b/extensions/xmlterm/base/mozXMLTermStream.cpp index 543a0506e2e7..c9593e222f84 100644 --- a/extensions/xmlterm/base/mozXMLTermStream.cpp +++ b/extensions/xmlterm/base/mozXMLTermStream.cpp @@ -56,7 +56,6 @@ #include "nsIViewManager.h" #include "nsIScrollableView.h" -#include "nsIDeviceContext.h" #include "nsIFrame.h" #include "nsICategoryManager.h" @@ -380,20 +379,12 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) if (NS_FAILED(result) || !scrollableView) return NS_ERROR_FAILURE; - // Get device context - nsCOMPtr deviceContext; - result = mozXMLTermUtils::GetPresContextDeviceContext(presContext, - getter_AddRefs(deviceContext)); - if (NS_FAILED(result) || !deviceContext) - return NS_ERROR_FAILURE; - // Determine twips to pixels conversion factor float pixelScale; pixelScale = presContext->TwipsToPixels(); - // Get scrollbar dimensions in pixels - float sbWidth, sbHeight; - deviceContext->GetScrollBarDimensions(sbWidth, sbHeight); + // Get scrollbar dimensions in pixels. Ideally we'd measure the actual scrollbars here. + float sbWidth = 15.0, sbHeight = 15.0; PRInt32 scrollBarWidth = PRInt32(sbWidth*pixelScale); PRInt32 scrollBarHeight = PRInt32(sbHeight*pixelScale); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index eed89790c1db..438b964ef7ef 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -89,6 +89,7 @@ #include "nsContentCreatorFunctions.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" +#include "nsBoxLayoutState.h" NS_IMETHODIMP nsComboboxControlFrame::RedisplayTextEvent::Run() @@ -659,15 +660,13 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, // First reflow our dropdown so that we know how tall we should be. ReflowDropdown(aPresContext, aReflowState); - // Get the default size of the scrollbar. - // That will be the default width of the dropdown button. - // The height will be the height of the text - // Can we cache this in a meaningful way? - float w, h; - // Get the width in Device pixels times p2t - aPresContext->DeviceContext()->GetScrollBarDimensions(w, h); - - nscoord buttonWidth = NSToCoordRound(w); + // Get the width of the vertical scrollbar. That will be the width of the + // dropdown button. + nsIScrollableFrame* scrollable; + CallQueryInterface(mListControlFrame, &scrollable); + NS_ASSERTION(scrollable, "List must be a scrollable frame"); + nsBoxLayoutState bls(GetPresContext(), aReflowState.rendContext); + nscoord buttonWidth = scrollable->GetDesiredScrollbarSizes(&bls).LeftRight(); if (buttonWidth > aReflowState.mComputedWidth) { buttonWidth = 0; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index b6d47d7b4fe9..7c5ab7131d24 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1360,24 +1360,18 @@ nsTextControlFrame::CalcIntrinsicSize(nsIRenderingContext* aRenderingContext, // Add in the size of the scrollbars for textarea if (IsTextArea()) { - float p2t; - p2t = presContext->PixelsToTwips(); + nsIFrame* first = GetFirstChild(nsnull); - nsIDeviceContext *dx = presContext->DeviceContext(); + nsIScrollableFrame *scrollableFrame; + CallQueryInterface(first, &scrollableFrame); + NS_ASSERTION(scrollableFrame, "Child must be scrollable"); - float scale; - dx->GetCanonicalPixelScale(scale); + nsBoxLayoutState bls(GetPresContext(), aRenderingContext); + nsMargin scrollbarSizes = scrollableFrame->GetDesiredScrollbarSizes(&bls); - float sbWidth; - float sbHeight; - dx->GetScrollBarDimensions(sbWidth, sbHeight); - - nscoord scrollbarWidth = PRInt32(sbWidth * scale); - nscoord scrollbarHeight = PRInt32(sbHeight * scale); - - aIntrinsicSize.height += scrollbarHeight; - - aIntrinsicSize.width += scrollbarWidth; + aIntrinsicSize.width += scrollbarSizes.LeftRight(); + + aIntrinsicSize.height += scrollbarSizes.TopBottom();; } return NS_OK;