diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-10-19 10:35:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 10:35:08 -0500 |
commit | fe16c1d5c3c9084da0ccb85af599d6ec0f8ab20b (patch) | |
tree | 84fe331eb4af20575050134b234b6c99a252726d /components/script | |
parent | 07e9794306d597afe5d90d192fd32a99572c3cc3 (diff) | |
parent | e8e2d0a4b24475b018dbc7e59ea46fdceaf20815 (diff) | |
download | servo-fe16c1d5c3c9084da0ccb85af599d6ec0f8ab20b.tar.gz servo-fe16c1d5c3c9084da0ccb85af599d6ec0f8ab20b.zip |
Auto merge of #18809 - Eijebong:bitflags, r=nox
Update bitflags to 1.0 in every servo crate
It still needs dependencies update to remove all the other bitflags
versions.
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because it's a dependency update
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18809)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
35 files changed, 194 insertions, 192 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 191a325f60a..7eb79b71cd3 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -28,7 +28,7 @@ tinyfiledialogs = "2.5.9" app_units = "0.5" audio-video-metadata = "0.1.4" base64 = "0.6" -bitflags = "0.7" +bitflags = "1.0" bluetooth_traits = {path = "../bluetooth_traits"} byteorder = "1.0" canvas_traits = {path = "../canvas_traits"} diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 9bcd2376167..585ecd47a15 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -2,9 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use devtools_traits::{AutoMargins, CONSOLE_API, CachedConsoleMessage, CachedConsoleMessageTypes}; +use devtools_traits::{AutoMargins, CachedConsoleMessage, CachedConsoleMessageTypes}; use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError}; -use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, PAGE_ERROR, TimelineMarker}; +use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker}; use devtools_traits::TimelineMarkerType; use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; @@ -168,7 +168,7 @@ pub fn handle_get_cached_messages(_pipeline_id: PipelineId, reply: IpcSender<Vec<CachedConsoleMessage>>) { // TODO: check the messageTypes against a global Cache for console messages and page exceptions let mut messages = Vec::new(); - if message_types.contains(PAGE_ERROR) { + if message_types.contains(CachedConsoleMessageTypes::PAGE_ERROR) { // TODO: make script error reporter pass all reported errors // to devtools and cache them for returning here. let msg = PageError { @@ -188,7 +188,7 @@ pub fn handle_get_cached_messages(_pipeline_id: PipelineId, }; messages.push(CachedConsoleMessage::PageError(msg)); } - if message_types.contains(CONSOLE_API) { + if message_types.contains(CachedConsoleMessageTypes::CONSOLE_API) { // TODO: do for real let msg = ConsoleAPI { type_: "ConsoleAPI".to_owned(), diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs index 3ba4fad6c66..c5a76bb4ee2 100644 --- a/components/script/dom/bindings/cell.rs +++ b/components/script/dom/bindings/cell.rs @@ -5,7 +5,7 @@ //! A shareable mutable container for the DOM. use std::cell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut}; -use style::thread_state; +use style::thread_state::{self, ThreadState}; /// A mutable field in the DOM. /// @@ -45,7 +45,7 @@ impl<T> DomRefCell<T> { /// #[allow(unsafe_code)] pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T { - debug_assert!(thread_state::get().contains(thread_state::SCRIPT)); + debug_assert!(thread_state::get().contains(ThreadState::SCRIPT)); &mut *self.value.as_ptr() } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 3251290f398..859e98931a5 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2039,7 +2039,7 @@ DOMClass { interface_chain: [ %s ], type_id: %s, malloc_size_of: %s as unsafe fn(&mut _, _) -> _, - global: InterfaceObjectMap::%s, + global: InterfaceObjectMap::Globals::%s, }""" % (prototypeChainString, DOMClassTypeId(descriptor), mallocSizeOf, globals_) @@ -2445,7 +2445,7 @@ class CGConstructorEnabled(CGAbstractMethod): iface = self.descriptor.interface bits = " | ".join(sorted( - "InterfaceObjectMap::" + camel_to_upper_snake(i) for i in iface.exposureSet + "InterfaceObjectMap::Globals::" + camel_to_upper_snake(i) for i in iface.exposureSet )) conditions.append("is_exposed_in(aObj, %s)" % bits) @@ -7092,9 +7092,9 @@ class GlobalGenRoots(): for (idx, d) in enumerate(global_descriptors) ) global_flags = CGWrapper(CGIndenter(CGList([ - CGGeneric("const %s = %#x," % args) + CGGeneric("const %s = %#x;" % args) for args in flags - ], "\n")), pre="pub flags Globals: u8 {\n", post="\n}") + ], "\n")), pre="pub struct Globals: u8 {\n", post="\n}") globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags! {\n", post="\n}") phf = CGGeneric("include!(concat!(env!(\"OUT_DIR\"), \"/InterfaceObjectMapPhf.rs\"));") diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index b1bc978c5fa..c78627b2e64 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -13,7 +13,7 @@ use style::context::QuirksMode; use style::parser::ParserContext; use style::stylesheets::CssRuleType; use style::stylesheets::supports_rule::{Declaration, parse_condition_or_declaration}; -use style_traits::PARSING_MODE_DEFAULT; +use style_traits::ParsingMode; #[dom_struct] pub struct CSS { @@ -39,7 +39,7 @@ impl CSS { let context = ParserContext::new_for_cssom( &url, Some(CssRuleType::Style), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, QuirksMode::NoQuirks ); decl.eval(&context) @@ -55,7 +55,7 @@ impl CSS { let context = ParserContext::new_for_cssom( &url, Some(CssRuleType::Style), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, QuirksMode::NoQuirks ); cond.eval(&context) diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index dc4a4c411a5..11f05d125a8 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -20,7 +20,7 @@ use style::media_queries::parse_media_query_list; use style::parser::ParserContext; use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::{CssRuleType, MediaRule}; -use style_traits::{PARSING_MODE_DEFAULT, ToCss}; +use style_traits::{ParsingMode, ToCss}; #[dom_struct] pub struct CSSMediaRule { @@ -76,7 +76,7 @@ impl CSSMediaRule { let url = window.get_url(); let quirks_mode = window.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); let new_medialist = parse_media_query_list(&context, &mut input, diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index e20d4e82e3f..d1d5aa505bf 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -22,7 +22,7 @@ use style::properties::{DeclarationSource, Importance, PropertyDeclarationBlock, use style::properties::{parse_one_declaration_into, parse_style_attribute, SourcePropertyDeclaration}; use style::selector_parser::PseudoElement; use style::shared_lock::Locked; -use style_traits::{PARSING_MODE_DEFAULT, ToCss}; +use style_traits::{ParsingMode, ToCss}; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface #[dom_struct] @@ -261,7 +261,7 @@ impl CSSStyleDeclaration { let mut declarations = SourcePropertyDeclaration::new(); let result = parse_one_declaration_into( &mut declarations, id, &value, &self.owner.base_url(), - window.css_error_reporter(), PARSING_MODE_DEFAULT, quirks_mode); + window.css_error_reporter(), ParsingMode::DEFAULT, quirks_mode); // Step 6 match result { diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index d9e3f8ac8a0..68d02aa241a 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -18,7 +18,7 @@ use style::parser::ParserContext; use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::{CssRuleType, SupportsRule}; use style::stylesheets::supports_rule::SupportsCondition; -use style_traits::{PARSING_MODE_DEFAULT, ToCss}; +use style_traits::{ParsingMode, ToCss}; #[dom_struct] pub struct CSSSupportsRule { @@ -64,7 +64,7 @@ impl CSSSupportsRule { let url = win.Document().url(); let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Supports), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); let enabled = cond.eval(&context); let mut guard = self.cssconditionrule.shared_lock().write(); diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index a754bbc4c6a..84b390ea1cf 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -42,7 +42,7 @@ use std::sync::{Arc, Mutex}; use std::sync::atomic::AtomicBool; use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel}; use std::thread; -use style::thread_state; +use style::thread_state::{self, ThreadState}; /// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular /// value for the duration of this object's lifetime. This ensures that the related Worker @@ -167,7 +167,7 @@ impl DedicatedWorkerGlobalScope { let origin = GlobalScope::current().expect("No current global object").origin().immutable().clone(); thread::Builder::new().name(name).spawn(move || { - thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER); + thread_state::initialize(ThreadState::SCRIPT | ThreadState::IN_WORKER); if let Some(top_level_browsing_context_id) = top_level_browsing_context_id { TopLevelBrowsingContextId::install(top_level_browsing_context_id); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 2e018bd62f5..731b89a26cb 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -66,7 +66,7 @@ use dom::keyboardevent::KeyboardEvent; use dom::location::Location; use dom::messageevent::MessageEvent; use dom::mouseevent::MouseEvent; -use dom::node::{self, CloneChildrenFlag, Node, NodeDamage, window_from_node, IS_IN_DOC, LayoutNodeHelpers}; +use dom::node::{self, CloneChildrenFlag, Node, NodeDamage, window_from_node, NodeFlags, LayoutNodeHelpers}; use dom::node::VecPreOrderInsertionHelper; use dom::nodeiterator::NodeIterator; use dom::nodelist::NodeList; @@ -99,7 +99,6 @@ use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; use js::jsapi::{JSContext, JSRuntime}; use js::jsapi::JS_GetRuntime; -use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId}; use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy}; use net_traits::CookieSource::NonHTTP; @@ -130,7 +129,7 @@ use std::rc::Rc; use std::time::{Duration, Instant}; use style::attr::AttrValue; use style::context::QuirksMode; -use style::invalidation::element::restyle_hints::{RestyleHint, RESTYLE_SELF, RESTYLE_STYLE_ATTRIBUTE}; +use style::invalidation::element::restyle_hints::RestyleHint; use style::media_queries::{Device, MediaList, MediaType}; use style::selector_parser::{RestyleDamage, Snapshot}; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard}; @@ -1276,10 +1275,10 @@ impl Document { (&None, &None) => self.window.upcast(), }; - let ctrl = modifiers.contains(CONTROL); - let alt = modifiers.contains(ALT); - let shift = modifiers.contains(SHIFT); - let meta = modifiers.contains(SUPER); + let ctrl = modifiers.contains(KeyModifiers::CONTROL); + let alt = modifiers.contains(KeyModifiers::ALT); + let shift = modifiers.contains(KeyModifiers::SHIFT); + let meta = modifiers.contains(KeyModifiers::SUPER); let is_composing = false; let is_repeating = state == KeyState::Repeated; @@ -2019,7 +2018,7 @@ impl LayoutDocumentHelpers for LayoutDom<Document> { // may no longer be true when the next layout occurs. let result = elements.drain() .map(|(k, v)| (k.to_layout(), v)) - .filter(|&(ref k, _)| k.upcast::<Node>().get_flag(IS_IN_DOC)) + .filter(|&(ref k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_IN_DOC)) .collect(); result } @@ -2466,11 +2465,11 @@ impl Document { entry.snapshot = Some(Snapshot::new(el.html_element_in_html_document())); } if attr.local_name() == &local_name!("style") { - entry.hint.insert(RESTYLE_STYLE_ATTRIBUTE); + entry.hint.insert(RestyleHint::RESTYLE_STYLE_ATTRIBUTE); } if vtable_for(el.upcast()).attribute_affects_presentational_hints(attr) { - entry.hint.insert(RESTYLE_SELF); + entry.hint.insert(RestyleHint::RESTYLE_SELF); } let snapshot = entry.snapshot.as_mut().unwrap(); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 1d8c12f9a64..0ca6a0e7e2e 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -65,8 +65,8 @@ use dom::htmltemplateelement::HTMLTemplateElement; use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers}; use dom::mutationobserver::{Mutation, MutationObserver}; use dom::namednodemap::NamedNodeMap; -use dom::node::{CLICK_IN_PROGRESS, ChildrenMutation, LayoutNodeHelpers, Node}; -use dom::node::{NodeDamage, SEQUENTIALLY_FOCUSABLE, UnbindContext}; +use dom::node::{ChildrenMutation, LayoutNodeHelpers, Node}; +use dom::node::{NodeDamage, NodeFlags, UnbindContext}; use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::promise::Promise; @@ -90,7 +90,6 @@ use script_thread::ScriptThread; use selectors::Element as SelectorsElement; use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity}; use selectors::matching::{ElementSelectorFlags, MatchingContext, RelevantLinkStatus}; -use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS}; use selectors::sink::Push; use servo_arc::Arc; use servo_atoms::Atom; @@ -107,8 +106,8 @@ use style::applicable_declarations::ApplicableDeclarationBlock; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::context::QuirksMode; use style::dom_apis; -use style::element_state::*; -use style::invalidation::element::restyle_hints::RESTYLE_SELF; +use style::element_state::ElementState; +use style::invalidation::element::restyle_hints::RestyleHint; use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x}; use style::rule_tree::CascadeLevel; @@ -292,7 +291,7 @@ impl Element { // FIXME(bholley): I think we should probably only do this for // NodeStyleDamaged, but I'm preserving existing behavior. - restyle.hint.insert(RESTYLE_SELF); + restyle.hint.insert(RestyleHint::RESTYLE_SELF); if damage == NodeDamage::OtherNodeDamage { restyle.damage = RestyleDamage::rebuild_and_reflow(); @@ -1069,7 +1068,7 @@ impl Element { } // TODO: Check whether the element is being rendered (i.e. not hidden). let node = self.upcast::<Node>(); - if node.get_flag(SEQUENTIALLY_FOCUSABLE) { + if node.get_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE) { return true; } // https://html.spec.whatwg.org/multipage/#specially-focusable @@ -2487,11 +2486,11 @@ impl VirtualMethods for Element { } let flags = self.selector_flags.get(); - if flags.intersects(HAS_SLOW_SELECTOR) { + if flags.intersects(ElementSelectorFlags::HAS_SLOW_SELECTOR) { // All children of this node need to be restyled when any child changes. self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } else { - if flags.intersects(HAS_SLOW_SELECTOR_LATER_SIBLINGS) { + if flags.intersects(ElementSelectorFlags::HAS_SLOW_SELECTOR_LATER_SIBLINGS) { if let Some(next_child) = mutation.next_child() { for child in next_child.inclusively_following_siblings() { if child.is::<Element>() { @@ -2500,7 +2499,7 @@ impl VirtualMethods for Element { } } } - if flags.intersects(HAS_EDGE_CHILD_SELECTOR) { + if flags.intersects(ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR) { if let Some(child) = mutation.modified_edge_element() { child.dirty(NodeDamage::OtherNodeDamage); } @@ -2754,11 +2753,11 @@ impl Element { } pub fn click_in_progress(&self) -> bool { - self.upcast::<Node>().get_flag(CLICK_IN_PROGRESS) + self.upcast::<Node>().get_flag(NodeFlags::CLICK_IN_PROGRESS) } pub fn set_click_in_progress(&self, click: bool) { - self.upcast::<Node>().set_flag(CLICK_IN_PROGRESS, click) + self.upcast::<Node>().set_flag(NodeFlags::CLICK_IN_PROGRESS, click) } // https://html.spec.whatwg.org/multipage/#nearest-activatable-element @@ -2858,12 +2857,12 @@ impl Element { } pub fn active_state(&self) -> bool { - self.state.get().contains(IN_ACTIVE_STATE) + self.state.get().contains(ElementState::IN_ACTIVE_STATE) } /// <https://html.spec.whatwg.org/multipage/#concept-selector-active> pub fn set_active_state(&self, value: bool) { - self.set_state(IN_ACTIVE_STATE, value); + self.set_state(ElementState::IN_ACTIVE_STATE, value); if let Some(parent) = self.upcast::<Node>().GetParentElement() { parent.set_active_state(value); @@ -2871,71 +2870,71 @@ impl Element { } pub fn focus_state(&self) -> bool { - self.state.get().contains(IN_FOCUS_STATE) + self.state.get().contains(ElementState::IN_FOCUS_STATE) } pub fn set_focus_state(&self, value: bool) { - self.set_state(IN_FOCUS_STATE, value); + self.set_state(ElementState::IN_FOCUS_STATE, value); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } pub fn hover_state(&self) -> bool { - self.state.get().contains(IN_HOVER_STATE) + self.state.get().contains(ElementState::IN_HOVER_STATE) } pub fn set_hover_state(&self, value: bool) { - self.set_state(IN_HOVER_STATE, value) + self.set_state(ElementState::IN_HOVER_STATE, value) } pub fn enabled_state(&self) -> bool { - self.state.get().contains(IN_ENABLED_STATE) + self.state.get().contains(ElementState::IN_ENABLED_STATE) } pub fn set_enabled_state(&self, value: bool) { - self.set_state(IN_ENABLED_STATE, value) + self.set_state(ElementState::IN_ENABLED_STATE, value) } pub fn disabled_state(&self) -> bool { - self.state.get().contains(IN_DISABLED_STATE) + self.state.get().contains(ElementState::IN_DISABLED_STATE) } pub fn set_disabled_state(&self, value: bool) { - self.set_state(IN_DISABLED_STATE, value) + self.set_state(ElementState::IN_DISABLED_STATE, value) } pub fn read_write_state(&self) -> bool { - self.state.get().contains(IN_READ_WRITE_STATE) + self.state.get().contains(ElementState::IN_READ_WRITE_STATE) } pub fn set_read_write_state(&self, value: bool) { - self.set_state(IN_READ_WRITE_STATE, value) + self.set_state(ElementState::IN_READ_WRITE_STATE, value) } pub fn placeholder_shown_state(&self) -> bool { - self.state.get().contains(IN_PLACEHOLDER_SHOWN_STATE) + self.state.get().contains(ElementState::IN_PLACEHOLDER_SHOWN_STATE) } pub fn set_placeholder_shown_state(&self, value: bool) { if self.placeholder_shown_state() != value { - self.set_state(IN_PLACEHOLDER_SHOWN_STATE, value); + self.set_state(ElementState::IN_PLACEHOLDER_SHOWN_STATE, value); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } } pub fn target_state(&self) -> bool { - self.state.get().contains(IN_TARGET_STATE) + self.state.get().contains(ElementState::IN_TARGET_STATE) } pub fn set_target_state(&self, value: bool) { - self.set_state(IN_TARGET_STATE, value) + self.set_state(ElementState::IN_TARGET_STATE, value) } pub fn fullscreen_state(&self) -> bool { - self.state.get().contains(IN_FULLSCREEN_STATE) + self.state.get().contains(ElementState::IN_FULLSCREEN_STATE) } pub fn set_fullscreen_state(&self, value: bool) { - self.set_state(IN_FULLSCREEN_STATE, value) + self.set_state(ElementState::IN_FULLSCREEN_STATE, value) } /// <https://dom.spec.whatwg.org/#connected> diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index feb9a3f1805..be2b26d2085 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -27,7 +27,7 @@ use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use std::cell::Cell; use std::default::Default; -use style::element_state::*; +use style::element_state::ElementState; #[derive(Clone, Copy, JSTraceable, PartialEq)] #[derive(MallocSizeOf)] @@ -51,7 +51,7 @@ impl HTMLButtonElement { document: &Document) -> HTMLButtonElement { HTMLButtonElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE, local_name, prefix, document), button_type: Cell::new(ButtonType::Submit), form_owner: Default::default(), diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index f88e26a22e5..616b69ebb95 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -24,7 +24,7 @@ use dom::htmlframesetelement::HTMLFrameSetElement; use dom::htmlhtmlelement::HTMLHtmlElement; use dom::htmlinputelement::HTMLInputElement; use dom::htmllabelelement::HTMLLabelElement; -use dom::node::{Node, SEQUENTIALLY_FOCUSABLE}; +use dom::node::{Node, NodeFlags}; use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::virtualmethods::VirtualMethods; @@ -76,18 +76,18 @@ impl HTMLElement { let element = self.upcast::<Element>(); let node = self.upcast::<Node>(); if element.has_attribute(&local_name!("tabindex")) { - node.set_flag(SEQUENTIALLY_FOCUSABLE, true); + node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true); } else { match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) - => node.set_flag(SEQUENTIALLY_FOCUSABLE, true), + => node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true), NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { if element.has_attribute(&local_name!("href")) { - node.set_flag(SEQUENTIALLY_FOCUSABLE, true); + node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true); } }, _ => { @@ -97,9 +97,9 @@ impl HTMLElement { AttrValue::String(ref string) => string == "true", _ => false, }; - node.set_flag(SEQUENTIALLY_FOCUSABLE, is_true); + node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, is_true); } else { - node.set_flag(SEQUENTIALLY_FOCUSABLE, false); + node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, false); } //TODO set SEQUENTIALLY_FOCUSABLE flag if editing host //TODO set SEQUENTIALLY_FOCUSABLE flag if "sorting interface th elements" diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 81fc57dbce3..cae9aa49ee5 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -19,7 +19,7 @@ use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use std::default::Default; -use style::element_state::*; +use style::element_state::ElementState; #[dom_struct] pub struct HTMLFieldSetElement { @@ -33,7 +33,7 @@ impl HTMLFieldSetElement { document: &Document) -> HTMLFieldSetElement { HTMLFieldSetElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE, local_name, prefix, document), form_owner: Default::default(), } diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index d99b101dd4a..9e0c32aa057 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -37,7 +37,7 @@ use dom::htmlobjectelement::HTMLObjectElement; use dom::htmloutputelement::HTMLOutputElement; use dom::htmlselectelement::HTMLSelectElement; use dom::htmltextareaelement::HTMLTextAreaElement; -use dom::node::{Node, PARSER_ASSOCIATED_FORM_OWNER, UnbindContext, VecPreOrderInsertionHelper}; +use dom::node::{Node, NodeFlags, UnbindContext, VecPreOrderInsertionHelper}; use dom::node::{document_from_node, window_from_node}; use dom::validitystate::ValidationFlags; use dom::virtualmethods::VirtualMethods; @@ -879,7 +879,7 @@ pub trait FormControl: DomObject { fn set_form_owner_from_parser(&self, form: &HTMLFormElement) { let elem = self.to_element(); let node = elem.upcast::<Node>(); - node.set_flag(PARSER_ASSOCIATED_FORM_OWNER, true); + node.set_flag(NodeFlags::PARSER_ASSOCIATED_FORM_OWNER, true); form.add_control(self); self.set_form_owner(Some(form)); } @@ -968,8 +968,8 @@ pub trait FormControl: DomObject { // Part of step 12. // '..suppress the running of the reset the form owner algorithm // when the parser subsequently attempts to insert the element..' - let must_skip_reset = node.get_flag(PARSER_ASSOCIATED_FORM_OWNER); - node.set_flag(PARSER_ASSOCIATED_FORM_OWNER, false); + let must_skip_reset = node.get_flag(NodeFlags::PARSER_ASSOCIATED_FORM_OWNER); + node.set_flag(NodeFlags::PARSER_ASSOCIATED_FORM_OWNER, false); if !must_skip_reset { self.form_attribute_mutated(AttributeMutation::Set(None)); diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 697e32636b1..64bd9926ca3 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -57,14 +57,14 @@ use task_source::TaskSource; bitflags! { #[derive(JSTraceable, MallocSizeOf)] - flags SandboxAllowance: u8 { - const ALLOW_NOTHING = 0x00, - const ALLOW_SAME_ORIGIN = 0x01, - const ALLOW_TOP_NAVIGATION = 0x02, - const ALLOW_FORMS = 0x04, - const ALLOW_SCRIPTS = 0x08, - const ALLOW_POINTER_LOCK = 0x10, - const ALLOW_POPUPS = 0x20 + struct SandboxAllowance: u8 { + const ALLOW_NOTHING = 0x00; + const ALLOW_SAME_ORIGIN = 0x01; + const ALLOW_TOP_NAVIGATION = 0x02; + const ALLOW_FORMS = 0x04; + const ALLOW_SCRIPTS = 0x08; + const ALLOW_POINTER_LOCK = 0x10; + const ALLOW_POPUPS = 0x20; } } @@ -726,16 +726,16 @@ impl VirtualMethods for HTMLIFrameElement { match attr.local_name() { &local_name!("sandbox") => { self.sandbox_allowance.set(mutation.new_value(attr).map(|value| { - let mut modes = ALLOW_NOTHING; + let mut modes = SandboxAllowance::ALLOW_NOTHING; for token in value.as_tokens() { modes |= match &*token.to_ascii_lowercase() { - "allow-same-origin" => ALLOW_SAME_ORIGIN, - "allow-forms" => ALLOW_FORMS, - "allow-pointer-lock" => ALLOW_POINTER_LOCK, - "allow-popups" => ALLOW_POPUPS, - "allow-scripts" => ALLOW_SCRIPTS, - "allow-top-navigation" => ALLOW_TOP_NAVIGATION, - _ => ALLOW_NOTHING + "allow-same-origin" => SandboxAllowance::ALLOW_SAME_ORIGIN, + "allow-forms" => SandboxAllowance::ALLOW_FORMS, + "allow-pointer-lock" => SandboxAllowance::ALLOW_POINTER_LOCK, + "allow-popups" => SandboxAllowance::ALLOW_POPUPS, + "allow-scripts" => SandboxAllowance::ALLOW_SCRIPTS, + "allow-top-navigation" => SandboxAllowance::ALLOW_TOP_NAVIGATION, + _ => SandboxAllowance::ALLOW_NOTHING }; } modes diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 459633836d3..4fd99b289a1 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -48,7 +48,7 @@ use std::borrow::ToOwned; use std::cell::Cell; use std::ops::Range; use style::attr::AttrValue; -use style::element_state::*; +use style::element_state::ElementState; use style::str::split_commas; use textinput::{SelectionDirection, TextInput}; use textinput::KeyReaction::{DispatchInput, Nothing, RedrawSelection, TriggerDefaultAction}; @@ -137,7 +137,8 @@ impl HTMLInputElement { let chan = document.window().upcast::<GlobalScope>().script_to_constellation_chan().clone(); HTMLInputElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE | + ElementState::IN_READ_WRITE_STATE, local_name, prefix, document), input_type: Cell::new(InputType::InputText), placeholder: DomRefCell::new(DOMString::new()), @@ -280,13 +281,13 @@ impl LayoutHTMLInputElementHelpers for LayoutDom<HTMLInputElement> { #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn checked_state_for_layout(self) -> bool { - self.upcast::<Element>().get_state_for_layout().contains(IN_CHECKED_STATE) + self.upcast::<Element>().get_state_for_layout().contains(ElementState::IN_CHECKED_STATE) } #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn indeterminate_state_for_layout(self) -> bool { - self.upcast::<Element>().get_state_for_layout().contains(IN_INDETERMINATE_STATE) + self.upcast::<Element>().get_state_for_layout().contains(ElementState::IN_INDETERMINATE_STATE) } } @@ -336,7 +337,7 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-input-checked fn Checked(&self) -> bool { - self.upcast::<Element>().state().contains(IN_CHECKED_STATE) + self.upcast::<Element>().state().contains(ElementState::IN_CHECKED_STATE) } // https://html.spec.whatwg.org/multipage/#dom-input-checked @@ -538,12 +539,12 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate fn Indeterminate(&self) -> bool { - self.upcast::<Element>().state().contains(IN_INDETERMINATE_STATE) + self.upcast::<Element>().state().contains(ElementState::IN_INDETERMINATE_STATE) } // https://html.spec.whatwg.org/multipage/#dom-input-indeterminate fn SetIndeterminate(&self, val: bool) { - self.upcast::<Element>().set_state(IN_INDETERMINATE_STATE, val) + self.upcast::<Element>().set_state(ElementState::IN_INDETERMINATE_STATE, val) } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels @@ -745,7 +746,7 @@ impl HTMLInputElement { } fn update_checked_state(&self, checked: bool, dirty: bool) { - self.upcast::<Element>().set_state(IN_CHECKED_STATE, checked); + self.upcast::<Element>().set_state(ElementState::IN_CHECKED_STATE, checked); if dirty { self.checked_changed.set(true); diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 03353d70bc4..3843bb034a7 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -35,7 +35,7 @@ use style::media_queries::parse_media_query_list; use style::parser::ParserContext as CssParserContext; use style::str::HTML_SPACE_CHARACTERS; use style::stylesheets::{CssRuleType, Stylesheet}; -use style_traits::PARSING_MODE_DEFAULT; +use style_traits::ParsingMode; use stylesheet_loader::{StylesheetLoader, StylesheetContextSource, StylesheetOwner}; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] @@ -287,7 +287,7 @@ impl HTMLLinkElement { let mut css_parser = CssParser::new(&mut input); let doc_url = document.url(); let context = CssParserContext::new_for_cssom(&doc_url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, document.quirks_mode()); let window = document.window(); let media = parse_media_query_list(&context, &mut css_parser, diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index 88e2d3012df..8413b464407 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -15,7 +15,7 @@ use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; -use style::element_state::*; +use style::element_state::ElementState; #[dom_struct] pub struct HTMLOptGroupElement { @@ -28,7 +28,7 @@ impl HTMLOptGroupElement { document: &Document) -> HTMLOptGroupElement { HTMLOptGroupElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE, local_name, prefix, document) } } diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 27e86e630f7..ff59c4b0e24 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -25,7 +25,7 @@ use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use std::cell::Cell; -use style::element_state::*; +use style::element_state::ElementState; use style::str::{split_html_space_chars, str_join}; #[dom_struct] @@ -45,7 +45,7 @@ impl HTMLOptionElement { document: &Document) -> HTMLOptionElement { HTMLOptionElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE, local_name, prefix, document), selectedness: Cell::new(false), dirtiness: Cell::new(false), diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 3423db303e4..401d29c6cb8 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -35,7 +35,7 @@ use html5ever::{LocalName, Prefix}; use std::default::Default; use std::iter; use style::attr::AttrValue; -use style::element_state::*; +use style::element_state::ElementState; #[derive(JSTraceable, MallocSizeOf)] struct OptionsFilter; @@ -73,7 +73,7 @@ impl HTMLSelectElement { document: &Document) -> HTMLSelectElement { HTMLSelectElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE, local_name, prefix, document), options: Default::default(), form_owner: Default::default(), diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index ef25b52dbb3..f6d2caaccf8 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -25,7 +25,7 @@ use std::cell::Cell; use style::media_queries::parse_media_query_list; use style::parser::ParserContext as CssParserContext; use style::stylesheets::{CssRuleType, Stylesheet, Origin}; -use style_traits::PARSING_MODE_DEFAULT; +use style_traits::ParsingMode; use stylesheet_loader::{StylesheetLoader, StylesheetOwner}; #[dom_struct] @@ -87,7 +87,7 @@ impl HTMLStyleElement { let url = window.get_url(); let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, doc.quirks_mode()); let shared_lock = node.owner_doc().style_shared_lock().clone(); let mut input = ParserInput::new(&mq_str); diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index c15553faa75..ce9c879d664 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -32,7 +32,7 @@ use std::cell::Cell; use std::default::Default; use std::ops::Range; use style::attr::AttrValue; -use style::element_state::*; +use style::element_state::ElementState; use textinput::{KeyReaction, Lines, SelectionDirection, TextInput}; #[dom_struct] @@ -111,7 +111,8 @@ impl HTMLTextAreaElement { let chan = document.window().upcast::<GlobalScope>().script_to_constellation_chan().clone(); HTMLTextAreaElement { htmlelement: - HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE, + HTMLElement::new_inherited_with_state(ElementState::IN_ENABLED_STATE | + ElementState::IN_READ_WRITE_STATE, local_name, prefix, document), placeholder: DomRefCell::new(DOMString::new()), textinput: DomRefCell::new(TextInput::new( diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 2d2a2391372..707c6b64afe 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -15,7 +15,6 @@ use dom::event::Event; use dom::uievent::UIEvent; use dom::window::Window; use dom_struct::dom_struct; -use msg::constellation_msg; use msg::constellation_msg::{Key, KeyModifiers}; use std::borrow::Cow; use std::cell::Cell; @@ -144,16 +143,16 @@ impl KeyboardEvent { pub fn get_key_modifiers(&self) -> KeyModifiers { let mut result = KeyModifiers::empty(); if self.shift.get() { - result = result | constellation_msg::SHIFT; + result = result | KeyModifiers::SHIFT; } if self.ctrl.get() { - result = result | constellation_msg::CONTROL; + result = result | KeyModifiers::CONTROL; } if self.alt.get() { - result = result | constellation_msg::ALT; + result = result | KeyModifiers::ALT; } if self.meta.get() { - result = result | constellation_msg::SUPER; + result = result | KeyModifiers::SUPER; } result } @@ -165,7 +164,7 @@ pub fn key_value(ch: Option<char>, key: Key, mods: KeyModifiers) -> Cow<'static, return Cow::from(format!("{}", ch)); } - let shift = mods.contains(constellation_msg::SHIFT); + let shift = mods.contains(KeyModifiers::SHIFT); Cow::from(match key { Key::Space => " ", Key::Apostrophe if shift => "\"", diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index 30d6ad9ed34..6ae318da582 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -18,7 +18,7 @@ use style::media_queries::MediaList as StyleMediaList; use style::parser::ParserContext; use style::shared_lock::{SharedRwLock, Locked}; use style::stylesheets::CssRuleType; -use style_traits::{PARSING_MODE_DEFAULT, ToCss}; +use style_traits::{ParsingMode, ToCss}; #[dom_struct] pub struct MediaList { @@ -78,7 +78,7 @@ impl MediaListMethods for MediaList { let url = window.get_url(); let quirks_mode = window.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); *media_queries = parse_media_query_list(&context, &mut parser, window.css_error_reporter()); @@ -116,7 +116,7 @@ impl MediaListMethods for MediaList { let url = win.get_url(); let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); let m = MediaQuery::parse(&context, &mut parser); // Step 2 @@ -145,7 +145,7 @@ impl MediaListMethods for MediaList { let url = win.get_url(); let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); let m = MediaQuery::parse(&context, &mut parser); // Step 2 diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 0186d9e6a67..2e05eb30971 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -148,39 +148,39 @@ pub struct Node { bitflags! { #[doc = "Flags for node items."] #[derive(JSTraceable, MallocSizeOf)] - pub flags NodeFlags: u16 { + pub struct NodeFlags: u16 { #[doc = "Specifies whether this node is in a document."] - const IS_IN_DOC = 1 << 0, + const IS_IN_DOC = 1 << 0; #[doc = "Specifies whether this node needs style recalc on next reflow."] - const HAS_DIRTY_DESCENDANTS = 1 << 1, + const HAS_DIRTY_DESCENDANTS = 1 << 1; // TODO: find a better place to keep this (#4105) // https://critic.hoppipolla.co.uk/showcomment?chain=8873 // Perhaps using a Set in Document? #[doc = "Specifies whether or not there is an authentic click in progress on \ this element."] - const CLICK_IN_PROGRESS = 1 << 2, + const CLICK_IN_PROGRESS = 1 << 2; #[doc = "Specifies whether this node is focusable and whether it is supposed \ to be reachable with using sequential focus navigation."] - const SEQUENTIALLY_FOCUSABLE = 1 << 3, + const SEQUENTIALLY_FOCUSABLE = 1 << 3; /// Whether any ancestor is a fragmentation container - const CAN_BE_FRAGMENTED = 1 << 4, + const CAN_BE_FRAGMENTED = 1 << 4; // There's a free bit here. #[doc = "Specifies whether the parser has set an associated form owner for \ this element. Only applicable for form-associatable elements."] - const PARSER_ASSOCIATED_FORM_OWNER = 1 << 6, + const PARSER_ASSOCIATED_FORM_OWNER = 1 << 6; /// Whether this element has a snapshot stored due to a style or /// attribute change. /// /// See the `style::restyle_hints` module. - const HAS_SNAPSHOT = 1 << 7, + const HAS_SNAPSHOT = 1 << 7; /// Whether this element has already handled the stored snapshot. - const HANDLED_SNAPSHOT = 1 << 8, + const HANDLED_SNAPSHOT = 1 << 8; } } @@ -261,9 +261,9 @@ impl Node { let parent_in_doc = self.is_in_doc(); for node in new_child.traverse_preorder() { - node.set_flag(IS_IN_DOC, parent_in_doc); + node.set_flag(NodeFlags::IS_IN_DOC, parent_in_doc); // Out-of-document elements never have the descendants flag set. - debug_assert!(!node.get_flag(HAS_DIRTY_DESCENDANTS)); + debug_assert!(!node.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS)); vtable_for(&&*node).bind_to_tree(parent_in_doc); } let document = new_child.owner_doc(); @@ -303,8 +303,8 @@ impl Node { for node in child.traverse_preorder() { // Out-of-document elements never have the descendants flag set. - node.set_flag(IS_IN_DOC | HAS_DIRTY_DESCENDANTS | - HAS_SNAPSHOT | HANDLED_SNAPSHOT, + node.set_flag(NodeFlags::IS_IN_DOC | NodeFlags::HAS_DIRTY_DESCENDANTS | + NodeFlags::HAS_SNAPSHOT | NodeFlags::HANDLED_SNAPSHOT, false); } for node in child.traverse_preorder() { @@ -427,7 +427,7 @@ impl Node { } pub fn is_in_doc(&self) -> bool { - self.flags.get().contains(IS_IN_DOC) + self.flags.get().contains(NodeFlags::IS_IN_DOC) } /// Returns the type ID of this node. @@ -489,7 +489,7 @@ impl Node { } pub fn has_dirty_descendants(&self) -> bool { - self.get_flag(HAS_DIRTY_DESCENDANTS) + self.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) } pub fn rev_version(&self) { @@ -1394,7 +1394,7 @@ impl Node { #[allow(unrooted_must_root)] pub fn new_document_node() -> Node { - Node::new_(NodeFlags::new() | IS_IN_DOC, None) + Node::new_(NodeFlags::new() | NodeFlags::IS_IN_DOC, None) } #[allow(unrooted_must_root)] diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index 9cffa2c341d..a0799fa0625 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -33,7 +33,7 @@ use servo_url::ServoUrl; use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel}; use std::thread; use std::time::Duration; -use style::thread_state::{self, IN_WORKER, SCRIPT}; +use style::thread_state::{self, ThreadState}; /// Messages used to control service worker event loop pub enum ServiceWorkerScriptMsg { @@ -154,7 +154,7 @@ impl ServiceWorkerGlobalScope { let serialized_worker_url = script_url.to_string(); let origin = GlobalScope::current().expect("No current global object").origin().immutable().clone(); thread::Builder::new().name(format!("ServiceWorker for {}", serialized_worker_url)).spawn(move || { - thread_state::initialize(SCRIPT | IN_WORKER); + thread_state::initialize(ThreadState::SCRIPT | ThreadState::IN_WORKER); let roots = RootCollection::new(); let _stack_roots = ThreadLocalStackRoots::new(&roots); diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index 0178764c3d0..58c05356204 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -28,17 +28,17 @@ pub enum ValidityStatus { } bitflags!{ - pub flags ValidationFlags: u32 { - const VALUE_MISSING = 0b0000000001, - const TYPE_MISMATCH = 0b0000000010, - const PATTERN_MISMATCH = 0b0000000100, - const TOO_LONG = 0b0000001000, - const TOO_SHORT = 0b0000010000, - const RANGE_UNDERFLOW = 0b0000100000, - const RANGE_OVERFLOW = 0b0001000000, - const STEP_MISMATCH = 0b0010000000, - const BAD_INPUT = 0b0100000000, - const CUSTOM_ERROR = 0b1000000000, + pub struct ValidationFlags: u32 { + const VALUE_MISSING = 0b0000000001; + const TYPE_MISMATCH = 0b0000000010; + const PATTERN_MISMATCH = 0b0000000100; + const TOO_LONG = 0b0000001000; + const TOO_SHORT = 0b0000010000; + const RANGE_UNDERFLOW = 0b0000100000; + const RANGE_OVERFLOW = 0b0001000000; + const STEP_MISMATCH = 0b0010000000; + const BAD_INPUT = 0b0100000000; + const CUSTOM_ERROR = 0b1000000000; } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 514fac1e492..b58481d9526 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -136,10 +136,10 @@ fn has_invalid_blend_constants(arg1: u32, arg2: u32) -> bool { /// Set of bitflags for texture unpacking (texImage2d, etc...) bitflags! { #[derive(JSTraceable, MallocSizeOf)] - flags TextureUnpacking: u8 { - const FLIP_Y_AXIS = 0x01, - const PREMULTIPLY_ALPHA = 0x02, - const CONVERT_COLORSPACE = 0x04, + struct TextureUnpacking: u8 { + const FLIP_Y_AXIS = 0x01; + const PREMULTIPLY_ALPHA = 0x02; + const CONVERT_COLORSPACE = 0x04; } } @@ -235,7 +235,7 @@ impl WebGLRenderingContext { limits: ctx_data.limits, canvas: Dom::from_ref(canvas), last_error: Cell::new(None), - texture_unpacking_settings: Cell::new(CONVERT_COLORSPACE), + texture_unpacking_settings: Cell::new(TextureUnpacking::CONVERT_COLORSPACE), texture_unpacking_alignment: Cell::new(4), bound_framebuffer: MutNullableDom::new(None), bound_textures: DomRefCell::new(Default::default()), @@ -878,7 +878,7 @@ impl WebGLRenderingContext { width: usize, height: usize, unpacking_alignment: usize) -> Vec<u8> { - if !self.texture_unpacking_settings.get().contains(FLIP_Y_AXIS) { + if !self.texture_unpacking_settings.get().contains(TextureUnpacking::FLIP_Y_AXIS) { return pixels; } @@ -906,7 +906,7 @@ impl WebGLRenderingContext { format: TexFormat, data_type: TexDataType, pixels: Vec<u8>) -> Vec<u8> { - if !self.texture_unpacking_settings.get().contains(PREMULTIPLY_ALPHA) { + if !self.texture_unpacking_settings.get().contains(TextureUnpacking::PREMULTIPLY_ALPHA) { return pixels; } @@ -990,7 +990,7 @@ impl WebGLRenderingContext { source_premultiplied: bool, source_from_image_or_canvas: bool, mut pixels: Vec<u8>) -> Vec<u8> { - let dest_premultiply = self.texture_unpacking_settings.get().contains(PREMULTIPLY_ALPHA); + let dest_premultiply = self.texture_unpacking_settings.get().contains(TextureUnpacking::PREMULTIPLY_ALPHA); if !source_premultiplied && dest_premultiply { if source_from_image_or_canvas { // When the pixels come from image or canvas or imagedata, use RGBA8 format @@ -2450,9 +2450,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { match param_name { constants::UNPACK_FLIP_Y_WEBGL => { if param_value != 0 { - texture_settings.insert(FLIP_Y_AXIS) + texture_settings.insert(TextureUnpacking::FLIP_Y_AXIS) } else { - texture_settings.remove(FLIP_Y_AXIS) + texture_settings.remove(TextureUnpacking::FLIP_Y_AXIS) } self.texture_unpacking_settings.set(texture_settings); @@ -2460,9 +2460,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { }, constants::UNPACK_PREMULTIPLY_ALPHA_WEBGL => { if param_value != 0 { - texture_settings.insert(PREMULTIPLY_ALPHA) + texture_settings.insert(TextureUnpacking::PREMULTIPLY_ALPHA) } else { - texture_settings.remove(PREMULTIPLY_ALPHA) + texture_settings.remove(TextureUnpacking::PREMULTIPLY_ALPHA) } self.texture_unpacking_settings.set(texture_settings); @@ -2471,9 +2471,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { constants::UNPACK_COLORSPACE_CONVERSION_WEBGL => { match param_value as u32 { constants::BROWSER_DEFAULT_WEBGL - => texture_settings.insert(CONVERT_COLORSPACE), + => texture_settings.insert(TextureUnpacking::CONVERT_COLORSPACE), constants::NONE - => texture_settings.remove(CONVERT_COLORSPACE), + => texture_settings.remove(TextureUnpacking::CONVERT_COLORSPACE), _ => return self.webgl_error(InvalidEnum), } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 7746e637758..422abd7079e 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -109,7 +109,7 @@ use style::properties::longhands::overflow_x; use style::selector_parser::PseudoElement; use style::str::HTML_SPACE_CHARACTERS; use style::stylesheets::CssRuleType; -use style_traits::PARSING_MODE_DEFAULT; +use style_traits::ParsingMode; use task::TaskCanceller; use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; @@ -1016,7 +1016,7 @@ impl WindowMethods for Window { let url = self.get_url(); let quirks_mode = self.Document().quirks_mode(); let context = CssParserContext::new_for_cssom(&url, Some(CssRuleType::Media), - PARSING_MODE_DEFAULT, + ParsingMode::DEFAULT, quirks_mode); let media_query_list = media_queries::parse_media_query_list(&context, &mut parser, self.css_error_reporter()); diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index 7a608a189e1..39e1bdba930 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -63,7 +63,7 @@ use std::sync::mpsc; use std::sync::mpsc::Receiver; use std::sync::mpsc::Sender; use std::thread; -use style::thread_state; +use style::thread_state::{self, ThreadState}; use swapper::Swapper; use swapper::swapper; use task::TaskBox; @@ -426,7 +426,7 @@ impl WorkletThread { // TODO: set interrupt handler? // TODO: configure the JS runtime (e.g. discourage GC, encourage agressive JIT) debug!("Initializing worklet thread."); - thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER); + thread_state::initialize(ThreadState::SCRIPT | ThreadState::IN_WORKER); let roots = RootCollection::new(); let _stack_roots = ThreadLocalStackRoots::new(&roots); let mut thread = RootedTraceableBox::new(WorkletThread { diff --git a/components/script/lib.rs b/components/script/lib.rs index df9679bcaf2..88fe2b4f593 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -140,8 +140,7 @@ pub mod layout_exports { pub use dom::characterdata::LayoutCharacterDataHelpers; pub use dom::document::{Document, LayoutDocumentHelpers, PendingRestyle}; pub use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; - pub use dom::node::{CAN_BE_FRAGMENTED, HAS_DIRTY_DESCENDANTS, IS_IN_DOC}; - pub use dom::node::{HANDLED_SNAPSHOT, HAS_SNAPSHOT}; + pub use dom::node::NodeFlags; pub use dom::node::{LayoutNodeHelpers, Node}; pub use dom::text::Text; } diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 7985f562cbe..9416e0d11ae 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -33,7 +33,7 @@ use std::os; use std::os::raw::c_void; use std::panic::AssertUnwindSafe; use std::ptr; -use style::thread_state; +use style::thread_state::{self, ThreadState}; use task::TaskBox; use time::{Tm, now}; @@ -394,8 +394,8 @@ unsafe extern "C" fn gc_slice_callback(_rt: *mut JSRuntime, progress: GCProgress #[allow(unsafe_code)] unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut os::raw::c_void) { match status { - JSGCStatus::JSGC_BEGIN => thread_state::enter(thread_state::IN_GC), - JSGCStatus::JSGC_END => thread_state::exit(thread_state::IN_GC), + JSGCStatus::JSGC_BEGIN => thread_state::enter(ThreadState::IN_GC), + JSGCStatus::JSGC_END => thread_state::exit(ThreadState::IN_GC), } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 8f17afaf9a7..2f0431acda8 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -114,7 +114,7 @@ use std::result::Result; use std::sync::Arc; use std::sync::mpsc::{Receiver, Select, Sender, channel}; use std::thread; -use style::thread_state; +use style::thread_state::{self, ThreadState}; use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::history_traversal::HistoryTraversalTaskSource; @@ -544,7 +544,7 @@ impl ScriptThreadFactory for ScriptThread { let (sender, receiver) = channel(); let layout_chan = sender.clone(); thread::Builder::new().name(format!("ScriptThread {:?}", state.id)).spawn(move || { - thread_state::initialize(thread_state::SCRIPT); + thread_state::initialize(ThreadState::SCRIPT); PipelineNamespace::install(state.pipeline_namespace_id); TopLevelBrowsingContextId::install(state.top_level_browsing_context_id); let roots = RootCollection::new(); diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 3c533964b7d..bfc34c9d5a6 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -7,7 +7,6 @@ use clipboard_provider::ClipboardProvider; use dom::bindings::str::DOMString; use dom::keyboardevent::KeyboardEvent; -use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{Key, KeyModifiers}; use std::borrow::ToOwned; use std::cmp::{max, min}; @@ -114,12 +113,12 @@ pub enum Direction { /// i.e. cmd on Mac OS or ctrl on other platforms. #[cfg(target_os = "macos")] fn is_control_key(mods: KeyModifiers) -> bool { - mods.contains(SUPER) && !mods.contains(CONTROL | ALT) + mods.contains(KeyModifiers::SUPER) && !mods.contains(KeyModifiers::CONTROL | KeyModifiers::ALT) } #[cfg(not(target_os = "macos"))] fn is_control_key(mods: KeyModifiers) -> bool { - mods.contains(CONTROL) && !mods.contains(SUPER | ALT) + mods.contains(KeyModifiers::CONTROL) && !mods.contains(KeyModifiers::SUPER | KeyModifiers::ALT) } /// The length in bytes of the first n characters in a UTF-8 string. @@ -585,31 +584,36 @@ impl<T: ClipboardProvider> TextInput<T> { printable: Option<char>, key: Key, mods: KeyModifiers) -> KeyReaction { - let maybe_select = if mods.contains(SHIFT) { Selection::Selected } else { Selection::NotSelected }; + let maybe_select = if mods.contains(KeyModifiers::SHIFT) { + Selection::Selected + } else { + Selection::NotSelected + }; + match (printable, key) { - (_, Key::B) if mods.contains(CONTROL | ALT) => { + (_, Key::B) if mods.contains(KeyModifiers::CONTROL | KeyModifiers::ALT) => { self.adjust_horizontal_by_word(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, - (_, Key::F) if mods.contains(CONTROL | ALT) => { + (_, Key::F) if mods.contains(KeyModifiers::CONTROL | KeyModifiers::ALT) => { self.adjust_horizontal_by_word(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, - (_, Key::A) if mods.contains(CONTROL | ALT) => { + (_, Key::A) if mods.contains(KeyModifiers::CONTROL | KeyModifiers::ALT) => { self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, - (_, Key::E) if mods.contains(CONTROL | ALT) => { + (_, Key::E) if mods.contains(KeyModifiers::CONTROL | KeyModifiers::ALT) => { self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, #[cfg(target_os = "macos")] - (None, Key::A) if mods == CONTROL => { + (None, Key::A) if mods == KeyModifiers::CONTROL => { self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, #[cfg(target_os = "macos")] - (None, Key::E) if mods == CONTROL => { + (None, Key::E) if mods == KeyModifiers::CONTROL => { self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, @@ -641,30 +645,30 @@ impl<T: ClipboardProvider> TextInput<T> { KeyReaction::DispatchInput }, #[cfg(target_os = "macos")] - (None, Key::Left) if mods.contains(SUPER) => { + (None, Key::Left) if mods.contains(KeyModifiers::SUPER) => { self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, #[cfg(target_os = "macos")] - (None, Key::Right) if mods.contains(SUPER) => { + (None, Key::Right) if mods.contains(KeyModifiers::SUPER) => { self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, #[cfg(target_os = "macos")] - (None, Key::Up) if mods.contains(SUPER) => { + (None, Key::Up) if mods.contains(KeyModifiers::SUPER) => { self.adjust_horizontal_to_limit(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, #[cfg(target_os = "macos")] - (None, Key::Down) if mods.contains(SUPER) => { + (None, Key::Down) if mods.contains(KeyModifiers::SUPER) => { self.adjust_horizontal_to_limit(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, - (None, Key::Left) if mods.contains(ALT) => { + (None, Key::Left) if mods.contains(KeyModifiers::ALT) => { self.adjust_horizontal_by_word(Direction::Backward, maybe_select); KeyReaction::RedrawSelection }, - (None, Key::Right) if mods.contains(ALT) => { + (None, Key::Right) if mods.contains(KeyModifiers::ALT) => { self.adjust_horizontal_by_word(Direction::Forward, maybe_select); KeyReaction::RedrawSelection }, |