Bug 1367312 - stylo: Implement :-moz-lwtheme* pseudo-classes. r=emilio

MozReview-Commit-ID: 4T6Tn1VEwXP

--HG--
extra : rebase_source : c2dd0b62757c3da5380414fa3214248b9328d38a
This commit is contained in:
Matt Brubeck 2017-06-28 09:04:49 -07:00
Родитель fd2567e118
Коммит 8f14d009f9
7 изменённых файлов: 43 добавлений и 24 удалений

Просмотреть файл

@ -2407,7 +2407,8 @@ public:
* Doc_Theme_Neutral for any other theme. This is used to determine the state
* of the pseudoclasses :-moz-lwtheme and :-moz-lwtheme-text.
*/
virtual int GetDocumentLWTheme() { return Doc_Theme_None; }
virtual DocumentTheme GetDocumentLWTheme() { return Doc_Theme_None; }
virtual DocumentTheme ThreadSafeGetDocumentLWTheme() const { return Doc_Theme_None; }
/**
* Returns the document state.

Просмотреть файл

@ -4554,32 +4554,42 @@ XULDocument::DirectionChanged(const char* aPrefName, void* aData)
}
}
int
nsIDocument::DocumentTheme
XULDocument::GetDocumentLWTheme()
{
if (mDocLWTheme == Doc_Theme_Uninitialized) {
mDocLWTheme = Doc_Theme_None; // No lightweight theme by default
Element* element = GetRootElement();
nsAutoString hasLWTheme;
if (element &&
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwtheme, hasLWTheme) &&
!(hasLWTheme.IsEmpty()) &&
hasLWTheme.EqualsLiteral("true")) {
mDocLWTheme = Doc_Theme_Neutral;
nsAutoString lwTheme;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwthemetextcolor, lwTheme);
if (!(lwTheme.IsEmpty())) {
if (lwTheme.EqualsLiteral("dark"))
mDocLWTheme = Doc_Theme_Dark;
else if (lwTheme.EqualsLiteral("bright"))
mDocLWTheme = Doc_Theme_Bright;
}
}
mDocLWTheme = ThreadSafeGetDocumentLWTheme();
}
return mDocLWTheme;
}
nsIDocument::DocumentTheme
XULDocument::ThreadSafeGetDocumentLWTheme() const
{
if (mDocLWTheme != Doc_Theme_Uninitialized) {
return mDocLWTheme;
}
DocumentTheme theme = Doc_Theme_None; // No lightweight theme by default
Element* element = GetRootElement();
nsAutoString hasLWTheme;
if (element &&
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwtheme, hasLWTheme) &&
!(hasLWTheme.IsEmpty()) &&
hasLWTheme.EqualsLiteral("true")) {
theme = Doc_Theme_Neutral;
nsAutoString lwTheme;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwthemetextcolor, lwTheme);
if (!(lwTheme.IsEmpty())) {
if (lwTheme.EqualsLiteral("dark"))
theme = Doc_Theme_Dark;
else if (lwTheme.EqualsLiteral("bright"))
theme = Doc_Theme_Bright;
}
}
return theme;
}
NS_IMETHODIMP
XULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
{

Просмотреть файл

@ -173,7 +173,8 @@ public:
virtual void ResetDocumentDirection() override;
virtual int GetDocumentLWTheme() override;
virtual nsIDocument::DocumentTheme GetDocumentLWTheme() override;
virtual nsIDocument::DocumentTheme ThreadSafeGetDocumentLWTheme() const override;
virtual void ResetDocumentLWTheme() override { mDocLWTheme = Doc_Theme_Uninitialized; }

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsDeviceContext.h"
#include "nsIContentInlines.h"
#include "nsIDOMNode.h"
#include "nsIDocument.h"
#include "nsIDocumentInlines.h"
#include "nsIFrame.h"
#include "nsINode.h"
@ -819,6 +818,12 @@ Gecko_GetXMLLangValue(RawGeckoElementBorrowed aElement)
return atom.forget().take();
}
nsIDocument::DocumentTheme
Gecko_GetDocumentLWTheme(const nsIDocument *aDocument)
{
return aDocument->ThreadSafeGetDocumentLWTheme();
}
template <typename Implementor>
static nsIAtom*
AtomAttrValue(Implementor* aElement, nsIAtom* aName)

Просмотреть файл

@ -18,6 +18,7 @@
#include "mozilla/ComputedTimingFunction.h"
#include "nsChangeHint.h"
#include "nsCSSPseudoClasses.h"
#include "nsIDocument.h"
#include "nsStyleStruct.h"
/*
@ -164,6 +165,7 @@ bool Gecko_MatchLang(RawGeckoElementBorrowed element,
nsIAtom* override_lang, bool has_override_lang,
const char16_t* value);
nsIAtom* Gecko_GetXMLLangValue(RawGeckoElementBorrowed element);
nsIDocument::DocumentTheme Gecko_GetDocumentLWTheme(const nsIDocument *aDocument);
// Attributes.
#define SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \

Просмотреть файл

@ -330,6 +330,8 @@ structs-types = [
"mozilla::MallocSizeOf",
"mozilla::Side",
"nsIContent",
"nsIDocument",
"nsIDocument_DocumentTheme",
"RawGeckoAnimationPropertySegment",
"RawGeckoComputedTiming",
"RawGeckoCSSPropertyIDList",

Просмотреть файл

@ -85,8 +85,6 @@ to mochitest command.
* :-moz-tree bits bug 1348488
* test_selectors.html `:-moz-tree` [10]
* Unsupported pseudo-classes
* :-moz-lwtheme-* bug 1367312
* test_selectors.html `:-moz-lwtheme` [3]
* :-moz-window-inactive bug 1348489
* test_selectors.html `:-moz-window-inactive` [2]
* Unit should be preserved after parsing servo/servo#15346