diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 6aef109a0cf..950cfb331ad 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -582,6 +582,12 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext, } if (hasOverflowClip) { + // XXX We should be able to replace the next 14 lines with just + // overflowClipRect.Deflate(aFrame->GetUsedBorderAndPadding()); + // but unfortunately this function gets called during frame + // construction (why?), and GetUsedBorderAndPadding asserts when + // called on a frame that hasn't been reflowed yet (for good + // reason). const nsStyleBorder* borderStyle = aStyleContext->GetStyleBorder(); const nsStylePadding* paddingStyle = aStyleContext->GetStylePadding(); diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 4f3b6c0b024..81e7812eacb 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -713,6 +713,24 @@ nsIFrame::GetUsedBorder() const (GetStateBits() & NS_FRAME_IN_REFLOW), "cannot call on a dirty frame not currently being reflowed"); + // Theme methods don't use const-ness. + nsIFrame *mutable_this = NS_CONST_CAST(nsIFrame*, this); + + const nsStyleDisplay *disp = GetStyleDisplay(); + if (mutable_this->IsThemed(disp)) { + nsMargin result; + nsPresContext *presContext = GetPresContext(); + presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), + mutable_this, disp->mAppearance, + &result); + float p2t = presContext->ScaledPixelsToTwips(); + result.top = NSIntPixelsToTwips(result.top, p2t); + result.right = NSIntPixelsToTwips(result.right, p2t); + result.bottom = NSIntPixelsToTwips(result.bottom, p2t); + result.left = NSIntPixelsToTwips(result.left, p2t); + return result; + } + return GetStyleBorder()->GetBorder(); } @@ -725,6 +743,25 @@ nsIFrame::GetUsedPadding() const "cannot call on a dirty frame not currently being reflowed"); nsMargin padding(0, 0, 0, 0); + + // Theme methods don't use const-ness. + nsIFrame *mutable_this = NS_CONST_CAST(nsIFrame*, this); + + const nsStyleDisplay *disp = GetStyleDisplay(); + if (mutable_this->IsThemed(disp)) { + nsPresContext *presContext = GetPresContext(); + if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(), + mutable_this, + disp->mAppearance, + &padding)) { + float p2t = presContext->ScaledPixelsToTwips(); + padding.top = NSIntPixelsToTwips(padding.top, p2t); + padding.right = NSIntPixelsToTwips(padding.right, p2t); + padding.bottom = NSIntPixelsToTwips(padding.bottom, p2t); + padding.left = NSIntPixelsToTwips(padding.left, p2t); + return padding; + } + } if (!GetStylePadding()->GetPadding(padding)) { nsMargin *p = NS_STATIC_CAST(nsMargin*, GetProperty(nsGkAtoms::usedPaddingProperty)); @@ -3040,6 +3077,26 @@ nsFrame::IntrinsicWidthOffsets(nsIRenderingContext* aRenderingContext) result.hBorder += styleBorder->GetBorderWidth(NS_SIDE_LEFT); result.hBorder += styleBorder->GetBorderWidth(NS_SIDE_RIGHT); + const nsStyleDisplay *disp = GetStyleDisplay(); + if (IsThemed(disp)) { + nsPresContext *presContext = GetPresContext(); + float p2t = presContext->ScaledPixelsToTwips(); + + nsMargin border; + presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), + this, disp->mAppearance, + &border); + result.hBorder = NSIntPixelsToTwips(border.LeftRight(), p2t); + + nsMargin padding; + if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(), + this, disp->mAppearance, + &padding)) { + result.hPadding = NSIntPixelsToTwips(padding.LeftRight(), p2t); + result.hPctPadding = 0; + } + } + return result; } diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp index 38ed9f9cffd..d8d9e8f3786 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.cpp +++ b/mozilla/layout/style/nsComputedDOMStyle.cpp @@ -2989,7 +2989,20 @@ nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue) nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); - val->SetTwips(GetStyleBorder()->GetComputedBorderWidth(aSide)); + nscoord width; + const nsStyleDisplay *disp = GetStyleDisplay(); + if (mFrame->IsThemed(disp)) { + nsMargin result; + nsPresContext *presContext = mFrame->GetPresContext(); + presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(), + mFrame, disp->mAppearance, + &result); + width = NSIntPixelsToTwips(result.side(aSide), + presContext->ScaledPixelsToTwips()); + } else { + width = GetStyleBorder()->GetComputedBorderWidth(aSide); + } + val->SetTwips(width); return CallQueryInterface(val, aValue); }