Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename ReadGuards to StylesheetGuards
  • Loading branch information
SimonSapin committed Mar 19, 2017
1 parent 2952ccf commit d507413
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions components/layout_thread/lib.rs
Expand Up @@ -116,7 +116,7 @@ use style::media_queries::{Device, MediaType};
use style::parser::ParserContextExtraData;
use style::servo::AUTHOR_SHARED_LOCK;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ReadGuards};
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
use style::stylist::Stylist;
use style::thread_state;
Expand Down Expand Up @@ -500,7 +500,7 @@ impl LayoutThread {

// Create a layout context for use in building display lists, hit testing, &c.
fn build_layout_context<'a>(&self,
guards: ReadGuards<'a>,
guards: StylesheetGuards<'a>,
rw_data: &LayoutThreadData,
request_images: bool)
-> LayoutContext<'a> {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ impl LayoutThread {
// If the entire flow tree is invalid, then it will be reflowed anyhow.
let ua_stylesheets = &*UA_STYLESHEETS;
let ua_or_user_guard = ua_stylesheets.shared_lock.read();
let guards = ReadGuards {
let guards = StylesheetGuards {
author: &author_guard,
ua_or_user: &ua_or_user_guard,
};
Expand Down Expand Up @@ -1353,7 +1353,7 @@ impl LayoutThread {

let author_guard = AUTHOR_SHARED_LOCK.read();
let ua_or_user_guard = UA_STYLESHEETS.shared_lock.read();
let guards = ReadGuards {
let guards = StylesheetGuards {
author: &author_guard,
ua_or_user: &ua_or_user_guard,
};
Expand Down
4 changes: 2 additions & 2 deletions components/style/context.rs
Expand Up @@ -17,7 +17,7 @@ use parking_lot::RwLock;
use selector_parser::PseudoElement;
use selectors::matching::ElementSelectorFlags;
use servo_config::opts;
use shared_lock::ReadGuards;
use shared_lock::StylesheetGuards;
use std::collections::HashMap;
use std::env;
use std::fmt;
Expand Down Expand Up @@ -67,7 +67,7 @@ pub struct SharedStyleContext<'a> {
pub stylist: Arc<Stylist>,

/// Guards for pre-acquired locks
pub guards: ReadGuards<'a>,
pub guards: StylesheetGuards<'a>,

/// The animations that are currently running.
pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko/data.rs
Expand Up @@ -13,7 +13,7 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::Device;
use parking_lot::RwLock;
use properties::ComputedValues;
use shared_lock::{ReadGuards, SharedRwLockReadGuard};
use shared_lock::{StylesheetGuards, SharedRwLockReadGuard};
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
Expand Down Expand Up @@ -97,7 +97,7 @@ impl PerDocumentStyleDataImpl {
pub fn flush_stylesheets(&mut self, guard: &SharedRwLockReadGuard) {
if self.stylesheets_changed {
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
stylist.update(&self.stylesheets, &ReadGuards::same(guard), None, true);
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard), None, true);
self.stylesheets_changed = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/style/properties/properties.mako.rs
Expand Up @@ -31,7 +31,7 @@ use parser::{Parse, ParserContext, ParserContextExtraData};
use properties::animated_properties::TransitionProperty;
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use shared_lock::ReadGuards;
use shared_lock::StylesheetGuards;
use style_traits::ToCss;
use stylesheets::Origin;
#[cfg(feature = "servo")] use values::Either;
Expand Down Expand Up @@ -1861,7 +1861,7 @@ bitflags! {
///
pub fn cascade(device: &Device,
rule_node: &StrongRuleNode,
guards: &ReadGuards,
guards: &StylesheetGuards,
parent_style: Option<<&ComputedValues>,
layout_parent_style: Option<<&ComputedValues>,
cascade_info: Option<<&mut CascadeInfo>,
Expand Down
12 changes: 6 additions & 6 deletions components/style/rule_tree/mod.rs
Expand Up @@ -11,7 +11,7 @@ use arc_ptr_eq;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
use properties::{Importance, PropertyDeclarationBlock};
use shared_lock::{Locked, ReadGuards, SharedRwLockReadGuard};
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use std::io::{self, Write};
use std::ptr;
use std::sync::Arc;
Expand Down Expand Up @@ -110,13 +110,13 @@ impl RuleTree {
self.root.clone()
}

fn dump<W: Write>(&self, guards: &ReadGuards, writer: &mut W) {
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W) {
let _ = writeln!(writer, " + RuleTree");
self.root.get().dump(guards, writer, 0);
}

/// Dump the rule tree to stdout.
pub fn dump_stdout(&self, guards: &ReadGuards) {
pub fn dump_stdout(&self, guards: &StylesheetGuards) {
let mut stdout = io::stdout();
self.dump(guards, &mut stdout);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ impl RuleTree {
level: CascadeLevel,
pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
path: &StrongRuleNode,
guards: &ReadGuards)
guards: &StylesheetGuards)
-> Option<StrongRuleNode> {
debug_assert!(level.is_unique_per_element());
// TODO(emilio): Being smarter with lifetimes we could avoid a bit of
Expand Down Expand Up @@ -282,7 +282,7 @@ pub enum CascadeLevel {

impl CascadeLevel {
/// Select a lock guard for this level
pub fn guard<'a>(&self, guards: &'a ReadGuards<'a>) -> &'a SharedRwLockReadGuard<'a> {
pub fn guard<'a>(&self, guards: &'a StylesheetGuards<'a>) -> &'a SharedRwLockReadGuard<'a> {
match *self {
CascadeLevel::UANormal |
CascadeLevel::UserNormal |
Expand Down Expand Up @@ -435,7 +435,7 @@ impl RuleNode {
}
}

fn dump<W: Write>(&self, guards: &ReadGuards, writer: &mut W, indent: usize) {
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W, indent: usize) {
const INDENT_INCREMENT: usize = 4;

for _ in 0..indent {
Expand Down
6 changes: 3 additions & 3 deletions components/style/shared_lock.rs
Expand Up @@ -180,18 +180,18 @@ pub trait ToCssWithGuard {

/// Guards for a document
#[derive(Clone)]
pub struct ReadGuards<'a> {
pub struct StylesheetGuards<'a> {
/// For author-origin stylesheets
pub author: &'a SharedRwLockReadGuard<'a>,

/// For user-agent-origin and user-origin stylesheets
pub ua_or_user: &'a SharedRwLockReadGuard<'a>,
}

impl<'a> ReadGuards<'a> {
impl<'a> StylesheetGuards<'a> {
/// Same guard for all origins
pub fn same(guard: &'a SharedRwLockReadGuard<'a>) -> Self {
ReadGuards {
StylesheetGuards {
author: guard,
ua_or_user: guard,
}
Expand Down
12 changes: 6 additions & 6 deletions components/style/stylist.rs
Expand Up @@ -27,7 +27,7 @@ use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONA
use selectors::matching::{ElementSelectorFlags, StyleRelations, matches_complex_selector};
use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
use selectors::parser::SelectorMethods;
use shared_lock::{Locked, SharedRwLockReadGuard, ReadGuards};
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use sink::Push;
use smallvec::VecLike;
use std::borrow::Borrow;
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Stylist {
/// device is dirty, which means we need to re-evaluate media queries.
pub fn update(&mut self,
doc_stylesheets: &[Arc<Stylesheet>],
guards: &ReadGuards,
guards: &StylesheetGuards,
ua_stylesheets: Option<&UserAgentStylesheets>,
stylesheets_changed: bool) -> bool {
if !(self.is_device_dirty || stylesheets_changed) {
Expand Down Expand Up @@ -299,7 +299,7 @@ impl Stylist {
/// values. The flow constructor uses this flag when constructing anonymous
/// flows.
pub fn precomputed_values_for_pseudo(&self,
guards: &ReadGuards,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&Arc<ComputedValues>>,
cascade_flags: CascadeFlags)
Expand Down Expand Up @@ -345,7 +345,7 @@ impl Stylist {
/// Returns the style for an anonymous box of the given type.
#[cfg(feature = "servo")]
pub fn style_for_anonymous_box(&self,
guards: &ReadGuards,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent_style: &Arc<ComputedValues>)
-> Arc<ComputedValues> {
Expand Down Expand Up @@ -382,7 +382,7 @@ impl Stylist {
/// Check the documentation on lazy pseudo-elements in
/// docs/components/style.md
pub fn lazily_compute_pseudo_element_style<E>(&self,
guards: &ReadGuards,
guards: &StylesheetGuards,
element: &E,
pseudo: &PseudoElement,
parent: &Arc<ComputedValues>)
Expand Down Expand Up @@ -544,7 +544,7 @@ impl Stylist {
style_attribute: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
animation_rules: AnimationRules,
pseudo_element: Option<&PseudoElement>,
guards: &ReadGuards,
guards: &StylesheetGuards,
applicable_declarations: &mut V,
flags: &mut ElementSelectorFlags) -> StyleRelations
where E: TElement +
Expand Down
8 changes: 4 additions & 4 deletions ports/geckolib/glue.rs
Expand Up @@ -74,7 +74,7 @@ use style::properties::parse_one_declaration;
use style::restyle_hints::{self, RestyleHint};
use style::selector_parser::PseudoElementCascadeType;
use style::sequential;
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ReadGuards, ToCssWithGuard, Locked};
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
use style::string_cache::Atom;
use style::stylesheets::{CssRule, CssRules, ImportRule, MediaRule, NamespaceRule};
use style::stylesheets::{Origin, Stylesheet, StyleRule};
Expand Down Expand Up @@ -129,7 +129,7 @@ fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,

SharedStyleContext {
stylist: per_doc_data.stylist.clone(),
guards: ReadGuards::same(guard),
guards: StylesheetGuards::same(guard),
running_animations: per_doc_data.running_animations.clone(),
expired_animations: per_doc_data.expired_animations.clone(),
// FIXME(emilio): Stop boxing here.
Expand Down Expand Up @@ -642,7 +642,7 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
-> ServoComputedValuesStrong {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let guards = ReadGuards::same(&guard);
let guards = StylesheetGuards::same(&guard);
let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
let atom = Atom::from(pseudo_tag);
let pseudo = PseudoElement::from_atom_unchecked(atom, /* anon_box = */ true);
Expand Down Expand Up @@ -699,7 +699,7 @@ fn get_pseudo_style(guard: &SharedRwLockReadGuard, element: GeckoElement, pseudo
PseudoElementCascadeType::Lazy => {
let d = doc_data.borrow_mut();
let base = styles.primary.values();
let guards = ReadGuards::same(guard);
let guards = StylesheetGuards::same(guard);
d.stylist.lazily_compute_pseudo_element_style(&guards,
&element,
&pseudo,
Expand Down

0 comments on commit d507413

Please sign in to comment.