servo: Merge #18933 - Use WebRender to compute text index on click events (from mrobinson:wr-text-index); r=jdm

This is the second half of switching over to WebRender for hit testing.
Now that WebRender gives us the location of the hit tested point in the
display item, we can use that to calculate text index.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they shouldn't change behavior.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 4cf2ce66fc4f970a47ab1fb4b9aa1a55282640f7

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 365f452e9e708080adbbfe4b09ccd2dafeb3eb75
This commit is contained in:
Martin Robinson 2017-10-19 02:36:32 -05:00
parent e14412541c
commit 54e8de2b45
12 changed files with 194 additions and 370 deletions

View File

@ -702,20 +702,20 @@ impl<Window: WindowMethods> IOCompositor<Window> {
None => return,
};
let point = result.point_in_viewport.to_untyped();
let node_address = Some(UntrustedNodeAddress(result.tag.0 as *const c_void));
let event_to_send = match mouse_window_event {
MouseWindowEvent::Click(button, _) => {
MouseButtonEvent(MouseEventType::Click, button, point, node_address)
}
MouseWindowEvent::MouseDown(button, _) => {
MouseButtonEvent(MouseEventType::MouseDown, button, point, node_address)
}
MouseWindowEvent::MouseUp(button, _) => {
MouseButtonEvent(MouseEventType::MouseUp, button, point, node_address)
}
let (button, event_type) = match mouse_window_event {
MouseWindowEvent::Click(button, _) => (button, MouseEventType::Click),
MouseWindowEvent::MouseDown(button, _) => (button, MouseEventType::MouseDown),
MouseWindowEvent::MouseUp(button, _) => (button, MouseEventType::MouseUp),
};
let event_to_send = MouseButtonEvent(
event_type,
button,
result.point_in_viewport.to_untyped(),
Some(UntrustedNodeAddress(result.tag.0 as *const c_void)),
Some(result.point_relative_to_item.to_untyped()),
);
let pipeline_id = PipelineId::from_webrender(result.pipeline);
let msg = ConstellationMsg::ForwardEvent(pipeline_id, event_to_send);
if let Err(e) = self.constellation_chan.send(msg) {

View File

@ -48,74 +48,6 @@ pub struct DisplayList {
pub list: Vec<DisplayItem>,
}
struct ScrollOffsetLookup<'a> {
parents: &'a mut HashMap<ClipId, ClipId>,
calculated_total_offsets: ScrollOffsetMap,
raw_offsets: &'a ScrollOffsetMap,
}
impl<'a> ScrollOffsetLookup<'a> {
fn new(parents: &'a mut HashMap<ClipId, ClipId>,
raw_offsets: &'a ScrollOffsetMap)
-> ScrollOffsetLookup<'a> {
ScrollOffsetLookup {
parents: parents,
calculated_total_offsets: HashMap::new(),
raw_offsets: raw_offsets,
}
}
fn new_for_reference_frame(&mut self,
clip_id: ClipId,
transform: &Transform3D<f32>,
point: &mut Point2D<Au>)
-> Option<ScrollOffsetLookup> {
// If a transform function causes the current transformation matrix of an object
// to be non-invertible, the object and its content do not get displayed.
let inv_transform = match transform.inverse() {
Some(transform) => transform,
None => return None,
};
let scroll_offset = self.full_offset_for_clip_scroll_node(&clip_id);
*point = Point2D::new(point.x - Au::from_f32_px(scroll_offset.x),
point.y - Au::from_f32_px(scroll_offset.y));
let frac_point = inv_transform.transform_point2d(&Point2D::new(point.x.to_f32_px(),
point.y.to_f32_px()));
*point = Point2D::new(Au::from_f32_px(frac_point.x), Au::from_f32_px(frac_point.y));
let mut sublookup = ScrollOffsetLookup {
parents: &mut self.parents,
calculated_total_offsets: HashMap::new(),
raw_offsets: self.raw_offsets,
};
sublookup.calculated_total_offsets.insert(clip_id, Vector2D::zero());
Some(sublookup)
}
fn add_clip_scroll_node(&mut self, clip_scroll_node: &ClipScrollNode) {
self.parents.insert(clip_scroll_node.id, clip_scroll_node.parent_id);
}
fn full_offset_for_clip_scroll_node(&mut self, id: &ClipId) -> Vector2D<f32> {
if let Some(offset) = self.calculated_total_offsets.get(id) {
return *offset;
}
let parent_offset = if !id.is_root_scroll_node() {
let parent_id = *self.parents.get(id).unwrap();
self.full_offset_for_clip_scroll_node(&parent_id)
} else {
Vector2D::zero()
};
let offset = parent_offset +
self.raw_offsets.get(id).cloned().unwrap_or_else(Vector2D::zero);
self.calculated_total_offsets.insert(*id, offset);
offset
}
}
impl DisplayList {
/// Return the bounds of this display list based on the dimensions of the root
/// stacking context.
@ -128,82 +60,22 @@ impl DisplayList {
}
// Returns the text index within a node for the point of interest.
pub fn text_index(&self,
node: OpaqueNode,
client_point: &Point2D<Au>,
scroll_offsets: &ScrollOffsetMap)
-> Option<usize> {
let mut result = Vec::new();
let mut traversal = DisplayListTraversal::new(self);
self.text_index_contents(node,
&mut traversal,
client_point,
&mut ScrollOffsetLookup::new(&mut HashMap::new(), scroll_offsets),
&mut result);
result.pop()
}
fn text_index_contents<'a>(&self,
node: OpaqueNode,
traversal: &mut DisplayListTraversal<'a>,
point: &Point2D<Au>,
offset_lookup: &mut ScrollOffsetLookup,
result: &mut Vec<usize>) {
while let Some(item) = traversal.next() {
pub fn text_index(&self, node: OpaqueNode, point_in_item: &Point2D<Au>) -> Option<usize> {
for item in &self.list {
match item {
&DisplayItem::PushStackingContext(ref context_item) => {
self.text_index_stacking_context(&context_item.stacking_context,
item.scroll_node_id(),
node,
traversal,
point,
offset_lookup,
result);
}
&DisplayItem::DefineClipScrollNode(ref item) => {
offset_lookup.add_clip_scroll_node(&item.node);
}
&DisplayItem::PopStackingContext(_) => return,
&DisplayItem::Text(ref text) => {
let base = item.base();
if base.metadata.node == node {
let offset = *point - text.baseline_origin;
let index = text.text_run.range_index_of_advance(&text.range, offset.x);
result.push(index);
let point = *point_in_item + item.base().bounds.origin.to_vector();
let offset = point - text.baseline_origin;
return Some(text.text_run.range_index_of_advance(&text.range, offset.x));
}
},
_ => {},
}
}
}
fn text_index_stacking_context<'a>(&self,
stacking_context: &StackingContext,
clip_id: ClipId,
node: OpaqueNode,
traversal: &mut DisplayListTraversal<'a>,
point: &Point2D<Au>,
offset_lookup: &mut ScrollOffsetLookup,
result: &mut Vec<usize>) {
let mut point = *point - stacking_context.bounds.origin.to_vector();
if stacking_context.scroll_policy == ScrollPolicy::Fixed {
let old_offset = offset_lookup.calculated_total_offsets.get(&clip_id).cloned();
offset_lookup.calculated_total_offsets.insert(clip_id, Vector2D::zero());
self.text_index_contents(node, traversal, &point, offset_lookup, result);
match old_offset {
Some(offset) => offset_lookup.calculated_total_offsets.insert(clip_id, offset),
None => offset_lookup.calculated_total_offsets.remove(&clip_id),
};
} else if let Some(transform) = stacking_context.transform {
if let Some(ref mut sublookup) =
offset_lookup.new_for_reference_frame(clip_id, &transform, &mut point) {
self.text_index_contents(node, traversal, &point, sublookup, result);
}
} else {
self.text_index_contents(node, traversal, &point, offset_lookup, result);
}
None
}
pub fn print(&self) {
@ -223,94 +95,6 @@ impl DisplayList {
}
}
pub struct DisplayListTraversal<'a> {
pub display_list: &'a DisplayList,
pub next_item_index: usize,
pub first_item_index: usize,
pub last_item_index: usize,
}
impl<'a> DisplayListTraversal<'a> {
pub fn new(display_list: &'a DisplayList) -> DisplayListTraversal {
DisplayListTraversal {
display_list: display_list,
next_item_index: 0,
first_item_index: 0,
last_item_index: display_list.list.len(),
}
}
pub fn new_partial(display_list: &'a DisplayList,
stacking_context_id: StackingContextId,
start: usize,
end: usize)
-> DisplayListTraversal {
debug_assert!(start <= end);
debug_assert!(display_list.list.len() > start);
debug_assert!(display_list.list.len() > end);
let stacking_context_start = display_list.list[0..start].iter().rposition(|item|
match item {
&DisplayItem::PushStackingContext(ref item) =>
item.stacking_context.id == stacking_context_id,
_ => false,
}).unwrap_or(start);
debug_assert!(stacking_context_start <= start);
DisplayListTraversal {
display_list: display_list,
next_item_index: stacking_context_start,
first_item_index: start,
last_item_index: end + 1,
}
}
pub fn previous_item_id(&self) -> usize {
self.next_item_index - 1
}
pub fn skip_to_end_of_stacking_context(&mut self, id: StackingContextId) {
self.next_item_index = self.display_list.list[self.next_item_index..].iter()
.position(|item| {
match item {
&DisplayItem::PopStackingContext(ref item) => item.stacking_context_id == id,
_ => false
}
}).unwrap_or(self.display_list.list.len());
debug_assert!(self.next_item_index < self.last_item_index);
}
}
impl<'a> Iterator for DisplayListTraversal<'a> {
type Item = &'a DisplayItem;
fn next(&mut self) -> Option<&'a DisplayItem> {
while self.next_item_index < self.last_item_index {
debug_assert!(self.next_item_index <= self.last_item_index);
let reached_first_item = self.next_item_index >= self.first_item_index;
let item = &self.display_list.list[self.next_item_index];
self.next_item_index += 1;
if reached_first_item {
return Some(item)
}
// Before we reach the starting item, we only emit stacking context boundaries. This
// is to ensure that we properly position items when we are processing a display list
// slice that is relative to a certain stacking context.
match item {
&DisplayItem::PushStackingContext(_) |
&DisplayItem::PopStackingContext(_) => return Some(item),
_ => {}
}
}
None
}
}
/// Display list sections that make up a stacking context. Each section here refers
/// to the steps in CSS 2.1 Appendix E.
///

