Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start precomputing presentational hints. #6311

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Add a vector of presentational hints to the Attr object.

  • Loading branch information
Ms2ger committed Jun 22, 2015
commit d2f18e807bf2bee5bd34c896ef8aef15f3394b88
@@ -17,6 +17,7 @@ use devtools_traits::AttrInfo;
use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars};

use string_cache::{Atom, Namespace};
use style::properties::PropertyDeclaration;

use std::borrow::ToOwned;
use std::cell::Ref;
@@ -120,6 +121,8 @@ pub struct Attr {

/// the element that owns this attribute.
owner: MutNullableHeap<JS<Element>>,

presentational_hints: DOMRefCell<Vec<PropertyDeclaration>>,
}

impl Attr {
@@ -133,6 +136,7 @@ impl Attr {
namespace: namespace,
prefix: prefix,
owner: MutNullableHeap::new(owner.map(JS::from_ref)),
presentational_hints: DOMRefCell::new(Vec::new()),
}
}

@@ -310,6 +314,7 @@ pub trait AttrHelpersForLayout {
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
unsafe fn local_name_atom_forever(&self) -> Atom;
unsafe fn value_for_layout(&self) -> &AttrValue;
fn presentational_hints(&self) -> &[PropertyDeclaration];
}

#[allow(unsafe_code)]
@@ -352,4 +357,11 @@ impl AttrHelpersForLayout for LayoutJS<Attr> {
unsafe fn value_for_layout(&self) -> &AttrValue {
(*self.unsafe_get()).value.borrow_for_layout()
}

#[inline]
fn presentational_hints(&self) -> &[PropertyDeclaration] {
unsafe {
(*self.unsafe_get()).presentational_hints.borrow_for_layout()
}
}
}
@@ -71,7 +71,7 @@ use std::rc::Rc;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender};
use string_cache::{Atom, Namespace};
use style::properties::PropertyDeclarationBlock;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use url::Url;


@@ -277,6 +277,7 @@ no_jsmanaged_fields!(Arc<T>);
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan);
no_jsmanaged_fields!(Atom, Namespace);
no_jsmanaged_fields!(Trusted<T>);
no_jsmanaged_fields!(PropertyDeclaration);
no_jsmanaged_fields!(PropertyDeclarationBlock);
no_jsmanaged_fields!(HashSet<T>);
// These three are interdependent, if you plan to put jsmanaged data
@@ -255,6 +255,13 @@ impl RawLayoutElementHelpers for Element {
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>
{
for attribute in self.attrs.borrow_for_layout().iter() {
let attribute = attribute.to_layout();
for hint in attribute.presentational_hints() {
hints.push(from_declaration(hint.clone()));
}
}

let bgcolor = if self.is_htmlbodyelement() {
let this: &HTMLBodyElement = mem::transmute(self);
this.get_background_color()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.