Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE

Backs out https://github.com/servo/servo/pull/18809
This commit is contained in:
Gecko Backout 2017-10-19 21:26:51 +00:00 committed by moz-servo-sync
parent fe16c1d5c3
commit 11c64178d8
142 changed files with 1635 additions and 1685 deletions

View file

@ -32,7 +32,7 @@ gecko_debug = ["nsstring_vendor/gecko_debug"]
app_units = "0.5.5"
arrayvec = "0.3.20"
atomic_refcell = "0.1"
bitflags = "1.0"
bitflags = "0.7"
byteorder = "1.0"
cfg-if = "0.1.0"
cssparser = "0.22.0"

View file

@ -37,7 +37,7 @@ use style_traits::CSSPixel;
use style_traits::DevicePixel;
#[cfg(feature = "servo")] use style_traits::SpeculativePainter;
use stylist::Stylist;
use thread_state::{self, ThreadState};
use thread_state;
use time;
use timer::Timer;
use traversal::DomTraversal;
@ -415,15 +415,15 @@ impl TraversalStatistics {
bitflags! {
/// Represents which tasks are performed in a SequentialTask of
/// UpdateAnimations which is a result of normal restyle.
pub struct UpdateAnimationsTasks: u8 {
pub flags UpdateAnimationsTasks: u8 {
/// Update CSS Animations.
const CSS_ANIMATIONS = structs::UpdateAnimationsTasks_CSSAnimations;
const CSS_ANIMATIONS = structs::UpdateAnimationsTasks_CSSAnimations,
/// Update CSS Transitions.
const CSS_TRANSITIONS = structs::UpdateAnimationsTasks_CSSTransitions;
const CSS_TRANSITIONS = structs::UpdateAnimationsTasks_CSSTransitions,
/// Update effect properties.
const EFFECT_PROPERTIES = structs::UpdateAnimationsTasks_EffectProperties;
const EFFECT_PROPERTIES = structs::UpdateAnimationsTasks_EffectProperties,
/// Update animation cacade results for animations running on the compositor.
const CASCADE_RESULTS = structs::UpdateAnimationsTasks_CascadeResults;
const CASCADE_RESULTS = structs::UpdateAnimationsTasks_CascadeResults,
}
}
@ -431,11 +431,11 @@ bitflags! {
bitflags! {
/// Represents which tasks are performed in a SequentialTask as a result of
/// animation-only restyle.
pub struct PostAnimationTasks: u8 {
pub flags PostAnimationTasks: u8 {
/// Display property was changed from none in animation-only restyle so
/// that we need to resolve styles for descendants in a subsequent
/// normal restyle.
const DISPLAY_CHANGED_FROM_NONE_FOR_SMIL = 0x01;
const DISPLAY_CHANGED_FROM_NONE_FOR_SMIL = 0x01,
}
}
@ -477,7 +477,7 @@ impl<E: TElement> SequentialTask<E> {
/// Executes this task.
pub fn execute(self) {
use self::SequentialTask::*;
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert!(thread_state::get() == thread_state::LAYOUT);
match self {
Unused(_) => unreachable!(),
#[cfg(feature = "gecko")]
@ -565,7 +565,7 @@ impl<E: TElement> SelectorFlagsMap<E> {
/// Applies the flags. Must be called on the main thread.
pub fn apply_flags(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert!(thread_state::get() == thread_state::LAYOUT);
for (el, flags) in self.map.drain() {
unsafe { el.set_selector_flags(flags); }
}
@ -602,7 +602,7 @@ where
E: TElement,
{
fn drop(&mut self) {
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert!(thread_state::get() == thread_state::LAYOUT);
for task in self.0.drain(..) {
task.execute()
}
@ -797,7 +797,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
impl<E: TElement> Drop for ThreadLocalStyleContext<E> {
fn drop(&mut self) {
debug_assert!(self.current_element_info.is_none());
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert!(thread_state::get() == thread_state::LAYOUT);
// Apply any slow selector flags that need to be set on parents.
self.selector_flags.apply_flags();

View file

@ -25,9 +25,9 @@ use style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle};
bitflags! {
/// Various flags stored on ElementData.
#[derive(Default)]
pub struct ElementDataFlags: u8 {
pub flags ElementDataFlags: u8 {
/// Whether the styles changed for this restyle.
const WAS_RESTYLED = 1 << 0;
const WAS_RESTYLED = 1 << 0,
/// Whether the last traversal of this element did not do
/// any style computation. This is not true during the initial
/// styling pass, nor is it true when we restyle (in which case
@ -36,16 +36,16 @@ bitflags! {
/// This bit always corresponds to the last time the element was
/// traversed, so each traversal simply updates it with the appropriate
/// value.
const TRAVERSED_WITHOUT_STYLING = 1 << 1;
const TRAVERSED_WITHOUT_STYLING = 1 << 1,
/// Whether we reframed/reconstructed any ancestor or self.
const ANCESTOR_WAS_RECONSTRUCTED = 1 << 2;
const ANCESTOR_WAS_RECONSTRUCTED = 1 << 2,
/// Whether the primary style of this element data was reused from another
/// element via a rule node comparison. This allows us to differentiate
/// between elements that shared styles because they met all the criteria
/// of the style sharing cache, compared to elements that reused style
/// structs via rule node identity. The former gives us stronger transitive
/// guarantees that allows us to apply the style sharing cache to cousins.
const PRIMARY_STYLE_REUSED_VIA_RULE_NODE = 1 << 3;
const PRIMARY_STYLE_REUSED_VIA_RULE_NODE = 1 << 3,
}
}
@ -298,7 +298,7 @@ impl ElementData {
/// Returns this element's primary style as a resolved style to use for sharing.
pub fn share_primary_style(&self) -> PrimaryStyle {
let reused_via_rule_node =
self.flags.contains(ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
self.flags.contains(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
PrimaryStyle {
style: ResolvedStyle(self.styles.primary().clone()),
@ -309,9 +309,9 @@ impl ElementData {
/// Sets a new set of styles, returning the old ones.
pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles {
if new_styles.primary.reused_via_rule_node {
self.flags.insert(ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
self.flags.insert(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
} else {
self.flags.remove(ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
self.flags.remove(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
}
mem::replace(&mut self.styles, new_styles.into())
}
@ -399,7 +399,7 @@ impl ElementData {
#[inline]
pub fn clear_restyle_flags_and_damage(&mut self) {
self.damage = RestyleDamage::empty();
self.flags.remove(ElementDataFlags::WAS_RESTYLED | ElementDataFlags::ANCESTOR_WAS_RECONSTRUCTED)
self.flags.remove(WAS_RESTYLED | ANCESTOR_WAS_RECONSTRUCTED)
}
/// Returns whether this element or any ancestor is going to be
@ -416,7 +416,7 @@ impl ElementData {
/// Returns whether any ancestor of this element is going to be
/// reconstructed.
fn reconstructed_ancestor(&self) -> bool {
self.flags.contains(ElementDataFlags::ANCESTOR_WAS_RECONSTRUCTED)
self.flags.contains(ANCESTOR_WAS_RECONSTRUCTED)
}
/// Sets the flag that tells us whether we've reconstructed an ancestor.
@ -424,34 +424,34 @@ impl ElementData {
if reconstructed {
// If it weren't for animation-only traversals, we could assert
// `!self.reconstructed_ancestor()` here.
self.flags.insert(ElementDataFlags::ANCESTOR_WAS_RECONSTRUCTED);
self.flags.insert(ANCESTOR_WAS_RECONSTRUCTED);
} else {
self.flags.remove(ElementDataFlags::ANCESTOR_WAS_RECONSTRUCTED);
self.flags.remove(ANCESTOR_WAS_RECONSTRUCTED);
}
}
/// Mark this element as restyled, which is useful to know whether we need
/// to do a post-traversal.
pub fn set_restyled(&mut self) {
self.flags.insert(ElementDataFlags::WAS_RESTYLED);
self.flags.remove(ElementDataFlags::TRAVERSED_WITHOUT_STYLING);
self.flags.insert(WAS_RESTYLED);
self.flags.remove(TRAVERSED_WITHOUT_STYLING);
}
/// Returns true if this element was restyled.
#[inline]
pub fn is_restyle(&self) -> bool {
self.flags.contains(ElementDataFlags::WAS_RESTYLED)
self.flags.contains(WAS_RESTYLED)
}
/// Mark that we traversed this element without computing any style for it.
pub fn set_traversed_without_styling(&mut self) {
self.flags.insert(ElementDataFlags::TRAVERSED_WITHOUT_STYLING);
self.flags.insert(TRAVERSED_WITHOUT_STYLING);
}
/// Returns whether the element was traversed without computing any style for
/// it.
pub fn traversed_without_styling(&self) -> bool {
self.flags.contains(ElementDataFlags::TRAVERSED_WITHOUT_STYLING)
self.flags.contains(TRAVERSED_WITHOUT_STYLING)
}
/// Returns whether this element has been part of a restyle.
@ -493,8 +493,7 @@ impl ElementData {
/// happens later in the styling pipeline. The former gives us the stronger guarantees
/// we need for style sharing, the latter does not.
pub fn safe_for_cousin_sharing(&self) -> bool {
!self.flags.intersects(ElementDataFlags::TRAVERSED_WITHOUT_STYLING |
ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE)
!self.flags.intersects(TRAVERSED_WITHOUT_STYLING | PRIMARY_STYLE_REUSED_VIA_RULE_NODE)
}
/// Measures memory usage.

View file

@ -32,7 +32,7 @@ use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Deref;
use stylist::Stylist;
use traversal_flags::TraversalFlags;
use traversal_flags::{TraversalFlags, self};
/// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
/// back into a non-opaque representation. The only safe operation that can be
@ -476,7 +476,7 @@ pub trait TElement
!data.hint.has_animation_hint_or_recascade();
}
if traversal_flags.contains(TraversalFlags::UnstyledOnly) {
if traversal_flags.contains(traversal_flags::UnstyledOnly) {
// We don't process invalidations in UnstyledOnly mode.
return data.has_styles();
}

View file

@ -15,128 +15,127 @@ bitflags! {
/// TODO(emilio): We really really want to use the NS_EVENT_STATE bindings
/// for this.
#[derive(MallocSizeOf)]
pub struct ElementState: u64 {
pub flags ElementState: u64 {
/// The mouse is down on this element.
/// <https://html.spec.whatwg.org/multipage/#selector-active>
/// FIXME(#7333): set/unset this when appropriate
const IN_ACTIVE_STATE = 1 << 0;
const IN_ACTIVE_STATE = 1 << 0,
/// This element has focus.
/// <https://html.spec.whatwg.org/multipage/#selector-focus>
const IN_FOCUS_STATE = 1 << 1;
const IN_FOCUS_STATE = 1 << 1,
/// The mouse is hovering over this element.
/// <https://html.spec.whatwg.org/multipage/#selector-hover>
const IN_HOVER_STATE = 1 << 2;
const IN_HOVER_STATE = 1 << 2,
/// Content is enabled (and can be disabled).
/// <http://www.whatwg.org/html/#selector-enabled>
const IN_ENABLED_STATE = 1 << 3;
const IN_ENABLED_STATE = 1 << 3,
/// Content is disabled.
/// <http://www.whatwg.org/html/#selector-disabled>
const IN_DISABLED_STATE = 1 << 4;
const IN_DISABLED_STATE = 1 << 4,
/// Content is checked.
/// <https://html.spec.whatwg.org/multipage/#selector-checked>
const IN_CHECKED_STATE = 1 << 5;
const IN_CHECKED_STATE = 1 << 5,
/// <https://html.spec.whatwg.org/multipage/#selector-indeterminate>
const IN_INDETERMINATE_STATE = 1 << 6;
const IN_INDETERMINATE_STATE = 1 << 6,
/// <https://html.spec.whatwg.org/multipage/#selector-placeholder-shown>
const IN_PLACEHOLDER_SHOWN_STATE = 1 << 7;
const IN_PLACEHOLDER_SHOWN_STATE = 1 << 7,
/// <https://html.spec.whatwg.org/multipage/#selector-target>
const IN_TARGET_STATE = 1 << 8;
const IN_TARGET_STATE = 1 << 8,
/// <https://fullscreen.spec.whatwg.org/#%3Afullscreen-pseudo-class>
const IN_FULLSCREEN_STATE = 1 << 9;
const IN_FULLSCREEN_STATE = 1 << 9,
/// <https://html.spec.whatwg.org/multipage/#selector-valid>
const IN_VALID_STATE = 1 << 10;
const IN_VALID_STATE = 1 << 10,
/// <https://html.spec.whatwg.org/multipage/#selector-invalid>
const IN_INVALID_STATE = 1 << 11;
const IN_INVALID_STATE = 1 << 11,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-valid
const IN_MOZ_UI_VALID_STATE = 1 << 12;
const IN_MOZ_UI_VALID_STATE = 1 << 12,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-invalid
const IN_MOZ_UI_INVALID_STATE = 1 << 13;
const IN_MOZ_UI_INVALID_STATE = 1 << 13,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-broken
const IN_BROKEN_STATE = 1 << 14;
const IN_BROKEN_STATE = 1 << 14,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-user-disabled
const IN_USER_DISABLED_STATE = 1 << 15;
const IN_USER_DISABLED_STATE = 1 << 15,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-suppressed
const IN_SUPPRESSED_STATE = 1 << 16;
const IN_SUPPRESSED_STATE = 1 << 16,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading
const IN_LOADING_STATE = 1 << 17;
const IN_LOADING_STATE = 1 << 17,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-blocked
const IN_HANDLER_BLOCKED_STATE = 1 << 18;
const IN_HANDLER_BLOCKED_STATE = 1 << 18,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-disabled
const IN_HANDLER_DISABLED_STATE = 1 << 19;
const IN_HANDLER_DISABLED_STATE = 1 << 19,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-crashed
const IN_HANDLER_CRASHED_STATE = 1 << 20;
const IN_HANDLER_CRASHED_STATE = 1 << 20,
/// <https://html.spec.whatwg.org/multipage/#selector-required>
const IN_REQUIRED_STATE = 1 << 21;
const IN_REQUIRED_STATE = 1 << 21,
/// <https://html.spec.whatwg.org/multipage/#selector-optional>
const IN_OPTIONAL_STATE = 1 << 22;
const IN_OPTIONAL_STATE = 1 << 22,
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
const IN_READ_WRITE_STATE = 1 << 22;
const IN_READ_WRITE_STATE = 1 << 22,
/// Non-standard: Older custom-elements spec.
const IN_UNRESOLVED_STATE = 1 << 23;
const IN_UNRESOLVED_STATE = 1 << 23,
/// <https://html.spec.whatwg.org/multipage/#selector-visited>
const IN_VISITED_STATE = 1 << 24;
const IN_VISITED_STATE = 1 << 24,
/// <https://html.spec.whatwg.org/multipage/#selector-link>
const IN_UNVISITED_STATE = 1 << 25;
const IN_UNVISITED_STATE = 1 << 25,
/// <https://drafts.csswg.org/selectors-4/#the-any-link-pseudo>
const IN_VISITED_OR_UNVISITED_STATE = ElementState::IN_VISITED_STATE.bits |
ElementState::IN_UNVISITED_STATE.bits;
const IN_VISITED_OR_UNVISITED_STATE = IN_VISITED_STATE.bits | IN_UNVISITED_STATE.bits,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-drag-over
const IN_DRAGOVER_STATE = 1 << 26;
const IN_DRAGOVER_STATE = 1 << 26,
/// <https://html.spec.whatwg.org/multipage/#selector-in-range>
const IN_INRANGE_STATE = 1 << 27;
const IN_INRANGE_STATE = 1 << 27,
/// <https://html.spec.whatwg.org/multipage/#selector-out-of-range>
const IN_OUTOFRANGE_STATE = 1 << 28;
const IN_OUTOFRANGE_STATE = 1 << 28,
/// <https://html.spec.whatwg.org/multipage/#selector-read-only>
const IN_MOZ_READONLY_STATE = 1 << 29;
const IN_MOZ_READONLY_STATE = 1 << 29,
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
const IN_MOZ_READWRITE_STATE = 1 << 30;
const IN_MOZ_READWRITE_STATE = 1 << 30,
/// <https://html.spec.whatwg.org/multipage/#selector-default>
const IN_DEFAULT_STATE = 1 << 31;
const IN_DEFAULT_STATE = 1 << 31,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-submit-invalid
const IN_MOZ_SUBMITINVALID_STATE = 1 << 32;
const IN_MOZ_SUBMITINVALID_STATE = 1 << 32,
/// Non-standard & undocumented.
const IN_OPTIMUM_STATE = 1 << 33;
const IN_OPTIMUM_STATE = 1 << 33,
/// Non-standard & undocumented.
const IN_SUB_OPTIMUM_STATE = 1 << 34;
const IN_SUB_OPTIMUM_STATE = 1 << 34,
/// Non-standard & undocumented.
const IN_SUB_SUB_OPTIMUM_STATE = 1 << 35;
const IN_SUB_SUB_OPTIMUM_STATE = 1 << 35,
/// Non-standard & undocumented.
const IN_DEVTOOLS_HIGHLIGHTED_STATE = 1 << 36;
const IN_DEVTOOLS_HIGHLIGHTED_STATE = 1 << 36,
/// Non-standard & undocumented.
const IN_STYLEEDITOR_TRANSITIONING_STATE = 1 << 37;
const IN_STYLEEDITOR_TRANSITIONING_STATE = 1 << 37,
/// Non-standard & undocumented.
const IN_INCREMENT_SCRIPT_LEVEL_STATE = 1 << 38;
const IN_INCREMENT_SCRIPT_LEVEL_STATE = 1 << 38,
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-focusring
const IN_FOCUSRING_STATE = 1 << 39;
const IN_FOCUSRING_STATE = 1 << 39,
/// Non-standard & undocumented.
const IN_HANDLER_CLICK_TO_PLAY_STATE = 1 << 40;
const IN_HANDLER_CLICK_TO_PLAY_STATE = 1 << 40,
/// Non-standard & undocumented.
const IN_HANDLER_VULNERABLE_UPDATABLE_STATE = 1 << 41;
const IN_HANDLER_VULNERABLE_UPDATABLE_STATE = 1 << 41,
/// Non-standard & undocumented.
const IN_HANDLER_VULNERABLE_NO_UPDATE_STATE = 1 << 42;
const IN_HANDLER_VULNERABLE_NO_UPDATE_STATE = 1 << 42,
/// <https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo>
const IN_FOCUS_WITHIN_STATE = 1 << 43;
const IN_FOCUS_WITHIN_STATE = 1 << 43,
/// :dir matching; the states are used for dynamic change detection.
/// State that elements that match :dir(ltr) are in.
const IN_LTR_STATE = 1 << 44;
const IN_LTR_STATE = 1 << 44,
/// State that elements that match :dir(rtl) are in.
const IN_RTL_STATE = 1 << 45;
const IN_RTL_STATE = 1 << 45,
/// State that HTML elements that have a "dir" attr are in.
const IN_HAS_DIR_ATTR_STATE = 1 << 46;
const IN_HAS_DIR_ATTR_STATE = 1 << 46,
/// State that HTML elements with dir="ltr" (or something
/// case-insensitively equal to "ltr") are in.
const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 47;
const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 47,
/// State that HTML elements with dir="rtl" (or something
/// case-insensitively equal to "rtl") are in.
const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 48;
const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 48,
/// State that HTML <bdi> elements without a valid-valued "dir" attr or
/// any HTML elements (including <bdi>) with dir="auto" (or something
/// case-insensitively equal to "auto") are in.
const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 49;
const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 49,
/// Non-standard & undocumented.
const IN_AUTOFILL_STATE = 1 << 50;
const IN_AUTOFILL_STATE = 1 << 50,
/// Non-standard & undocumented.
const IN_AUTOFILL_PREVIEW_STATE = 1 << 51;
const IN_AUTOFILL_PREVIEW_STATE = 1 << 51,
}
}
@ -145,10 +144,10 @@ bitflags! {
///
/// NB: Is important for this to remain in sync with Gecko's
/// dom/base/nsIDocument.h.
pub struct DocumentState: u64 {
pub flags DocumentState: u64 {
/// RTL locale: specific to the XUL localedir attribute
const NS_DOCUMENT_STATE_RTL_LOCALE = 1 << 0;
const NS_DOCUMENT_STATE_RTL_LOCALE = 1 << 0,
/// Window activation status
const NS_DOCUMENT_STATE_WINDOW_INACTIVE = 1 << 1;
const NS_DOCUMENT_STATE_WINDOW_INACTIVE = 1 << 1,
}
}

View file

@ -10,7 +10,9 @@
use cssparser::{ToCss, serialize_identifier};
use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::{ComputedValues, PropertyFlags};
use properties::{PropertyFlags, APPLIES_TO_FIRST_LETTER, APPLIES_TO_FIRST_LINE};
use properties::APPLIES_TO_PLACEHOLDER;
use properties::ComputedValues;
use properties::longhands::display::computed_value as display;
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt;
@ -151,9 +153,9 @@ impl PseudoElement {
#[inline]
pub fn property_restriction(&self) -> Option<PropertyFlags> {
match *self {
PseudoElement::FirstLetter => Some(PropertyFlags::APPLIES_TO_FIRST_LETTER),
PseudoElement::FirstLine => Some(PropertyFlags::APPLIES_TO_FIRST_LINE),
PseudoElement::Placeholder => Some(PropertyFlags::APPLIES_TO_PLACEHOLDER),
PseudoElement::FirstLetter => Some(APPLIES_TO_FIRST_LETTER),
PseudoElement::FirstLine => Some(APPLIES_TO_FIRST_LINE),
PseudoElement::Placeholder => Some(APPLIES_TO_PLACEHOLDER),
_ => None,
}
}

View file

@ -22,12 +22,11 @@ pub use gecko::snapshot::SnapshotMap;
bitflags! {
// See NonTSPseudoClass::is_enabled_in()
struct NonTSPseudoClassFlag: u8 {
const PSEUDO_CLASS_ENABLED_IN_UA_SHEETS = 1 << 0;
const PSEUDO_CLASS_ENABLED_IN_CHROME = 1 << 1;
flags NonTSPseudoClassFlag: u8 {
const PSEUDO_CLASS_ENABLED_IN_UA_SHEETS = 1 << 0,
const PSEUDO_CLASS_ENABLED_IN_CHROME = 1 << 1,
const PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME =
NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS.bits |
NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_CHROME.bits;
PSEUDO_CLASS_ENABLED_IN_UA_SHEETS.bits | PSEUDO_CLASS_ENABLED_IN_CHROME.bits,
}
}
@ -135,7 +134,7 @@ impl NonTSPseudoClass {
fn has_any_flag(&self, flags: NonTSPseudoClassFlag) -> bool {
macro_rules! check_flag {
(_) => (false);
($flags:ident) => (NonTSPseudoClassFlag::$flags.intersects(flags));
($flags:expr) => ($flags.intersects(flags));
}
macro_rules! pseudo_class_check_is_enabled_in {
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
@ -162,7 +161,7 @@ impl NonTSPseudoClass {
unsafe { mozilla::StylePrefs_sUnprefixedFullscreenApiEnabled },
// Otherwise, a pseudo-class is enabled in content when it
// doesn't have any enabled flag.
_ => !self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
_ => !self.has_any_flag(PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
}
}
@ -179,7 +178,7 @@ impl NonTSPseudoClass {
pub fn state_flag(&self) -> ElementState {
macro_rules! flag {
(_) => (ElementState::empty());
($state:ident) => (ElementState::$state);
($state:ident) => (::element_state::$state);
}
macro_rules! pseudo_class_state {
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
@ -291,9 +290,9 @@ impl<'a> SelectorParser<'a> {
-> bool {
pseudo_class.is_enabled_in_content() ||
(self.in_user_agent_stylesheet() &&
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS)) ||
pseudo_class.has_any_flag(PSEUDO_CLASS_ENABLED_IN_UA_SHEETS)) ||
(self.in_chrome_stylesheet() &&
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_CHROME))
pseudo_class.has_any_flag(PSEUDO_CLASS_ENABLED_IN_CHROME))
}
}

View file

@ -22,7 +22,7 @@ use context::{QuirksMode, SharedStyleContext, PostAnimationTasks, UpdateAnimatio
use data::ElementData;
use dom::{LayoutIterator, NodeInfo, TElement, TNode};
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
use element_state::{ElementState, DocumentState};
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
use error_reporting::ParseErrorReporter;
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use gecko::data::PerDocumentStyleData;
@ -729,17 +729,18 @@ impl<'le> GeckoElement<'le> {
/// it's probably not worth the trouble.
fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
use gecko_bindings::structs::*;
use selectors::matching::*;
let mut gecko_flags = 0u32;
if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR) {
if flags.contains(HAS_SLOW_SELECTOR) {
gecko_flags |= NODE_HAS_SLOW_SELECTOR as u32;
}
if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
if flags.contains(HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
gecko_flags |= NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS as u32;
}
if flags.contains(ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR) {
if flags.contains(HAS_EDGE_CHILD_SELECTOR) {
gecko_flags |= NODE_HAS_EDGE_CHILD_SELECTOR as u32;
}
if flags.contains(ElementSelectorFlags::HAS_EMPTY_SELECTOR) {
if flags.contains(HAS_EMPTY_SELECTOR) {
gecko_flags |= NODE_HAS_EMPTY_SELECTOR as u32;
}
@ -1079,7 +1080,8 @@ impl<'le> TElement for GeckoElement<'le> {
}
fn is_visited_link(&self) -> bool {
self.get_state().intersects(ElementState::IN_VISITED_STATE)
use element_state::IN_VISITED_STATE;
self.get_state().intersects(IN_VISITED_STATE)
}
#[inline]
@ -1190,6 +1192,7 @@ impl<'le> TElement for GeckoElement<'le> {
/// Process various tasks that are a result of animation-only restyle.
fn process_post_animation(&self,
tasks: PostAnimationTasks) {
use context::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL;
use gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
@ -1199,7 +1202,7 @@ impl<'le> TElement for GeckoElement<'le> {
// the descendants in the display:none subtree. Instead of resolving
// those styles in animation-only restyle, we defer it to a subsequent
// normal restyle.
if tasks.intersects(PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL) {
if tasks.intersects(DISPLAY_CHANGED_FROM_NONE_FOR_SMIL) {
debug_assert!(self.implemented_pseudo_element()
.map_or(true, |p| !p.is_before_or_after()),
"display property animation shouldn't run on pseudo elements \
@ -1895,7 +1898,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::Link => relevant_link.is_unvisited(self, context),
NonTSPseudoClass::Visited => relevant_link.is_visited(self, context),
NonTSPseudoClass::MozFirstNode => {
flags_setter(self, ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR);
flags_setter(self, HAS_EDGE_CHILD_SELECTOR);
let mut elem = self.as_node();
while let Some(prev) = elem.prev_sibling() {
if prev.contains_non_whitespace_content() {
@ -1906,7 +1909,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
true
}
NonTSPseudoClass::MozLastNode => {
flags_setter(self, ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR);
flags_setter(self, HAS_EDGE_CHILD_SELECTOR);
let mut elem = self.as_node();
while let Some(next) = elem.next_sibling() {
if next.contains_non_whitespace_content() {
@ -1917,7 +1920,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
true
}
NonTSPseudoClass::MozOnlyWhitespace => {
flags_setter(self, ElementSelectorFlags::HAS_EMPTY_SELECTOR);
flags_setter(self, HAS_EMPTY_SELECTOR);
if self.as_node().dom_children().any(|c| c.contains_non_whitespace_content()) {
return false
}
@ -1942,7 +1945,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
}
NonTSPseudoClass::MozWindowInactive => {
self.document_state().contains(DocumentState::NS_DOCUMENT_STATE_WINDOW_INACTIVE)
self.document_state().contains(NS_DOCUMENT_STATE_WINDOW_INACTIVE)
}
NonTSPseudoClass::MozPlaceholder => false,
NonTSPseudoClass::MozAny(ref sels) => {

View file

@ -9,7 +9,7 @@ description = "Rust bindings to xpcom string types"
# Revendoring nsstring from m-c into Servo
[dependencies]
bitflags = "1.0"
bitflags = "0.8"
[features]
gecko_debug = []

View file

@ -138,13 +138,13 @@ mod data_flags {
// While this has the same layout as u16, it cannot be passed
// over FFI safely as a u16.
#[repr(C)]
pub struct DataFlags : u16 {
const TERMINATED = 1 << 0; // IsTerminated returns true
const VOIDED = 1 << 1; // IsVoid returns true
const SHARED = 1 << 2; // mData points to a heap-allocated, shared buffer
const OWNED = 1 << 3; // mData points to a heap-allocated, raw buffer
const INLINE = 1 << 4; // mData points to a writable, inline buffer
const LITERAL = 1 << 5; // mData points to a string literal; TERMINATED will also be set
pub flags DataFlags : u16 {
const TERMINATED = 1 << 0, // IsTerminated returns true
const VOIDED = 1 << 1, // IsVoid returns true
const SHARED = 1 << 2, // mData points to a heap-allocated, shared buffer
const OWNED = 1 << 3, // mData points to a heap-allocated, raw buffer
const INLINE = 1 << 4, // mData points to a writable, inline buffer
const LITERAL = 1 << 5, // mData points to a string literal; TERMINATED will also be set
}
}
}
@ -154,9 +154,9 @@ mod class_flags {
// While this has the same layout as u16, it cannot be passed
// over FFI safely as a u16.
#[repr(C)]
pub struct ClassFlags : u16 {
const INLINE = 1 << 0; // |this|'s buffer is inline
const NULL_TERMINATED = 1 << 1; // |this| requires its buffer is null-terminated
pub flags ClassFlags : u16 {
const INLINE = 1 << 0, // |this|'s buffer is inline
const NULL_TERMINATED = 1 << 1, // |this| requires its buffer is null-terminated
}
}
}
@ -212,7 +212,7 @@ macro_rules! define_string_types {
$StringRepr {
data: &NUL,
length: 0,
dataflags: DataFlags::TERMINATED | DataFlags::LITERAL,
dataflags: data_flags::TERMINATED | data_flags::LITERAL,
classflags: classflags,
}
}
@ -536,7 +536,7 @@ macro_rules! define_string_types {
impl $String {
pub fn new() -> $String {
$String {
hdr: $StringRepr::new(ClassFlags::NULL_TERMINATED),
hdr: $StringRepr::new(class_flags::NULL_TERMINATED),
}
}
}
@ -618,8 +618,8 @@ macro_rules! define_string_types {
hdr: $StringRepr {
data: ptr,
length: length,
dataflags: DataFlags::OWNED | DataFlags::TERMINATED,
classflags: ClassFlags::NULL_TERMINATED,
dataflags: data_flags::OWNED | data_flags::TERMINATED,
classflags: class_flags::NULL_TERMINATED,
}
}
}

View file

@ -13,9 +13,9 @@ use stylesheets::OriginSet;
/// Checks that the values for OriginFlags are the ones we expect.
pub fn assert_flags_match() {
use stylesheets::origin::*;
debug_assert_eq!(OriginFlags_UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
debug_assert_eq!(OriginFlags_Author.0, OriginSet::ORIGIN_AUTHOR.bits());
debug_assert_eq!(OriginFlags_User.0, OriginSet::ORIGIN_USER.bits());
debug_assert_eq!(OriginFlags_UserAgent.0, ORIGIN_USER_AGENT.bits());
debug_assert_eq!(OriginFlags_Author.0, ORIGIN_AUTHOR.bits());
debug_assert_eq!(OriginFlags_User.0, ORIGIN_USER.bits());
}
impl From<OriginFlags> for OriginSet {

View file

@ -9,11 +9,11 @@ use Atom;
use context::{QuirksMode, SharedStyleContext};
use data::ElementData;
use dom::TElement;
use element_state::ElementState;
use element_state::{ElementState, IN_VISITED_OR_UNVISITED_STATE};
use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
use invalidation::element::invalidation_map::*;
use invalidation::element::invalidator::{InvalidationVector, Invalidation, InvalidationProcessor};
use invalidation::element::restyle_hints::RestyleHint;
use invalidation::element::restyle_hints::*;
use selector_map::SelectorMap;
use selector_parser::Snapshot;
use selectors::NthIndexCache;
@ -102,7 +102,7 @@ where
// force a restyle here. Matching doesn't depend on the actual visited
// state at all, so we can't look at matching results to decide what to
// do for this case.
if state_changes.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
if state_changes.intersects(IN_VISITED_OR_UNVISITED_STATE) {
trace!(" > visitedness change, force subtree restyle");
// We can't just return here because there may also be attribute
// changes as well that imply additional hints.
@ -186,7 +186,7 @@ where
};
if invalidated_self {
self.data.hint.insert(RestyleHint::RESTYLE_SELF);
self.data.hint.insert(RESTYLE_SELF);
}
invalidated_self
@ -195,7 +195,7 @@ where
fn should_process_descendants(&mut self, element: E) -> bool {
if element == self.element {
return !self.data.styles.is_display_none() &&
!self.data.hint.contains(RestyleHint::RESTYLE_DESCENDANTS)
!self.data.hint.contains(RESTYLE_DESCENDANTS)
}
let data = match element.borrow_data() {
@ -204,17 +204,17 @@ where
};
!data.styles.is_display_none() &&
!data.hint.contains(RestyleHint::RESTYLE_DESCENDANTS)
!data.hint.contains(RESTYLE_DESCENDANTS)
}
fn recursion_limit_exceeded(&mut self, element: E) {
if element == self.element {
self.data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
self.data.hint.insert(RESTYLE_DESCENDANTS);
return;
}
if let Some(mut data) = element.mutate_data() {
data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
data.hint.insert(RESTYLE_DESCENDANTS);
}
}
@ -242,7 +242,7 @@ where
fn invalidated_self(&mut self, element: E) {
debug_assert_ne!(element, self.element);
if let Some(mut data) = element.mutate_data() {
data.hint.insert(RestyleHint::RESTYLE_SELF);
data.hint.insert(RESTYLE_SELF);
}
}
}
@ -333,7 +333,7 @@ where
return true;
}
let visited_dependent =
if dependency.state.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
if dependency.state.intersects(IN_VISITED_OR_UNVISITED_STATE) {
VisitedDependent::Yes
} else {
VisitedDependent::No

View file

@ -20,16 +20,16 @@ use smallvec::SmallVec;
#[cfg(feature = "gecko")]
/// Gets the element state relevant to the given `:dir` pseudo-class selector.
pub fn dir_selector_to_state(s: &[u16]) -> ElementState {
use element_state::ElementState;
use element_state::{IN_LTR_STATE, IN_RTL_STATE};
// Jump through some hoops to deal with our Box<[u16]> thing.
const LTR: [u16; 4] = [b'l' as u16, b't' as u16, b'r' as u16, 0];
const RTL: [u16; 4] = [b'r' as u16, b't' as u16, b'l' as u16, 0];
if LTR == *s {
ElementState::IN_LTR_STATE
IN_LTR_STATE
} else if RTL == *s {
ElementState::IN_RTL_STATE
IN_RTL_STATE
} else {
// :dir(something-random) is a valid selector, but shouldn't
// match anything.

View file

@ -10,38 +10,38 @@ use traversal_flags::TraversalFlags;
bitflags! {
/// The kind of restyle we need to do for a given element.
pub struct RestyleHint: u8 {
pub flags RestyleHint: u8 {
/// Do a selector match of the element.
const RESTYLE_SELF = 1 << 0;
const RESTYLE_SELF = 1 << 0,
/// Do a selector match of the element's descendants.
const RESTYLE_DESCENDANTS = 1 << 1;
const RESTYLE_DESCENDANTS = 1 << 1,
/// Recascade the current element.
const RECASCADE_SELF = 1 << 2;
const RECASCADE_SELF = 1 << 2,
/// Recascade all descendant elements.
const RECASCADE_DESCENDANTS = 1 << 3;
const RECASCADE_DESCENDANTS = 1 << 3,
/// Replace the style data coming from CSS transitions without updating
/// any other style data. This hint is only processed in animation-only
/// traversal which is prior to normal traversal.
const RESTYLE_CSS_TRANSITIONS = 1 << 4;
const RESTYLE_CSS_TRANSITIONS = 1 << 4,
/// Replace the style data coming from CSS animations without updating
/// any other style data. This hint is only processed in animation-only
/// traversal which is prior to normal traversal.
const RESTYLE_CSS_ANIMATIONS = 1 << 5;
const RESTYLE_CSS_ANIMATIONS = 1 << 5,
/// Don't re-run selector-matching on the element, only the style
/// attribute has changed, and this change didn't have any other
/// dependencies.
const RESTYLE_STYLE_ATTRIBUTE = 1 << 6;
const RESTYLE_STYLE_ATTRIBUTE = 1 << 6,
/// Replace the style data coming from SMIL animations without updating
/// any other style data. This hint is only processed in animation-only
/// traversal which is prior to normal traversal.
const RESTYLE_SMIL = 1 << 7;
const RESTYLE_SMIL = 1 << 7,
}
}
@ -49,26 +49,26 @@ impl RestyleHint {
/// Creates a new `RestyleHint` indicating that the current element and all
/// its descendants must be fully restyled.
pub fn restyle_subtree() -> Self {
RestyleHint::RESTYLE_SELF | RestyleHint::RESTYLE_DESCENDANTS
RESTYLE_SELF | RESTYLE_DESCENDANTS
}
/// Creates a new `RestyleHint` indicating that the current element and all
/// its descendants must be recascaded.
pub fn recascade_subtree() -> Self {
RestyleHint::RECASCADE_SELF | RestyleHint::RECASCADE_DESCENDANTS
RECASCADE_SELF | RECASCADE_DESCENDANTS
}
/// Returns whether this hint invalidates the element and all its
/// descendants.
pub fn contains_subtree(&self) -> bool {
self.contains(RestyleHint::RESTYLE_SELF | RestyleHint::RESTYLE_DESCENDANTS)
self.contains(RESTYLE_SELF | RESTYLE_DESCENDANTS)
}
/// Returns whether we need to restyle this element.
pub fn has_non_animation_invalidations(&self) -> bool {
self.intersects(
RestyleHint::RESTYLE_SELF |
RestyleHint::RECASCADE_SELF |
RESTYLE_SELF |
RECASCADE_SELF |
(Self::replacements() & !Self::for_animations())
)
}
@ -96,10 +96,10 @@ impl RestyleHint {
/// Returns a new `CascadeHint` appropriate for children of the current
/// element.
fn propagate_for_non_animation_restyle(&self) -> Self {
if self.contains(RestyleHint::RESTYLE_DESCENDANTS) {
if self.contains(RESTYLE_DESCENDANTS) {
return Self::restyle_subtree()
}
if self.contains(RestyleHint::RECASCADE_DESCENDANTS) {
if self.contains(RECASCADE_DESCENDANTS) {
return Self::recascade_subtree()
}
Self::empty()
@ -108,24 +108,24 @@ impl RestyleHint {
/// Creates a new `RestyleHint` that indicates the element must be
/// recascaded.
pub fn recascade_self() -> Self {
RestyleHint::RECASCADE_SELF
RECASCADE_SELF
}
/// Returns a hint that contains all the replacement hints.
pub fn replacements() -> Self {
RestyleHint::RESTYLE_STYLE_ATTRIBUTE | Self::for_animations()
RESTYLE_STYLE_ATTRIBUTE | Self::for_animations()
}
/// The replacements for the animation cascade levels.
#[inline]
pub fn for_animations() -> Self {
RestyleHint::RESTYLE_SMIL | RestyleHint::RESTYLE_CSS_ANIMATIONS | RestyleHint::RESTYLE_CSS_TRANSITIONS
RESTYLE_SMIL | RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS
}
/// Returns whether the hint specifies that the currently element must be
/// recascaded.
pub fn has_recascade_self(&self) -> bool {
self.contains(RestyleHint::RECASCADE_SELF)
self.contains(RECASCADE_SELF)
}
/// Returns whether the hint specifies that an animation cascade level must
@ -139,7 +139,7 @@ impl RestyleHint {
/// be replaced.
#[inline]
pub fn has_animation_hint_or_recascade(&self) -> bool {
self.intersects(Self::for_animations() | RestyleHint::RECASCADE_SELF)
self.intersects(Self::for_animations() | RECASCADE_SELF)
}
/// Returns whether the hint specifies some restyle work other than an
@ -153,7 +153,7 @@ impl RestyleHint {
/// for the element.
#[inline]
pub fn match_self(&self) -> bool {
self.intersects(RestyleHint::RESTYLE_SELF)
self.intersects(RESTYLE_SELF)
}
/// Returns whether the hint specifies that some cascade levels must be
@ -177,7 +177,7 @@ impl RestyleHint {
// normal restyle. (We could have separate RECASCADE_SELF_NORMAL and
// RECASCADE_SELF_ANIMATIONS flags to make it clear, but this isn't
// currently necessary.)
self.remove(RestyleHint::RECASCADE_SELF);
self.remove(RECASCADE_SELF);
}
}
@ -204,23 +204,23 @@ impl From<nsRestyleHint> for RestyleHint {
if (raw.0 & (eRestyle_Self.0 | eRestyle_Subtree.0)) != 0 {
raw.0 &= !eRestyle_Self.0;
hint.insert(RestyleHint::RESTYLE_SELF);
hint.insert(RESTYLE_SELF);
}
if (raw.0 & (eRestyle_Subtree.0 | eRestyle_SomeDescendants.0)) != 0 {
raw.0 &= !eRestyle_Subtree.0;
raw.0 &= !eRestyle_SomeDescendants.0;
hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
hint.insert(RESTYLE_DESCENDANTS);
}
if (raw.0 & (eRestyle_ForceDescendants.0 | eRestyle_Force.0)) != 0 {
raw.0 &= !eRestyle_Force.0;
hint.insert(RestyleHint::RECASCADE_SELF);
hint.insert(RECASCADE_SELF);
}
if (raw.0 & eRestyle_ForceDescendants.0) != 0 {
raw.0 &= !eRestyle_ForceDescendants.0;
hint.insert(RestyleHint::RECASCADE_DESCENDANTS);
hint.insert(RECASCADE_DESCENDANTS);
}
hint.insert(RestyleHint::from_bits_truncate(raw.0 as u8));
@ -239,7 +239,7 @@ pub fn assert_restyle_hints_match() {
use gecko_bindings::structs;
macro_rules! check_restyle_hints {
( $( $a:ident => $b:path),*, ) => {
( $( $a:ident => $b:ident ),*, ) => {
if cfg!(debug_assertions) {
let mut replacements = RestyleHint::replacements();
$(
@ -254,9 +254,9 @@ pub fn assert_restyle_hints_match() {
}
check_restyle_hints! {
nsRestyleHint_eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS,
nsRestyleHint_eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS,
nsRestyleHint_eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE,
nsRestyleHint_eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL,
nsRestyleHint_eRestyle_CSSTransitions => RESTYLE_CSS_TRANSITIONS,
nsRestyleHint_eRestyle_CSSAnimations => RESTYLE_CSS_ANIMATIONS,
nsRestyleHint_eRestyle_StyleAttribute => RESTYLE_STYLE_ATTRIBUTE,
nsRestyleHint_eRestyle_StyleAttribute_Animations => RESTYLE_SMIL,
}
}

View file

@ -11,7 +11,7 @@ use Atom;
use LocalName as SelectorLocalName;
use dom::{TElement, TNode};
use fnv::FnvHashSet;
use invalidation::element::restyle_hints::RestyleHint;
use invalidation::element::restyle_hints::{RESTYLE_SELF, RestyleHint};
use media_queries::Device;
use selector_parser::SelectorImpl;
use selectors::attr::CaseSensitivity;
@ -223,12 +223,12 @@ impl StylesheetInvalidationSet {
let mut self_invalid = false;
if !data.hint.contains(RestyleHint::RESTYLE_SELF) {
if !data.hint.contains(RESTYLE_SELF) {
for invalidation in &self.invalid_elements {
if invalidation.matches(element) {
debug!("process_invalidations_in_subtree: {:?} matched self {:?}",
element, invalidation);
data.hint.insert(RestyleHint::RESTYLE_SELF);
data.hint.insert(RESTYLE_SELF);
self_invalid = true;
break;
}

View file

@ -25,51 +25,51 @@ pub enum InlineBaseDirection {
// TODO: improve the readability of the WritingMode serialization, refer to the Debug:fmt()
bitflags!(
#[cfg_attr(feature = "servo", derive(MallocSizeOf, Serialize))]
pub struct WritingMode: u8 {
const RTL = 1 << 0;
const VERTICAL = 1 << 1;
const VERTICAL_LR = 1 << 2;
pub flags WritingMode: u8 {
const FLAG_RTL = 1 << 0,
const FLAG_VERTICAL = 1 << 1,
const FLAG_VERTICAL_LR = 1 << 2,
/// For vertical writing modes only. When set, line-over/line-under
/// sides are inverted from block-start/block-end. This flag is
/// set when sideways-lr is used.
const LINE_INVERTED = 1 << 3;
const SIDEWAYS = 1 << 4;
const UPRIGHT = 1 << 5;
const FLAG_LINE_INVERTED = 1 << 3,
const FLAG_SIDEWAYS = 1 << 4,
const FLAG_UPRIGHT = 1 << 5,
}
);
impl WritingMode {
#[inline]
pub fn is_vertical(&self) -> bool {
self.intersects(WritingMode::VERTICAL)
self.intersects(FLAG_VERTICAL)
}
/// Assuming .is_vertical(), does the block direction go left to right?
#[inline]
pub fn is_vertical_lr(&self) -> bool {
self.intersects(WritingMode::VERTICAL_LR)
self.intersects(FLAG_VERTICAL_LR)
}
/// Assuming .is_vertical(), does the inline direction go top to bottom?
#[inline]
pub fn is_inline_tb(&self) -> bool {
// https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
self.intersects(WritingMode::RTL) == self.intersects(WritingMode::LINE_INVERTED)
self.intersects(FLAG_RTL) == self.intersects(FLAG_LINE_INVERTED)
}
#[inline]
pub fn is_bidi_ltr(&self) -> bool {
!self.intersects(WritingMode::RTL)
!self.intersects(FLAG_RTL)
}
#[inline]
pub fn is_sideways(&self) -> bool {
self.intersects(WritingMode::SIDEWAYS)
self.intersects(FLAG_SIDEWAYS)
}
#[inline]
pub fn is_upright(&self) -> bool {
self.intersects(WritingMode::UPRIGHT)
self.intersects(FLAG_UPRIGHT)
}
#[inline]
@ -121,7 +121,7 @@ impl WritingMode {
#[inline]
pub fn inline_base_direction(&self) -> InlineBaseDirection {
if self.intersects(WritingMode::RTL) {
if self.intersects(FLAG_RTL) {
InlineBaseDirection::RightToLeft
} else {
InlineBaseDirection::LeftToRight
@ -150,10 +150,10 @@ impl fmt::Display for WritingMode {
} else {
write!(formatter, " RL")?;
}
if self.intersects(WritingMode::SIDEWAYS) {
if self.intersects(FLAG_SIDEWAYS) {
write!(formatter, " Sideways")?;
}
if self.intersects(WritingMode::LINE_INVERTED) {
if self.intersects(FLAG_LINE_INVERTED) {
write!(formatter, " Inverted")?;
}
} else {

View file

@ -11,6 +11,8 @@ use context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap};
use context::{SharedStyleContext, StyleContext};
use data::ElementData;
use dom::TElement;
use invalidation::element::restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS};
use invalidation::element::restyle_hints::{RESTYLE_SMIL, RESTYLE_STYLE_ATTRIBUTE};
use invalidation::element::restyle_hints::RestyleHint;
use properties::ComputedValues;
use rule_tree::{CascadeLevel, StrongRuleNode};
@ -18,7 +20,7 @@ use selector_parser::{PseudoElement, RestyleDamage};
use selectors::matching::ElementSelectorFlags;
use servo_arc::{Arc, ArcBorrow};
use style_resolver::ResolvedElementStyles;
use traversal_flags::TraversalFlags;
use traversal_flags;
/// Represents the result of comparing an element's old and new style.
#[derive(Debug)]
@ -159,7 +161,7 @@ trait PrivateMatchMethods: TElement {
// animation is running or not.
// TODO: We should check which @keyframes changed/added/deleted
// and update only animations corresponding to those @keyframes.
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) &&
(context.shared.traversal_flags.contains(traversal_flags::ForCSSRuleChanges) &&
(has_new_animation_style || has_animations)) ||
!old_box_style.animations_equals(new_box_style) ||
(old_display_style == display::T::none &&
@ -181,10 +183,10 @@ trait PrivateMatchMethods: TElement {
new_values: &ComputedValues,
restyle_hints: RestyleHint
) {
use context::PostAnimationTasks;
use context::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL;
use properties::longhands::display::computed_value as display;
if !restyle_hints.intersects(RestyleHint::RESTYLE_SMIL) {
if !restyle_hints.intersects(RESTYLE_SMIL) {
return;
}
@ -204,7 +206,7 @@ trait PrivateMatchMethods: TElement {
// restyle).
let task = ::context::SequentialTask::process_post_animation(
*self,
PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL,
DISPLAY_CHANGED_FROM_NONE_FOR_SMIL,
);
context.thread_local.tasks.push(task);
}
@ -217,6 +219,7 @@ trait PrivateMatchMethods: TElement {
new_values: &mut Arc<ComputedValues>,
restyle_hint: RestyleHint,
important_rules_changed: bool) {
use context::{CASCADE_RESULTS, CSS_ANIMATIONS, CSS_TRANSITIONS, EFFECT_PROPERTIES};
use context::UpdateAnimationsTasks;
if context.shared.traversal_flags.for_animation_only() {
@ -234,7 +237,7 @@ trait PrivateMatchMethods: TElement {
let mut tasks = UpdateAnimationsTasks::empty();
if self.needs_animations_update(context, old_values.as_ref(), new_values) {
tasks.insert(UpdateAnimationsTasks::CSS_ANIMATIONS);
tasks.insert(CSS_ANIMATIONS);
}
let before_change_style = if self.might_need_transitions_update(old_values.as_ref().map(|s| &**s),
@ -262,7 +265,7 @@ trait PrivateMatchMethods: TElement {
if let Some(values_without_transitions) = after_change_style {
*new_values = values_without_transitions;
}
tasks.insert(UpdateAnimationsTasks::CSS_TRANSITIONS);
tasks.insert(CSS_TRANSITIONS);
// We need to clone old_values into SequentialTask, so we can use it later.
old_values.clone()
@ -274,9 +277,9 @@ trait PrivateMatchMethods: TElement {
};
if self.has_animations() {
tasks.insert(UpdateAnimationsTasks::EFFECT_PROPERTIES);
tasks.insert(EFFECT_PROPERTIES);
if important_rules_changed {
tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS);
tasks.insert(CASCADE_RESULTS);
}
}
@ -342,7 +345,7 @@ trait PrivateMatchMethods: TElement {
debug!("accumulate_damage_for: {:?}", self);
// Don't accumulate damage if we're in a forgetful traversal.
if shared_context.traversal_flags.contains(TraversalFlags::Forgetful) {
if shared_context.traversal_flags.contains(traversal_flags::Forgetful) {
debug!(" > forgetful traversal");
return ChildCascadeRequirement::MustCascadeChildren;
}
@ -398,7 +401,7 @@ trait PrivateMatchMethods: TElement {
// seems not common enough to care about.
#[cfg(feature = "gecko")]
{
use values::specified::align::AlignFlags;
use values::specified::align;
let old_justify_items =
old_values.get_position().clone_justify_items();
@ -406,10 +409,10 @@ trait PrivateMatchMethods: TElement {
new_values.get_position().clone_justify_items();
let was_legacy_justify_items =
old_justify_items.computed.0.contains(AlignFlags::LEGACY);
old_justify_items.computed.0.contains(align::ALIGN_LEGACY);
let is_legacy_justify_items =
new_justify_items.computed.0.contains(AlignFlags::LEGACY);
new_justify_items.computed.0.contains(align::ALIGN_LEGACY);
if is_legacy_justify_items != was_legacy_justify_items {
return ChildCascadeRequirement::MustCascadeChildren;
@ -581,7 +584,7 @@ pub trait MatchMethods : TElement {
}
// Don't accumulate damage if we're in a forgetful traversal.
if context.shared.traversal_flags.contains(TraversalFlags::Forgetful) {
if context.shared.traversal_flags.contains(traversal_flags::Forgetful) {
return ChildCascadeRequirement::MustCascadeChildren;
}
@ -765,7 +768,7 @@ pub trait MatchMethods : TElement {
if !context.shared.traversal_flags.for_animation_only() {
let mut result = false;
if replacements.contains(RestyleHint::RESTYLE_STYLE_ATTRIBUTE) {
if replacements.contains(RESTYLE_STYLE_ATTRIBUTE) {
let style_attribute = self.style_attribute();
result |= replace_rule_node(CascadeLevel::StyleAttributeNormal,
style_attribute,
@ -787,7 +790,7 @@ pub trait MatchMethods : TElement {
if replacements.intersects(RestyleHint::for_animations()) {
debug_assert!(context.shared.traversal_flags.for_animation_only());
if replacements.contains(RestyleHint::RESTYLE_SMIL) {
if replacements.contains(RESTYLE_SMIL) {
replace_rule_node(CascadeLevel::SMILOverride,
self.get_smil_override(),
primary_rules);
@ -803,12 +806,12 @@ pub trait MatchMethods : TElement {
// Apply Transition rules and Animation rules if the corresponding restyle hint
// is contained.
if replacements.contains(RestyleHint::RESTYLE_CSS_TRANSITIONS) {
if replacements.contains(RESTYLE_CSS_TRANSITIONS) {
replace_rule_node_for_animation(CascadeLevel::Transitions,
primary_rules);
}
if replacements.contains(RestyleHint::RESTYLE_CSS_ANIMATIONS) {
if replacements.contains(RESTYLE_CSS_ANIMATIONS) {
replace_rule_node_for_animation(CascadeLevel::Animations,
primary_rules);
}

View file

@ -8,6 +8,8 @@ use context::QuirksMode;
use cssparser::{Parser, SourceLocation, UnicodeRange};
use error_reporting::{ParseErrorReporter, ContextualParseError};
use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator};
#[cfg(feature = "gecko")]
use style_traits::{PARSING_MODE_DEFAULT, PARSING_MODE_ALLOW_UNITLESS_LENGTH, PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES};
use stylesheets::{CssRuleType, Origin, UrlExtraData, Namespaces};
/// Asserts that all ParsingMode flags have a matching ParsingMode value in gecko.
@ -17,7 +19,7 @@ pub fn assert_parsing_mode_match() {
use gecko_bindings::structs;
macro_rules! check_parsing_modes {
( $( $a:ident => $b:path ),*, ) => {
( $( $a:ident => $b:ident ),*, ) => {
if cfg!(debug_assertions) {
let mut modes = ParsingMode::all();
$(
@ -30,9 +32,9 @@ pub fn assert_parsing_mode_match() {
}
check_parsing_modes! {
ParsingMode_Default => ParsingMode::DEFAULT,
ParsingMode_AllowUnitlessLength => ParsingMode::ALLOW_UNITLESS_LENGTH,
ParsingMode_AllowAllNumericValues => ParsingMode::ALLOW_ALL_NUMERIC_VALUES,
ParsingMode_Default => PARSING_MODE_DEFAULT,
ParsingMode_AllowUnitlessLength => PARSING_MODE_ALLOW_UNITLESS_LENGTH,
ParsingMode_AllowAllNumericValues => PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES,
}
}

View file

@ -11,13 +11,13 @@ bitflags! {
/// anonymous boxes, see StyleBuilder::for_inheritance and its callsites.
/// If we ever want to add some flags that shouldn't inherit for them,
/// we might want to add a function to handle this.
pub struct ComputedValueFlags: u16 {
pub flags ComputedValueFlags: u16 {
/// Whether the style or any of the ancestors has a text-decoration-line
/// property that should get propagated to descendants.
///
/// text-decoration-line is a reset property, but gets propagated in the
/// frame/box tree.
const HAS_TEXT_DECORATION_LINES = 1 << 0;
const HAS_TEXT_DECORATION_LINES = 1 << 0,
/// Whether line break inside should be suppressed.
///
@ -27,41 +27,41 @@ bitflags! {
///
/// This bit is propagated to all children of line participants.
/// It is currently used by ruby to make its content unbreakable.
const SHOULD_SUPPRESS_LINEBREAK = 1 << 1;
const SHOULD_SUPPRESS_LINEBREAK = 1 << 1,
/// A flag used to mark text that that has text-combine-upright.
///
/// This is used from Gecko's layout engine.
const IS_TEXT_COMBINED = 1 << 2;
const IS_TEXT_COMBINED = 1 << 2,
/// A flag used to mark styles under a relevant link that is also
/// visited.
const IS_RELEVANT_LINK_VISITED = 1 << 3;
const IS_RELEVANT_LINK_VISITED = 1 << 3,
/// A flag used to mark styles which are a pseudo-element or under one.
const IS_IN_PSEUDO_ELEMENT_SUBTREE = 1 << 4;
const IS_IN_PSEUDO_ELEMENT_SUBTREE = 1 << 4,
/// A flag used to mark styles which are in a display: none subtree, or
/// under one.
const IS_IN_DISPLAY_NONE_SUBTREE = 1 << 5;
const IS_IN_DISPLAY_NONE_SUBTREE = 1 << 5,
/// Whether this style inherits the `display` property.
///
/// This is important because it may affect our optimizations to avoid
/// computing the style of pseudo-elements, given whether the
/// pseudo-element is generated depends on the `display` value.
const INHERITS_DISPLAY = 1 << 6;
const INHERITS_DISPLAY = 1 << 6,
/// Whether this style inherits the `content` property.
///
/// Important because of the same reason.
const INHERITS_CONTENT = 1 << 7;
const INHERITS_CONTENT = 1 << 7,
/// Whether the child explicitly inherits any reset property.
const INHERITS_RESET_STYLE = 1 << 8;
const INHERITS_RESET_STYLE = 1 << 8,
/// A flag to mark a style which is a visited style.
const IS_STYLE_IF_VISITED = 1 << 9;
const IS_STYLE_IF_VISITED = 1 << 9,
}
}
@ -69,8 +69,6 @@ impl ComputedValueFlags {
/// Returns the flags that are inherited.
#[inline]
pub fn inherited(self) -> Self {
self & !(ComputedValueFlags::INHERITS_DISPLAY |
ComputedValueFlags::INHERITS_CONTENT |
ComputedValueFlags::INHERITS_RESET_STYLE)
self & !(INHERITS_DISPLAY | INHERITS_CONTENT | INHERITS_RESET_STYLE)
}
}

View file

@ -19,7 +19,7 @@ use smallvec::SmallVec;
use std::fmt;
use std::iter::{DoubleEndedIterator, Zip};
use std::slice::Iter;
use style_traits::{ToCss, ParseError, ParsingMode, StyleParseErrorKind};
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, ParsingMode, StyleParseErrorKind};
use stylesheets::{CssRuleType, Origin, UrlExtraData};
use super::*;
use values::computed::Context;
@ -853,7 +853,7 @@ impl ToCss for PropertyDeclarationBlock {
// Substeps 7 and 8
// We need to check the shorthand whether it's an alias property or not.
// If it's an alias property, it should be serialized like its longhand.
if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) {
append_serialization::<_, Cloned<slice::Iter< _>>, _>(
dest,
&property,
@ -1023,7 +1023,7 @@ pub fn parse_style_attribute<R>(input: &str,
let context = ParserContext::new(Origin::Author,
url_data,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
PARSING_MODE_DEFAULT,
quirks_mode);
let error_context = ParserErrorContext { error_reporter: error_reporter };
let mut input = ParserInput::new(input);

View file

@ -1538,7 +1538,7 @@ fn static_assert() {
}
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert!(v.0 != ::values::specified::align::AlignFlags::AUTO);
debug_assert!(v.0 != ::values::specified::align::ALIGN_AUTO);
self.gecko.mJustifyItems = v.into();
}
@ -3364,20 +3364,20 @@ fn static_assert() {
use properties::longhands::will_change::computed_value::T;
fn will_change_bitfield_from_prop_flags(prop: &LonghandId) -> u8 {
use properties::PropertyFlags;
use properties::{ABSPOS_CB, CREATES_STACKING_CONTEXT, FIXPOS_CB};
use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_ABSPOS_CB;
use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_FIXPOS_CB;
use gecko_bindings::structs::NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
let servo_flags = prop.flags();
let mut bitfield = 0;
if servo_flags.contains(PropertyFlags::CREATES_STACKING_CONTEXT) {
if servo_flags.contains(CREATES_STACKING_CONTEXT) {
bitfield |= NS_STYLE_WILL_CHANGE_STACKING_CONTEXT;
}
if servo_flags.contains(PropertyFlags::FIXPOS_CB) {
if servo_flags.contains(FIXPOS_CB) {
bitfield |= NS_STYLE_WILL_CHANGE_FIXPOS_CB;
}
if servo_flags.contains(PropertyFlags::ABSPOS_CB) {
if servo_flags.contains(ABSPOS_CB) {
bitfield |= NS_STYLE_WILL_CHANGE_ABSPOS_CB;
}
@ -3470,26 +3470,26 @@ fn static_assert() {
use gecko_bindings::structs::NS_STYLE_CONTAIN_STYLE;
use gecko_bindings::structs::NS_STYLE_CONTAIN_PAINT;
use gecko_bindings::structs::NS_STYLE_CONTAIN_ALL_BITS;
use properties::longhands::contain::SpecifiedValue;
use properties::longhands::contain;
if v.is_empty() {
self.gecko.mContain = NS_STYLE_CONTAIN_NONE as u8;
return;
}
if v.contains(SpecifiedValue::STRICT) {
if v.contains(contain::STRICT) {
self.gecko.mContain = (NS_STYLE_CONTAIN_STRICT | NS_STYLE_CONTAIN_ALL_BITS) as u8;
return;
}
let mut bitfield = 0;
if v.contains(SpecifiedValue::LAYOUT) {
if v.contains(contain::LAYOUT) {
bitfield |= NS_STYLE_CONTAIN_LAYOUT;
}
if v.contains(SpecifiedValue::STYLE) {
if v.contains(contain::STYLE) {
bitfield |= NS_STYLE_CONTAIN_STYLE;
}
if v.contains(SpecifiedValue::PAINT) {
if v.contains(contain::PAINT) {
bitfield |= NS_STYLE_CONTAIN_PAINT;
}
@ -3502,25 +3502,25 @@ fn static_assert() {
use gecko_bindings::structs::NS_STYLE_CONTAIN_STYLE;
use gecko_bindings::structs::NS_STYLE_CONTAIN_PAINT;
use gecko_bindings::structs::NS_STYLE_CONTAIN_ALL_BITS;
use properties::longhands::contain::{self, SpecifiedValue};
use properties::longhands::contain;
let mut servo_flags = contain::computed_value::T::empty();
let gecko_flags = self.gecko.mContain;
if gecko_flags & (NS_STYLE_CONTAIN_STRICT as u8) != 0 &&
gecko_flags & (NS_STYLE_CONTAIN_ALL_BITS as u8) != 0 {
servo_flags.insert(SpecifiedValue::STRICT | SpecifiedValue::STRICT_BITS);
servo_flags.insert(contain::STRICT | contain::STRICT_BITS);
return servo_flags;
}
if gecko_flags & (NS_STYLE_CONTAIN_LAYOUT as u8) != 0 {
servo_flags.insert(SpecifiedValue::LAYOUT);
servo_flags.insert(contain::LAYOUT);
}
if gecko_flags & (NS_STYLE_CONTAIN_STYLE as u8) != 0{
servo_flags.insert(SpecifiedValue::STYLE);
servo_flags.insert(contain::STYLE);
}
if gecko_flags & (NS_STYLE_CONTAIN_PAINT as u8) != 0 {
servo_flags.insert(SpecifiedValue::PAINT);
servo_flags.insert(contain::PAINT);
}
return servo_flags;

View file

@ -15,8 +15,7 @@ ${helpers.predefined_type(
animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True,
allow_quirks=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
)}
${helpers.predefined_type("background-image", "ImageLayer",
@ -26,8 +25,7 @@ ${helpers.predefined_type("background-image", "ImageLayer",
vector="True",
animation_value_type="discrete",
ignored_when_colors_disabled="True",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""")}
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
% for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]:
${helpers.predefined_type(
@ -38,15 +36,13 @@ ${helpers.predefined_type("background-image", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis,
animation_value_type="ComputedValue",
vector=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
)}
% endfor
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""">
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER">
use std::fmt;
use style_traits::ToCss;
@ -146,8 +142,7 @@ ${helpers.single_keyword("background-attachment",
gecko_constant_prefix="NS_STYLE_IMAGELAYER_ATTACHMENT",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-attachment",
animation_value_type="discrete",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""")}
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.single_keyword("background-clip",
"border-box padding-box content-box",
@ -156,8 +151,7 @@ ${helpers.single_keyword("background-clip",
gecko_enum_prefix="StyleGeometryBox",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-clip",
animation_value_type="discrete",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""")}
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.single_keyword("background-origin",
"padding-box border-box content-box",
@ -165,8 +159,7 @@ ${helpers.single_keyword("background-origin",
gecko_enum_prefix="StyleGeometryBox",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-origin",
animation_value_type="discrete",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""")}
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
${helpers.predefined_type("background-size", "BackgroundSize",
initial_value="computed::BackgroundSize::auto()",
@ -175,8 +168,7 @@ ${helpers.predefined_type("background-size", "BackgroundSize",
vector=True,
animation_value_type="BackgroundSizeList",
need_animatable=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
extra_prefixes="webkit")}
// https://drafts.fxtf.org/compositing/#background-blend-mode
@ -187,5 +179,4 @@ ${helpers.single_keyword("background-blend-mode",
gecko_constant_prefix="NS_STYLE_BLEND",
vector=True, products="gecko", animation_value_type="discrete",
spec="https://drafts.fxtf.org/compositing/#background-blend-mode",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""")}
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}

View file

@ -28,7 +28,7 @@
animation_value_type="AnimatedColor",
logical=is_logical,
allow_quirks=not is_logical,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
ignored_when_colors_disabled=True,
)}
@ -36,7 +36,7 @@
"specified::BorderStyle::none",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"),
spec=maybe_logical_spec(side, "style"),
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
animation_value_type="discrete" if not is_logical else "none",
logical=is_logical)}
@ -48,7 +48,7 @@
spec=maybe_logical_spec(side, "width"),
animation_value_type="NonNegativeLength",
logical=is_logical,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
allow_quirks=not is_logical)}
% endfor
@ -63,7 +63,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
"parse", extra_prefixes="webkit",
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,
boxed=True,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
animation_value_type="BorderCornerRadius")}
% endfor
@ -73,7 +73,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
<%helpers:longhand name="-moz-border-${side}-colors" animation_value_type="discrete"
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-*-colors)"
products="gecko"
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER"
flags="APPLIES_TO_FIRST_LETTER"
ignored_when_colors_disabled="True">
use std::fmt;
use style_traits::ToCss;
@ -207,7 +207,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
vector=False,
animation_value_type="discrete",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
boxed="True")}
${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
@ -216,11 +216,11 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
initial_specified_value="specified::LengthOrNumberRect::all(specified::LengthOrNumber::zero())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
animation_value_type="discrete",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)}
<%helpers:longhand name="border-image-repeat" animation_value_type="discrete"
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER"
flags="APPLIES_TO_FIRST_LETTER"
spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat">
use style_traits::ToCss;
@ -279,7 +279,7 @@ ${helpers.predefined_type("border-image-width", "BorderImageWidth",
initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
animation_value_type="discrete",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)}
${helpers.predefined_type("border-image-slice", "BorderImageSlice",
@ -287,7 +287,7 @@ ${helpers.predefined_type("border-image-slice", "BorderImageSlice",
initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage::new(1.)).into()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
animation_value_type="discrete",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
boxed=True)}
#[cfg(feature = "gecko")]

View file

@ -16,7 +16,7 @@
<%helpers:longhand name="display"
animation_value_type="discrete"
custom_cascade="${product == 'servo'}"
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-display/#propdef-display">
<%
values = """inline block inline-block
@ -227,7 +227,7 @@ ${helpers.single_keyword("-moz-top-layer", "none top",
${helpers.single_keyword("position", "static absolute relative fixed sticky",
animation_value_type="discrete",
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::ABSPOS_CB",
flags="CREATES_STACKING_CONTEXT ABSPOS_CB",
spec="https://drafts.csswg.org/css-position/#position-property")}
<%helpers:single_keyword_computed name="float"
@ -240,7 +240,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
gecko_inexhaustive="True"
gecko_ffi_name="mFloat"
gecko_pref_ident="float_"
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER"
flags="APPLIES_TO_FIRST_LETTER"
spec="https://drafts.csswg.org/css-box/#propdef-float">
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
@ -362,8 +362,7 @@ ${helpers.predefined_type(
"VerticalAlign",
"computed::VerticalAlign::baseline()",
animation_value_type="ComputedValue",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align",
)}
@ -376,7 +375,7 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
${helpers.single_keyword("overflow-clip-box", "padding-box content-box",
products="gecko", animation_value_type="discrete", internal=True,
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
@ -390,12 +389,12 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
extra_gecko_values="-moz-hidden-unscrollable",
custom_consts=overflow_custom_consts,
gecko_constant_prefix="NS_STYLE_OVERFLOW",
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x")}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
<%helpers:longhand name="overflow-y" animation_value_type="discrete"
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y">
pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value};
</%helpers:longhand>
@ -669,7 +668,7 @@ ${helpers.predefined_type(
<%helpers:longhand name="transform" extra_prefixes="webkit"
animation_value_type="ComputedValue"
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::FIXPOS_CB"
flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
use values::computed::{LengthOrPercentageOrNumber as ComputedLoPoNumber, LengthOrNumber as ComputedLoN};
use values::computed::{LengthOrPercentage as ComputedLoP, Length as ComputedLength};
@ -1572,7 +1571,7 @@ ${helpers.single_keyword("isolation",
"auto isolate",
products="gecko",
spec="https://drafts.fxtf.org/compositing/#isolation",
flags="PropertyFlags::CREATES_STACKING_CONTEXT",
flags="CREATES_STACKING_CONTEXT",
animation_value_type="discrete")}
// TODO add support for logical values recto and verso
@ -1605,7 +1604,7 @@ ${helpers.single_keyword("resize",
"none both horizontal vertical",
products="gecko",
spec="https://drafts.csswg.org/css-ui/#propdef-resize",
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
@ -1616,7 +1615,7 @@ ${helpers.predefined_type("perspective",
gecko_ffi_name="mChildPerspective",
spec="https://drafts.csswg.org/css-transforms/#perspective",
extra_prefixes="moz webkit",
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::FIXPOS_CB",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
animation_value_type="ComputedValue")}
${helpers.predefined_type("perspective-origin",
@ -1647,7 +1646,7 @@ ${helpers.single_keyword("transform-style",
"flat preserve-3d",
spec="https://drafts.csswg.org/css-transforms/#transform-style-property",
extra_prefixes="moz webkit",
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::FIXPOS_CB",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
animation_value_type="discrete")}
${helpers.predefined_type("transform-origin",
@ -1662,7 +1661,7 @@ ${helpers.predefined_type("transform-origin",
// like `content`(layout style paint) in gecko. We should implement `size` and `content`,
// also update the glue once they are implemented in gecko.
<%helpers:longhand name="contain" animation_value_type="discrete" products="gecko"
flags="PropertyFlags::FIXPOS_CB"
flags="FIXPOS_CB"
spec="https://drafts.csswg.org/css-contain/#contain-property">
use std::fmt;
use style_traits::ToCss;
@ -1673,12 +1672,12 @@ ${helpers.predefined_type("transform-origin",
bitflags! {
#[derive(MallocSizeOf, ToComputedValue)]
pub struct SpecifiedValue: u8 {
const LAYOUT = 0x01;
const STYLE = 0x02;
const PAINT = 0x04;
const STRICT = 0x8;
const STRICT_BITS = SpecifiedValue::LAYOUT.bits | SpecifiedValue::STYLE.bits | SpecifiedValue::PAINT.bits;
pub flags SpecifiedValue: u8 {
const LAYOUT = 0x01,
const STYLE = 0x02,
const PAINT = 0x04,
const STRICT = 0x8,
const STRICT_BITS = LAYOUT.bits | STYLE.bits | PAINT.bits,
}
}
@ -1687,13 +1686,13 @@ ${helpers.predefined_type("transform-origin",
if self.is_empty() {
return dest.write_str("none")
}
if self.contains(SpecifiedValue::STRICT) {
if self.contains(STRICT) {
return dest.write_str("strict")
}
let mut has_any = false;
macro_rules! maybe_write_value {
($ident:path => $str:expr) => {
($ident:ident => $str:expr) => {
if self.contains($ident) {
if has_any {
dest.write_str(" ")?;
@ -1703,9 +1702,9 @@ ${helpers.predefined_type("transform-origin",
}
}
}
maybe_write_value!(SpecifiedValue::LAYOUT => "layout");
maybe_write_value!(SpecifiedValue::STYLE => "style");
maybe_write_value!(SpecifiedValue::PAINT => "paint");
maybe_write_value!(LAYOUT => "layout");
maybe_write_value!(STYLE => "style");
maybe_write_value!(PAINT => "paint");
debug_assert!(has_any);
Ok(())
@ -1726,15 +1725,15 @@ ${helpers.predefined_type("transform-origin",
return Ok(result)
}
if input.try(|input| input.expect_ident_matching("strict")).is_ok() {
result.insert(SpecifiedValue::STRICT | SpecifiedValue::STRICT_BITS);
result.insert(STRICT | STRICT_BITS);
return Ok(result)
}
while let Ok(name) = input.try(|i| i.expect_ident_cloned()) {
let flag = match_ignore_ascii_case! { &name,
"layout" => Some(SpecifiedValue::LAYOUT),
"style" => Some(SpecifiedValue::STYLE),
"paint" => Some(SpecifiedValue::PAINT),
"layout" => Some(LAYOUT),
"style" => Some(STYLE),
"paint" => Some(PAINT),
_ => None
};
let flag = match flag {
@ -1865,7 +1864,7 @@ ${helpers.predefined_type(
products="gecko",
boxed=True,
animation_value_type="ComputedValue",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property",
)}
@ -1885,28 +1884,28 @@ ${helpers.predefined_type(
/// These constants match Gecko's `NS_STYLE_TOUCH_ACTION_*` constants.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(ToComputedValue)]
pub struct SpecifiedValue: u8 {
const TOUCH_ACTION_NONE = structs::NS_STYLE_TOUCH_ACTION_NONE as u8;
const TOUCH_ACTION_AUTO = structs::NS_STYLE_TOUCH_ACTION_AUTO as u8;
const TOUCH_ACTION_PAN_X = structs::NS_STYLE_TOUCH_ACTION_PAN_X as u8;
const TOUCH_ACTION_PAN_Y = structs::NS_STYLE_TOUCH_ACTION_PAN_Y as u8;
const TOUCH_ACTION_MANIPULATION = structs::NS_STYLE_TOUCH_ACTION_MANIPULATION as u8;
pub flags SpecifiedValue: u8 {
const TOUCH_ACTION_NONE = structs::NS_STYLE_TOUCH_ACTION_NONE as u8,
const TOUCH_ACTION_AUTO = structs::NS_STYLE_TOUCH_ACTION_AUTO as u8,
const TOUCH_ACTION_PAN_X = structs::NS_STYLE_TOUCH_ACTION_PAN_X as u8,
const TOUCH_ACTION_PAN_Y = structs::NS_STYLE_TOUCH_ACTION_PAN_Y as u8,
const TOUCH_ACTION_MANIPULATION = structs::NS_STYLE_TOUCH_ACTION_MANIPULATION as u8,
}
}
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
SpecifiedValue::TOUCH_ACTION_NONE => dest.write_str("none"),
SpecifiedValue::TOUCH_ACTION_AUTO => dest.write_str("auto"),
SpecifiedValue::TOUCH_ACTION_MANIPULATION => dest.write_str("manipulation"),
_ if self.contains(SpecifiedValue::TOUCH_ACTION_PAN_X | SpecifiedValue::TOUCH_ACTION_PAN_Y) => {
TOUCH_ACTION_NONE => dest.write_str("none"),
TOUCH_ACTION_AUTO => dest.write_str("auto"),
TOUCH_ACTION_MANIPULATION => dest.write_str("manipulation"),
_ if self.contains(TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y) => {
dest.write_str("pan-x pan-y")
},
_ if self.contains(SpecifiedValue::TOUCH_ACTION_PAN_X) => {
_ if self.contains(TOUCH_ACTION_PAN_X) => {
dest.write_str("pan-x")
},
_ if self.contains(SpecifiedValue::TOUCH_ACTION_PAN_Y) => {
_ if self.contains(TOUCH_ACTION_PAN_Y) => {
dest.write_str("pan-y")
},
_ => panic!("invalid touch-action value"),
@ -1916,28 +1915,28 @@ ${helpers.predefined_type(
#[inline]
pub fn get_initial_value() -> computed_value::T {
SpecifiedValue::TOUCH_ACTION_AUTO
TOUCH_ACTION_AUTO
}
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> {
// FIXME: remove clone() when lifetimes are non-lexical
try_match_ident_ignore_ascii_case! { input,
"auto" => Ok(SpecifiedValue::TOUCH_ACTION_AUTO),
"none" => Ok(SpecifiedValue::TOUCH_ACTION_NONE),
"manipulation" => Ok(SpecifiedValue::TOUCH_ACTION_MANIPULATION),
"auto" => Ok(TOUCH_ACTION_AUTO),
"none" => Ok(TOUCH_ACTION_NONE),
"manipulation" => Ok(TOUCH_ACTION_MANIPULATION),
"pan-x" => {
if input.try(|i| i.expect_ident_matching("pan-y")).is_ok() {
Ok(SpecifiedValue::TOUCH_ACTION_PAN_X | SpecifiedValue::TOUCH_ACTION_PAN_Y)
Ok(TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y)
} else {
Ok(SpecifiedValue::TOUCH_ACTION_PAN_X)
Ok(TOUCH_ACTION_PAN_X)
}
},
"pan-y" => {
if input.try(|i| i.expect_ident_matching("pan-x")).is_ok() {
Ok(SpecifiedValue::TOUCH_ACTION_PAN_X | SpecifiedValue::TOUCH_ACTION_PAN_Y)
Ok(TOUCH_ACTION_PAN_X | TOUCH_ACTION_PAN_Y)
} else {
Ok(SpecifiedValue::TOUCH_ACTION_PAN_Y)
Ok(TOUCH_ACTION_PAN_Y)
}
},
}

View file

@ -13,8 +13,7 @@ ${helpers.predefined_type(
"ColorPropertyValue",
"::cssparser::RGBA::new(0, 0, 0, 255)",
animation_value_type="AnimatedRGBA",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
ignored_when_colors_disabled="True",
spec="https://drafts.csswg.org/css-color/#color"
)}

View file

@ -11,7 +11,7 @@ ${helpers.predefined_type("opacity",
"Opacity",
"1.0",
animation_value_type="ComputedValue",
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="CREATES_STACKING_CONTEXT APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-color/#opacity")}
${helpers.predefined_type(
@ -22,7 +22,7 @@ ${helpers.predefined_type(
animation_value_type="AnimatedBoxShadowList",
extra_prefixes="webkit",
ignored_when_colors_disabled=True,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-backgrounds/#box-shadow",
)}
@ -42,7 +42,7 @@ ${helpers.predefined_type(
separator="Space",
animation_value_type="AnimatedFilterList",
extra_prefixes="webkit",
flags="PropertyFlags::CREATES_STACKING_CONTEXT PropertyFlags::FIXPOS_CB",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
spec="https://drafts.fxtf.org/filters/#propdef-filter",
)}
@ -51,5 +51,5 @@ ${helpers.single_keyword("mix-blend-mode",
color-burn hard-light soft-light difference exclusion hue
saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND",
animation_value_type="discrete",
flags="PropertyFlags::CREATES_STACKING_CONTEXT",
flags="CREATES_STACKING_CONTEXT",
spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")}

View file

@ -69,8 +69,7 @@ macro_rules! impl_gecko_keyword_conversions {
</%def>
<%helpers:longhand name="font-family" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family">
#[cfg(feature = "gecko")] use gecko_bindings::bindings;
#[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
@ -597,8 +596,7 @@ ${helpers.single_keyword_system("font-style",
gecko_constant_prefix="NS_FONT_STYLE",
gecko_ffi_name="mFont.style",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
@ -615,13 +613,11 @@ ${helpers.single_keyword_system("font-variant-caps",
gecko_ffi_name="mFont.variantCaps",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps",
custom_consts=font_variant_caps_custom_consts,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
<%helpers:longhand name="font-weight" animation_value_type="ComputedValue"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight">
use properties::longhands::system_font::SystemFont;
@ -786,8 +782,7 @@ ${helpers.single_keyword_system("font-variant-caps",
</%helpers:longhand>
<%helpers:longhand name="font-size" animation_value_type="NonNegativeLength"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size">
use app_units::Au;
use values::specified::AllowQuirks;
@ -922,8 +917,7 @@ ${helpers.single_keyword_system("font-variant-caps",
<%helpers:longhand products="gecko" name="font-size-adjust"
animation_value_type="longhands::font_size_adjust::computed_value::T"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust">
use properties::longhands::system_font::SystemFont;
@ -1040,8 +1034,7 @@ ${helpers.single_keyword_system("font-variant-caps",
</%helpers:longhand>
<%helpers:longhand products="gecko" name="font-synthesis" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis">
use std::fmt;
use style_traits::ToCss;
@ -1135,8 +1128,7 @@ ${helpers.single_keyword_system("font-stretch",
gecko_constant_prefix="NS_FONT_STRETCH",
cast_type='i16',
spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="ComputedValue")}
${helpers.single_keyword_system("font-kerning",
@ -1145,13 +1137,11 @@ ${helpers.single_keyword_system("font-kerning",
gecko_ffi_name="mFont.kerning",
gecko_constant_prefix="NS_FONT_KERNING",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-kerning",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
<%helpers:longhand name="font-variant-alternates" products="gecko" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-alternates">
use properties::longhands::system_font::SystemFont;
use std::fmt;
@ -1263,15 +1253,15 @@ ${helpers.single_keyword_system("font-kerning",
bitflags! {
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
pub struct ParsingFlags: u8 {
const NORMAL = 0;
const HISTORICAL_FORMS = 0x01;
const STYLISTIC = 0x02;
const STYLESET = 0x04;
const CHARACTER_VARIANT = 0x08;
const SWASH = 0x10;
const ORNAMENTS = 0x20;
const ANNOTATION = 0x40;
pub flags ParsingFlags: u8 {
const NORMAL = 0,
const HISTORICAL_FORMS = 0x01,
const STYLISTIC = 0x02,
const STYLESET = 0x04,
const CHARACTER_VARIANT = 0x08,
const SWASH = 0x10,
const ORNAMENTS = 0x20,
const ANNOTATION = 0x40,
}
}
@ -1292,7 +1282,7 @@ ${helpers.single_keyword_system("font-kerning",
let mut parsed_alternates = ParsingFlags::empty();
macro_rules! check_if_parsed(
($input:expr, $flag:path) => (
($input:expr, $flag:ident) => (
if parsed_alternates.contains($flag) {
return Err($input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
@ -1304,7 +1294,7 @@ ${helpers.single_keyword_system("font-kerning",
match input.next()?.clone() {
Token::Ident(ref ident) => {
if *ident == "historical-forms" {
check_if_parsed!(input, ParsingFlags::HISTORICAL_FORMS);
check_if_parsed!(input, HISTORICAL_FORMS);
alternates.push(VariantAlternates::HistoricalForms);
Ok(())
} else {
@ -1316,7 +1306,7 @@ ${helpers.single_keyword_system("font-kerning",
match_ignore_ascii_case! { &name,
% for value in "swash stylistic ornaments annotation".split():
"${value}" => {
check_if_parsed!(i, ParsingFlags::${value.upper()});
check_if_parsed!(i, ${value.upper()});
let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::${to_camel_case(value)}(ident));
@ -1325,7 +1315,7 @@ ${helpers.single_keyword_system("font-kerning",
% endfor
% for value in "styleset character-variant".split():
"${value}" => {
check_if_parsed!(i, ParsingFlags:: ${to_rust_ident(value).upper()});
check_if_parsed!(i, ${to_rust_ident(value).upper()});
let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location();
CustomIdent::from_ident(location, i.expect_ident()?, &[])
@ -1351,7 +1341,7 @@ ${helpers.single_keyword_system("font-kerning",
#[cfg(feature = "gecko")]
macro_rules! exclusive_value {
(($value:ident, $set:expr) => $ident:path) => {
(($value:ident, $set:expr) => $ident:ident) => {
if $value.intersects($set) {
return Err(())
} else {
@ -1361,8 +1351,7 @@ macro_rules! exclusive_value {
}
<%helpers:longhand name="font-variant-east-asian" products="gecko" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian">
use properties::longhands::system_font::SystemFont;
use std::fmt;
@ -1371,17 +1360,17 @@ macro_rules! exclusive_value {
bitflags! {
#[derive(MallocSizeOf)]
pub struct VariantEastAsian: u16 {
const NORMAL = 0;
const JIS78 = 0x01;
const JIS83 = 0x02;
const JIS90 = 0x04;
const JIS04 = 0x08;
const SIMPLIFIED = 0x10;
const TRADITIONAL = 0x20;
const FULL_WIDTH = 0x40;
const PROPORTIONAL_WIDTH = 0x80;
const RUBY = 0x100;
pub flags VariantEastAsian: u16 {
const NORMAL = 0,
const JIS78 = 0x01,
const JIS83 = 0x02,
const JIS90 = 0x04,
const JIS04 = 0x08,
const SIMPLIFIED = 0x10,
const TRADITIONAL = 0x20,
const FULL_WIDTH = 0x40,
const PROPORTIONAL_WIDTH = 0x80,
const RUBY = 0x100,
}
}
@ -1395,15 +1384,15 @@ macro_rules! exclusive_value {
<%self:simple_system_boilerplate name="font_variant_east_asian"></%self:simple_system_boilerplate>
// servo_bit: gecko_bit
<% font_variant_east_asian_map = { "VariantEastAsian::JIS78": "JIS78",
"VariantEastAsian::JIS83": "JIS83",
"VariantEastAsian::JIS90": "JIS90",
"VariantEastAsian::JIS04": "JIS04",
"VariantEastAsian::SIMPLIFIED": "SIMPLIFIED",
"VariantEastAsian::TRADITIONAL": "TRADITIONAL",
"VariantEastAsian::FULL_WIDTH": "FULL_WIDTH",
"VariantEastAsian::PROPORTIONAL_WIDTH": "PROP_WIDTH",
"VariantEastAsian::RUBY": "RUBY" } %>
<% font_variant_east_asian_map = { "JIS78": "JIS78",
"JIS83": "JIS83",
"JIS90": "JIS90",
"JIS04": "JIS04",
"SIMPLIFIED": "SIMPLIFIED",
"TRADITIONAL": "TRADITIONAL",
"FULL_WIDTH": "FULL_WIDTH",
"PROPORTIONAL_WIDTH": "PROP_WIDTH",
"RUBY": "RUBY" } %>
${helpers.gecko_bitflags_conversion(font_variant_east_asian_map, 'NS_FONT_VARIANT_EAST_ASIAN_',
'VariantEastAsian', kw_type='u16')}
@ -1418,7 +1407,7 @@ macro_rules! exclusive_value {
let mut has_any = false;
macro_rules! write_value {
($ident:path => $str:expr) => {
($ident:ident => $str:expr) => {
if self.intersects($ident) {
if has_any {
dest.write_str(" ")?;
@ -1429,15 +1418,15 @@ macro_rules! exclusive_value {
}
}
write_value!(VariantEastAsian::JIS78 => "jis78");
write_value!(VariantEastAsian::JIS83 => "jis83");
write_value!(VariantEastAsian::JIS90 => "jis90");
write_value!(VariantEastAsian::JIS04 => "jis04");
write_value!(VariantEastAsian::SIMPLIFIED => "simplified");
write_value!(VariantEastAsian::TRADITIONAL => "traditional");
write_value!(VariantEastAsian::FULL_WIDTH => "full-width");
write_value!(VariantEastAsian::PROPORTIONAL_WIDTH => "proportional-width");
write_value!(VariantEastAsian::RUBY => "ruby");
write_value!(JIS78 => "jis78");
write_value!(JIS83 => "jis83");
write_value!(JIS90 => "jis90");
write_value!(JIS04 => "jis04");
write_value!(SIMPLIFIED => "simplified");
write_value!(TRADITIONAL => "traditional");
write_value!(FULL_WIDTH => "full-width");
write_value!(PROPORTIONAL_WIDTH => "proportional-width");
write_value!(RUBY => "ruby");
debug_assert!(has_any);
Ok(())
@ -1459,10 +1448,8 @@ macro_rules! exclusive_value {
/// normal | [ <east-asian-variant-values> || <east-asian-width-values> || ruby ]
/// <east-asian-variant-values> = [ jis78 | jis83 | jis90 | jis04 | simplified | traditional ]
/// <east-asian-width-values> = [ full-width | proportional-width ]
<% east_asian_variant_values = """VariantEastAsian::JIS78 | VariantEastAsian::JIS83 |
VariantEastAsian::JIS90 | VariantEastAsian::JIS04 |
VariantEastAsian::SIMPLIFIED | VariantEastAsian::TRADITIONAL""" %>
<% east_asian_width_values = "VariantEastAsian::FULL_WIDTH | VariantEastAsian::PROPORTIONAL_WIDTH" %>
<% east_asian_variant_values = "JIS78 | JIS83 | JIS90 | JIS04 | SIMPLIFIED | TRADITIONAL" %>
<% east_asian_width_values = "FULL_WIDTH | PROPORTIONAL_WIDTH" %>
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> {
let mut result = VariantEastAsian::empty();
@ -1474,23 +1461,23 @@ macro_rules! exclusive_value {
while let Ok(flag) = input.try(|input| {
Ok(match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?,
"jis78" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::JIS78),
exclusive_value!((result, ${east_asian_variant_values}) => JIS78),
"jis83" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::JIS83),
exclusive_value!((result, ${east_asian_variant_values}) => JIS83),
"jis90" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::JIS90),
exclusive_value!((result, ${east_asian_variant_values}) => JIS90),
"jis04" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::JIS04),
exclusive_value!((result, ${east_asian_variant_values}) => JIS04),
"simplified" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::SIMPLIFIED),
exclusive_value!((result, ${east_asian_variant_values}) => SIMPLIFIED),
"traditional" =>
exclusive_value!((result, ${east_asian_variant_values}) => VariantEastAsian::TRADITIONAL),
exclusive_value!((result, ${east_asian_variant_values}) => TRADITIONAL),
"full-width" =>
exclusive_value!((result, ${east_asian_width_values}) => VariantEastAsian::FULL_WIDTH),
exclusive_value!((result, ${east_asian_width_values}) => FULL_WIDTH),
"proportional-width" =>
exclusive_value!((result, ${east_asian_width_values}) => VariantEastAsian::PROPORTIONAL_WIDTH),
exclusive_value!((result, ${east_asian_width_values}) => PROPORTIONAL_WIDTH),
"ruby" =>
exclusive_value!((result, VariantEastAsian::RUBY) => VariantEastAsian::RUBY),
exclusive_value!((result, RUBY) => RUBY),
_ => return Err(()),
})
}) {
@ -1509,8 +1496,7 @@ macro_rules! exclusive_value {
</%helpers:longhand>
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures">
use properties::longhands::system_font::SystemFont;
use std::fmt;
@ -1518,18 +1504,18 @@ macro_rules! exclusive_value {
bitflags! {
#[derive(MallocSizeOf)]
pub struct VariantLigatures: u16 {
const NORMAL = 0;
const NONE = 0x01;
const COMMON_LIGATURES = 0x02;
const NO_COMMON_LIGATURES = 0x04;
const DISCRETIONARY_LIGATURES = 0x08;
const NO_DISCRETIONARY_LIGATURES = 0x10;
const HISTORICAL_LIGATURES = 0x20;
const NO_HISTORICAL_LIGATURES = 0x40;
const CONTEXTUAL = 0x80;
const NO_CONTEXTUAL = 0x100;
#[derive(MallocSizeOf)]
pub flags VariantLigatures: u16 {
const NORMAL = 0,
const NONE = 0x01,
const COMMON_LIGATURES = 0x02,
const NO_COMMON_LIGATURES = 0x04,
const DISCRETIONARY_LIGATURES = 0x08,
const NO_DISCRETIONARY_LIGATURES = 0x10,
const HISTORICAL_LIGATURES = 0x20,
const NO_HISTORICAL_LIGATURES = 0x40,
const CONTEXTUAL = 0x80,
const NO_CONTEXTUAL = 0x100,
}
}
@ -1543,15 +1529,15 @@ macro_rules! exclusive_value {
<%self:simple_system_boilerplate name="font_variant_ligatures"></%self:simple_system_boilerplate>
// servo_bit: gecko_bit
<% font_variant_ligatures_map = { "VariantLigatures::NONE": "NONE",
"VariantLigatures::COMMON_LIGATURES": "COMMON",
"VariantLigatures::NO_COMMON_LIGATURES": "NO_COMMON",
"VariantLigatures::DISCRETIONARY_LIGATURES": "DISCRETIONARY",
"VariantLigatures::NO_DISCRETIONARY_LIGATURES": "NO_DISCRETIONARY",
"VariantLigatures::HISTORICAL_LIGATURES": "HISTORICAL",
"VariantLigatures::NO_HISTORICAL_LIGATURES": "NO_HISTORICAL",
"VariantLigatures::CONTEXTUAL": "CONTEXTUAL",
"VariantLigatures::NO_CONTEXTUAL": "NO_CONTEXTUAL" } %>
<% font_variant_ligatures_map = { "NONE": "NONE",
"COMMON_LIGATURES": "COMMON",
"NO_COMMON_LIGATURES": "NO_COMMON",
"DISCRETIONARY_LIGATURES": "DISCRETIONARY",
"NO_DISCRETIONARY_LIGATURES": "NO_DISCRETIONARY",
"HISTORICAL_LIGATURES": "HISTORICAL",
"NO_HISTORICAL_LIGATURES": "NO_HISTORICAL",
"CONTEXTUAL": "CONTEXTUAL",
"NO_CONTEXTUAL": "NO_CONTEXTUAL" } %>
${helpers.gecko_bitflags_conversion(font_variant_ligatures_map, 'NS_FONT_VARIANT_LIGATURES_',
'VariantLigatures', kw_type='u16')}
@ -1561,14 +1547,14 @@ macro_rules! exclusive_value {
if self.is_empty() {
return dest.write_str("normal")
}
if self.contains(VariantLigatures::NONE) {
if self.contains(NONE) {
return dest.write_str("none")
}
let mut has_any = false;
macro_rules! write_value {
($ident:path => $str:expr) => {
($ident:ident => $str:expr) => {
if self.intersects($ident) {
if has_any {
dest.write_str(" ")?;
@ -1579,14 +1565,14 @@ macro_rules! exclusive_value {
}
}
write_value!(VariantLigatures::COMMON_LIGATURES => "common-ligatures");
write_value!(VariantLigatures::NO_COMMON_LIGATURES => "no-common-ligatures");
write_value!(VariantLigatures::DISCRETIONARY_LIGATURES => "discretionary-ligatures");
write_value!(VariantLigatures::NO_DISCRETIONARY_LIGATURES => "no-discretionary-ligatures");
write_value!(VariantLigatures::HISTORICAL_LIGATURES => "historical-ligatures");
write_value!(VariantLigatures::NO_HISTORICAL_LIGATURES => "no-historical-ligatures");
write_value!(VariantLigatures::CONTEXTUAL => "contextual");
write_value!(VariantLigatures::NO_CONTEXTUAL => "no-contextual");
write_value!(COMMON_LIGATURES => "common-ligatures");
write_value!(NO_COMMON_LIGATURES => "no-common-ligatures");
write_value!(DISCRETIONARY_LIGATURES => "discretionary-ligatures");
write_value!(NO_DISCRETIONARY_LIGATURES => "no-discretionary-ligatures");
write_value!(HISTORICAL_LIGATURES => "historical-ligatures");
write_value!(NO_HISTORICAL_LIGATURES => "no-historical-ligatures");
write_value!(CONTEXTUAL => "contextual");
write_value!(NO_CONTEXTUAL => "no-contextual");
debug_assert!(has_any);
Ok(())
@ -1606,7 +1592,7 @@ macro_rules! exclusive_value {
}
#[inline]
pub fn get_none_specified_value() -> SpecifiedValue {
SpecifiedValue::Value(VariantLigatures::NONE)
SpecifiedValue::Value(NONE)
}
/// normal | none |
@ -1618,11 +1604,10 @@ macro_rules! exclusive_value {
/// <discretionary-lig-values> = [ discretionary-ligatures | no-discretionary-ligatures ]
/// <historical-lig-values> = [ historical-ligatures | no-historical-ligatures ]
/// <contextual-alt-values> = [ contextual | no-contextual ]
<% common_lig_values = "VariantLigatures::COMMON_LIGATURES | VariantLigatures::NO_COMMON_LIGATURES" %>
<% discretionary_lig_values = """VariantLigatures::DISCRETIONARY_LIGATURES |
VariantLigatures::NO_DISCRETIONARY_LIGATURES""" %>
<% historical_lig_values = "VariantLigatures::HISTORICAL_LIGATURES | VariantLigatures::NO_HISTORICAL_LIGATURES" %>
<% contextual_alt_values = "VariantLigatures::CONTEXTUAL | VariantLigatures::NO_CONTEXTUAL" %>
<% common_lig_values = "COMMON_LIGATURES | NO_COMMON_LIGATURES" %>
<% discretionary_lig_values = "DISCRETIONARY_LIGATURES | NO_DISCRETIONARY_LIGATURES" %>
<% historical_lig_values = "HISTORICAL_LIGATURES | NO_HISTORICAL_LIGATURES" %>
<% contextual_alt_values = "CONTEXTUAL | NO_CONTEXTUAL" %>
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> {
let mut result = VariantLigatures::empty();
@ -1631,29 +1616,27 @@ macro_rules! exclusive_value {
return Ok(SpecifiedValue::Value(result))
}
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
return Ok(SpecifiedValue::Value(VariantLigatures::NONE))
return Ok(SpecifiedValue::Value(NONE))
}
while let Ok(flag) = input.try(|input| {
Ok(match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?,
"common-ligatures" =>
exclusive_value!((result, ${common_lig_values}) => VariantLigatures::COMMON_LIGATURES),
exclusive_value!((result, ${common_lig_values}) => COMMON_LIGATURES),
"no-common-ligatures" =>
exclusive_value!((result, ${common_lig_values}) => VariantLigatures::NO_COMMON_LIGATURES),
exclusive_value!((result, ${common_lig_values}) => NO_COMMON_LIGATURES),
"discretionary-ligatures" =>
exclusive_value!((result, ${discretionary_lig_values}) =>
VariantLigatures::DISCRETIONARY_LIGATURES),
exclusive_value!((result, ${discretionary_lig_values}) => DISCRETIONARY_LIGATURES),
"no-discretionary-ligatures" =>
exclusive_value!((result, ${discretionary_lig_values}) =>
VariantLigatures::NO_DISCRETIONARY_LIGATURES),
exclusive_value!((result, ${discretionary_lig_values}) => NO_DISCRETIONARY_LIGATURES),
"historical-ligatures" =>
exclusive_value!((result, ${historical_lig_values}) => VariantLigatures::HISTORICAL_LIGATURES),
exclusive_value!((result, ${historical_lig_values}) => HISTORICAL_LIGATURES),
"no-historical-ligatures" =>
exclusive_value!((result, ${historical_lig_values}) => VariantLigatures::NO_HISTORICAL_LIGATURES),
exclusive_value!((result, ${historical_lig_values}) => NO_HISTORICAL_LIGATURES),
"contextual" =>
exclusive_value!((result, ${contextual_alt_values}) => VariantLigatures::CONTEXTUAL),
exclusive_value!((result, ${contextual_alt_values}) => CONTEXTUAL),
"no-contextual" =>
exclusive_value!((result, ${contextual_alt_values}) => VariantLigatures::NO_CONTEXTUAL),
exclusive_value!((result, ${contextual_alt_values}) => NO_CONTEXTUAL),
_ => return Err(()),
})
}) {
@ -1672,8 +1655,7 @@ macro_rules! exclusive_value {
</%helpers:longhand>
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric">
use properties::longhands::system_font::SystemFont;
use std::fmt;
@ -1682,16 +1664,16 @@ macro_rules! exclusive_value {
bitflags! {
#[derive(MallocSizeOf)]
pub struct VariantNumeric: u8 {
const NORMAL = 0;
const LINING_NUMS = 0x01;
const OLDSTYLE_NUMS = 0x02;
const PROPORTIONAL_NUMS = 0x04;
const TABULAR_NUMS = 0x08;
const DIAGONAL_FRACTIONS = 0x10;
const STACKED_FRACTIONS = 0x20;
const SLASHED_ZERO = 0x40;
const ORDINAL = 0x80;
pub flags VariantNumeric: u8 {
const NORMAL = 0,
const LINING_NUMS = 0x01,
const OLDSTYLE_NUMS = 0x02,
const PROPORTIONAL_NUMS = 0x04,
const TABULAR_NUMS = 0x08,
const DIAGONAL_FRACTIONS = 0x10,
const STACKED_FRACTIONS = 0x20,
const SLASHED_ZERO = 0x40,
const ORDINAL = 0x80,
}
}
@ -1706,14 +1688,14 @@ macro_rules! exclusive_value {
// servo_bit: gecko_bit
<% font_variant_numeric_map = { "VariantNumeric::LINING_NUMS": "LINING",
"VariantNumeric::OLDSTYLE_NUMS": "OLDSTYLE",
"VariantNumeric::PROPORTIONAL_NUMS": "PROPORTIONAL",
"VariantNumeric::TABULAR_NUMS": "TABULAR",
"VariantNumeric::DIAGONAL_FRACTIONS": "DIAGONAL_FRACTIONS",
"VariantNumeric::STACKED_FRACTIONS": "STACKED_FRACTIONS",
"VariantNumeric::SLASHED_ZERO": "SLASHZERO",
"VariantNumeric::ORDINAL": "ORDINAL" } %>
<% font_variant_numeric_map = { "LINING_NUMS": "LINING",
"OLDSTYLE_NUMS": "OLDSTYLE",
"PROPORTIONAL_NUMS": "PROPORTIONAL",
"TABULAR_NUMS": "TABULAR",
"DIAGONAL_FRACTIONS": "DIAGONAL_FRACTIONS",
"STACKED_FRACTIONS": "STACKED_FRACTIONS",
"SLASHED_ZERO": "SLASHZERO",
"ORDINAL": "ORDINAL" } %>
${helpers.gecko_bitflags_conversion(font_variant_numeric_map, 'NS_FONT_VARIANT_NUMERIC_',
'VariantNumeric')}
@ -1727,7 +1709,7 @@ macro_rules! exclusive_value {
let mut has_any = false;
macro_rules! write_value {
($ident:path => $str:expr) => {
($ident:ident => $str:expr) => {
if self.intersects($ident) {
if has_any {
dest.write_str(" ")?;
@ -1738,14 +1720,14 @@ macro_rules! exclusive_value {
}
}
write_value!(VariantNumeric::LINING_NUMS => "lining-nums");
write_value!(VariantNumeric::OLDSTYLE_NUMS => "oldstyle-nums");
write_value!(VariantNumeric::PROPORTIONAL_NUMS => "proportional-nums");
write_value!(VariantNumeric::TABULAR_NUMS => "tabular-nums");
write_value!(VariantNumeric::DIAGONAL_FRACTIONS => "diagonal-fractions");
write_value!(VariantNumeric::STACKED_FRACTIONS => "stacked-fractions");
write_value!(VariantNumeric::SLASHED_ZERO => "slashed-zero");
write_value!(VariantNumeric::ORDINAL => "ordinal");
write_value!(LINING_NUMS => "lining-nums");
write_value!(OLDSTYLE_NUMS => "oldstyle-nums");
write_value!(PROPORTIONAL_NUMS => "proportional-nums");
write_value!(TABULAR_NUMS => "tabular-nums");
write_value!(DIAGONAL_FRACTIONS => "diagonal-fractions");
write_value!(STACKED_FRACTIONS => "stacked-fractions");
write_value!(SLASHED_ZERO => "slashed-zero");
write_value!(ORDINAL => "ordinal");
debug_assert!(has_any);
Ok(())
@ -1773,9 +1755,9 @@ macro_rules! exclusive_value {
/// <numeric-figure-values> = [ lining-nums | oldstyle-nums ]
/// <numeric-spacing-values> = [ proportional-nums | tabular-nums ]
/// <numeric-fraction-values> = [ diagonal-fractions | stacked-fractions ]
<% numeric_figure_values = "VariantNumeric::LINING_NUMS | VariantNumeric::OLDSTYLE_NUMS" %>
<% numeric_spacing_values = "VariantNumeric::PROPORTIONAL_NUMS | VariantNumeric::TABULAR_NUMS" %>
<% numeric_fraction_values = "VariantNumeric::DIAGONAL_FRACTIONS | VariantNumeric::STACKED_FRACTIONS" %>
<% numeric_figure_values = "LINING_NUMS | OLDSTYLE_NUMS" %>
<% numeric_spacing_values = "PROPORTIONAL_NUMS | TABULAR_NUMS" %>
<% numeric_fraction_values = "DIAGONAL_FRACTIONS | STACKED_FRACTIONS" %>
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> {
let mut result = VariantNumeric::empty();
@ -1787,21 +1769,21 @@ macro_rules! exclusive_value {
while let Ok(flag) = input.try(|input| {
Ok(match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?,
"ordinal" =>
exclusive_value!((result, VariantNumeric::ORDINAL) => VariantNumeric::ORDINAL),
exclusive_value!((result, ORDINAL) => ORDINAL),
"slashed-zero" =>
exclusive_value!((result, VariantNumeric::SLASHED_ZERO) => VariantNumeric::SLASHED_ZERO),
exclusive_value!((result, SLASHED_ZERO) => SLASHED_ZERO),
"lining-nums" =>
exclusive_value!((result, ${numeric_figure_values}) => VariantNumeric::LINING_NUMS),
exclusive_value!((result, ${numeric_figure_values}) => LINING_NUMS),
"oldstyle-nums" =>
exclusive_value!((result, ${numeric_figure_values}) => VariantNumeric::OLDSTYLE_NUMS),
exclusive_value!((result, ${numeric_figure_values}) => OLDSTYLE_NUMS),
"proportional-nums" =>
exclusive_value!((result, ${numeric_spacing_values}) => VariantNumeric::PROPORTIONAL_NUMS),
exclusive_value!((result, ${numeric_spacing_values}) => PROPORTIONAL_NUMS),
"tabular-nums" =>
exclusive_value!((result, ${numeric_spacing_values}) => VariantNumeric::TABULAR_NUMS),
exclusive_value!((result, ${numeric_spacing_values}) => TABULAR_NUMS),
"diagonal-fractions" =>
exclusive_value!((result, ${numeric_fraction_values}) => VariantNumeric::DIAGONAL_FRACTIONS),
exclusive_value!((result, ${numeric_fraction_values}) => DIAGONAL_FRACTIONS),
"stacked-fractions" =>
exclusive_value!((result, ${numeric_fraction_values}) => VariantNumeric::STACKED_FRACTIONS),
exclusive_value!((result, ${numeric_fraction_values}) => STACKED_FRACTIONS),
_ => return Err(()),
})
}) {
@ -1825,14 +1807,12 @@ ${helpers.single_keyword_system("font-variant-position",
gecko_ffi_name="mFont.variantPosition",
gecko_constant_prefix="NS_FONT_VARIANT_POSITION",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="discrete"
extra_prefixes="moz" boxed="True"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings">
use properties::longhands::system_font::SystemFont;
use values::generics::FontSettings;
@ -1876,8 +1856,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
%>
<%helpers:longhand name="font-variation-settings" products="gecko"
animation_value_type="ComputedValue"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="${variation_spec}">
use values::generics::FontSettings;
@ -1902,8 +1881,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
<%helpers:longhand name="font-language-override" products="gecko" animation_value_type="discrete"
extra_prefixes="moz" boxed="True"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER"""
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override">
use properties::longhands::system_font::SystemFont;
use std::fmt;
@ -2485,8 +2463,7 @@ ${helpers.single_keyword("-moz-osx-font-smoothing",
gecko_ffi_name="mFont.smoothing",
products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
${helpers.predefined_type("-moz-min-font-size-ratio",

View file

@ -10,8 +10,7 @@ ${helpers.predefined_type("line-height",
"LineHeight",
"computed::LineHeight::normal()",
animation_value_type="LineHeight",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height")}
// CSS Text Module Level 3
@ -21,8 +20,7 @@ ${helpers.single_keyword("text-transform",
"none capitalize uppercase lowercase",
extra_gecko_values="full-width",
animation_value_type="discrete",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-text-transform")}
${helpers.single_keyword("hyphens", "manual none auto",
@ -68,7 +66,7 @@ ${helpers.single_keyword("word-break",
extra_specified="${'distribute' if product == 'gecko' else ''}"
gecko_enum_prefix="StyleTextJustify"
animation_value_type="discrete"
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
impl ToComputedValue for SpecifiedValue {
@ -111,7 +109,7 @@ ${helpers.single_keyword("text-align-last",
// TODO make this a shorthand and implement text-align-last/text-align-all
<%helpers:longhand name="text-align" animation_value_type="discrete"
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-text/#propdef-text-align">
pub mod computed_value {
use style_traits::ToCss;
@ -269,16 +267,14 @@ ${helpers.predefined_type("letter-spacing",
"LetterSpacing",
"computed::LetterSpacing::normal()",
animation_value_type="ComputedValue",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing")}
${helpers.predefined_type("word-spacing",
"WordSpacing",
"computed::WordSpacing::normal()",
animation_value_type="ComputedValue",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-word-spacing")}
<%helpers:longhand name="-servo-text-decorations-in-effect"
@ -351,7 +347,7 @@ ${helpers.predefined_type("word-spacing",
animation_value_type="discrete"
// Only allowed for UA sheets, which set it
// !important.
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-text/#propdef-white-space">
trivial_to_computed_value!(SpecifiedValue);
% if product != "gecko":
@ -396,8 +392,7 @@ ${helpers.predefined_type(
vector=True,
animation_value_type="AnimatedTextShadowList",
ignored_when_colors_disabled=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property",
)}
@ -699,8 +694,7 @@ ${helpers.predefined_type(
products="gecko",
animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color",
)}
@ -712,8 +706,7 @@ ${helpers.predefined_type(
products="gecko",
animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color",
)}
@ -723,8 +716,7 @@ ${helpers.predefined_type("-webkit-text-stroke-width",
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
computed_type="::values::computed::NonNegativeLength",
products="gecko",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
animation_value_type="discrete")}

View file

@ -17,6 +17,6 @@
alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"),
allow_quirks=not side[1],
animation_value_type="ComputedValue", logical = side[1], spec = spec,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
allowed_in_page_rule=True)}
% endfor

View file

@ -20,6 +20,6 @@
animation_value_type="NonNegativeLengthOrPercentage",
logical = side[1],
spec = spec,
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_PLACEHOLDER",
allow_quirks=not side[1])}
% endfor

View file

@ -148,7 +148,7 @@
// TODO(pcwalton): SVG-only values.
${helpers.single_keyword("pointer-events", "auto none", animation_value_type="discrete",
extra_gecko_values="visiblepainted visiblefill visiblestroke visible painted fill stroke all",
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty")}
${helpers.single_keyword("-moz-user-input", "auto none enabled disabled",

View file

@ -45,7 +45,7 @@ macro_rules! impl_align_conversions {
${helpers.predefined_type("z-index", "IntegerOrAuto",
"Either::Second(Auto)",
spec="https://www.w3.org/TR/CSS2/visuren.html#z-index",
flags="PropertyFlags::CREATES_STACKING_CONTEXT",
flags="CREATES_STACKING_CONTEXT",
animation_value_type="ComputedValue")}

View file

@ -70,7 +70,7 @@ ${helpers.predefined_type(
products="gecko",
boxed=True,
animation_value_type="ComputedValue",
flags="PropertyFlags::CREATES_STACKING_CONTEXT",
flags="CREATES_STACKING_CONTEXT",
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path",
)}
@ -167,4 +167,4 @@ ${helpers.predefined_type("mask-image", "ImageLayer",
products="gecko",
extra_prefixes="webkit",
animation_value_type="discrete",
flags="PropertyFlags::CREATES_STACKING_CONTEXT")}
flags="CREATES_STACKING_CONTEXT")}

View file

@ -13,7 +13,7 @@
Method("has_line_through", "bool")]) %>
<%helpers:longhand name="text-overflow" animation_value_type="discrete" boxed="True"
flags="PropertyFlags::APPLIES_TO_PLACEHOLDER"
flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow">
use std::fmt;
use style_traits::ToCss;
@ -141,20 +141,19 @@ ${helpers.single_keyword("unicode-bidi",
<%helpers:longhand name="text-decoration-line"
custom_cascade="${product == 'servo'}"
animation_value_type="discrete"
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line">
use std::fmt;
use style_traits::ToCss;
bitflags! {
#[derive(MallocSizeOf, ToComputedValue)]
pub struct SpecifiedValue: u8 {
const NONE = 0;
const UNDERLINE = 0x01;
const OVERLINE = 0x02;
const LINE_THROUGH = 0x04;
const BLINK = 0x08;
pub flags SpecifiedValue: u8 {
const NONE = 0,
const UNDERLINE = 0x01,
const OVERLINE = 0x02,
const LINE_THROUGH = 0x04,
const BLINK = 0x08,
% if product == "gecko":
/// Only set by presentation attributes
///
@ -163,7 +162,7 @@ ${helpers.single_keyword("unicode-bidi",
///
/// For example, this gives <a href=foo><font color="red">text</font></a>
/// a red text decoration
const COLOR_OVERRIDE = 0x10;
const COLOR_OVERRIDE = 0x10,
% endif
}
}
@ -173,7 +172,7 @@ ${helpers.single_keyword("unicode-bidi",
let mut has_any = false;
macro_rules! write_value {
($line:path => $css:expr) => {
($line:ident => $css:expr) => {
if self.contains($line) {
if has_any {
dest.write_str(" ")?;
@ -183,10 +182,10 @@ ${helpers.single_keyword("unicode-bidi",
}
}
}
write_value!(SpecifiedValue::UNDERLINE => "underline");
write_value!(SpecifiedValue::OVERLINE => "overline");
write_value!(SpecifiedValue::LINE_THROUGH => "line-through");
write_value!(SpecifiedValue::BLINK => "blink");
write_value!(UNDERLINE => "underline");
write_value!(OVERLINE => "overline");
write_value!(LINE_THROUGH => "line-through");
write_value!(BLINK => "blink");
if !has_any {
dest.write_str("none")?;
}
@ -223,17 +222,14 @@ ${helpers.single_keyword("unicode-bidi",
match input.expect_ident() {
Ok(ident) => {
(match_ignore_ascii_case! { &ident,
"underline" => if result.contains(SpecifiedValue::UNDERLINE) { Err(()) }
else { empty = false; result.insert(SpecifiedValue::UNDERLINE); Ok(()) },
"overline" => if result.contains(SpecifiedValue::OVERLINE) { Err(()) }
else { empty = false; result.insert(SpecifiedValue::OVERLINE); Ok(()) },
"line-through" => if result.contains(SpecifiedValue::LINE_THROUGH) { Err(()) }
else {
empty = false;
result.insert(SpecifiedValue::LINE_THROUGH); Ok(())
},
"blink" => if result.contains(SpecifiedValue::BLINK) { Err(()) }
else { empty = false; result.insert(SpecifiedValue::BLINK); Ok(()) },
"underline" => if result.contains(UNDERLINE) { Err(()) }
else { empty = false; result.insert(UNDERLINE); Ok(()) },
"overline" => if result.contains(OVERLINE) { Err(()) }
else { empty = false; result.insert(OVERLINE); Ok(()) },
"line-through" => if result.contains(LINE_THROUGH) { Err(()) }
else { empty = false; result.insert(LINE_THROUGH); Ok(()) },
"blink" => if result.contains(BLINK) { Err(()) }
else { empty = false; result.insert(BLINK); Ok(()) },
_ => Err(())
}).map_err(|()| {
location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))
@ -265,8 +261,7 @@ ${helpers.single_keyword("text-decoration-style",
"solid double dotted dashed wavy -moz-none",
products="gecko",
animation_value_type="discrete",
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style")}
${helpers.predefined_type(
@ -277,8 +272,7 @@ ${helpers.predefined_type(
products="gecko",
animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True,
flags="""PropertyFlags::APPLIES_TO_FIRST_LETTER PropertyFlags::APPLIES_TO_FIRST_LINE
PropertyFlags::APPLIES_TO_PLACEHOLDER""",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color",
)}
@ -289,5 +283,5 @@ ${helpers.predefined_type(
initial_specified_value="specified::InitialLetter::normal()",
animation_value_type="discrete",
products="gecko",
flags="PropertyFlags::APPLIES_TO_FIRST_LETTER",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")}

View file

@ -38,7 +38,7 @@ use selector_parser::PseudoElement;
use selectors::parser::SelectorParseErrorKind;
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
use shared_lock::StylesheetGuards;
use style_traits::{ParsingMode, ToCss, ParseError, StyleParseErrorKind};
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, StyleParseErrorKind};
use stylesheets::{CssRuleType, Origin, UrlExtraData};
#[cfg(feature = "servo")] use values::Either;
use values::generics::text::LineHeight;
@ -440,23 +440,23 @@ impl CSSWideKeyword {
bitflags! {
/// A set of flags for properties.
pub struct PropertyFlags: u8 {
pub flags PropertyFlags: u8 {
/// This property requires a stacking context.
const CREATES_STACKING_CONTEXT = 1 << 0;
const CREATES_STACKING_CONTEXT = 1 << 0,
/// This property has values that can establish a containing block for
/// fixed positioned and absolutely positioned elements.
const FIXPOS_CB = 1 << 1;
const FIXPOS_CB = 1 << 1,
/// This property has values that can establish a containing block for
/// absolutely positioned elements.
const ABSPOS_CB = 1 << 2;
const ABSPOS_CB = 1 << 2,
/// This shorthand property is an alias of another property.
const SHORTHAND_ALIAS_PROPERTY = 1 << 3;
const SHORTHAND_ALIAS_PROPERTY = 1 << 3,
/// This longhand property applies to ::first-letter.
const APPLIES_TO_FIRST_LETTER = 1 << 4;
const APPLIES_TO_FIRST_LETTER = 1 << 4,
/// This longhand property applies to ::first-line.
const APPLIES_TO_FIRST_LINE = 1 << 5;
const APPLIES_TO_FIRST_LINE = 1 << 5,
/// This longhand property applies to ::placeholder.
const APPLIES_TO_PLACEHOLDER = 1 << 6;
const APPLIES_TO_PLACEHOLDER = 1 << 6,
}
}
@ -948,7 +948,7 @@ impl UnparsedValue {
Origin::Author,
&self.url_data,
None,
ParsingMode::DEFAULT,
PARSING_MODE_DEFAULT,
quirks_mode,
);
let mut input = ParserInput::new(&css);
@ -1428,7 +1428,7 @@ impl ToCss for PropertyDeclaration {
// Normally, we shouldn't be printing variables here if they came from
// shorthands. But we should allow properties that came from shorthand
// aliases. That also matches with the Gecko behavior.
Some(shorthand) if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) =>
Some(shorthand) if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) =>
dest.write_str(&*with_variables.css)?,
None => dest.write_str(&*with_variables.css)?,
_ => {},
@ -1487,7 +1487,7 @@ impl PropertyDeclaration {
// should return None here. But we return Some to longhands if they
// came from a shorthand alias. Because for example, we should be able to
// get -moz-transform's value from transform.
if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) {
return Some(&*with_variables.css);
}
None
@ -1940,19 +1940,19 @@ pub mod style_structs {
/// Whether the text decoration has an underline.
#[inline]
pub fn has_underline(&self) -> bool {
self.text_decoration_line.contains(longhands::text_decoration_line::SpecifiedValue::UNDERLINE)
self.text_decoration_line.contains(longhands::text_decoration_line::UNDERLINE)
}
/// Whether the text decoration has an overline.
#[inline]
pub fn has_overline(&self) -> bool {
self.text_decoration_line.contains(longhands::text_decoration_line::SpecifiedValue::OVERLINE)
self.text_decoration_line.contains(longhands::text_decoration_line::OVERLINE)
}
/// Whether the text decoration has a line through.
#[inline]
pub fn has_line_through(&self) -> bool {
self.text_decoration_line.contains(longhands::text_decoration_line::SpecifiedValue::LINE_THROUGH)
self.text_decoration_line.contains(longhands::text_decoration_line::LINE_THROUGH)
}
% elif style_struct.name == "Box":
/// Sets the display property, but without touching
@ -2089,7 +2089,7 @@ pub struct ComputedValues {
impl ComputedValues {
/// Whether we're a visited style.
pub fn is_style_if_visited(&self) -> bool {
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
self.flags.contains(IS_STYLE_IF_VISITED)
}
/// Gets a reference to the rule node. Panic if no rule node exists.
@ -2109,9 +2109,9 @@ impl ComputedValues {
/// Returns whether we're in a display: none subtree.
pub fn is_in_display_none_subtree(&self) -> bool {
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::IS_IN_DISPLAY_NONE_SUBTREE;
self.flags.contains(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE)
self.flags.contains(IS_IN_DISPLAY_NONE_SUBTREE)
}
/// Gets a reference to the custom properties map (if one exists).
@ -2443,28 +2443,28 @@ pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Wri
match inheritedbox_style.clone_direction() {
computed_values::direction::T::ltr => {},
computed_values::direction::T::rtl => {
flags.insert(logical_geometry::WritingMode::RTL);
flags.insert(logical_geometry::FLAG_RTL);
},
}
match inheritedbox_style.clone_writing_mode() {
computed_values::writing_mode::T::horizontal_tb => {},
computed_values::writing_mode::T::vertical_rl => {
flags.insert(logical_geometry::WritingMode::VERTICAL);
flags.insert(logical_geometry::FLAG_VERTICAL);
},
computed_values::writing_mode::T::vertical_lr => {
flags.insert(logical_geometry::WritingMode::VERTICAL);
flags.insert(logical_geometry::WritingMode::VERTICAL_LR);
flags.insert(logical_geometry::FLAG_VERTICAL);
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
},
% if product == "gecko":
computed_values::writing_mode::T::sideways_rl => {
flags.insert(logical_geometry::WritingMode::VERTICAL);
flags.insert(logical_geometry::WritingMode::SIDEWAYS);
flags.insert(logical_geometry::FLAG_VERTICAL);
flags.insert(logical_geometry::FLAG_SIDEWAYS);
},
computed_values::writing_mode::T::sideways_lr => {
flags.insert(logical_geometry::WritingMode::VERTICAL);
flags.insert(logical_geometry::WritingMode::VERTICAL_LR);
flags.insert(logical_geometry::WritingMode::LINE_INVERTED);
flags.insert(logical_geometry::WritingMode::SIDEWAYS);
flags.insert(logical_geometry::FLAG_VERTICAL);
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
flags.insert(logical_geometry::FLAG_LINE_INVERTED);
flags.insert(logical_geometry::FLAG_SIDEWAYS);
},
% endif
}
@ -2472,14 +2472,14 @@ pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Wri
// If FLAG_SIDEWAYS is already set, this means writing-mode is either
// sideways-rl or sideways-lr, and for both of these values,
// text-orientation has no effect.
if !flags.intersects(logical_geometry::WritingMode::SIDEWAYS) {
if !flags.intersects(logical_geometry::FLAG_SIDEWAYS) {
match inheritedbox_style.clone_text_orientation() {
computed_values::text_orientation::T::mixed => {},
computed_values::text_orientation::T::upright => {
flags.insert(logical_geometry::WritingMode::UPRIGHT);
flags.insert(logical_geometry::FLAG_UPRIGHT);
},
computed_values::text_orientation::T::sideways => {
flags.insert(logical_geometry::WritingMode::SIDEWAYS);
flags.insert(logical_geometry::FLAG_SIDEWAYS);
},
}
}
@ -2668,14 +2668,14 @@ impl<'a> StyleBuilder<'a> {
// 99% sure it should give incorrect behavior for table anonymous box
// backgrounds, for example. This code doesn't attempt to make it play
// nice with inherited_style_ignoring_first_line.
let reset_style = if cascade_flags.contains(CascadeFlags::INHERIT_ALL) {
let reset_style = if cascade_flags.contains(INHERIT_ALL) {
inherited_style
} else {
reset_style
};
if cascade_flags.contains(CascadeFlags::VISITED_DEPENDENT_ONLY) {
flags.insert(ComputedValueFlags::IS_STYLE_IF_VISITED);
if cascade_flags.contains(VISITED_DEPENDENT_ONLY) {
flags.insert(IS_STYLE_IF_VISITED);
}
StyleBuilder {
@ -2703,7 +2703,7 @@ impl<'a> StyleBuilder<'a> {
/// Whether we're a visited style.
pub fn is_style_if_visited(&self) -> bool {
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
self.flags.contains(IS_STYLE_IF_VISITED)
}
/// Creates a StyleBuilder holding only references to the structs of `s`, in
@ -2765,16 +2765,16 @@ impl<'a> StyleBuilder<'a> {
% endif
% if not property.style_struct.inherited:
self.flags.insert(::properties::computed_value_flags::ComputedValueFlags::INHERITS_RESET_STYLE);
self.flags.insert(::properties::computed_value_flags::INHERITS_RESET_STYLE);
self.modified_reset = true;
% endif
% if property.ident == "content":
self.flags.insert(::properties::computed_value_flags::ComputedValueFlags::INHERITS_CONTENT);
self.flags.insert(::properties::computed_value_flags::INHERITS_CONTENT);
% endif
% if property.ident == "display":
self.flags.insert(::properties::computed_value_flags::ComputedValueFlags::INHERITS_DISPLAY);
self.flags.insert(::properties::computed_value_flags::INHERITS_DISPLAY);
% endif
self.${property.style_struct.ident}.mutate()
@ -3070,17 +3070,17 @@ static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
bitflags! {
/// A set of flags to tweak the behavior of the `cascade` function.
pub struct CascadeFlags: u8 {
pub flags CascadeFlags: u8 {
/// Whether to inherit all styles from the parent. If this flag is not
/// present, non-inherited styles are reset to their initial values.
const INHERIT_ALL = 1;
const INHERIT_ALL = 1,
/// Whether to skip any display style fixup for root element, flex/grid
/// item, and ruby descendants.
const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 1 << 1;
const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 1 << 1,
/// Whether to only cascade properties that are visited dependent.
const VISITED_DEPENDENT_ONLY = 1 << 2;
const VISITED_DEPENDENT_ONLY = 1 << 2,
/// Whether the given element we're styling is the document element,
/// that is, matches :root.
@ -3090,23 +3090,23 @@ bitflags! {
///
/// This affects some style adjustments, like blockification, and means
/// that it may affect global state, like the Device's root font-size.
const IS_ROOT_ELEMENT = 1 << 3;
const IS_ROOT_ELEMENT = 1 << 3,
/// Whether to convert display:contents into display:inline. This
/// is used by Gecko to prevent display:contents on generated
/// content.
const PROHIBIT_DISPLAY_CONTENTS = 1 << 4;
const PROHIBIT_DISPLAY_CONTENTS = 1 << 4,
/// Whether we're styling the ::-moz-fieldset-content anonymous box.
const IS_FIELDSET_CONTENT = 1 << 5;
const IS_FIELDSET_CONTENT = 1 << 5,
/// Whether we're computing the style of a link, either visited or
/// unvisited.
const IS_LINK = 1 << 6;
const IS_LINK = 1 << 6,
/// Whether we're computing the style of a link element that happens to
/// be visited.
const IS_VISITED_LINK = 1 << 7;
const IS_VISITED_LINK = 1 << 7,
}
}
@ -3251,7 +3251,7 @@ where
};
let mut context = computed::Context {
is_root_element: flags.contains(CascadeFlags::IS_ROOT_ELEMENT),
is_root_element: flags.contains(IS_ROOT_ELEMENT),
// We'd really like to own the rules here to avoid refcount traffic, but
// animation's usage of `apply_declarations` make this tricky. See bug
// 1375525.
@ -3328,7 +3328,7 @@ where
// Only a few properties are allowed to depend on the visited state
// of links. When cascading visited styles, we can save time by
// only processing these properties.
if flags.contains(CascadeFlags::VISITED_DEPENDENT_ONLY) &&
if flags.contains(VISITED_DEPENDENT_ONLY) &&
!longhand_id.is_visited_dependent() {
continue
}

View file

@ -360,7 +360,7 @@ macro_rules! try_parse_one {
<%helpers:shorthand name="-moz-transform" products="gecko"
sub_properties="transform"
flags="PropertyFlags::SHORTHAND_ALIAS_PROPERTY"
flags="SHORTHAND_ALIAS_PROPERTY"
derive_serialize="True"
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
use properties::longhands::transform;

View file

@ -14,41 +14,41 @@ use std::fmt;
bitflags! {
#[doc = "Individual layout actions that may be necessary after restyling."]
pub struct ServoRestyleDamage: u8 {
pub flags ServoRestyleDamage: u8 {
#[doc = "Repaint the node itself."]
#[doc = "Currently unused; need to decide how this propagates."]
const REPAINT = 0x01;
const REPAINT = 0x01,
#[doc = "The stacking-context-relative position of this node or its descendants has \
changed."]
#[doc = "Propagates both up and down the flow tree."]
const REPOSITION = 0x02;
const REPOSITION = 0x02,
#[doc = "Recompute the overflow regions (bounding box of object and all descendants)."]
#[doc = "Propagates down the flow tree because the computation is bottom-up."]
const STORE_OVERFLOW = 0x04;
const STORE_OVERFLOW = 0x04,
#[doc = "Recompute intrinsic inline_sizes (minimum and preferred)."]
#[doc = "Propagates down the flow tree because the computation is"]
#[doc = "bottom-up."]
const BUBBLE_ISIZES = 0x08;
const BUBBLE_ISIZES = 0x08,
#[doc = "Recompute actual inline-sizes and block-sizes, only taking out-of-flow children \
into account. \
Propagates up the flow tree because the computation is top-down."]
const REFLOW_OUT_OF_FLOW = 0x10;
const REFLOW_OUT_OF_FLOW = 0x10,
#[doc = "Recompute actual inline_sizes and block_sizes."]
#[doc = "Propagates up the flow tree because the computation is"]
#[doc = "top-down."]
const REFLOW = 0x20;
const REFLOW = 0x20,
#[doc = "Re-resolve generated content. \
Propagates up the flow tree because the computation is inorder."]
const RESOLVE_GENERATED_CONTENT = 0x40;
const RESOLVE_GENERATED_CONTENT = 0x40,
#[doc = "The entire flow needs to be reconstructed."]
const RECONSTRUCT_FLOW = 0x80;
const RECONSTRUCT_FLOW = 0x80
}
}
@ -79,28 +79,24 @@ impl ServoRestyleDamage {
/// FIXME(bholley): Do we ever actually need this? Shouldn't
/// RECONSTRUCT_FLOW imply everything else?
pub fn rebuild_and_reflow() -> ServoRestyleDamage {
ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::BUBBLE_ISIZES |
ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW |
ServoRestyleDamage::RECONSTRUCT_FLOW
REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW |
RECONSTRUCT_FLOW
}
/// Returns a bitmask indicating that the frame needs to be reconstructed.
pub fn reconstruct() -> ServoRestyleDamage {
ServoRestyleDamage::RECONSTRUCT_FLOW
RECONSTRUCT_FLOW
}
/// Supposing a flow has the given `position` property and this damage,
/// returns the damage that we should add to the *parent* of this flow.
pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> ServoRestyleDamage {
if child_is_absolutely_positioned {
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::REFLOW_OUT_OF_FLOW |
ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_CONTENT)
} else {
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::REFLOW |
ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW | REFLOW_OUT_OF_FLOW |
RESOLVE_GENERATED_CONTENT)
}
}
@ -115,20 +111,20 @@ impl ServoRestyleDamage {
// Absolute children are out-of-flow and therefore insulated from changes.
//
// FIXME(pcwalton): Au contraire, if the containing block dimensions change!
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION)
self & (REPAINT | REPOSITION)
}
(true, false) => {
// Changing the position of an absolutely-positioned block requires us to reflow
// its kids.
if self.contains(ServoRestyleDamage::REFLOW_OUT_OF_FLOW) {
self | ServoRestyleDamage::REFLOW
if self.contains(REFLOW_OUT_OF_FLOW) {
self | REFLOW
} else {
self
}
}
_ => {
// TODO(pcwalton): Take floatedness into account.
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION | ServoRestyleDamage::REFLOW)
self & (REPAINT | REPOSITION | REFLOW)
}
}
}
@ -145,14 +141,14 @@ impl fmt::Display for ServoRestyleDamage {
let mut first_elem = true;
let to_iter =
[ (ServoRestyleDamage::REPAINT, "Repaint")
, (ServoRestyleDamage::REPOSITION, "Reposition")
, (ServoRestyleDamage::STORE_OVERFLOW, "StoreOverflow")
, (ServoRestyleDamage::BUBBLE_ISIZES, "BubbleISizes")
, (ServoRestyleDamage::REFLOW_OUT_OF_FLOW, "ReflowOutOfFlow")
, (ServoRestyleDamage::REFLOW, "Reflow")
, (ServoRestyleDamage::RESOLVE_GENERATED_CONTENT, "ResolveGeneratedContent")
, (ServoRestyleDamage::RECONSTRUCT_FLOW, "ReconstructFlow")
[ (REPAINT, "Repaint")
, (REPOSITION, "Reposition")
, (STORE_OVERFLOW, "StoreOverflow")
, (BUBBLE_ISIZES, "BubbleISizes")
, (REFLOW_OUT_OF_FLOW, "ReflowOutOfFlow")
, (REFLOW, "Reflow")
, (RESOLVE_GENERATED_CONTENT, "ResolveGeneratedContent")
, (RECONSTRUCT_FLOW, "ReconstructFlow")
];
for &(damage, damage_str) in &to_iter {
@ -176,7 +172,7 @@ impl fmt::Display for ServoRestyleDamage {
// breakage on modifications.
macro_rules! add_if_not_equal(
($old:ident, $new:ident, $damage:ident,
[ $($effect:path),* ], [ $($style_struct_getter:ident.$name:ident),* ]) => ({
[ $($effect:ident),* ], [ $($style_struct_getter:ident.$name:ident),* ]) => ({
if $( ($old.$style_struct_getter().$name != $new.$style_struct_getter().$name) )||* {
$damage.insert($($effect)|*);
true
@ -195,10 +191,8 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
// FIXME: Test somehow that every property is included.
add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW,
ServoRestyleDamage::RECONSTRUCT_FLOW], [
[REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW,
REFLOW, RECONSTRUCT_FLOW], [
get_box.clear, get_box.float, get_box.display, get_box.position, get_counters.content,
get_counters.counter_reset, get_counters.counter_increment,
get_list.quotes, get_list.list_style_type,
@ -217,10 +211,8 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
get_column.column_width, get_column.column_count
]) || (new.get_box().display == display::T::inline &&
add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW,
ServoRestyleDamage::RECONSTRUCT_FLOW], [
[REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES,
REFLOW_OUT_OF_FLOW, REFLOW, RECONSTRUCT_FLOW], [
// For inline boxes only, border/padding styles are used in flow construction (to decide
// whether to create fragments for empty flows).
get_border.border_top_width, get_border.border_right_width,
@ -228,9 +220,8 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
get_padding.padding_top, get_padding.padding_right,
get_padding.padding_bottom, get_padding.padding_left
])) || add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW],
[REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES,
REFLOW_OUT_OF_FLOW, REFLOW],
[get_border.border_top_width, get_border.border_right_width,
get_border.border_bottom_width, get_border.border_left_width,
get_margin.margin_top, get_margin.margin_right,
@ -255,15 +246,14 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
get_position.flex_shrink,
get_position.align_self
]) || add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::REFLOW_OUT_OF_FLOW],
[get_position.top, get_position.left,
[REPAINT, REPOSITION, STORE_OVERFLOW, REFLOW_OUT_OF_FLOW], [
get_position.top, get_position.left,
get_position.right, get_position.bottom,
get_effects.opacity,
get_box.transform, get_box.transform_style, get_box.transform_origin,
get_box.perspective, get_box.perspective_origin
]) || add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT], [
[REPAINT], [
get_color.color, get_background.background_color,
get_background.background_image, get_background.background_position_x,
get_background.background_position_y, get_background.background_repeat,
@ -289,7 +279,7 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
// Paint worklets may depend on custom properties,
// so if they have changed we should repaint.
if old.custom_properties() != new.custom_properties() {
damage.insert(ServoRestyleDamage::REPAINT);
damage.insert(REPAINT);
}
// If the layer requirements of this flow have changed due to the value

View file

@ -329,20 +329,20 @@ impl NonTSPseudoClass {
/// Gets a given state flag for this pseudo-class. This is used to do
/// selector matching, and it's set from the DOM.
pub fn state_flag(&self) -> ElementState {
use element_state::ElementState;
use element_state::*;
use self::NonTSPseudoClass::*;
match *self {
Active => ElementState::IN_ACTIVE_STATE,
Focus => ElementState::IN_FOCUS_STATE,
Fullscreen => ElementState::IN_FULLSCREEN_STATE,
Hover => ElementState::IN_HOVER_STATE,
Enabled => ElementState::IN_ENABLED_STATE,
Disabled => ElementState::IN_DISABLED_STATE,
Checked => ElementState::IN_CHECKED_STATE,
Indeterminate => ElementState::IN_INDETERMINATE_STATE,
ReadOnly | ReadWrite => ElementState::IN_READ_WRITE_STATE,
PlaceholderShown => ElementState::IN_PLACEHOLDER_SHOWN_STATE,
Target => ElementState::IN_TARGET_STATE,
Active => IN_ACTIVE_STATE,
Focus => IN_FOCUS_STATE,
Fullscreen => IN_FULLSCREEN_STATE,
Hover => IN_HOVER_STATE,
Enabled => IN_ENABLED_STATE,
Disabled => IN_DISABLED_STATE,
Checked => IN_CHECKED_STATE,
Indeterminate => IN_INDETERMINATE_STATE,
ReadOnly | ReadWrite => IN_READ_WRITE_STATE,
PlaceholderShown => IN_PLACEHOLDER_SHOWN_STATE,
Target => IN_TARGET_STATE,
AnyLink |
Lang(_) |

View file

@ -6,7 +6,8 @@
//! a computed style needs in order for it to adhere to the CSS spec.
use app_units::Au;
use properties::{self, CascadeFlags, ComputedValues, StyleBuilder};
use properties::{self, CascadeFlags, ComputedValues};
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
use properties::longhands::display::computed_value::T as display;
use properties::longhands::float::computed_value::T as float;
use properties::longhands::overflow_x::computed_value::T as overflow;
@ -67,8 +68,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}
if !flags.contains(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
blockify_if!(flags.contains(CascadeFlags::IS_ROOT_ELEMENT));
if !flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
blockify_if!(flags.contains(IS_ROOT_ELEMENT));
blockify_if!(layout_parent_style.get_box().clone_display().is_item_container());
}
@ -83,7 +84,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
let display = self.style.get_box().clone_display();
let blockified_display =
display.equivalent_block_display(flags.contains(CascadeFlags::IS_ROOT_ELEMENT));
display.equivalent_block_display(flags.contains(IS_ROOT_ELEMENT));
if display != blockified_display {
self.style.mutate_box().set_adjusted_display(
blockified_display,
@ -94,16 +95,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// Compute a few common flags for both text and element's style.
pub fn set_bits(&mut self) {
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::IS_IN_DISPLAY_NONE_SUBTREE;
use properties::computed_value_flags::IS_IN_PSEUDO_ELEMENT_SUBTREE;
if self.style.inherited_flags().contains(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE) ||
if self.style.inherited_flags().contains(IS_IN_DISPLAY_NONE_SUBTREE) ||
self.style.get_box().clone_display() == display::none {
self.style.flags.insert(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE);
self.style.flags.insert(IS_IN_DISPLAY_NONE_SUBTREE);
}
if self.style.inherited_flags().contains(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE) ||
if self.style.inherited_flags().contains(IS_IN_PSEUDO_ELEMENT_SUBTREE) ||
self.style.is_pseudo_element() {
self.style.flags.insert(ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE);
self.style.flags.insert(IS_IN_PSEUDO_ELEMENT_SUBTREE);
}
}
@ -131,7 +133,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
fn adjust_for_text_combine_upright(&mut self) {
use computed_values::text_combine_upright::T as text_combine_upright;
use computed_values::writing_mode::T as writing_mode;
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::IS_TEXT_COMBINED;
let writing_mode =
self.style.get_inheritedbox().clone_writing_mode();
@ -140,7 +142,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
if writing_mode != writing_mode::horizontal_tb &&
text_combine_upright == text_combine_upright::all {
self.style.flags.insert(ComputedValueFlags::IS_TEXT_COMBINED);
self.style.flags.insert(IS_TEXT_COMBINED);
self.style.mutate_inheritedbox().set_writing_mode(writing_mode::horizontal_tb);
}
}
@ -151,10 +153,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// from them.
#[cfg(feature = "gecko")]
fn adjust_for_text_in_ruby(&mut self) {
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
let parent_display = self.style.get_parent_box().clone_display();
if parent_display.is_ruby_type() {
self.style.flags.insert(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
self.style.flags.insert(SHOULD_SUPPRESS_LINEBREAK);
}
}
@ -188,14 +190,14 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
#[cfg(feature = "gecko")]
fn adjust_for_contain(&mut self) {
use properties::longhands::contain::SpecifiedValue;
use properties::longhands::contain;
// An element with contain: paint needs to be a formatting context, and
// also implies overflow: clip.
//
// TODO(emilio): This mimics Gecko, but spec links are missing!
let contain = self.style.get_box().clone_contain();
if !contain.contains(SpecifiedValue::PAINT) {
if !contain.contains(contain::PAINT) {
return;
}
@ -206,7 +208,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
// When 'contain: paint', update overflow from 'visible' to 'clip'.
if self.style.get_box().clone_contain().contains(SpecifiedValue::PAINT) {
if self.style.get_box().clone_contain().contains(contain::PAINT) {
if self.style.get_box().clone_overflow_x() == overflow::visible {
let box_style = self.style.mutate_box();
box_style.set_overflow_x(overflow::_moz_hidden_unscrollable);
@ -319,11 +321,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// Native anonymous content converts display:contents into display:inline.
#[cfg(feature = "gecko")]
fn adjust_for_prohibited_display_contents(&mut self, flags: CascadeFlags) {
use properties::CascadeFlags;
use properties::PROHIBIT_DISPLAY_CONTENTS;
// TODO: We should probably convert display:contents into display:none
// in some cases too: https://drafts.csswg.org/css-display/#unbox
if !flags.contains(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS) ||
if !flags.contains(PROHIBIT_DISPLAY_CONTENTS) ||
self.style.get_box().clone_display() != display::contents {
return;
}
@ -343,8 +345,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
layout_parent_style: &ComputedValues,
flags: CascadeFlags,
) {
use properties::CascadeFlags;
if !flags.contains(CascadeFlags::IS_FIELDSET_CONTENT) {
use properties::IS_FIELDSET_CONTENT;
if !flags.contains(IS_FIELDSET_CONTENT) {
return;
}
debug_assert_eq!(self.style.get_box().clone_display(), display::block);
@ -392,10 +394,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
&mut self,
layout_parent_style: &ComputedValues,
) {
use properties::computed_value_flags::ComputedValueFlags;
if layout_parent_style.flags.contains(ComputedValueFlags::HAS_TEXT_DECORATION_LINES) ||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
!self.style.get_text().clone_text_decoration_line().is_empty() {
self.style.flags.insert(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
self.style.flags.insert(HAS_TEXT_DECORATION_LINES);
}
}
@ -404,13 +406,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
&self,
layout_parent_style: &ComputedValues,
) -> bool {
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
// Line break suppression should only be propagated to in-flow children.
if self.style.floated() || self.style.out_of_flow_positioned() {
return false;
}
let parent_display = layout_parent_style.get_box().clone_display();
if layout_parent_style.flags.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK) {
if layout_parent_style.flags.contains(SHOULD_SUPPRESS_LINEBREAK) {
// Line break suppression is propagated to any children of
// line participants.
if parent_display.is_line_participant() {
@ -446,16 +448,16 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
layout_parent_style: &ComputedValues,
flags: CascadeFlags,
) {
use properties::CascadeFlags;
use properties::computed_value_flags::ComputedValueFlags;
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
use properties::longhands::unicode_bidi::computed_value::T as unicode_bidi;
let self_display = self.style.get_box().clone_display();
// Check whether line break should be suppressed for this element.
if self.should_suppress_linebreak(layout_parent_style) {
self.style.flags.insert(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK);
self.style.flags.insert(SHOULD_SUPPRESS_LINEBREAK);
// Inlinify the display type if allowed.
if !flags.contains(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
if !flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) {
let inline_display = self_display.inlinify();
if self_display != inline_display {
self.style.mutate_box().set_display(inline_display);
@ -496,21 +498,21 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// FIXME(emilio): This isn't technically a style adjustment thingie, could
/// it move somewhere else?
fn adjust_for_visited(&mut self, flags: CascadeFlags) {
use properties::CascadeFlags;
use properties::computed_value_flags::ComputedValueFlags;
use properties::{IS_LINK, IS_VISITED_LINK};
use properties::computed_value_flags::IS_RELEVANT_LINK_VISITED;
if !self.style.has_visited_style() {
return;
}
let relevant_link_visited = if flags.contains(CascadeFlags::IS_LINK) {
flags.contains(CascadeFlags::IS_VISITED_LINK)
let relevant_link_visited = if flags.contains(IS_LINK) {
flags.contains(IS_VISITED_LINK)
} else {
self.style.inherited_flags().contains(ComputedValueFlags::IS_RELEVANT_LINK_VISITED)
self.style.inherited_flags().contains(IS_RELEVANT_LINK_VISITED)
};
if relevant_link_visited {
self.style.flags.insert(ComputedValueFlags::IS_RELEVANT_LINK_VISITED);
self.style.flags.insert(IS_RELEVANT_LINK_VISITED);
}
}
@ -524,14 +526,14 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
fn adjust_for_justify_items(&mut self) {
use values::specified::align;
let justify_items = self.style.get_position().clone_justify_items();
if justify_items.specified.0 != align::AlignFlags::AUTO {
if justify_items.specified.0 != align::ALIGN_AUTO {
return;
}
let parent_justify_items =
self.style.get_parent_position().clone_justify_items();
if !parent_justify_items.computed.0.contains(align::AlignFlags::LEGACY) {
if !parent_justify_items.computed.0.contains(align::ALIGN_LEGACY) {
return;
}

View file

@ -11,7 +11,9 @@ use dom::TElement;
use log::LogLevel::Trace;
use matching::{CascadeVisitedMode, MatchMethods};
use properties::{AnimationRules, CascadeFlags, ComputedValues};
use properties::cascade;
use properties::{IS_LINK, IS_ROOT_ELEMENT, IS_VISITED_LINK};
use properties::{PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
use properties::{VISITED_DEPENDENT_ONLY, cascade};
use properties::longhands::display::computed_value::T as display;
use rule_tree::StrongRuleNode;
use selector_parser::{PseudoElement, SelectorImpl};
@ -108,18 +110,18 @@ fn eager_pseudo_is_definitely_not_generated(
pseudo: &PseudoElement,
style: &ComputedValues,
) -> bool {
use properties::computed_value_flags::ComputedValueFlags;
use properties::computed_value_flags::{INHERITS_CONTENT, INHERITS_DISPLAY};
if !pseudo.is_before_or_after() {
return false;
}
if !style.flags.intersects(ComputedValueFlags::INHERITS_DISPLAY) &&
if !style.flags.intersects(INHERITS_DISPLAY) &&
style.get_box().clone_display() == display::none {
return true;
}
if !style.flags.intersects(ComputedValueFlags::INHERITS_CONTENT) &&
if !style.flags.intersects(INHERITS_CONTENT) &&
style.ineffective_content_property() {
return true;
}
@ -548,14 +550,14 @@ where
if self.element.skip_root_and_item_based_display_fixup() ||
pseudo.map_or(false, |p| p.skip_item_based_display_fixup()) {
cascade_flags.insert(CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP);
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP);
}
if pseudo.is_none() && self.element.is_link() {
cascade_flags.insert(CascadeFlags::IS_LINK);
cascade_flags.insert(IS_LINK);
if self.element.is_visited_link() &&
self.context.shared.visited_styles_enabled {
cascade_flags.insert(CascadeFlags::IS_VISITED_LINK);
cascade_flags.insert(IS_VISITED_LINK);
}
}
@ -568,12 +570,12 @@ where
s.visited_style().unwrap_or(s)
});
}
cascade_flags.insert(CascadeFlags::VISITED_DEPENDENT_ONLY);
cascade_flags.insert(VISITED_DEPENDENT_ONLY);
}
if self.element.is_native_anonymous() || pseudo.is_some() {
cascade_flags.insert(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS);
cascade_flags.insert(PROHIBIT_DISPLAY_CONTENTS);
} else if self.element.is_root() {
cascade_flags.insert(CascadeFlags::IS_ROOT_ELEMENT);
cascade_flags.insert(IS_ROOT_ELEMENT);
}
let implemented_pseudo = self.element.implemented_pseudo_element();

View file

@ -15,7 +15,7 @@ use properties::longhands::transition_timing_function::single_value::SpecifiedVa
use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard};
use std::fmt;
use style_traits::{ParsingMode, ToCss, ParseError, StyleParseErrorKind};
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError, StyleParseErrorKind};
use stylesheets::{CssRuleType, StylesheetContents};
use stylesheets::rule_parser::VendorPrefix;
use values::{KeyframesName, serialize_percentage};
@ -218,7 +218,7 @@ impl Keyframe {
parent_stylesheet_contents.origin,
&url_data,
Some(CssRuleType::Keyframe),
ParsingMode::DEFAULT,
PARSING_MODE_DEFAULT,
parent_stylesheet_contents.quirks_mode
);
let error_context = ParserErrorContext { error_reporter: &error_reporter };

View file

@ -31,7 +31,7 @@ use parser::{ParserContext, ParserErrorContext};
use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt;
use style_traits::ParsingMode;
use style_traits::PARSING_MODE_DEFAULT;
pub use self::counter_style_rule::CounterStyleRule;
pub use self::document_rule::DocumentRule;
@ -241,7 +241,7 @@ impl CssRule {
parent_stylesheet_contents.origin,
&url_data,
None,
ParsingMode::DEFAULT,
PARSING_MODE_DEFAULT,
parent_stylesheet_contents.quirks_mode,
);

View file

@ -41,13 +41,13 @@ impl Origin {
bitflags! {
/// A set of origins. This is equivalent to Gecko's OriginFlags.
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
pub struct OriginSet: u8 {
pub flags OriginSet: u8 {
/// <https://drafts.csswg.org/css-cascade/#cascade-origin-user-agent>
const ORIGIN_USER_AGENT = Origin::UserAgent as u8;
const ORIGIN_USER_AGENT = Origin::UserAgent as u8,
/// <https://drafts.csswg.org/css-cascade/#cascade-origin-user>
const ORIGIN_USER = Origin::User as u8;
const ORIGIN_USER = Origin::User as u8,
/// <https://drafts.csswg.org/css-cascade/#cascade-origin-author>
const ORIGIN_AUTHOR = Origin::Author as u8;
const ORIGIN_AUTHOR = Origin::Author as u8,
}
}

View file

@ -18,7 +18,7 @@ use servo_arc::Arc;
use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard};
use std::mem;
use std::sync::atomic::{AtomicBool, Ordering};
use style_traits::ParsingMode;
use style_traits::PARSING_MODE_DEFAULT;
use stylesheets::{CssRule, CssRules, Origin, UrlExtraData};
use stylesheets::loader::StylesheetLoader;
use stylesheets::rule_parser::{State, TopLevelRuleParser};
@ -364,7 +364,7 @@ impl Stylesheet {
origin,
url_data,
None,
ParsingMode::DEFAULT,
PARSING_MODE_DEFAULT,
quirks_mode
);
let error_context = ParserErrorContext { error_reporter };

View file

@ -22,6 +22,10 @@ use malloc_size_of::MallocUnconditionalShallowSizeOf;
use media_queries::Device;
use properties::{self, CascadeFlags, ComputedValues};
use properties::{AnimationRules, PropertyDeclarationBlock};
#[cfg(feature = "servo")]
use properties::INHERIT_ALL;
use properties::IS_LINK;
use properties::VISITED_DEPENDENT_ONLY;
use rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
use selector_map::{PrecomputedHashMap, SelectorMap, SelectorMapEntry};
use selector_parser::{SelectorImpl, PerPseudoElementMap, PseudoElement};
@ -50,7 +54,7 @@ use stylesheets::StyleRule;
use stylesheets::StylesheetInDocument;
use stylesheets::keyframes_rule::KeyframesAnimation;
use stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
use thread_state::{self, ThreadState};
use thread_state;
/// The type of the stylesheets that the stylist contains.
#[cfg(feature = "servo")]
@ -787,7 +791,7 @@ impl Stylist {
};
let mut cascade_flags = CascadeFlags::empty();
if inherit_all {
cascade_flags.insert(CascadeFlags::INHERIT_ALL);
cascade_flags.insert(INHERIT_ALL);
}
self.precomputed_values_for_pseudo(
guards,
@ -903,7 +907,7 @@ impl Stylist {
let inherited_style;
let inherited_style_ignoring_first_line;
let layout_parent_style_for_visited;
if cascade_flags.contains(CascadeFlags::IS_LINK) {
if cascade_flags.contains(IS_LINK) {
// We just want to use our parent style as our parent.
inherited_style = parent_style;
inherited_style_ignoring_first_line = parent_style_ignoring_first_line;
@ -929,7 +933,7 @@ impl Stylist {
Some(layout_parent_style_for_visited),
None,
font_metrics,
cascade_flags | CascadeFlags::VISITED_DEPENDENT_ONLY,
cascade_flags | VISITED_DEPENDENT_ONLY,
self.quirks_mode,
/* rule_cache = */ None,
&mut Default::default(),
@ -998,7 +1002,7 @@ impl Stylist {
// Gecko calls this from sequential mode, so we can directly apply
// the flags.
debug_assert!(thread_state::get() == ThreadState::LAYOUT);
debug_assert!(thread_state::get() == thread_state::LAYOUT);
let self_flags = flags.for_self();
if !self_flags.is_empty() {
unsafe { element.set_selector_flags(self_flags); }

View file

@ -11,26 +11,26 @@ use std::cell::RefCell;
bitflags! {
/// A thread state flag, used for multiple assertions.
pub struct ThreadState: u32 {
pub flags ThreadState: u32 {
/// Whether we're in a script thread.
const SCRIPT = 0x01;
const SCRIPT = 0x01,
/// Whether we're in a layout thread.
const LAYOUT = 0x02;
const LAYOUT = 0x02,
/// Whether we're in a script worker thread (actual web workers), or in
/// a layout worker thread.
const IN_WORKER = 0x0100;
const IN_WORKER = 0x0100,
/// Whether the current thread is going through a GC.
const IN_GC = 0x0200;
const IN_GC = 0x0200,
}
}
macro_rules! thread_types ( ( $( $fun:ident = $flag:path ; )* ) => (
macro_rules! thread_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
impl ThreadState {
/// Whether the current thread is a worker thread.
pub fn is_worker(self) -> bool {
self.contains(ThreadState::IN_WORKER)
self.contains(IN_WORKER)
}
$(
@ -43,8 +43,8 @@ macro_rules! thread_types ( ( $( $fun:ident = $flag:path ; )* ) => (
));
thread_types! {
is_script = ThreadState::SCRIPT;
is_layout = ThreadState::LAYOUT;
is_script = SCRIPT;
is_layout = LAYOUT;
}
thread_local!(static STATE: RefCell<Option<ThreadState>> = RefCell::new(None));
@ -63,7 +63,7 @@ pub fn initialize(x: ThreadState) {
/// Initializes the current thread as a layout worker thread.
pub fn initialize_layout_worker_thread() {
initialize(ThreadState::LAYOUT | ThreadState::IN_WORKER);
initialize(LAYOUT | IN_WORKER);
}
/// Gets the current thread state.

View file

@ -7,14 +7,14 @@
use context::{ElementCascadeInputs, StyleContext, SharedStyleContext};
use data::{ElementData, ElementStyles};
use dom::{NodeInfo, OpaqueNode, TElement, TNode};
use invalidation::element::restyle_hints::RestyleHint;
use invalidation::element::restyle_hints::{RECASCADE_SELF, RECASCADE_DESCENDANTS, RestyleHint};
use matching::{ChildCascadeRequirement, MatchMethods};
use selector_parser::PseudoElement;
use sharing::StyleSharingTarget;
use smallvec::SmallVec;
use style_resolver::{PseudoElementResolution, StyleResolverForElement};
use stylist::RuleInclusion;
use traversal_flags::TraversalFlags;
use traversal_flags::{TraversalFlags, self};
/// A per-traversal-level chunk of data. This is sent down by the traversal, and
/// currently only holds the dom depth for the bloom filter.
@ -149,7 +149,7 @@ pub trait DomTraversal<E: TElement> : Sync {
// If this is an unstyled-only traversal, the caller has already verified
// that there's something to traverse, and we don't need to do any
// invalidation since we're not doing any restyling.
if traversal_flags.contains(TraversalFlags::UnstyledOnly) {
if traversal_flags.contains(traversal_flags::UnstyledOnly) {
return PreTraverseToken(Some(root))
}
@ -222,7 +222,7 @@ pub trait DomTraversal<E: TElement> : Sync {
debug!("element_needs_traversal({:?}, {:?}, {:?}, {:?})",
el, traversal_flags, data, parent_data);
if traversal_flags.contains(TraversalFlags::UnstyledOnly) {
if traversal_flags.contains(traversal_flags::UnstyledOnly) {
return data.map_or(true, |d| !d.has_styles()) || el.has_dirty_descendants();
}
@ -473,12 +473,12 @@ where
F: FnMut(E::ConcreteNode),
{
use std::cmp;
use traversal_flags::TraversalFlags;
use traversal_flags::*;
let flags = context.shared.traversal_flags;
context.thread_local.begin_element(element, data);
context.thread_local.statistics.elements_traversed += 1;
debug_assert!(flags.intersects(TraversalFlags::AnimationOnly | TraversalFlags::UnstyledOnly) ||
debug_assert!(flags.intersects(AnimationOnly | UnstyledOnly) ||
!element.has_snapshot() || element.handled_snapshot(),
"Should've handled snapshots here already");
@ -525,7 +525,7 @@ where
// those operations and compute the propagated restyle hint (unless we're
// not processing invalidations, in which case don't need to propagate it
// and must avoid clearing it).
let propagated_hint = if flags.contains(TraversalFlags::UnstyledOnly) {
let propagated_hint = if flags.contains(UnstyledOnly) {
RestyleHint::empty()
} else {
debug_assert!(flags.for_animation_only() ||
@ -596,7 +596,7 @@ where
}
debug_assert!(flags.for_animation_only() ||
!flags.contains(TraversalFlags::ClearDirtyBits) ||
!flags.contains(ClearDirtyBits) ||
!element.has_animation_only_dirty_descendants(),
"Should have cleared animation bits already");
clear_state_after_traversing(element, data, flags);
@ -612,19 +612,21 @@ fn clear_state_after_traversing<E>(
where
E: TElement,
{
use traversal_flags::*;
// If we are in a forgetful traversal, drop the existing restyle
// data here, since we won't need to perform a post-traversal to pick up
// any change hints.
if flags.contains(TraversalFlags::Forgetful) {
if flags.contains(Forgetful) {
data.clear_restyle_flags_and_damage();
}
// Clear dirty bits as appropriate.
if flags.for_animation_only() {
if flags.intersects(TraversalFlags::ClearDirtyBits | TraversalFlags::ClearAnimationOnlyDirtyDescendants) {
if flags.intersects(ClearDirtyBits | ClearAnimationOnlyDirtyDescendants) {
unsafe { element.unset_animation_only_dirty_descendants(); }
}
} else if flags.contains(TraversalFlags::ClearDirtyBits) {
} else if flags.contains(ClearDirtyBits) {
// The animation traversal happens first, so we don't need to guard against
// clearing the animation bit on the regular traversal.
unsafe { element.clear_dirty_bits(); }
@ -861,7 +863,7 @@ where
// Make sure to not run style invalidation of styled elements in an
// unstyled-children-only traversal.
if child_data.is_some() && flags.intersects(TraversalFlags::UnstyledOnly) {
if child_data.is_some() && flags.intersects(traversal_flags::UnstyledOnly) {
continue;
}
@ -874,16 +876,16 @@ where
match cascade_requirement {
ChildCascadeRequirement::CanSkipCascade => {}
ChildCascadeRequirement::MustCascadeDescendants => {
child_hint |= RestyleHint::RECASCADE_SELF | RestyleHint::RECASCADE_DESCENDANTS;
child_hint |= RECASCADE_SELF | RECASCADE_DESCENDANTS;
}
ChildCascadeRequirement::MustCascadeChildrenIfInheritResetStyle => {
use properties::computed_value_flags::ComputedValueFlags;
if child_data.styles.primary().flags.contains(ComputedValueFlags::INHERITS_RESET_STYLE) {
child_hint |= RestyleHint::RECASCADE_SELF;
use properties::computed_value_flags::INHERITS_RESET_STYLE;
if child_data.styles.primary().flags.contains(INHERITS_RESET_STYLE) {
child_hint |= RECASCADE_SELF;
}
}
ChildCascadeRequirement::MustCascadeChildren => {
child_hint |= RestyleHint::RECASCADE_SELF;
child_hint |= RECASCADE_SELF;
}
}

View file

@ -10,31 +10,31 @@
bitflags! {
/// Flags that control the traversal process.
pub struct TraversalFlags: u32 {
pub flags TraversalFlags: u32 {
/// Traverse only elements for animation restyles.
const AnimationOnly = 1 << 0;
const AnimationOnly = 1 << 0,
/// Traverse and update all elements with CSS animations since
/// @keyframes rules may have changed. Triggered by CSS rule changes.
const ForCSSRuleChanges = 1 << 1;
const ForCSSRuleChanges = 1 << 1,
/// Styles unstyled elements, but does not handle invalidations on
/// already-styled elements.
const UnstyledOnly = 1 << 2;
const UnstyledOnly = 1 << 2,
/// A forgetful traversal ignores the previous state of the frame tree, and
/// thus does not compute damage or maintain other state describing the styles
/// pre-traversal. A forgetful traversal is usually the right thing if you
/// aren't going to do a post-traversal.
const Forgetful = 1 << 3;
const Forgetful = 1 << 3,
/// Clears all the dirty bits on the elements traversed.
const ClearDirtyBits = 1 << 5;
const ClearDirtyBits = 1 << 5,
/// Clears the animation-only dirty descendants bit in the subtree.
const ClearAnimationOnlyDirtyDescendants = 1 << 6;
const ClearAnimationOnlyDirtyDescendants = 1 << 6,
/// Allows the traversal to run in parallel if there are sufficient cores on
/// the machine.
const ParallelTraversal = 1 << 7;
const ParallelTraversal = 1 << 7,
/// Flush throttled animations. By default, we only update throttled animations
/// when we have other non-throttled work to do. With this flag, we
/// unconditionally tick and process them.
const FlushThrottledAnimations = 1 << 8;
const FlushThrottledAnimations = 1 << 8,
}
}
@ -46,7 +46,7 @@ pub fn assert_traversal_flags_match() {
use gecko_bindings::structs;
macro_rules! check_traversal_flags {
( $( $a:ident => $b:path ),*, ) => {
( $( $a:ident => $b:ident ),*, ) => {
if cfg!(debug_assertions) {
let mut modes = TraversalFlags::all();
$(
@ -59,15 +59,15 @@ pub fn assert_traversal_flags_match() {
}
check_traversal_flags! {
ServoTraversalFlags_AnimationOnly => TraversalFlags::AnimationOnly,
ServoTraversalFlags_ForCSSRuleChanges => TraversalFlags::ForCSSRuleChanges,
ServoTraversalFlags_UnstyledOnly => TraversalFlags::UnstyledOnly,
ServoTraversalFlags_Forgetful => TraversalFlags::Forgetful,
ServoTraversalFlags_ClearDirtyBits => TraversalFlags::ClearDirtyBits,
ServoTraversalFlags_AnimationOnly => AnimationOnly,
ServoTraversalFlags_ForCSSRuleChanges => ForCSSRuleChanges,
ServoTraversalFlags_UnstyledOnly => UnstyledOnly,
ServoTraversalFlags_Forgetful => Forgetful,
ServoTraversalFlags_ClearDirtyBits => ClearDirtyBits,
ServoTraversalFlags_ClearAnimationOnlyDirtyDescendants =>
TraversalFlags::ClearAnimationOnlyDirtyDescendants,
ServoTraversalFlags_ParallelTraversal => TraversalFlags::ParallelTraversal,
ServoTraversalFlags_FlushThrottledAnimations => TraversalFlags::FlushThrottledAnimations,
ClearAnimationOnlyDirtyDescendants,
ServoTraversalFlags_ParallelTraversal => ParallelTraversal,
ServoTraversalFlags_FlushThrottledAnimations => FlushThrottledAnimations,
}
}
@ -75,6 +75,6 @@ impl TraversalFlags {
/// Returns true if the traversal is for animation-only restyles.
#[inline]
pub fn for_animation_only(&self) -> bool {
self.contains(TraversalFlags::AnimationOnly)
self.contains(AnimationOnly)
}
}

View file

@ -51,7 +51,7 @@ impl ToComputedValue for specified::JustifyItems {
use values::specified::align;
let specified = *self;
let computed =
if self.0 != align::AlignFlags::AUTO {
if self.0 != align::ALIGN_AUTO {
*self
} else {
// If the inherited value of `justify-items` includes the

View file

@ -20,84 +20,84 @@ bitflags! {
/// These constants match Gecko's `NS_STYLE_ALIGN_*` constants.
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(ToComputedValue)]
pub struct AlignFlags: u8 {
pub flags AlignFlags: u8 {
// Enumeration stored in the lower 5 bits:
/// 'auto'
const AUTO = structs::NS_STYLE_ALIGN_AUTO as u8;
const ALIGN_AUTO = structs::NS_STYLE_ALIGN_AUTO as u8,
/// 'normal'
const NORMAL = structs::NS_STYLE_ALIGN_NORMAL as u8;
const ALIGN_NORMAL = structs::NS_STYLE_ALIGN_NORMAL as u8,
/// 'start'
const START = structs::NS_STYLE_ALIGN_START as u8;
const ALIGN_START = structs::NS_STYLE_ALIGN_START as u8,
/// 'end'
const END = structs::NS_STYLE_ALIGN_END as u8;
const ALIGN_END = structs::NS_STYLE_ALIGN_END as u8,
/// 'flex-start'
const FLEX_START = structs::NS_STYLE_ALIGN_FLEX_START as u8;
const ALIGN_FLEX_START = structs::NS_STYLE_ALIGN_FLEX_START as u8,
/// 'flex-end'
const FLEX_END = structs::NS_STYLE_ALIGN_FLEX_END as u8;
const ALIGN_FLEX_END = structs::NS_STYLE_ALIGN_FLEX_END as u8,
/// 'center'
const CENTER = structs::NS_STYLE_ALIGN_CENTER as u8;
const ALIGN_CENTER = structs::NS_STYLE_ALIGN_CENTER as u8,
/// 'left'
const LEFT = structs::NS_STYLE_ALIGN_LEFT as u8;
const ALIGN_LEFT = structs::NS_STYLE_ALIGN_LEFT as u8,
/// 'right'
const RIGHT = structs::NS_STYLE_ALIGN_RIGHT as u8;
const ALIGN_RIGHT = structs::NS_STYLE_ALIGN_RIGHT as u8,
/// 'baseline'
const BASELINE = structs::NS_STYLE_ALIGN_BASELINE as u8;
const ALIGN_BASELINE = structs::NS_STYLE_ALIGN_BASELINE as u8,
/// 'last-baseline'
const LAST_BASELINE = structs::NS_STYLE_ALIGN_LAST_BASELINE as u8;
const ALIGN_LAST_BASELINE = structs::NS_STYLE_ALIGN_LAST_BASELINE as u8,
/// 'stretch'
const STRETCH = structs::NS_STYLE_ALIGN_STRETCH as u8;
const ALIGN_STRETCH = structs::NS_STYLE_ALIGN_STRETCH as u8,
/// 'self-start'
const SELF_START = structs::NS_STYLE_ALIGN_SELF_START as u8;
const ALIGN_SELF_START = structs::NS_STYLE_ALIGN_SELF_START as u8,
/// 'self-end'
const SELF_END = structs::NS_STYLE_ALIGN_SELF_END as u8;
const ALIGN_SELF_END = structs::NS_STYLE_ALIGN_SELF_END as u8,
/// 'space-between'
const SPACE_BETWEEN = structs::NS_STYLE_ALIGN_SPACE_BETWEEN as u8;
const ALIGN_SPACE_BETWEEN = structs::NS_STYLE_ALIGN_SPACE_BETWEEN as u8,
/// 'space-around'
const SPACE_AROUND = structs::NS_STYLE_ALIGN_SPACE_AROUND as u8;
const ALIGN_SPACE_AROUND = structs::NS_STYLE_ALIGN_SPACE_AROUND as u8,
/// 'space-evenly'
const SPACE_EVENLY = structs::NS_STYLE_ALIGN_SPACE_EVENLY as u8;
const ALIGN_SPACE_EVENLY = structs::NS_STYLE_ALIGN_SPACE_EVENLY as u8,
// Additional flags stored in the upper bits:
/// 'legacy' (mutually exclusive w. SAFE & UNSAFE)
const LEGACY = structs::NS_STYLE_ALIGN_LEGACY as u8;
const ALIGN_LEGACY = structs::NS_STYLE_ALIGN_LEGACY as u8,
/// 'safe'
const SAFE = structs::NS_STYLE_ALIGN_SAFE as u8;
const ALIGN_SAFE = structs::NS_STYLE_ALIGN_SAFE as u8,
/// 'unsafe' (mutually exclusive w. SAFE)
const UNSAFE = structs::NS_STYLE_ALIGN_UNSAFE as u8;
const ALIGN_UNSAFE = structs::NS_STYLE_ALIGN_UNSAFE as u8,
/// Mask for the additional flags above.
const FLAG_BITS = structs::NS_STYLE_ALIGN_FLAG_BITS as u8;
const ALIGN_FLAG_BITS = structs::NS_STYLE_ALIGN_FLAG_BITS as u8,
}
}
impl ToCss for AlignFlags {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
let s = match *self & !AlignFlags::FLAG_BITS {
AlignFlags::AUTO => "auto",
AlignFlags::NORMAL => "normal",
AlignFlags::START => "start",
AlignFlags::END => "end",
AlignFlags::FLEX_START => "flex-start",
AlignFlags::FLEX_END => "flex-end",
AlignFlags::CENTER => "center",
AlignFlags::LEFT => "left",
AlignFlags::RIGHT => "right",
AlignFlags::BASELINE => "baseline",
AlignFlags::LAST_BASELINE => "last baseline",
AlignFlags::STRETCH => "stretch",
AlignFlags::SELF_START => "self-start",
AlignFlags::SELF_END => "self-end",
AlignFlags::SPACE_BETWEEN => "space-between",
AlignFlags::SPACE_AROUND => "space-around",
AlignFlags::SPACE_EVENLY => "space-evenly",
let s = match *self & !ALIGN_FLAG_BITS {
ALIGN_AUTO => "auto",
ALIGN_NORMAL => "normal",
ALIGN_START => "start",
ALIGN_END => "end",
ALIGN_FLEX_START => "flex-start",
ALIGN_FLEX_END => "flex-end",
ALIGN_CENTER => "center",
ALIGN_LEFT => "left",
ALIGN_RIGHT => "right",
ALIGN_BASELINE => "baseline",
ALIGN_LAST_BASELINE => "last baseline",
ALIGN_STRETCH => "stretch",
ALIGN_SELF_START => "self-start",
ALIGN_SELF_END => "self-end",
ALIGN_SPACE_BETWEEN => "space-between",
ALIGN_SPACE_AROUND => "space-around",
ALIGN_SPACE_EVENLY => "space-evenly",
_ => unreachable!()
};
dest.write_str(s)?;
match *self & AlignFlags::FLAG_BITS {
AlignFlags::LEGACY => { dest.write_str(" legacy")?; }
AlignFlags::SAFE => { dest.write_str(" safe")?; }
AlignFlags::UNSAFE => { dest.write_str(" unsafe")?; }
match *self & ALIGN_FLAG_BITS {
ALIGN_LEGACY => { dest.write_str(" legacy")?; }
ALIGN_SAFE => { dest.write_str(" safe")?; }
ALIGN_UNSAFE => { dest.write_str(" unsafe")?; }
_ => {}
}
Ok(())
@ -123,7 +123,7 @@ impl AlignJustifyContent {
/// The initial value 'normal'
#[inline]
pub fn normal() -> Self {
Self::new(AlignFlags::NORMAL)
Self::new(ALIGN_NORMAL)
}
/// Construct a value with no fallback.
@ -157,7 +157,7 @@ impl AlignJustifyContent {
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.primary().intersects(AlignFlags::FLAG_BITS) || self.fallback().intersects(AlignFlags::FLAG_BITS)
self.primary().intersects(ALIGN_FLAG_BITS) || self.fallback().intersects(ALIGN_FLAG_BITS)
}
}
@ -165,7 +165,7 @@ impl ToCss for AlignJustifyContent {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.primary().to_css(dest)?;
match self.fallback() {
AlignFlags::AUTO => {}
ALIGN_AUTO => {}
fallback => {
dest.write_str(" ")?;
fallback.to_css(dest)?;
@ -215,13 +215,13 @@ impl AlignJustifySelf {
/// The initial value 'auto'
#[inline]
pub fn auto() -> Self {
AlignJustifySelf(AlignFlags::AUTO)
AlignJustifySelf(ALIGN_AUTO)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
self.0.intersects(ALIGN_FLAG_BITS)
}
}
@ -253,13 +253,13 @@ impl AlignItems {
/// The initial value 'normal'
#[inline]
pub fn normal() -> Self {
AlignItems(AlignFlags::NORMAL)
AlignItems(ALIGN_NORMAL)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
self.0.intersects(ALIGN_FLAG_BITS)
}
}
@ -291,19 +291,19 @@ impl JustifyItems {
/// The initial value 'auto'
#[inline]
pub fn auto() -> Self {
JustifyItems(AlignFlags::AUTO)
JustifyItems(ALIGN_AUTO)
}
/// The value 'normal'
#[inline]
pub fn normal() -> Self {
JustifyItems(AlignFlags::NORMAL)
JustifyItems(ALIGN_NORMAL)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {
self.0.intersects(AlignFlags::FLAG_BITS)
self.0.intersects(ALIGN_FLAG_BITS)
}
}
@ -351,9 +351,9 @@ fn parse_auto_normal_stretch_baseline<'i, 't>(input: &mut Parser<'i, 't>)
}
try_match_ident_ignore_ascii_case! { input,
"auto" => Ok(AlignFlags::AUTO),
"normal" => Ok(AlignFlags::NORMAL),
"stretch" => Ok(AlignFlags::STRETCH),
"auto" => Ok(ALIGN_AUTO),
"normal" => Ok(ALIGN_NORMAL),
"stretch" => Ok(ALIGN_STRETCH),
}
}
@ -364,8 +364,8 @@ fn parse_normal_stretch_baseline<'i, 't>(input: &mut Parser<'i, 't>) -> Result<A
}
try_match_ident_ignore_ascii_case! { input,
"normal" => Ok(AlignFlags::NORMAL),
"stretch" => Ok(AlignFlags::STRETCH),
"normal" => Ok(ALIGN_NORMAL),
"stretch" => Ok(ALIGN_STRETCH),
}
}
@ -376,21 +376,21 @@ fn parse_normal_or_baseline<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignF
}
input.expect_ident_matching("normal")?;
Ok(AlignFlags::NORMAL)
Ok(ALIGN_NORMAL)
}
// <baseline-position>
fn parse_baseline<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseError<'i>> {
// FIXME: remove clone() when lifetimes are non-lexical
try_match_ident_ignore_ascii_case! { input,
"baseline" => Ok(AlignFlags::BASELINE),
"baseline" => Ok(ALIGN_BASELINE),
"first" => {
input.expect_ident_matching("baseline")?;
Ok(AlignFlags::BASELINE)
Ok(ALIGN_BASELINE)
}
"last" => {
input.expect_ident_matching("baseline")?;
Ok(AlignFlags::LAST_BASELINE)
Ok(ALIGN_LAST_BASELINE)
}
}
}
@ -398,10 +398,10 @@ fn parse_baseline<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, Pars
// <content-distribution>
fn parse_content_distribution<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"stretch" => Ok(AlignFlags::STRETCH),
"space-between" => Ok(AlignFlags::SPACE_BETWEEN),
"space-around" => Ok(AlignFlags::SPACE_AROUND),
"space-evenly" => Ok(AlignFlags::SPACE_EVENLY),
"stretch" => Ok(ALIGN_STRETCH),
"space-between" => Ok(ALIGN_SPACE_BETWEEN),
"space-around" => Ok(ALIGN_SPACE_AROUND),
"space-evenly" => Ok(ALIGN_SPACE_EVENLY),
}
}
@ -426,21 +426,21 @@ fn parse_overflow_content_position<'i, 't>(input: &mut Parser<'i, 't>) -> Result
// <content-position>
fn parse_content_position<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"start" => Ok(AlignFlags::START),
"end" => Ok(AlignFlags::END),
"flex-start" => Ok(AlignFlags::FLEX_START),
"flex-end" => Ok(AlignFlags::FLEX_END),
"center" => Ok(AlignFlags::CENTER),
"left" => Ok(AlignFlags::LEFT),
"right" => Ok(AlignFlags::RIGHT),
"start" => Ok(ALIGN_START),
"end" => Ok(ALIGN_END),
"flex-start" => Ok(ALIGN_FLEX_START),
"flex-end" => Ok(ALIGN_FLEX_END),
"center" => Ok(ALIGN_CENTER),
"left" => Ok(ALIGN_LEFT),
"right" => Ok(ALIGN_RIGHT),
}
}
// <overflow-position>
fn parse_overflow_position<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"safe" => Ok(AlignFlags::SAFE),
"unsafe" => Ok(AlignFlags::UNSAFE),
"safe" => Ok(ALIGN_SAFE),
"unsafe" => Ok(ALIGN_UNSAFE),
}
}
@ -465,15 +465,15 @@ fn parse_overflow_self_position<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Al
// <self-position>
fn parse_self_position<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseError<'i>> {
try_match_ident_ignore_ascii_case! { input,
"start" => Ok(AlignFlags::START),
"end" => Ok(AlignFlags::END),
"flex-start" => Ok(AlignFlags::FLEX_START),
"flex-end" => Ok(AlignFlags::FLEX_END),
"center" => Ok(AlignFlags::CENTER),
"left" => Ok(AlignFlags::LEFT),
"right" => Ok(AlignFlags::RIGHT),
"self-start" => Ok(AlignFlags::SELF_START),
"self-end" => Ok(AlignFlags::SELF_END),
"start" => Ok(ALIGN_START),
"end" => Ok(ALIGN_END),
"flex-start" => Ok(ALIGN_FLEX_START),
"flex-end" => Ok(ALIGN_FLEX_END),
"center" => Ok(ALIGN_CENTER),
"left" => Ok(ALIGN_LEFT),
"right" => Ok(ALIGN_RIGHT),
"self-start" => Ok(ALIGN_SELF_START),
"self-end" => Ok(ALIGN_SELF_END),
}
}
@ -485,16 +485,16 @@ fn parse_legacy<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseE
let b = input.expect_ident()?;
if a.eq_ignore_ascii_case("legacy") {
(match_ignore_ascii_case! { &b,
"left" => Ok(AlignFlags::LEGACY | AlignFlags::LEFT),
"right" => Ok(AlignFlags::LEGACY | AlignFlags::RIGHT),
"center" => Ok(AlignFlags::LEGACY | AlignFlags::CENTER),
"left" => Ok(ALIGN_LEGACY | ALIGN_LEFT),
"right" => Ok(ALIGN_LEGACY | ALIGN_RIGHT),
"center" => Ok(ALIGN_LEGACY | ALIGN_CENTER),
_ => Err(())
}).map_err(|()| b_location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(b.clone())))
} else if b.eq_ignore_ascii_case("legacy") {
(match_ignore_ascii_case! { &a,
"left" => Ok(AlignFlags::LEGACY | AlignFlags::LEFT),
"right" => Ok(AlignFlags::LEGACY | AlignFlags::RIGHT),
"center" => Ok(AlignFlags::LEGACY | AlignFlags::CENTER),
"left" => Ok(ALIGN_LEGACY | ALIGN_LEFT),
"right" => Ok(ALIGN_LEGACY | ALIGN_RIGHT),
"center" => Ok(ALIGN_LEGACY | ALIGN_CENTER),
_ => Err(())
}).map_err(|()| a_location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(a)))
} else {

View file

@ -77,7 +77,7 @@ impl Time {
input: &mut Parser<'i, 't>,
clamping_mode: AllowedNumericType
) -> Result<Self, ParseError<'i>> {
use style_traits::ParsingMode;
use style_traits::PARSING_MODE_DEFAULT;
let location = input.current_source_location();
// FIXME: remove early returns when lifetimes are non-lexical
@ -86,8 +86,8 @@ impl Time {
// that the ParserMode of the ParserContext allows all numeric
// values for SMIL regardless of clamping_mode, but in this Time
// value case, the value does not animate for SMIL at all, so we use
// ParsingMode::DEFAULT directly.
Ok(&Token::Dimension { value, ref unit, .. }) if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => {
// PARSING_MODE_DEFAULT directly.
Ok(&Token::Dimension { value, ref unit, .. }) if clamping_mode.is_ok(PARSING_MODE_DEFAULT, value) => {
return Time::parse_dimension(value, unit, /* from_calc = */ false)
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
@ -96,7 +96,7 @@ impl Time {
Err(e) => return Err(e.into())
}
match input.parse_nested_block(|i| CalcNode::parse_time(context, i)) {
Ok(time) if clamping_mode.is_ok(ParsingMode::DEFAULT, time.seconds) => Ok(time),
Ok(time) if clamping_mode.is_ok(PARSING_MODE_DEFAULT, time.seconds) => Ok(time),
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
}