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

Implement support for style attributes. #678

Merged
merged 1 commit into from Aug 7, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -28,18 +28,24 @@ impl MatchMethods for AbstractNode<LayoutView> {
fn restyle_subtree(&self, select_ctx: &SelectCtx) {
// Only elements have styles
if self.is_element() {
let select_handler = NodeSelectHandler { node: *self };
let incomplete_results = select_ctx.select_style(self, &select_handler);
// Combine this node's results with its parent's to resolve all inherited values
let complete_results = compose_results(*self, incomplete_results);
do self.with_imm_element |elem| {
let inline_style = match elem.style_attribute {
None => None,
Some(ref sheet) => Some(sheet),
};
let select_handler = NodeSelectHandler { node: *self };
let incomplete_results = select_ctx.select_style(self, inline_style, &select_handler);
// Combine this node's results with its parent's to resolve all inherited values
let complete_results = compose_results(*self, incomplete_results);

// If there was an existing style, compute the damage that
// incremental layout will need to fix.
if self.have_css_select_results() {
let damage = incremental::compute_damage(self, self.get_css_select_results(), &complete_results);
self.set_restyle_damage(damage);
}
self.set_css_select_results(complete_results);
// If there was an existing style, compute the damage that
// incremental layout will need to fix.
if self.have_css_select_results() {
let damage = incremental::compute_damage(self, self.get_css_select_results(), &complete_results);
self.set_restyle_damage(damage);
}
self.set_css_select_results(complete_results);
};
}

for self.each_child |kid| {
@@ -10,6 +10,7 @@ use dom::clientrectlist::ClientRectList;
use dom::node::{ElementNodeTypeId, Node, ScriptView};
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
use layout_interface::{ContentBoxesResponse};
use newcss::stylesheet::Stylesheet;

use std::cell::Cell;
use std::comm::ChanOne;
@@ -24,6 +25,7 @@ pub struct Element {
parent: Node<ScriptView>,
tag_name: ~str, // TODO: This should be an atom, not a ~str.
attrs: ~[Attr],
style_attribute: Option<Stylesheet>,
}

#[deriving(Eq)]
@@ -132,7 +134,8 @@ impl<'self> Element {
Element {
parent: Node::new(ElementNodeTypeId(type_id)),
tag_name: tag_name,
attrs: ~[]
attrs: ~[],
style_attribute: None,
}
}

@@ -314,6 +314,13 @@ pub fn parse_html(cx: *JSContext,
do node.as_mut_element |element| {
for tag.attributes.iter().advance |attr| {
element.attrs.push(Attr::new(attr.name.clone(), attr.value.clone()));

if "style" == attr.name {
element.style_attribute = Some(
Stylesheet::from_attribute(
url::from_str("http://www.example.com/").unwrap(),
attr.value));
}
}
}

@@ -374,7 +381,6 @@ pub fn parse_html(cx: *JSContext,
}
}

//TODO (Issue #86): handle inline styles ('style' attr)
_ => {}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.