View File

@ -10,8 +10,7 @@
use app_units::Au;
use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D};
use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClipScrollNodeType};
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, DisplayListTraversal};
use gfx::display_list::StackingContextType;
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode, transform_style};
use style::values::computed::{BorderStyle, Filter};
@ -221,7 +220,6 @@ impl ToTransformStyle for transform_style::T {
impl WebRenderDisplayListConverter for DisplayList {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
let traversal = DisplayListTraversal::new(self);
let mut builder = DisplayListBuilder::with_capacity(pipeline_id.to_webrender(),
self.bounds().size.to_sizef(),
1024 * 1024); // 1 MB of space
@ -229,7 +227,7 @@ impl WebRenderDisplayListConverter for DisplayList {
let mut current_clip_and_scroll_info = pipeline_id.root_clip_and_scroll_info();
builder.push_clip_and_scroll_info(current_clip_and_scroll_info);
for item in traversal {
for item in &self.list {
item.convert_to_webrender(&mut builder, &mut current_clip_and_scroll_info);
}
builder

View File

@ -1361,18 +1361,19 @@ impl LayoutThread {
let node = unsafe { ServoLayoutNode::new(&node) };
rw_data.content_boxes_response = process_content_boxes_request(node, root_flow);
},
ReflowGoal::TextIndexQuery(node, mouse_x, mouse_y) => {
ReflowGoal::TextIndexQuery(node, point_in_node) => {
let node = unsafe { ServoLayoutNode::new(&node) };
let opaque_node = node.opaque();
let client_point = Point2D::new(Au::from_px(mouse_x),
Au::from_px(mouse_y));
rw_data.text_index_response =
TextIndexResponse(rw_data.display_list
.as_ref()
.expect("Tried to hit test with no display list")
.text_index(opaque_node,
&client_point,
&rw_data.scroll_offsets));
let point_in_node = Point2D::new(
Au::from_f32_px(point_in_node.x),
Au::from_f32_px(point_in_node.y)
);
rw_data.text_index_response = TextIndexResponse(
rw_data.display_list
.as_ref()
.expect("Tried to hit test with no display list")
.text_index(opaque_node, &point_in_node)
);
},
ReflowGoal::NodeGeometryQuery(node) => {
let node = unsafe { ServoLayoutNode::new(&node) };

View File

@ -93,6 +93,7 @@ pub fn synthetic_click_activation(element: &Element,
alt_key,
meta_key,
0,
None,
None);
let event = mouse.upcast::<Event>();
if source == ActivationSource::FromClick {

View File

@ -836,7 +836,8 @@ impl Document {
_button: MouseButton,
client_point: Point2D<f32>,
mouse_event_type: MouseEventType,
node_address: Option<UntrustedNodeAddress>
node_address: Option<UntrustedNodeAddress>,
point_in_node: Option<Point2D<f32>>
) {
let mouse_event_type_string = match mouse_event_type {
MouseEventType::Click => "click".to_owned(),
@ -871,22 +872,25 @@ impl Document {
let client_x = client_point.x as i32;
let client_y = client_point.y as i32;
let click_count = 1;
let event = MouseEvent::new(&self.window,
DOMString::from(mouse_event_type_string),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
click_count,
client_x,
client_y,
client_x,
client_y, // TODO: Get real screen coordinates?
false,
false,
false,
false,
0i16,
None);
let event = MouseEvent::new(
&self.window,
DOMString::from(mouse_event_type_string),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
click_count,
client_x,
client_y,
client_x,
client_y, // TODO: Get real screen coordinates?
false,
false,
false,
false,
0i16,
None,
point_in_node,
);
let event = event.upcast::<Event>();
// https://w3c.github.io/uievents/#trusted-events
@ -943,22 +947,25 @@ impl Document {
let client_x = click_pos.x as i32;
let client_y = click_pos.y as i32;
let event = MouseEvent::new(&self.window,
DOMString::from("dblclick"),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
click_count,
client_x,
client_y,
client_x,
client_y,
false,
false,
false,
false,
0i16,
None);
let event = MouseEvent::new(
&self.window,
DOMString::from("dblclick"),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
click_count,
client_x,
client_y,
client_x,
client_y,
false,
false,
false,
false,
0i16,
None,
None
);
event.upcast::<Event>().fire(target.upcast());
// When a double click occurs, self.last_click_info is left as None so that a
@ -1034,22 +1041,25 @@ impl Document {
let client_x = client_point.x.to_i32().unwrap_or(0);
let client_y = client_point.y.to_i32().unwrap_or(0);
let mouse_event = MouseEvent::new(&self.window,
DOMString::from(event_name),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
0i32,
client_x,
client_y,
client_x,
client_y,
false,
false,
false,
false,
0i16,
None);
let mouse_event = MouseEvent::new(
&self.window,
DOMString::from(event_name),
EventBubbles::Bubbles,
EventCancelable::Cancelable,
Some(&self.window),
0i32,
client_x,
client_y,
client_x,
client_y,
false,
false,
false,
false,
0i16,
None,
None
);
let event = mouse_event.upcast::<Event>();
event.fire(target);
}

View File

@ -11,8 +11,6 @@ use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods;
use dom::bindings::codegen::Bindings::HTMLInputElementBinding;
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen::Bindings::KeyboardEventBinding::KeyboardEventMethods;
use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
@ -1106,23 +1104,19 @@ impl VirtualMethods for HTMLInputElement {
// dispatch_key_event (document.rs) triggers a click event when releasing
// the space key. There's no nice way to catch this so let's use this for
// now.
if !(mouse_event.ScreenX() == 0 && mouse_event.ScreenY() == 0 &&
mouse_event.GetRelatedTarget().is_none()) {
let window = window_from_node(self);
let translated_x = mouse_event.ClientX() + window.PageXOffset();
let translated_y = mouse_event.ClientY() + window.PageYOffset();
let TextIndexResponse(index) = window.text_index_query(
self.upcast::<Node>().to_trusted_node_address(),
translated_x,
translated_y
);
if let Some(i) = index {
self.textinput.borrow_mut().set_edit_point_index(i as usize);
// trigger redraw
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
event.PreventDefault();
}
if let Some(point_in_target) = mouse_event.point_in_target() {
let window = window_from_node(self);
let TextIndexResponse(index) = window.text_index_query(
self.upcast::<Node>().to_trusted_node_address(),
point_in_target
);
if let Some(i) = index {
self.textinput.borrow_mut().set_edit_point_index(i as usize);
// trigger redraw
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
event.PreventDefault();
}
}
}
}
} else if event.type_() == atom!("keydown") && !event.DefaultPrevented() &&

View File

@ -15,6 +15,7 @@ use dom::eventtarget::EventTarget;
use dom::uievent::UIEvent;
use dom::window::Window;
use dom_struct::dom_struct;
use euclid::Point2D;
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::default::Default;
@ -32,6 +33,7 @@ pub struct MouseEvent {
meta_key: Cell<bool>,
button: Cell<i16>,
related_target: MutNullableDom<EventTarget>,
point_in_target: Cell<Option<Point2D<f32>>>
}
impl MouseEvent {
@ -48,6 +50,7 @@ impl MouseEvent {
meta_key: Cell::new(false),
button: Cell::new(0),
related_target: Default::default(),
point_in_target: Cell::new(None),
}
}
@ -57,28 +60,34 @@ impl MouseEvent {
MouseEventBinding::Wrap)
}
pub fn new(window: &Window,
type_: DOMString,
can_bubble: EventBubbles,
cancelable: EventCancelable,
view: Option<&Window>,
detail: i32,
screen_x: i32,
screen_y: i32,
client_x: i32,
client_y: i32,
ctrl_key: bool,
alt_key: bool,
shift_key: bool,
meta_key: bool,
button: i16,
related_target: Option<&EventTarget>) -> DomRoot<MouseEvent> {
pub fn new(
window: &Window,
type_: DOMString,
can_bubble: EventBubbles,
cancelable: EventCancelable,
view: Option<&Window>,
detail: i32,
screen_x: i32,
screen_y: i32,
client_x: i32,
client_y: i32,
ctrl_key: bool,
alt_key: bool,
shift_key: bool,
meta_key: bool,
button: i16,
related_target: Option<&EventTarget>,
point_in_target: Option<Point2D<f32>>
) -> DomRoot<MouseEvent> {
let ev = MouseEvent::new_uninitialized(window);
ev.InitMouseEvent(type_, bool::from(can_bubble), bool::from(cancelable),
view, detail,
screen_x, screen_y, client_x, client_y,
ctrl_key, alt_key, shift_key, meta_key,
button, related_target);
ev.InitMouseEvent(
type_, bool::from(can_bubble), bool::from(cancelable),
view, detail,
screen_x, screen_y, client_x, client_y,
ctrl_key, alt_key, shift_key, meta_key,
button, related_target,
);
ev.point_in_target.set(point_in_target);
ev
}
@ -87,18 +96,24 @@ impl MouseEvent {
init: &MouseEventBinding::MouseEventInit) -> Fallible<DomRoot<MouseEvent>> {
let bubbles = EventBubbles::from(init.parent.parent.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.parent.parent.cancelable);
let event = MouseEvent::new(window,
type_,
bubbles,
cancelable,
init.parent.parent.view.r(),
init.parent.parent.detail,
init.screenX, init.screenY,
init.clientX, init.clientY, init.parent.ctrlKey,
init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
init.button, init.relatedTarget.r());
let event = MouseEvent::new(
window,
type_,
bubbles,
cancelable,
init.parent.parent.view.r(),
init.parent.parent.detail,
init.screenX, init.screenY,
init.clientX, init.clientY, init.parent.ctrlKey,
init.parent.altKey, init.parent.shiftKey, init.parent.metaKey,
init.button, init.relatedTarget.r(), None
);
Ok(event)
}
pub fn point_in_target(&self) -> Option<Point2D<f32>> {
self.point_in_target.get()
}
}
impl MouseEventMethods for MouseEvent {
@ -166,22 +181,24 @@ impl MouseEventMethods for MouseEvent {
}
// https://w3c.github.io/uievents/#widl-MouseEvent-initMouseEvent
fn InitMouseEvent(&self,
type_arg: DOMString,
can_bubble_arg: bool,
cancelable_arg: bool,
view_arg: Option<&Window>,
detail_arg: i32,
screen_x_arg: i32,
screen_y_arg: i32,
client_x_arg: i32,
client_y_arg: i32,
ctrl_key_arg: bool,
alt_key_arg: bool,
shift_key_arg: bool,
meta_key_arg: bool,
button_arg: i16,
related_target_arg: Option<&EventTarget>) {
fn InitMouseEvent(
&self,
type_arg: DOMString,
can_bubble_arg: bool,
cancelable_arg: bool,
view_arg: Option<&Window>,
detail_arg: i32,
screen_x_arg: i32,
screen_y_arg: i32,
client_x_arg: i32,
client_y_arg: i32,
ctrl_key_arg: bool,
alt_key_arg: bool,
shift_key_arg: bool,
meta_key_arg: bool,
button_arg: i16,
related_target_arg: Option<&EventTarget>,
) {
if self.upcast::<Event>().dispatching() {
return;
}

View File

@ -1481,8 +1481,12 @@ impl Window {
self.layout_rpc.margin_style()
}
pub fn text_index_query(&self, node: TrustedNodeAddress, mouse_x: i32, mouse_y: i32) -> TextIndexResponse {
if !self.reflow(ReflowGoal::TextIndexQuery(node, mouse_x, mouse_y), ReflowReason::Query) {
pub fn text_index_query(
&self,
node: TrustedNodeAddress,
point_in_node: Point2D<f32>
) -> TextIndexResponse {
if !self.reflow(ReflowGoal::TextIndexQuery(node, point_in_node), ReflowReason::Query) {
return TextIndexResponse(None);
}
self.layout_rpc.text_index()

View File

@ -2191,8 +2191,15 @@ impl ScriptThread {
self.handle_resize_event(pipeline_id, new_size, size_type);
}
MouseButtonEvent(event_type, button, point, node_address) => {
self.handle_mouse_event(pipeline_id, event_type, button, point, node_address);
MouseButtonEvent(event_type, button, point, node_address, point_in_node) => {
self.handle_mouse_event(
pipeline_id,
event_type,
button,
point,
node_address,
point_in_node
);
}
MouseMoveEvent(point, node_address) => {
@ -2303,7 +2310,8 @@ impl ScriptThread {
mouse_event_type: MouseEventType,
button: MouseButton,
point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>
node_address: Option<UntrustedNodeAddress>,
point_in_node: Option<Point2D<f32>>
) {
let document = match { self.documents.borrow().find_document(pipeline_id) } {
Some(document) => document,
@ -2314,7 +2322,8 @@ impl ScriptThread {
button,
point,
mouse_event_type,
node_address
node_address,
point_in_node
);
}

View File

@ -120,7 +120,7 @@ pub enum ReflowGoal {
ResolvedStyleQuery(TrustedNodeAddress, Option<PseudoElement>, PropertyId),
OffsetParentQuery(TrustedNodeAddress),
MarginStyleQuery(TrustedNodeAddress),
TextIndexQuery(TrustedNodeAddress, i32, i32),
TextIndexQuery(TrustedNodeAddress, Point2D<f32>),
NodesFromPointQuery(Point2D<f32>, NodesFromPointQueryType),
}

View File

@ -432,7 +432,13 @@ pub enum CompositorEvent {
/// The window was resized.
ResizeEvent(WindowSizeData, WindowSizeType),
/// A mouse button state changed.
MouseButtonEvent(MouseEventType, MouseButton, Point2D<f32>, Option<UntrustedNodeAddress>),
MouseButtonEvent(
MouseEventType,
MouseButton,
Point2D<f32>,
Option<UntrustedNodeAddress>,
Option<Point2D<f32>>
),
/// The mouse was moved over a point (or was moved out of the recognizable region).
MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>),
/// A touch event was generated with a touch ID and location.