From a01c16299725a40ac7062abd4ceb30fcf2f42bfd Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Wed, 6 Nov 2013 10:05:18 +0000 Subject: [PATCH] Bug 866659 - Avoid bad cast in nsNativeTheme::IsRangeHorizontal. r=bz --- widget/xpwidgets/nsNativeTheme.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/widget/xpwidgets/nsNativeTheme.cpp b/widget/xpwidgets/nsNativeTheme.cpp index 2dfe2d241ab3..b764fbc89d9a 100644 --- a/widget/xpwidgets/nsNativeTheme.cpp +++ b/widget/xpwidgets/nsNativeTheme.cpp @@ -664,11 +664,15 @@ nsNativeTheme::IsRangeHorizontal(nsIFrame* aFrame) { nsIFrame* rangeFrame = aFrame; if (rangeFrame->GetType() != nsGkAtoms::rangeFrame) { + // If the thumb's frame is passed in, get its range parent: rangeFrame = aFrame->GetParent(); } - MOZ_ASSERT(rangeFrame->GetType() == nsGkAtoms::rangeFrame); - - return static_cast(rangeFrame)->IsHorizontal(); + if (rangeFrame->GetType() == nsGkAtoms::rangeFrame) { + return static_cast(rangeFrame)->IsHorizontal(); + } + // Not actually a range frame - just use the ratio of the frame's size to + // decide: + return aFrame->GetSize().width >= aFrame->GetSize().height; } static nsIFrame*