mirror of
https://github.com/servo/servo.git
synced 2025-09-11 15:38:24 +01:00
Auto merge of #13134 - servo:archery, r=emilio
Add lots of Arc’s in style, and prepare for using DOMRefCell <!-- Please describe your changes on the following line: --> `DOMRefCell` usage is not there year because of thread-safety questions, but I have this much already that I’d like to land before it bitrots. r? @emilio --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/13134) <!-- Reviewable:end -->
This commit is contained in:
commit
bbfe38e35f
29 changed files with 487 additions and 246 deletions
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"
|
||||
|
|
|
@ -356,7 +356,7 @@ pub extern "C" fn Servo_StyleSet_Drop(data: *mut RawServoStyleSet) -> () {
|
|||
}
|
||||
|
||||
pub struct GeckoDeclarationBlock {
|
||||
pub declarations: Option<PropertyDeclarationBlock>,
|
||||
pub declarations: Option<Arc<PropertyDeclarationBlock>>,
|
||||
// XXX The following two fields are made atomic to work around the
|
||||
// ownership system so that they can be changed inside a shared
|
||||
// instance. It wouldn't provide safety as Rust usually promises,
|
||||
|
@ -377,7 +377,7 @@ pub extern "C" fn Servo_ParseStyleAttribute(bytes: *const u8, length: u32,
|
|||
-> ServoDeclarationBlockStrong {
|
||||
let value = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) };
|
||||
GeckoDeclarationBlock::from_arc(Arc::new(GeckoDeclarationBlock {
|
||||
declarations: GeckoElement::parse_style_attribute(value),
|
||||
declarations: GeckoElement::parse_style_attribute(value).map(Arc::new),
|
||||
cache: AtomicPtr::new(cache),
|
||||
immutable: AtomicBool::new(false),
|
||||
}))
|
||||
|
|
|
@ -35,7 +35,6 @@ use snapshot::GeckoElementSnapshot;
|
|||
use snapshot_helpers;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::transmute;
|
||||
use std::ops::BitOr;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
|
@ -462,8 +461,6 @@ lazy_static! {
|
|||
};
|
||||
}
|
||||
|
||||
static NO_STYLE_ATTRIBUTE: Option<PropertyDeclarationBlock> = None;
|
||||
|
||||
impl<'le> TElement for GeckoElement<'le> {
|
||||
type ConcreteNode = GeckoNode<'le>;
|
||||
type ConcreteDocument = GeckoDocument<'le>;
|
||||
|
@ -472,14 +469,16 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
unsafe { GeckoNode::from_raw(self.element as *mut RawGeckoNode) }
|
||||
}
|
||||
|
||||
fn style_attribute(&self) -> &Option<PropertyDeclarationBlock> {
|
||||
fn style_attribute(&self) -> Option<&Arc<PropertyDeclarationBlock>> {
|
||||
let declarations = unsafe { Gecko_GetServoDeclarationBlock(self.element) };
|
||||
if declarations.is_null() {
|
||||
&NO_STYLE_ATTRIBUTE
|
||||
None
|
||||
} else {
|
||||
GeckoDeclarationBlock::with(declarations, |declarations| {
|
||||
unsafe { transmute(&declarations.declarations) }
|
||||
})
|
||||
let opt_ptr = GeckoDeclarationBlock::with(declarations, |declarations| {
|
||||
// Use a raw pointer to extend the lifetime
|
||||
declarations.declarations.as_ref().map(|r| r as *const Arc<_>)
|
||||
});
|
||||
opt_ptr.map(|ptr| unsafe { &*ptr })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue