Skip to content

Commit

Permalink
Remove ComputedValuesCursorUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jan 14, 2019
1 parent 9825b85 commit b9b7044
Showing 1 changed file with 33 additions and 41 deletions.
74 changes: 33 additions & 41 deletions components/layout/display_list/builder.rs
Expand Up @@ -692,7 +692,7 @@ impl Fragment {
bounds,
bounds,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
display_list_section,
);
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
Expand Down Expand Up @@ -823,7 +823,7 @@ impl Fragment {
placement.bounds,
placement.clip_rect,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
display_list_section,
);

Expand Down Expand Up @@ -938,7 +938,7 @@ impl Fragment {
placement.bounds,
placement.clip_rect,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
display_list_section,
);

Expand Down Expand Up @@ -1004,7 +1004,7 @@ impl Fragment {
bounds,
clip,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
display_list_section,
);
let border_radius = border::radii(absolute_bounds, style.get_border());
Expand Down Expand Up @@ -1088,7 +1088,7 @@ impl Fragment {
bounds,
clip,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
display_list_section,
);

Expand Down Expand Up @@ -1287,7 +1287,7 @@ impl Fragment {
bounds,
clip,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
DisplayListSection::Outlines,
);
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
Expand Down Expand Up @@ -1318,7 +1318,7 @@ impl Fragment {
stacking_relative_border_box,
clip,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
Expand Down Expand Up @@ -1347,7 +1347,7 @@ impl Fragment {
baseline,
clip,
self.node,
style.get_cursor(CursorKind::Default),
get_cursor(&style, CursorKind::Default),
DisplayListSection::Content,
);
// TODO(gw): Use a better estimate for wavy line thickness.
Expand Down Expand Up @@ -1375,7 +1375,7 @@ impl Fragment {
stacking_relative_border_box,
clip,
self.node,
self.style.get_cursor(CursorKind::Default),
get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Border(CommonDisplayItem::with_data(
Expand Down Expand Up @@ -1417,7 +1417,7 @@ impl Fragment {
stacking_relative_border_box,
clip,
self.node,
self.style.get_cursor(CursorKind::Default),
get_cursor(&self.style, CursorKind::Default),
display_list_section,
);
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
Expand Down Expand Up @@ -1463,7 +1463,7 @@ impl Fragment {
insertion_point_bounds,
clip,
self.node,
self.style.get_cursor(cursor),
get_cursor(&self.style, cursor),
display_list_section,
);
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
Expand Down Expand Up @@ -1645,9 +1645,7 @@ impl Fragment {
content_size,
content_size,
self.node,
self.style
.get_cursor(CursorKind::Default)
.or_else(|| Some(CursorKind::Default)),
get_cursor(&self.style, CursorKind::Default).or(Some(CursorKind::Default)),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
Expand Down Expand Up @@ -1698,7 +1696,7 @@ impl Fragment {
stacking_relative_content_box,
stacking_relative_border_box,
self.node,
self.style.get_cursor(CursorKind::Default),
get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content,
)
};
Expand Down Expand Up @@ -1974,7 +1972,7 @@ impl Fragment {
stacking_relative_content_box,
clip,
self.node,
self.style().get_cursor(cursor),
get_cursor(&self.style, cursor),
DisplayListSection::Content,
);

Expand Down Expand Up @@ -2098,7 +2096,7 @@ impl Fragment {
stacking_relative_box,
clip,
self.node,
self.style.get_cursor(CursorKind::Default),
get_cursor(&self.style, CursorKind::Default),
DisplayListSection::Content,
);

Expand Down Expand Up @@ -2828,30 +2826,24 @@ 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
/// 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]
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> {
match (
self.get_inherited_ui().pointer_events,
&self.get_inherited_ui().cursor,
) {
(PointerEvents::None, _) => None,
(
PointerEvents::Auto,
&Cursor {
keyword: CursorKind::Auto,
..
},
) => Some(default_cursor),
(PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
}
/// 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
/// text display items it may be `TextCursor` or `VerticalTextCursor`.
#[inline]
fn get_cursor(values: &ComputedValues, default_cursor: CursorKind) -> Option<CursorKind> {
match (
values.get_inherited_ui().pointer_events,
&values.get_inherited_ui().cursor,
) {
(PointerEvents::None, _) => None,
(
PointerEvents::Auto,
&Cursor {
keyword: CursorKind::Auto,
..
},
) => Some(default_cursor),
(PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
}
}

Expand Down

0 comments on commit b9b7044

Please sign in to comment.