mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add media queries for all of our system metrics exposed in :-moz-system-metric(). (Bug 522149) r=bzbarsky
This commit is contained in:
parent
2c64d5b55a
commit
30ac481d4d
@ -1711,3 +1711,18 @@ GK_ATOM(windows_compositor, "windows-compositor")
|
||||
GK_ATOM(windows_classic, "windows-classic")
|
||||
GK_ATOM(touch_enabled, "touch-enabled")
|
||||
GK_ATOM(maemo_classic, "maemo-classic")
|
||||
|
||||
// And the same again, as media query keywords.
|
||||
GK_ATOM(_moz_scrollbar_start_backward, "-moz-scrollbar-start-backward")
|
||||
GK_ATOM(_moz_scrollbar_start_forward, "-moz-scrollbar-start-forward")
|
||||
GK_ATOM(_moz_scrollbar_end_backward, "-moz-scrollbar-end-backward")
|
||||
GK_ATOM(_moz_scrollbar_end_forward, "-moz-scrollbar-end-forward")
|
||||
GK_ATOM(_moz_scrollbar_thumb_proportional, "-moz-scrollbar-thumb-proportional")
|
||||
GK_ATOM(_moz_images_in_menus, "-moz-images-in-menus")
|
||||
GK_ATOM(_moz_images_in_buttons, "-moz-images-in-buttons")
|
||||
GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme")
|
||||
GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme")
|
||||
GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor")
|
||||
GK_ATOM(_moz_windows_classic, "-moz-windows-classic")
|
||||
GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
|
||||
GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
|
||||
|
@ -1468,6 +1468,9 @@ nsPresContext::ThemeChangedInternal()
|
||||
// This will force the system metrics to be generated the next time they're used
|
||||
nsCSSRuleProcessor::FreeSystemMetrics();
|
||||
|
||||
// Changes to system metrics can change media queries on them.
|
||||
MediaFeatureValuesChanged(PR_TRUE);
|
||||
|
||||
// Changes in theme can change system colors (whose changes are
|
||||
// properly reflected in computed style data), system fonts (whose
|
||||
// changes are not), and -moz-appearance (whose changes likewise are
|
||||
|
@ -879,6 +879,15 @@ nsCSSRuleProcessor::FreeSystemMetrics()
|
||||
sSystemMetrics = nsnull;
|
||||
}
|
||||
|
||||
/* static */ PRBool
|
||||
nsCSSRuleProcessor::HasSystemMetric(nsIAtom* aMetric)
|
||||
{
|
||||
if (!sSystemMetrics && !InitSystemMetrics()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
return sSystemMetrics->IndexOf(aMetric) != sSystemMetrics->NoIndex;
|
||||
}
|
||||
|
||||
RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsRuleWalker* aRuleWalker,
|
||||
@ -1424,13 +1433,9 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||
result = (child == nsnull);
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozSystemMetric == pseudoClass->mAtom) {
|
||||
if (!sSystemMetrics && !InitSystemMetrics()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
NS_ASSERTION(pseudoClass->u.mString, "Must have string!");
|
||||
nsCOMPtr<nsIAtom> metric = do_GetAtom(pseudoClass->u.mString);
|
||||
result = sSystemMetrics->IndexOf(metric) !=
|
||||
sSystemMetrics->NoIndex;
|
||||
result = nsCSSRuleProcessor::HasSystemMetric(metric);
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozHasHandlerRef == pseudoClass->mAtom) {
|
||||
nsIContent *child = nsnull;
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
|
||||
static void Startup();
|
||||
static void FreeSystemMetrics();
|
||||
static PRBool HasSystemMetric(nsIAtom* aMetric);
|
||||
|
||||
/*
|
||||
* Returns true if the given RuleProcessorData matches one of the
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsCSSRuleProcessor.h"
|
||||
|
||||
static const PRInt32 kOrientationKeywords[] = {
|
||||
eCSSKeyword_portrait, NS_STYLE_ORIENTATION_PORTRAIT,
|
||||
@ -260,6 +261,18 @@ GetGrid(nsPresContext* aPresContext, const nsMediaFeature*,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
|
||||
nsCSSValue& aResult)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aFeature->mValueType == nsMediaFeature::eBoolInteger,
|
||||
"unexpected type");
|
||||
nsIAtom *metricAtom = *aFeature->mData.mMetric;
|
||||
PRBool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom);
|
||||
aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adding new media features requires (1) adding the new feature to this
|
||||
* array, with appropriate entries (and potentially any new code needed
|
||||
@ -362,6 +375,100 @@ nsMediaFeatures::features[] = {
|
||||
{ nsnull },
|
||||
GetGrid
|
||||
},
|
||||
|
||||
// Mozilla extensions
|
||||
{
|
||||
&nsGkAtoms::_moz_scrollbar_start_backward,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::scrollbar_start_backward },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_scrollbar_start_forward,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::scrollbar_start_forward },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_scrollbar_end_backward,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::scrollbar_end_backward },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_scrollbar_end_forward,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::scrollbar_end_forward },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_scrollbar_thumb_proportional,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::scrollbar_thumb_proportional },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_images_in_menus,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::images_in_menus },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_images_in_buttons,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::images_in_buttons },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_windows_default_theme,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::windows_default_theme },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_mac_graphite_theme,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::mac_graphite_theme },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_windows_compositor,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::windows_compositor },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_windows_classic,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::windows_classic },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_touch_enabled,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::touch_enabled },
|
||||
GetSystemMetric
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::_moz_maemo_classic,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eBoolInteger,
|
||||
{ &nsGkAtoms::maemo_classic },
|
||||
GetSystemMetric
|
||||
},
|
||||
|
||||
// Null-mName terminator:
|
||||
{
|
||||
nsnull,
|
||||
|
@ -84,6 +84,9 @@ struct nsMediaFeature {
|
||||
// If mValueType == eEnumerated: const PRInt32*: keyword table in
|
||||
// the same format as the keyword tables in nsCSSProps.
|
||||
const PRInt32* mKeywordTable;
|
||||
// If mGetter == GetSystemMetric (which implies mValueType ==
|
||||
// eBoolInteger): nsIAtom * const *, for the system metric.
|
||||
nsIAtom * const * mMetric;
|
||||
} mData;
|
||||
|
||||
// A function that returns the current value for this feature for a
|
||||
|
Loading…
Reference in New Issue
Block a user