mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make DOMRefCell use style’s copy of RefCell
This commit is contained in:
parent
edbd88cce5
commit
ec723057b2
12 changed files with 31 additions and 24 deletions
|
@ -53,6 +53,8 @@ fn is_unrooted_ty(cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool
|
|||
false
|
||||
} else if match_def_path(cx, did.did, &["core", "cell", "Ref"])
|
||||
|| match_def_path(cx, did.did, &["core", "cell", "RefMut"])
|
||||
|| match_def_path(cx, did.did, &["style", "refcell", "Ref"])
|
||||
|| match_def_path(cx, did.did, &["style", "refcell", "RefMut"])
|
||||
|| match_def_path(cx, did.did, &["core", "slice", "Iter"])
|
||||
|| match_def_path(cx, did.did, &["std", "collections", "hash", "map", "OccupiedEntry"])
|
||||
|| match_def_path(cx, did.did, &["std", "collections", "hash", "map", "VacantEntry"]) {
|
||||
|
|
|
@ -56,7 +56,6 @@ plugins = {path = "../plugins"}
|
|||
profile_traits = {path = "../profile_traits"}
|
||||
rand = "0.3"
|
||||
range = {path = "../range"}
|
||||
ref_filter_map = "1.0"
|
||||
ref_slice = "1.0"
|
||||
regex = "0.1.43"
|
||||
rustc-serialize = "0.3"
|
||||
|
|
|
@ -15,10 +15,10 @@ use dom::element::{AttributeMutation, Element};
|
|||
use dom::virtualmethods::vtable_for;
|
||||
use dom::window::Window;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Ref;
|
||||
use std::mem;
|
||||
use string_cache::{Atom, Namespace};
|
||||
use style::attr::{AttrIdentifier, AttrValue};
|
||||
use style::refcell::Ref;
|
||||
|
||||
// https://dom.spec.whatwg.org/#interface-attr
|
||||
#[dom_struct]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use js::jsapi::JSTracer;
|
||||
use std::cell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut};
|
||||
use style::refcell::{BorrowError, BorrowMutError, Ref, RefCell, RefMut};
|
||||
use style::thread_state;
|
||||
use style::thread_state::SCRIPT;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use dom::element::Element;
|
|||
use dom::node::{Node, NodeDamage};
|
||||
use dom::processinginstruction::ProcessingInstruction;
|
||||
use dom::text::Text;
|
||||
use std::cell::Ref;
|
||||
use style::refcell::Ref;
|
||||
use util::opts;
|
||||
|
||||
// https://dom.spec.whatwg.org/#characterdata
|
||||
|
|
|
@ -14,12 +14,12 @@ use dom::element::Element;
|
|||
use dom::node::{Node, NodeDamage, window_from_node};
|
||||
use dom::window::Window;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Ref;
|
||||
use std::slice;
|
||||
use string_cache::Atom;
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::properties::{PropertyDeclaration, Shorthand, Importance};
|
||||
use style::properties::{is_supported_property, parse_one_declaration, parse_style_attribute};
|
||||
use style::refcell::Ref;
|
||||
use style::selector_impl::PseudoElement;
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
|
||||
|
|
|
@ -110,7 +110,7 @@ use script_traits::{TouchEventType, TouchId};
|
|||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::FnBox;
|
||||
use std::cell::{Cell, Ref, RefMut};
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::default::Default;
|
||||
|
@ -122,6 +122,7 @@ use std::sync::Arc;
|
|||
use string_cache::{Atom, QualName};
|
||||
use style::attr::AttrValue;
|
||||
use style::context::ReflowGoal;
|
||||
use style::refcell::{Ref, RefMut};
|
||||
use style::selector_impl::ElementSnapshot;
|
||||
use style::str::{split_html_space_chars, str_join};
|
||||
use style::stylesheets::Stylesheet;
|
||||
|
|
|
@ -70,13 +70,12 @@ use html5ever::serialize::SerializeOpts;
|
|||
use html5ever::serialize::TraversalScope;
|
||||
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
|
||||
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
|
||||
use ref_filter_map::ref_filter_map;
|
||||
use selectors::matching::{ElementFlags, matches};
|
||||
use selectors::matching::{HAS_SLOW_SELECTOR, HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
|
||||
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::{Cell, Ref};
|
||||
use std::cell::Cell;
|
||||
use std::convert::TryFrom;
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
|
@ -90,6 +89,7 @@ use style::parser::ParserContextExtraData;
|
|||
use style::properties::longhands::{self, background_image, border_spacing, font_family, overflow_x, font_size};
|
||||
use style::properties::{DeclaredValue, Importance};
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
|
||||
use style::refcell::Ref;
|
||||
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
|
||||
use style::selector_matching::DeclarationBlock;
|
||||
use style::sink::Push;
|
||||
|
@ -871,7 +871,7 @@ impl Element {
|
|||
pub fn get_inline_style_declaration(&self,
|
||||
property: &Atom)
|
||||
-> Option<Ref<(PropertyDeclaration, Importance)>> {
|
||||
ref_filter_map(self.style_attribute.borrow(), |inline_declarations| {
|
||||
Ref::filter_map(self.style_attribute.borrow(), |inline_declarations| {
|
||||
inline_declarations.as_ref().and_then(|declarations| {
|
||||
declarations.declarations
|
||||
.iter()
|
||||
|
|
|
@ -69,7 +69,6 @@ extern crate phf;
|
|||
extern crate profile_traits;
|
||||
extern crate rand;
|
||||
extern crate range;
|
||||
extern crate ref_filter_map;
|
||||
extern crate ref_slice;
|
||||
extern crate regex;
|
||||
extern crate rustc_serialize;
|
||||
|
|
7
components/servo/Cargo.lock
generated
7
components/servo/Cargo.lock
generated
|
@ -1839,11 +1839,6 @@ dependencies = [
|
|||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_filter_map"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "1.0.0"
|
||||
|
@ -1929,7 +1924,6 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"range 0.0.1",
|
||||
"ref_filter_map 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2866,7 +2860,6 @@ dependencies = [
|
|||
"checksum quickersort 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e952ea7699262481636004bc4ab8afaccf2bc13f91b79d1aee6617bd8fc39651"
|
||||
"checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5"
|
||||
"checksum rayon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e501871917624668fe601ad12a730450414f9b0b64722a898b040ce3ae1b0fa"
|
||||
"checksum ref_filter_map 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b5ceb840e4009da4841ed22a15eb49f64fdd00a2138945c5beacf506b2fb5ed"
|
||||
"checksum ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24c91f8f8903c37f0525112df98ef53b1985abca5702972e5e00854cd874baf2"
|
||||
"checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2"
|
||||
"checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
#[cfg(feature = "servo")] use heapsize::HeapSizeOf;
|
||||
use std::cell::{UnsafeCell, Cell};
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::{self, Debug, Display};
|
||||
|
@ -31,6 +32,13 @@ pub struct RefCell<T: ?Sized> {
|
|||
value: UnsafeCell<T>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl<T: HeapSizeOf> HeapSizeOf for RefCell<T> {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
self.borrow().heap_size_of_children()
|
||||
}
|
||||
}
|
||||
|
||||
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum BorrowState {
|
||||
|
@ -527,6 +535,18 @@ impl<'b, T: ?Sized> Ref<'b, T> {
|
|||
borrow: orig.borrow,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn filter_map<U: ?Sized, F>(orig: Ref<'b, T>, f: F) -> Option<Ref<'b, U>>
|
||||
where F: FnOnce(&T) -> Option<&U>
|
||||
{
|
||||
f(orig.value).map(move |new_value| {
|
||||
Ref {
|
||||
value: new_value,
|
||||
borrow: orig.borrow,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, T: ?Sized> RefMut<'b, T> {
|
||||
|
|
7
ports/cef/Cargo.lock
generated
7
ports/cef/Cargo.lock
generated
|
@ -1691,11 +1691,6 @@ dependencies = [
|
|||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_filter_map"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "1.0.0"
|
||||
|
@ -1781,7 +1776,6 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"range 0.0.1",
|
||||
"ref_filter_map 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2720,7 +2714,6 @@ dependencies = [
|
|||
"checksum quickersort 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e952ea7699262481636004bc4ab8afaccf2bc13f91b79d1aee6617bd8fc39651"
|
||||
"checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5"
|
||||
"checksum rayon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e501871917624668fe601ad12a730450414f9b0b64722a898b040ce3ae1b0fa"
|
||||
"checksum ref_filter_map 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b5ceb840e4009da4841ed22a15eb49f64fdd00a2138945c5beacf506b2fb5ed"
|
||||
"checksum ref_slice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24c91f8f8903c37f0525112df98ef53b1985abca5702972e5e00854cd874baf2"
|
||||
"checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2"
|
||||
"checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue