mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Move arc_ptr_eq to style.
This commit is contained in:
parent
8ded106186
commit
9f13278b77
6 changed files with 17 additions and 17 deletions
|
@ -37,6 +37,7 @@ use std::cmp::{max, min};
|
||||||
use std::collections::LinkedList;
|
use std::collections::LinkedList;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use style::arc_ptr_eq;
|
||||||
use style::computed_values::content::ContentItem;
|
use style::computed_values::content::ContentItem;
|
||||||
use style::computed_values::{border_collapse, clear, color, display, mix_blend_mode};
|
use style::computed_values::{border_collapse, clear, color, display, mix_blend_mode};
|
||||||
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration};
|
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration};
|
||||||
|
@ -50,7 +51,6 @@ use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use text;
|
use text;
|
||||||
use text::TextRunScanner;
|
use text::TextRunScanner;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util;
|
|
||||||
|
|
||||||
/// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position
|
/// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position
|
||||||
/// themselves. In general, fragments do not have a simple correspondence with CSS fragments in the
|
/// themselves. In general, fragments do not have a simple correspondence with CSS fragments in the
|
||||||
|
@ -1732,7 +1732,7 @@ impl Fragment {
|
||||||
match (&mut self.specific, &next_fragment.specific) {
|
match (&mut self.specific, &next_fragment.specific) {
|
||||||
(&mut SpecificFragmentInfo::ScannedText(ref mut this_info),
|
(&mut SpecificFragmentInfo::ScannedText(ref mut this_info),
|
||||||
&SpecificFragmentInfo::ScannedText(ref other_info)) => {
|
&SpecificFragmentInfo::ScannedText(ref other_info)) => {
|
||||||
debug_assert!(util::arc_ptr_eq(&this_info.run, &other_info.run));
|
debug_assert!(arc_ptr_eq(&this_info.run, &other_info.run));
|
||||||
this_info.range_end_including_stripped_whitespace =
|
this_info.range_end_including_stripped_whitespace =
|
||||||
other_info.range_end_including_stripped_whitespace;
|
other_info.range_end_including_stripped_whitespace;
|
||||||
if other_info.requires_line_break_afterward_if_wrapping_on_newlines() {
|
if other_info.requires_line_break_afterward_if_wrapping_on_newlines() {
|
||||||
|
|
|
@ -32,6 +32,7 @@ use std::cmp::max;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fmt, i32, isize, mem};
|
use std::{fmt, i32, isize, mem};
|
||||||
|
use style::arc_ptr_eq;
|
||||||
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
|
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
|
||||||
use style::computed_values::{text_overflow, vertical_align, white_space};
|
use style::computed_values::{text_overflow, vertical_align, white_space};
|
||||||
use style::context::StyleContext;
|
use style::context::StyleContext;
|
||||||
|
@ -41,7 +42,6 @@ use style::servo::SharedStyleContext;
|
||||||
use style::values::computed::LengthOrPercentage;
|
use style::values::computed::LengthOrPercentage;
|
||||||
use text;
|
use text;
|
||||||
use unicode_bidi;
|
use unicode_bidi;
|
||||||
use util;
|
|
||||||
|
|
||||||
// From gfxFontConstants.h in Firefox
|
// From gfxFontConstants.h in Firefox
|
||||||
static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20;
|
static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20;
|
||||||
|
@ -360,7 +360,7 @@ impl LineBreaker {
|
||||||
(&mut SpecificFragmentInfo::ScannedText(ref mut result_info),
|
(&mut SpecificFragmentInfo::ScannedText(ref mut result_info),
|
||||||
&SpecificFragmentInfo::ScannedText(ref candidate_info)) => {
|
&SpecificFragmentInfo::ScannedText(ref candidate_info)) => {
|
||||||
result_info.selected() == candidate_info.selected() &&
|
result_info.selected() == candidate_info.selected() &&
|
||||||
util::arc_ptr_eq(&result_info.run, &candidate_info.run) &&
|
arc_ptr_eq(&result_info.run, &candidate_info.run) &&
|
||||||
inline_contexts_are_equal(&result.inline_context,
|
inline_contexts_are_equal(&result.inline_context,
|
||||||
&candidate.inline_context)
|
&candidate.inline_context)
|
||||||
}
|
}
|
||||||
|
@ -1780,7 +1780,7 @@ impl InlineFragmentContext {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for (this_node, other_node) in self.nodes.iter().zip(&other.nodes) {
|
for (this_node, other_node) in self.nodes.iter().zip(&other.nodes) {
|
||||||
if !util::arc_ptr_eq(&this_node.style, &other_node.style) {
|
if !arc_ptr_eq(&this_node.style, &other_node.style) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ pub mod values;
|
||||||
pub mod viewport;
|
pub mod viewport;
|
||||||
pub mod workqueue;
|
pub mod workqueue;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// The CSS properties supported by the style system.
|
/// The CSS properties supported by the style system.
|
||||||
// Generated from the properties.mako.rs template by build.rs
|
// Generated from the properties.mako.rs template by build.rs
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -126,3 +128,11 @@ macro_rules! reexport_computed_values {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
longhand_properties_idents!(reexport_computed_values);
|
longhand_properties_idents!(reexport_computed_values);
|
||||||
|
|
||||||
|
/// Returns whether the two arguments point to the same value.
|
||||||
|
#[inline]
|
||||||
|
pub fn arc_ptr_eq<T: 'static>(a: &Arc<T>, b: &Arc<T>) -> bool {
|
||||||
|
let a: &T = &**a;
|
||||||
|
let b: &T = &**b;
|
||||||
|
(a as *const T) == (b as *const T)
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
use animation::{self, Animation};
|
use animation::{self, Animation};
|
||||||
|
use arc_ptr_eq;
|
||||||
use cache::{LRUCache, SimpleHashCache};
|
use cache::{LRUCache, SimpleHashCache};
|
||||||
use context::{StyleContext, SharedStyleContext};
|
use context::{StyleContext, SharedStyleContext};
|
||||||
use data::PrivateStyleData;
|
use data::PrivateStyleData;
|
||||||
|
@ -25,7 +26,6 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
use util::arc_ptr_eq;
|
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
|
||||||
fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &E)
|
fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &E)
|
||||||
|
|
|
@ -26,8 +26,6 @@ extern crate url;
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
||||||
extern crate xdg;
|
extern crate xdg;
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub mod basedir;
|
pub mod basedir;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod ipc;
|
#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod ipc;
|
||||||
|
@ -38,14 +36,6 @@ pub mod resource_files;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
pub mod thread_state;
|
pub mod thread_state;
|
||||||
|
|
||||||
// Workaround for lack of `ptr_eq` on Arcs...
|
|
||||||
#[inline]
|
|
||||||
pub fn arc_ptr_eq<T: 'static>(a: &Arc<T>, b: &Arc<T>) -> bool {
|
|
||||||
let a: &T = &**a;
|
|
||||||
let b: &T = &**b;
|
|
||||||
(a as *const T) == (b as *const T)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn servo_version() -> &'static str {
|
pub fn servo_version() -> &'static str {
|
||||||
concat!("Servo ", env!("CARGO_PKG_VERSION"), env!("GIT_INFO"))
|
concat!("Servo ", env!("CARGO_PKG_VERSION"), env!("GIT_INFO"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::str::from_utf8_unchecked;
|
use std::str::from_utf8_unchecked;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use style::arc_ptr_eq;
|
||||||
use style::context::{LocalStyleContextCreationInfo, ReflowGoal};
|
use style::context::{LocalStyleContextCreationInfo, ReflowGoal};
|
||||||
use style::dom::{TDocument, TElement, TNode};
|
use style::dom::{TDocument, TElement, TNode};
|
||||||
use style::error_reporting::StdoutErrorReporter;
|
use style::error_reporting::StdoutErrorReporter;
|
||||||
|
@ -33,7 +34,6 @@ use style::sequential;
|
||||||
use style::stylesheets::Origin;
|
use style::stylesheets::Origin;
|
||||||
use traversal::RecalcStyleOnly;
|
use traversal::RecalcStyleOnly;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::arc_ptr_eq;
|
|
||||||
use wrapper::{GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData};
|
use wrapper::{GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData};
|
||||||
|
|
||||||
// TODO: This is ugly and should go away once we get an atom back-end.
|
// TODO: This is ugly and should go away once we get an atom back-end.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue