mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 543910 - Layout support for -moz-windows-theme. r=dbaron, a=final.
This commit is contained in:
parent
00bcc039b2
commit
4aed135ef5
@ -1757,11 +1757,20 @@ GK_ATOM(images_in_buttons, "images-in-buttons")
|
||||
GK_ATOM(windows_default_theme, "windows-default-theme")
|
||||
GK_ATOM(mac_graphite_theme, "mac-graphite-theme")
|
||||
GK_ATOM(windows_compositor, "windows-compositor")
|
||||
GK_ATOM(windows_classic, "windows-classic")
|
||||
GK_ATOM(touch_enabled, "touch-enabled")
|
||||
GK_ATOM(maemo_classic, "maemo-classic")
|
||||
GK_ATOM(menubar_drag, "menubar-drag")
|
||||
|
||||
// windows theme selector metrics
|
||||
GK_ATOM(windows_classic, "windows-classic")
|
||||
GK_ATOM(windows_theme_aero, "windows-theme-aero")
|
||||
GK_ATOM(windows_theme_luna_blue, "windows-theme-luna-blue")
|
||||
GK_ATOM(windows_theme_luna_olive, "windows-theme-luna-olive")
|
||||
GK_ATOM(windows_theme_luna_silver, "windows-theme-luna-silver")
|
||||
GK_ATOM(windows_theme_royale, "windows-theme-royale")
|
||||
GK_ATOM(windows_theme_zune, "windows-theme-zune")
|
||||
GK_ATOM(windows_theme_generic, "windows-theme-generic")
|
||||
|
||||
// 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")
|
||||
@ -1774,6 +1783,7 @@ 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_windows_theme, "-moz-windows-theme")
|
||||
GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
|
||||
GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
|
||||
GK_ATOM(_moz_menubar_drag, "-moz-menubar-drag")
|
||||
|
@ -1835,6 +1835,9 @@ CSSParserImpl::ParseMediaQueryExpression(nsMediaQuery* aQuery)
|
||||
rv = ParseVariant(expr->mValue, VARIANT_KEYWORD,
|
||||
feature->mData.mKeywordTable);
|
||||
break;
|
||||
case nsMediaFeature::eIdent:
|
||||
rv = ParseVariant(expr->mValue, VARIANT_IDENTIFIER, nsnull);
|
||||
break;
|
||||
}
|
||||
if (!rv || !ExpectSymbol(')', PR_TRUE)) {
|
||||
REPORT_UNEXPECTED(PEMQExpectedFeatureValue);
|
||||
|
@ -103,6 +103,10 @@ static PRBool gSupportVisitedPseudo = PR_TRUE;
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static nsTArray< nsCOMPtr<nsIAtom> >* sSystemMetrics = 0;
|
||||
|
||||
#ifdef XP_WIN
|
||||
PRUint8 nsCSSRuleProcessor::sWinThemeId = nsILookAndFeel::eWindowsTheme_Generic;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A struct representing a given CSS rule and a particular selector
|
||||
* from that rule's selector list.
|
||||
@ -1036,6 +1040,36 @@ InitSystemMetrics()
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::maemo_classic);
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetric_WindowsThemeIdentifier,
|
||||
metricResult))) {
|
||||
nsCSSRuleProcessor::SetWindowsThemeIdentifier(static_cast<PRUint8>(metricResult));
|
||||
switch(metricResult) {
|
||||
case nsILookAndFeel::eWindowsTheme_Aero:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_aero);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_LunaBlue:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_blue);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_LunaOlive:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_olive);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_LunaSilver:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_luna_silver);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_Royale:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_royale);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_Zune:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_zune);
|
||||
break;
|
||||
case nsILookAndFeel::eWindowsTheme_Generic:
|
||||
sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_generic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -1063,6 +1097,16 @@ nsCSSRuleProcessor::HasSystemMetric(nsIAtom* aMetric)
|
||||
return sSystemMetrics->IndexOf(aMetric) != sSystemMetrics->NoIndex;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
/* static */ PRUint8
|
||||
nsCSSRuleProcessor::GetWindowsThemeIdentifier()
|
||||
{
|
||||
if (!sSystemMetrics)
|
||||
InitSystemMetrics();
|
||||
return sWinThemeId;
|
||||
}
|
||||
#endif
|
||||
|
||||
RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
Element* aElement,
|
||||
nsRuleWalker* aRuleWalker,
|
||||
|
@ -125,6 +125,14 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Cached theme identifier for the moz-windows-theme media query.
|
||||
static PRUint8 GetWindowsThemeIdentifier();
|
||||
static void SetWindowsThemeIdentifier(PRUint8 aId) {
|
||||
sWinThemeId = aId;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
static PRBool CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData);
|
||||
|
||||
@ -142,6 +150,10 @@ private:
|
||||
|
||||
// type of stylesheet using this processor
|
||||
PRUint8 mSheetType; // == nsStyleSet::sheetType
|
||||
|
||||
#ifdef XP_WIN
|
||||
static PRUint8 sWinThemeId;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsCSSRuleProcessor_h_ */
|
||||
|
@ -316,6 +316,17 @@ nsMediaExpression::Matches(nsPresContext *aPresContext,
|
||||
cmp = DoCompare(actual.GetIntValue(), required.GetIntValue());
|
||||
}
|
||||
break;
|
||||
case nsMediaFeature::eIdent:
|
||||
{
|
||||
NS_ASSERTION(actual.GetUnit() == eCSSUnit_Ident,
|
||||
"bad actual value");
|
||||
NS_ASSERTION(required.GetUnit() == eCSSUnit_Ident,
|
||||
"bad required value");
|
||||
NS_ASSERTION(mFeature->mRangeType == nsMediaFeature::eMinMaxNotAllowed,
|
||||
"bad range");
|
||||
cmp = !(actual == required); // string comparison
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (mRange) {
|
||||
case nsMediaExpression::eMin:
|
||||
@ -478,6 +489,11 @@ nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
feature->mData.mKeywordTable),
|
||||
aString);
|
||||
break;
|
||||
case nsMediaFeature::eIdent:
|
||||
NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Ident,
|
||||
"bad unit");
|
||||
aString.Append(expr.mValue.GetStringBufferValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsCSSRuleProcessor.h"
|
||||
|
||||
static const PRInt32 kOrientationKeywords[] = {
|
||||
@ -60,6 +61,24 @@ static const PRInt32 kScanKeywords[] = {
|
||||
eCSSKeyword_UNKNOWN, -1
|
||||
};
|
||||
|
||||
#ifdef XP_WIN
|
||||
struct WindowsThemeName {
|
||||
nsILookAndFeel::WindowsThemeIdentifier id;
|
||||
const wchar_t* name;
|
||||
};
|
||||
|
||||
// Windows theme identities used in the -moz-windows-theme media query.
|
||||
const WindowsThemeName themeStrings[] = {
|
||||
{ nsILookAndFeel::eWindowsTheme_Aero, L"aero" },
|
||||
{ nsILookAndFeel::eWindowsTheme_LunaBlue, L"luna-blue" },
|
||||
{ nsILookAndFeel::eWindowsTheme_LunaOlive, L"luna-olive" },
|
||||
{ nsILookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" },
|
||||
{ nsILookAndFeel::eWindowsTheme_Royale, L"royale" },
|
||||
{ nsILookAndFeel::eWindowsTheme_Zune, L"zune" },
|
||||
{ nsILookAndFeel::eWindowsTheme_Generic, L"generic" }
|
||||
};
|
||||
#endif
|
||||
|
||||
// A helper for four features below
|
||||
static nsSize
|
||||
GetSize(nsPresContext* aPresContext)
|
||||
@ -280,6 +299,31 @@ GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetWindowsTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
|
||||
nsCSSValue& aResult)
|
||||
{
|
||||
aResult.Reset();
|
||||
#ifdef XP_WIN
|
||||
PRUint8 windowsThemeId =
|
||||
nsCSSRuleProcessor::GetWindowsThemeIdentifier();
|
||||
|
||||
// Classic mode should fail to match.
|
||||
if (windowsThemeId == nsILookAndFeel::eWindowsTheme_Classic)
|
||||
return NS_OK;
|
||||
|
||||
// Look up the appropriate theme string
|
||||
for (size_t i = 0; i < NS_ARRAY_LENGTH(themeStrings); ++i) {
|
||||
if (windowsThemeId == themeStrings[i].id) {
|
||||
aResult.SetStringValue(nsDependentString(themeStrings[i].name),
|
||||
eCSSUnit_Ident);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
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
|
||||
@ -489,7 +533,13 @@ nsMediaFeatures::features[] = {
|
||||
{ &nsGkAtoms::menubar_drag },
|
||||
GetSystemMetric
|
||||
},
|
||||
|
||||
{
|
||||
&nsGkAtoms::_moz_windows_theme,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eIdent,
|
||||
{ nsnull },
|
||||
GetWindowsTheme
|
||||
},
|
||||
// Null-mName terminator:
|
||||
{
|
||||
nsnull,
|
||||
|
@ -68,8 +68,8 @@ struct nsMediaFeature {
|
||||
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
|
||||
eResolution, // values are in eCSSUnit_Inch (for dpi) or
|
||||
// eCSSUnit_Centimeter (for dpcm)
|
||||
eEnumerated // values are eCSSUnit_Enumerated (uses keyword table)
|
||||
|
||||
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
|
||||
eIdent // values are eCSSUnit_Ident
|
||||
// Note that a number of pieces of code (both for parsing and
|
||||
// for matching of valueless expressions) assume that all numeric
|
||||
// value types cannot be negative. The parsing code also does
|
||||
|
Loading…
Reference in New Issue
Block a user