diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index b3652e85e662..4c66ae2a30a5 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -203,6 +203,7 @@ nsMeterFrame::ReflowBarFrame(nsIFrame* aBarFrame, xoffset += aReflowState.ComputedWidth() - size; } + // The bar position is *always* constrained. if (vertical) { // We want the bar to begin at the bottom. yoffset += aReflowState.ComputedHeight() - size; @@ -272,3 +273,19 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, return autoSize; } + +bool +nsMeterFrame::ShouldUseNativeStyle() const +{ + // Use the native style if these conditions are satisfied: + // - both frames use the native appearance; + // - neither frame has author specified rules setting the border or the + // background. + return GetStyleDisplay()->mAppearance == NS_THEME_METERBAR && + mBarDiv->GetPrimaryFrame()->GetStyleDisplay()->mAppearance == NS_THEME_METERBAR_CHUNK && + !PresContext()->HasAuthorSpecifiedRules(const_cast(this), + NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND) && + !PresContext()->HasAuthorSpecifiedRules(mBarDiv->GetPrimaryFrame(), + NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND); +} + diff --git a/layout/forms/nsMeterFrame.h b/layout/forms/nsMeterFrame.h index b0685b79d486..c2f3f555770a 100644 --- a/layout/forms/nsMeterFrame.h +++ b/layout/forms/nsMeterFrame.h @@ -91,6 +91,11 @@ public: ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); } + /** + * Returns whether the frame and its child should use the native style. + */ + bool ShouldUseNativeStyle() const; + protected: // Helper function which reflow the anonymous div frame. void ReflowBarFrame(nsIFrame* aBarFrame, diff --git a/widget/reftests/meter-fallback-default-style-ref.html b/widget/reftests/meter-fallback-default-style-ref.html new file mode 100644 index 000000000000..f4263d59175c --- /dev/null +++ b/widget/reftests/meter-fallback-default-style-ref.html @@ -0,0 +1,57 @@ + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/widget/reftests/meter-fallback-default-style.html b/widget/reftests/meter-fallback-default-style.html new file mode 100644 index 000000000000..a5942d7e5515 --- /dev/null +++ b/widget/reftests/meter-fallback-default-style.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/widget/reftests/reftest.list b/widget/reftests/reftest.list index 7200783baf84..5e500bbd14a3 100644 --- a/widget/reftests/reftest.list +++ b/widget/reftests/reftest.list @@ -1,3 +1,4 @@ skip-if(!cocoaWidget) != 507947.html about:blank == progressbar-fallback-default-style.html progressbar-fallback-default-style-ref.html +== meter-fallback-default-style.html meter-fallback-default-style-ref.html load 664925.xhtml diff --git a/widget/xpwidgets/nsNativeTheme.cpp b/widget/xpwidgets/nsNativeTheme.cpp index 5c84001abc30..472be785f1df 100644 --- a/widget/xpwidgets/nsNativeTheme.cpp +++ b/widget/xpwidgets/nsNativeTheme.cpp @@ -19,6 +19,7 @@ #include "nsIComponentManager.h" #include "nsPIDOMWindow.h" #include "nsProgressFrame.h" +#include "nsMeterFrame.h" #include "nsMenuFrame.h" #include "mozilla/dom/Element.h" @@ -247,6 +248,19 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, } } + /** + * Meter bar appearance should be the same for the bar and the container + * frame. nsMeterFrame owns the logic and will tell us what we should do. + */ + if (aWidgetType == NS_THEME_METERBAR_CHUNK || + aWidgetType == NS_THEME_METERBAR) { + nsMeterFrame* meterFrame = do_QueryFrame(aWidgetType == NS_THEME_METERBAR_CHUNK + ? aFrame->GetParent() : aFrame); + if (meterFrame) { + return !meterFrame->ShouldUseNativeStyle(); + } + } + return (aWidgetType == NS_THEME_BUTTON || aWidgetType == NS_THEME_TEXTFIELD || aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||