servo: Merge #16028 - Stylo: Add support for -moz-* pseudo-classes for alt text (from canaltinova:pseudos-for-alt); r=Manishearth

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1341642](https://bugzilla.mozilla.org/show_bug.cgi?id=1341642)

<!-- Either: -->
- [X] These changes do not require tests because they are stylo changes.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: a2c33ac6e6e18c186e9af45274a7b8499ba1bc4c

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 9aeaa20c216e7d4c7fb5726b64c2deef33a27f90
This commit is contained in:
Nazım Can Altınova 2017-03-18 13:45:01 -07:00
parent d5ac420cfd
commit 4865b9f2a6
4 changed files with 36 additions and 5 deletions

View File

@ -9,7 +9,7 @@
bitflags! {
#[doc = "Event-based element states."]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub flags ElementState: u16 {
pub flags ElementState: u32 {
#[doc = "The mouse is down on this element. \
https://html.spec.whatwg.org/multipage/#selector-active \
FIXME(#7333): set/unset this when appropriate"]
@ -43,7 +43,21 @@ bitflags! {
const IN_INVALID_STATE = 0x800,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-valid"]
const IN_MOZ_UI_VALID_STATE = 0x1000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-broken"]
const IN_BROKEN_STATE = 0x2000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-user-disabled"]
const IN_USER_DISABLED_STATE = 0x4000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-suppressed"]
const IN_SUPPRESSED_STATE = 0x8000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading"]
const IN_LOADING_STATE = 0x10000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-blocked"]
const IN_HANDLER_BLOCKED_STATE = 0x20000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-disabled"]
const IN_HANDLER_DISABLED_STATE = 0x40000,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-crashed"]
const IN_HANDLER_CRASHED_STATE = 0x80000,
#[doc = "https://html.spec.whatwg.org/multipage/#selector-read-write"]
const IN_READ_WRITE_STATE = 0x2000,
const IN_READ_WRITE_STATE = 0x100000,
}
}

View File

@ -49,6 +49,16 @@ macro_rules! apply_non_ts_list {
("valid", Valid, valid, IN_VALID_STATE, _),
("invalid", Invalid, invalid, IN_INVALID_STATE, _),
("-moz-ui-valid", MozUIValid, mozUIValid, IN_MOZ_UI_VALID_STATE, _),
("-moz-broken", MozBroken, mozBroken, IN_BROKEN_STATE, _),
("-moz-user-disabled", MozUserDisabled, mozUserDisabled, IN_USER_DISABLED_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-suppressed", MozSuppressed, mozSuppressed, IN_SUPPRESSED_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-loading", MozLoading, mozLoading, IN_LOADING_STATE, _),
("-moz-handler-blocked", MozHandlerBlocked, mozHandlerBlocked, IN_HANDLER_BLOCKED_STATE,
PSEUDO_CLASS_INTERNAL),
("-moz-handler-disabled", MozHandlerDisabled, mozHandlerDisabled, IN_HANDLER_DISABLED_STATE,
PSEUDO_CLASS_INTERNAL),
("-moz-handler-crashed", MozHandlerCrashed, mozHandlerCrashed, IN_HANDLER_CRASHED_STATE,
PSEUDO_CLASS_INTERNAL),
("read-write", ReadWrite, _, IN_READ_WRITE_STATE, _),
("read-only", ReadOnly, _, IN_READ_WRITE_STATE, _),

View File

@ -138,7 +138,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
impl ElementSnapshot for GeckoElementSnapshot {
fn state(&self) -> Option<ElementState> {
if self.has_any(Flags::State) {
Some(ElementState::from_bits_truncate(unsafe { (*self.0).mState as u16 }))
Some(ElementState::from_bits_truncate(unsafe { (*self.0).mState as u32 }))
} else {
None
}

View File

@ -447,7 +447,7 @@ impl<'le> TElement for GeckoElement<'le> {
fn get_state(&self) -> ElementState {
unsafe {
ElementState::from_bits_truncate(Gecko_ElementState(self.0))
ElementState::from_bits_truncate(Gecko_ElementState(self.0) as u32)
}
}
@ -680,7 +680,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::Target |
NonTSPseudoClass::Valid |
NonTSPseudoClass::Invalid |
NonTSPseudoClass::MozUIValid => {
NonTSPseudoClass::MozUIValid |
NonTSPseudoClass::MozBroken |
NonTSPseudoClass::MozUserDisabled |
NonTSPseudoClass::MozSuppressed |
NonTSPseudoClass::MozLoading |
NonTSPseudoClass::MozHandlerBlocked |
NonTSPseudoClass::MozHandlerDisabled |
NonTSPseudoClass::MozHandlerCrashed => {
self.get_state().contains(pseudo_class.state_flag())
},
NonTSPseudoClass::ReadOnly => {