mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
servo: Change StyleMethods::style to return a region pointer instead of copying the style object
Source-Repo: https://github.com/servo/servo Source-Revision: c0350e77394be91456b475e7a72ab6b364544aa6
This commit is contained in:
parent
f33cd7cce8
commit
fe38b6ed19
@ -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…
Reference in New Issue
Block a user