Add :-moz-browser-frame pseudo-class

This commit is contained in:
Xidorn Quan 2017-01-06 21:21:41 +11:00
parent 0399f359c1
commit e7e3889422
3 changed files with 24 additions and 2 deletions

View file

@ -154,6 +154,10 @@ pub enum NonTSPseudoClass {
ReadWrite,
/// :read-only
ReadOnly,
// Internal pseudo-classes
/// :-moz-browser-frame
MozBrowserFrame,
}
impl ToCss for NonTSPseudoClass {
@ -173,6 +177,8 @@ impl ToCss for NonTSPseudoClass {
Indeterminate => ":indeterminate",
ReadWrite => ":read-write",
ReadOnly => ":read-only",
MozBrowserFrame => ":-moz-browser-frame",
})
}
}
@ -196,6 +202,7 @@ impl NonTSPseudoClass {
Indeterminate |
ReadWrite |
ReadOnly => false,
MozBrowserFrame => true,
}
}
@ -216,7 +223,8 @@ impl NonTSPseudoClass {
AnyLink |
Link |
Visited => ElementState::empty(),
Visited |
MozBrowserFrame => ElementState::empty(),
}
}
@ -236,6 +244,7 @@ impl NonTSPseudoClass {
Disabled => disabled,
Checked => checked,
Indeterminate => indeterminate,
MozBrowserFrame => mozBrowserFrame,
ReadWrite | ReadOnly => { return None; }
})
}
@ -287,6 +296,10 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> {
"indeterminate" => Indeterminate,
"read-write" => ReadWrite,
"read-only" => ReadOnly,
// Internal
"-moz-browser-frame" => MozBrowserFrame,
_ => return Err(())
};

View file

@ -26,7 +26,7 @@ use gecko_bindings::bindings;
use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetLastChild, Gecko_GetNextStyleChild};
use gecko_bindings::bindings::{Gecko_GetServoDeclarationBlock, Gecko_IsHTMLElementInHTMLDocument};
use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement};
use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement, Gecko_MatchesElement};
use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink, Gecko_Namespace};
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::bindings::Gecko_ClassOrClassList;
@ -519,6 +519,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::ReadOnly => {
!self.get_state().contains(pseudo_class.state_flag())
}
NonTSPseudoClass::MozBrowserFrame => unsafe {
Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0)
}
}
}

View file

@ -10,6 +10,7 @@ use gecko_bindings::structs::RawGeckoPresContext;
use gecko_bindings::structs::ThreadSafeURIHolder;
use gecko_bindings::structs::ThreadSafePrincipalHolder;
use gecko_bindings::structs::ConsumeStyleBehavior;
use gecko_bindings::structs::CSSPseudoClassType;
use gecko_bindings::structs::TraversalRootBehavior;
use gecko_bindings::structs::FontFamilyList;
use gecko_bindings::structs::FontFamilyType;
@ -370,6 +371,10 @@ extern "C" {
extern "C" {
pub fn Gecko_IsRootElement(element: RawGeckoElementBorrowed) -> bool;
}
extern "C" {
pub fn Gecko_MatchesElement(type_: CSSPseudoClassType,
element: RawGeckoElementBorrowed) -> bool;
}
extern "C" {
pub fn Gecko_LocalName(element: RawGeckoElementBorrowed) -> *mut nsIAtom;
}