diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-31 00:47:07 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-31 00:47:07 +0530 |
commit | 723989b9dddeb9bcdc28dc7d640fd6fd7247a27f (patch) | |
tree | 1cc0d0875809577e8d2dafab2a3623b043022523 /components/layout/display_list_builder.rs | |
parent | e1485718128bff632eff5445583e925ff796bdba (diff) | |
parent | 46829bd53ced5d7d5a4b4c6600f2061cc8720536 (diff) | |
download | servo-723989b9dddeb9bcdc28dc7d640fd6fd7247a27f.tar.gz servo-723989b9dddeb9bcdc28dc7d640fd6fd7247a27f.zip |
Auto merge of #10252 - emilio:selection, r=mbrubeck
Implement ::selection pseudo-element
It only supports `color` and `background`, for now, but it shouldn't be hard to add more properties (like text-shadow).
r? @mbrubeck
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10252)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/display_list_builder.rs')
-rw-r--r-- | components/layout/display_list_builder.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 7c65db972cf..e6034bb29ab 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -104,10 +104,6 @@ impl<'a> DisplayListBuildState<'a> { /// The logical width of an insertion point: at the moment, a one-pixel-wide line. const INSERTION_POINT_LOGICAL_WIDTH: Au = Au(1 * AU_PER_PX); -// Colors for selected text. TODO (#8077): Use the ::selection pseudo-element to set these. -const SELECTION_FOREGROUND_COLOR: RGBA = RGBA { red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0 }; -const SELECTION_BACKGROUND_COLOR: RGBA = RGBA { red: 0.69, green: 0.84, blue: 1.0, alpha: 1.0 }; - // TODO(gw): The transforms spec says that perspective length must // be positive. However, there is some confusion between the spec // and browser implementations as to handling the case of 0 for the @@ -931,6 +927,8 @@ impl FragmentDisplayListBuilding for Fragment { // // TODO: Allow non-text fragments to be selected too. if scanned_text_fragment_info.selected() { + let style = self.selected_style(); + let background_color = style.resolve_color(style.get_background().background_color); state.add_display_item( DisplayItem::SolidColorClass(box SolidColorDisplayItem { base: BaseDisplayItem::new(stacking_relative_border_box, @@ -938,7 +936,7 @@ impl FragmentDisplayListBuilding for Fragment { &*self.style, Cursor::DefaultCursor), &clip), - color: SELECTION_BACKGROUND_COLOR.to_gfx_color() + color: background_color.to_gfx_color(), }), display_list_section); } @@ -1116,11 +1114,14 @@ impl FragmentDisplayListBuilding for Fragment { // // NB: According to CSS-BACKGROUNDS, text shadows render in *reverse* order (front // to back). + + // TODO(emilio): Allow changing more properties by ::selection let text_color = if text_fragment.selected() { - SELECTION_FOREGROUND_COLOR + self.selected_style().get_color().color } else { self.style().get_color().color }; + for text_shadow in self.style.get_effects().text_shadow.0.iter().rev() { let offset = &Point2D::new(text_shadow.offset_x, text_shadow.offset_y); let color = self.style().resolve_color(text_shadow.color); |