Skip to content

Commit

Permalink
Do not paint when sending events from EventSender
Browse files Browse the repository at this point in the history
EventSender only needs to update the lifecycle to PrePaint and
does not need to paint. Two tests have been updated that
relied on EventSender's paints for invalidation tracking.

TBR=pfeldman@chromium.org

Bug: 841423
Change-Id: I8a1ef02870241d9b4adecf3a3f905272f845ef0f
Reviewed-on: https://chromium-review.googlesource.com/1062907
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560168}
  • Loading branch information
progers authored and Commit Bot committed May 19, 2018
1 parent 6d7f5b7 commit 028845b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
28 changes: 14 additions & 14 deletions content/shell/test_runner/event_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ void EventSender::PointerDown(int button_number,
int tiltX,
int tiltY) {
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

DCHECK_NE(-1, button_number);

Expand Down Expand Up @@ -1466,7 +1466,7 @@ void EventSender::PointerUp(int button_number,
int tiltX,
int tiltY) {
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

DCHECK_NE(-1, button_number);

Expand Down Expand Up @@ -1732,7 +1732,7 @@ void EventSender::KeyDown(const std::string& code_str,
// EventSender.m forces a layout here, with at least one
// test (fast/forms/focus-control-to-page.html) relying on this.
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

// In the browser, if a keyboard event corresponds to an editor command,
// the command will be dispatched to the renderer just before dispatching
Expand Down Expand Up @@ -1775,7 +1775,7 @@ void EventSender::ClearKillRing() {}

std::vector<std::string> EventSender::ContextClick() {
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

UpdateClickCountForButton(WebMouseEvent::Button::kRight);

Expand Down Expand Up @@ -1964,7 +1964,7 @@ void EventSender::GestureFlingCancel() {
// choose Touchpad here.

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

HandleInputEventOnViewOrPopup(event);
}
Expand Down Expand Up @@ -2005,7 +2005,7 @@ void EventSender::GestureFlingStart(float x,
event.data.fling_start.velocity_y = velocity_y;

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

HandleInputEventOnViewOrPopup(event);
}
Expand Down Expand Up @@ -2196,7 +2196,7 @@ void EventSender::MouseScrollBy(gin::Arguments* args,

void EventSender::MouseMoveTo(gin::Arguments* args) {
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

double x;
double y;
Expand Down Expand Up @@ -2253,7 +2253,7 @@ void EventSender::MouseLeave(
blink::WebPointerProperties::PointerType pointerType,
int pointerId) {
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

WebMouseEvent event(WebInputEvent::kMouseLeave,
ModifiersForPointer(pointerId), GetCurrentEventTime());
Expand Down Expand Up @@ -2309,7 +2309,7 @@ void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
DCHECK_LE(touch_points_.size(),
static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap));
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

base::TimeTicks time_stamp = GetCurrentEventTime();
blink::WebInputEvent::DispatchType dispatch_type =
Expand Down Expand Up @@ -2560,7 +2560,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type, gin::Arguments* args) {
event.SetPositionInScreen(event.PositionInWidget());

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

WebInputEventResult result = HandleInputEventOnViewOrPopup(event);

Expand Down Expand Up @@ -2600,7 +2600,7 @@ WebMouseWheelEvent EventSender::GetMouseWheelEvent(gin::Arguments* args,
// determined before we send events (as well as all the other methods
// that send an event do).
if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

double horizontal;
double vertical;
Expand Down Expand Up @@ -2879,7 +2879,7 @@ void EventSender::SendGesturesForMouseWheelEvent(
}

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);

HandleInputEventOnViewOrPopup(begin_event);

Expand All @@ -2895,7 +2895,7 @@ void EventSender::SendGesturesForMouseWheelEvent(
begin_event.data.scroll_begin.delta_hint_units;

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);
HandleInputEventOnViewOrPopup(update_event);

WebGestureEvent end_event(WebInputEvent::kGestureScrollEnd,
Expand All @@ -2906,7 +2906,7 @@ void EventSender::SendGesturesForMouseWheelEvent(
begin_event.data.scroll_begin.delta_hint_units;

if (force_layout_on_events_)
widget()->UpdateAllLifecyclePhases();
widget()->UpdateLifecycle(blink::WebWidget::LifecycleUpdate::kPrePaint);
HandleInputEventOnViewOrPopup(end_event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@
</style>
<head>
<script type="text/javascript">
window.testIsAsync = true;
function repaintTest() {
row = document.getElementById('row1');
rowRect = row.getBoundingClientRect();
x = rowRect.left + 75;
y = rowRect.top;
document.body.offsetTop;
if (window.eventSender) {
eventSender.mouseMoveTo(x, y + 1);
eventSender.mouseMoveTo(x, y - 1);
}
requestAnimationFrame(function() {
// Move cursor over row.
if (window.eventSender)
eventSender.mouseMoveTo(x, y + 1);
requestAnimationFrame(function() {
// Move cursor off row.
if (window.eventSender)
eventSender.mouseMoveTo(x, y - 1);
finishRepaintTest();
});
});
}
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<!DOCTYPE html>
<script src="../resources/text-based-repaint.js"></script>
<script>
window.testIsAsync = true;
function repaintTest() {
editor.focus();
if (!window.eventSender)
return;
eventSender.keyDown('a');
eventSender.keyDown('b');
eventSender.keyDown('c');
requestAnimationFrame(function() {
editor.focus();
requestAnimationFrame(function() {
if (window.eventSender)
eventSender.keyDown('a');
requestAnimationFrame(function() {
if (window.eventSender)
eventSender.keyDown('b');
requestAnimationFrame(function() {
if (window.eventSender)
eventSender.keyDown('c');
finishRepaintTest();
});
});
});
});
}
onload = runRepaintAndPixelTest;
</script>
Expand Down

0 comments on commit 028845b

Please sign in to comment.