Remove ComputedValuesCursorUtility

This commit is contained in:
Anthony Ramine 2019-01-14 12:07:33 +01:00
parent 9825b85acd
commit b9b70445cb

View file

@ -692,7 +692,7 @@ impl Fragment {
bounds, bounds,
bounds, bounds,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
display_list_section, display_list_section,
); );
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
@ -823,7 +823,7 @@ impl Fragment {
placement.bounds, placement.bounds,
placement.clip_rect, placement.clip_rect,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
display_list_section, display_list_section,
); );
@ -938,7 +938,7 @@ impl Fragment {
placement.bounds, placement.bounds,
placement.clip_rect, placement.clip_rect,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
display_list_section, display_list_section,
); );
@ -1004,7 +1004,7 @@ impl Fragment {
bounds, bounds,
clip, clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
display_list_section, display_list_section,
); );
let border_radius = border::radii(absolute_bounds, style.get_border()); let border_radius = border::radii(absolute_bounds, style.get_border());
@ -1088,7 +1088,7 @@ impl Fragment {
bounds, bounds,
clip, clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
display_list_section, display_list_section,
); );
@ -1287,7 +1287,7 @@ impl Fragment {
bounds, bounds,
clip, clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
DisplayListSection::Outlines, DisplayListSection::Outlines,
); );
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
@ -1318,7 +1318,7 @@ impl Fragment {
stacking_relative_border_box, stacking_relative_border_box,
clip, clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
); );
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
@ -1347,7 +1347,7 @@ impl Fragment {
baseline, baseline,
clip, clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), get_cursor(&style, CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
); );
// TODO(gw): Use a better estimate for wavy line thickness. // TODO(gw): Use a better estimate for wavy line thickness.
@ -1375,7 +1375,7 @@ impl Fragment {
stacking_relative_border_box, stacking_relative_border_box,
clip, clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
); );
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data( state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
@ -1417,7 +1417,7 @@ impl Fragment {
stacking_relative_border_box, stacking_relative_border_box,
clip, clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), get_cursor(&self.style, CursorKind::Default),
display_list_section, display_list_section,
); );
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
@ -1463,7 +1463,7 @@ impl Fragment {
insertion_point_bounds, insertion_point_bounds,
clip, clip,
self.node, self.node,
self.style.get_cursor(cursor), get_cursor(&self.style, cursor),
display_list_section, display_list_section,
); );
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
@ -1645,9 +1645,7 @@ impl Fragment {
content_size, content_size,
content_size, content_size,
self.node, self.node,
self.style get_cursor(&self.style, CursorKind::Default).or(Some(CursorKind::Default)),
.get_cursor(CursorKind::Default)
.or_else(|| Some(CursorKind::Default)),
DisplayListSection::Content, DisplayListSection::Content,
); );
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new( state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
@ -1698,7 +1696,7 @@ impl Fragment {
stacking_relative_content_box, stacking_relative_content_box,
stacking_relative_border_box, stacking_relative_border_box,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
) )
}; };
@ -1974,7 +1972,7 @@ impl Fragment {
stacking_relative_content_box, stacking_relative_content_box,
clip, clip,
self.node, self.node,
self.style().get_cursor(cursor), get_cursor(&self.style, cursor),
DisplayListSection::Content, DisplayListSection::Content,
); );
@ -2098,7 +2096,7 @@ impl Fragment {
stacking_relative_box, stacking_relative_box,
clip, clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
); );
@ -2828,30 +2826,24 @@ impl BaseFlow {
} }
} }
trait ComputedValuesCursorUtility { /// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind>; /// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
} /// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline]
impl ComputedValuesCursorUtility for ComputedValues { fn get_cursor(values: &ComputedValues, default_cursor: CursorKind) -> Option<CursorKind> {
/// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies match (
/// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for values.get_inherited_ui().pointer_events,
/// text display items it may be `TextCursor` or `VerticalTextCursor`. &values.get_inherited_ui().cursor,
#[inline] ) {
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> { (PointerEvents::None, _) => None,
match ( (
self.get_inherited_ui().pointer_events, PointerEvents::Auto,
&self.get_inherited_ui().cursor, &Cursor {
) { keyword: CursorKind::Auto,
(PointerEvents::None, _) => None, ..
( },
PointerEvents::Auto, ) => Some(default_cursor),
&Cursor { (PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
keyword: CursorKind::Auto,
..
},
) => Some(default_cursor),
(PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
}
} }
} }