mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Change StyleMethods::style to return a region pointer instead of copying the style object
This commit is contained in:
parent
b00885f77a
commit
c0350e7739
2 changed files with 7 additions and 6 deletions
|
@ -105,7 +105,7 @@ fn empty_style_for_node_kind(kind: &NodeKind) -> SpecifiedStyle {
|
|||
trait StyleMethods {
|
||||
fn initialize_layout_data() -> Option<@LayoutData>;
|
||||
|
||||
fn style() -> SpecifiedStyle;
|
||||
fn style() -> &self/SpecifiedStyle;
|
||||
fn initialize_style_for_subtree(ctx: &LayoutContext, refs: &DVec<@LayoutData>);
|
||||
fn recompute_style_for_subtree(ctx: &LayoutContext, styles : &SelectCtx);
|
||||
}
|
||||
|
@ -129,15 +129,16 @@ impl Node : StyleMethods {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the computed style for the given node. If CSS selector
|
||||
* Provides the computed style for the given node. If CSS selector
|
||||
* matching has not yet been performed, fails.
|
||||
* FIXME: This isn't completely memory safe since the style is
|
||||
* stored in a box that can be overwritten
|
||||
*/
|
||||
fn style() -> SpecifiedStyle {
|
||||
fn style() -> &self/SpecifiedStyle {
|
||||
if !self.has_aux() {
|
||||
fail ~"get_style() called on a node without a style!";
|
||||
}
|
||||
// TODO: return a safe reference; don't copy!
|
||||
return copy *self.aux(|x| copy *x).style;
|
||||
unsafe { &*self.aux( |x| ptr::to_unsafe_ptr(&*x.style) ) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -457,7 +457,7 @@ impl RenderBox : RenderBoxMethods {
|
|||
fn add_border_to_list(list: &mut DisplayList, abs_bounds: &Rect<Au>) {
|
||||
let style = self.d().node.style();
|
||||
match style.border_width {
|
||||
Specified(Px(px)) => {
|
||||
Specified(Px(copy px)) => {
|
||||
// If there's a border, let's try to display *something*
|
||||
let border_width = au::from_frac_px(px);
|
||||
let abs_bounds = Rect {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue