mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #18933 - mrobinson:wr-text-index, r=jdm
Use WebRender to compute text index on click events 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18933) <!-- Reviewable:end -->
This commit is contained in:
commit
4cf2ce66fc
12 changed files with 194 additions and 370 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue