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,19 +2826,14 @@ impl BaseFlow {
} }
} }
trait ComputedValuesCursorUtility {
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind>;
}
impl ComputedValuesCursorUtility for ComputedValues {
/// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies /// Gets the cursor to use given the specific ComputedValues. `default_cursor` specifies
/// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for /// the cursor to use if `cursor` is `auto`. Typically, this will be `PointerCursor`, but for
/// text display items it may be `TextCursor` or `VerticalTextCursor`. /// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline] #[inline]
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> { fn get_cursor(values: &ComputedValues, default_cursor: CursorKind) -> Option<CursorKind> {
match ( match (
self.get_inherited_ui().pointer_events, values.get_inherited_ui().pointer_events,
&self.get_inherited_ui().cursor, &values.get_inherited_ui().cursor,
) { ) {
(PointerEvents::None, _) => None, (PointerEvents::None, _) => None,
( (
@ -2853,7 +2846,6 @@ impl ComputedValuesCursorUtility for ComputedValues {
(PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword), (PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
} }
} }
}
/// Adjusts `content_rect` as necessary for the given spread, and blur so that the resulting /// Adjusts `content_rect` as necessary for the given spread, and blur so that the resulting
/// bounding rect contains all of a shadow's ink. /// bounding rect contains all of a shadow's ink.