Implement ::selection pseudo-element

This commit is contained in:
Emilio Cobos Álvarez 2016-03-28 23:08:32 +02:00
parent 4aa1da3211
commit 92f39ea5cf
10 changed files with 67 additions and 21 deletions

View file

@ -85,6 +85,9 @@ pub struct Fragment {
/// The CSS style of this fragment.
pub style: Arc<ServoComputedValues>,
/// The CSS style of this fragment when it's selected
pub selected_style: Arc<ServoComputedValues>,
/// The position of this fragment relative to its owning flow. The size includes padding and
/// border, but not margin.
///
@ -798,6 +801,7 @@ impl Fragment {
Fragment {
node: node.opaque(),
style: style,
selected_style: node.selected_style().clone(),
restyle_damage: restyle_damage,
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
@ -815,6 +819,7 @@ impl Fragment {
pub fn from_opaque_node_and_style(node: OpaqueNode,
pseudo: PseudoElementType<()>,
style: Arc<ServoComputedValues>,
selected_style: Arc<ServoComputedValues>,
mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo)
-> Fragment {
@ -825,6 +830,7 @@ impl Fragment {
Fragment {
node: node,
style: style,
selected_style: selected_style,
restyle_damage: restyle_damage,
border_box: LogicalRect::zero(writing_mode),
border_padding: LogicalMargin::zero(writing_mode),
@ -858,6 +864,7 @@ impl Fragment {
Fragment {
node: self.node,
style: self.style.clone(),
selected_style: self.selected_style.clone(),
restyle_damage: restyle_damage,
border_box: new_border_box,
border_padding: self.border_padding,
@ -1286,6 +1293,11 @@ impl Fragment {
&*self.style
}
#[inline(always)]
pub fn selected_style(&self) -> &ServoComputedValues {
&*self.selected_style
}
pub fn white_space(&self) -> white_space::T {
self.style().get_inheritedtext().white_space
}