mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
Bug 663365 - Implement the rules for the fallback to the default rendering for the meter element. r=roc
--HG-- rename : widget/reftests/progressbar-fallback-default-style-ref.html => widget/reftests/meter-fallback-default-style-ref.html rename : widget/reftests/progressbar-fallback-default-style.html => widget/reftests/meter-fallback-default-style.html
This commit is contained in:
parent
6d2bb3dfaa
commit
8aee8c7ad2
@ -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<nsMeterFrame*>(this),
|
||||
NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND) &&
|
||||
!PresContext()->HasAuthorSpecifiedRules(mBarDiv->GetPrimaryFrame(),
|
||||
NS_AUTHOR_SPECIFIED_BORDER | NS_AUTHOR_SPECIFIED_BACKGROUND);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
57
widget/reftests/meter-fallback-default-style-ref.html
Normal file
57
widget/reftests/meter-fallback-default-style-ref.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>
|
||||
div.meter-element {
|
||||
/**
|
||||
* The purpose of this test is to not show the native style.
|
||||
* -moz-appearance: meterbar;
|
||||
*/
|
||||
display: inline-block;
|
||||
height: 1em;
|
||||
width: 5em;
|
||||
vertical-align: -0.2em;
|
||||
|
||||
background: -moz-linear-gradient(top, #e6e6e6, #e6e6e6, #eeeeee 20%, #cccccc 45%, #cccccc 55%);
|
||||
}
|
||||
|
||||
div.meter-bar {
|
||||
/**
|
||||
* The purpose of this test is to not show the native style.
|
||||
* -moz-appearance: meterchunk;
|
||||
*/
|
||||
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
background: -moz-linear-gradient(top, #ad7, #ad7, #cea 20%, #7a3 45%, #7a3 55%);
|
||||
}
|
||||
|
||||
div.meter-element { padding: 5px; }
|
||||
body > div:nth-child(1) { -moz-appearance: none; }
|
||||
body > div:nth-child(2) > .meter-bar { -moz-appearance: none; }
|
||||
body > div:nth-child(3) { background: red; }
|
||||
body > div:nth-child(4) > .meter-bar { background: red; }
|
||||
body > div:nth-child(5) { border: 2px solid red; }
|
||||
body > div:nth-child(6) > .meter-bar { border: 5px solid red; width: -moz-calc(100% - 10px); }
|
||||
</style>
|
||||
<body>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
<div class="meter-element">
|
||||
<div class="meter-bar"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
20
widget/reftests/meter-fallback-default-style.html
Normal file
20
widget/reftests/meter-fallback-default-style.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>
|
||||
meter { padding: 5px }
|
||||
body > meter:nth-child(1) { -moz-appearance: none; }
|
||||
body > meter:nth-child(2)::-moz-meter-bar { -moz-appearance: none; }
|
||||
body > meter:nth-child(3) { background: red; }
|
||||
body > meter:nth-child(4)::-moz-meter-bar { background: red; }
|
||||
body > meter:nth-child(5) { border: 2px solid red; }
|
||||
body > meter:nth-child(6)::-moz-meter-bar { border: 5px solid red; }
|
||||
</style>
|
||||
<body>
|
||||
<meter value=1></meter>
|
||||
<meter value=1></meter>
|
||||
<meter value=1></meter>
|
||||
<meter value=1></meter>
|
||||
<meter value=1></meter>
|
||||
<meter value=1></meter>
|
||||
</body>
|
||||
</html>
|
@ -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
|
||||
|
@ -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 ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user