mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Parse the legacy border
attribute per the legacy HTML specification.
Additionally, this patch cleans up some miscellaneous formatting issues and refactors files in `layout/css/` somewhat to eliminate needless levels of indirection. It also fixes our handling of presentational hints that only apply if border is nonzero.
This commit is contained in:
parent
e0e14c60d6
commit
10f1ed5e31
19 changed files with 350 additions and 127 deletions
|
@ -2,27 +2,75 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Style retrieval from DOM elements.
|
||||
//! Style retrieval from DOM elements.
|
||||
|
||||
use css::node_util::NodeUtil;
|
||||
use wrapper::ThreadSafeLayoutNode;
|
||||
use wrapper::{After, Before, Normal, ThreadSafeLayoutNode};
|
||||
|
||||
use std::mem;
|
||||
use style::ComputedValues;
|
||||
use sync::Arc;
|
||||
|
||||
/// Node mixin providing `style` method that returns a `NodeStyle`
|
||||
pub trait StyledNode {
|
||||
/// Returns the style results for the given node. If CSS selector matching has not yet been
|
||||
/// performed, fails.
|
||||
fn style<'a>(&'a self) -> &'a Arc<ComputedValues>;
|
||||
/// Does this node have a computed style yet?
|
||||
fn has_style(&self) -> bool;
|
||||
/// Removes the style from this node.
|
||||
fn unstyle(self);
|
||||
}
|
||||
|
||||
impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> {
|
||||
#[inline]
|
||||
fn style<'a>(&'a self) -> &'a Arc<ComputedValues> {
|
||||
self.get_css_select_results()
|
||||
unsafe {
|
||||
let layout_data_ref = self.borrow_layout_data();
|
||||
match self.get_pseudo_element_type() {
|
||||
Before(_) => {
|
||||
mem::transmute(layout_data_ref.as_ref()
|
||||
.unwrap()
|
||||
.data
|
||||
.before_style
|
||||
.as_ref()
|
||||
.unwrap())
|
||||
}
|
||||
After(_) => {
|
||||
mem::transmute(layout_data_ref.as_ref()
|
||||
.unwrap()
|
||||
.data
|
||||
.after_style
|
||||
.as_ref()
|
||||
.unwrap())
|
||||
}
|
||||
Normal => {
|
||||
mem::transmute(layout_data_ref.as_ref()
|
||||
.unwrap()
|
||||
.shared_data
|
||||
.style
|
||||
.as_ref()
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn has_style(&self) -> bool {
|
||||
let layout_data_ref = self.borrow_layout_data();
|
||||
layout_data_ref.as_ref().unwrap().shared_data.style.is_some()
|
||||
}
|
||||
|
||||
fn unstyle(self) {
|
||||
self.remove_css_select_results()
|
||||
let mut layout_data_ref = self.mutate_layout_data();
|
||||
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
||||
|
||||
let style =
|
||||
match self.get_pseudo_element_type() {
|
||||
Before(_) => &mut layout_data.data.before_style,
|
||||
After (_) => &mut layout_data.data.after_style,
|
||||
Normal => &mut layout_data.shared_data.style,
|
||||
};
|
||||
|
||||
*style = None;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue