Skip to content

Commit

Permalink
Revert middle click related changes
Browse files Browse the repository at this point in the history
This is the CL to revert the related middle button click changes. We
decided to revert those changes because the issues that were caused by
suppressing click event for middle button was hard to fix without having
that event. Particularly the ability to prevent opening a new tab which
can be done by "preventDefault"ing the click event of middle button was
removed as the result of the original change. For now we revert these
changes and we pursue the line of adding a new event for non-primary
button click to be able to fix these problem in a more clean way.

Revert "Prevent sending click event for non primary button"

This reverts commit 76fea00.

Revert "Dispatch middle click manually by tracking mouse"

This reverts commit 88eb111.

Revert "Fix history page middle click action"

This reverts commit a154aed.

BUG=255,618593,617444,611019,617875
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2107093003
Cr-Commit-Position: refs/heads/master@{#403496}
(cherry picked from commit 4d9d918)

Review URL: https://codereview.chromium.org/2124533002 .

Cr-Commit-Position: refs/branch-heads/2743@{#580}
Cr-Branched-From: 2b3ae3b-refs/heads/master@{#394939}
  • Loading branch information
dtapuska committed Jul 4, 2016
1 parent 5f87571 commit eaaefc2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 50 deletions.
1 change: 0 additions & 1 deletion chrome/browser/resources/history/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

<include src="../synthetic_middleclick.js">
<include src="../uber/uber_utils.js">
<include src="history_focus_manager.js">

Expand Down
1 change: 0 additions & 1 deletion chrome/browser/resources/ntp4/new_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<script src="../../../../ui/webui/resources/js/cr/ui/context_menu_button.js"></script>
<script src="../../../../ui/webui/resources/js/cr/ui/touch_handler.js"></script>

<script src="../synthetic_middleclick.js"></script>
<script src="tile_page.js"></script>
<script src="apps_page.js"></script>
<script src="dot_list.js"></script>
Expand Down
29 changes: 0 additions & 29 deletions chrome/browser/resources/synthetic_middleclick.js

This file was deleted.

22 changes: 22 additions & 0 deletions chrome/browser/ui/browser_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,28 @@ IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) {
RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
}

// Middle-clicks open in a background tab.
#if defined(OS_LINUX)
// http://crbug.com/396347
#define MAYBE_WindowOpenMiddleClickTest DISABLED_WindowOpenMiddleClickTest
#else
#define MAYBE_WindowOpenMiddleClickTest WindowOpenMiddleClickTest
#endif
IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_WindowOpenMiddleClickTest) {
int modifiers = 0;
blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle;
WindowOpenDisposition disposition = NEW_BACKGROUND_TAB;
RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
}

// Shift-middle-clicks open in a foreground tab.
IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftMiddleClickTest) {
int modifiers = blink::WebInputEvent::ShiftKey;
blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle;
WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition);
}

// Tests for clicking on normal links.

IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
-ChromeServiceWorkerFetchPPAPITest.SameOriginCredentials
-ClickModifierTest.WindowOpenBasicClickTest
-ClickModifierTest.WindowOpenControlShiftClickTest
-ClickModifierTest.WindowOpenShiftMiddleClickTest
-CommonNameMismatchBrowserTest.CheckWWWSubdomainMismatchInverse
-CommonNameMismatchBrowserTest.ShouldShowWWWSubdomainMismatchInterstitial
-ContentSettingsExceptionsAreaBrowserTest.OpenIncognitoWindow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Left Mouse Button
PASS eventLog is "mousedown(0) mouseup(0) click(0) mousedown(0) mouseup(0) click(0) dblclick(0) "
Middle Mouse Button
PASS eventLog is "mousedown(1) mouseup(1) mousedown(1) mouseup(1) "
PASS eventLog is "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) "
Right Mouse Button
PASS eventLog is "mousedown(2) mouseup(2) mousedown(2) mouseup(2) "
PASS successfullyParsed is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ function testEvents(description, button, expectedString) {

if (window.eventSender) {
testEvents("Left Mouse Button", 0, "mousedown(0) mouseup(0) click(0) mousedown(0) mouseup(0) click(0) dblclick(0) ");
testEvents("Middle Mouse Button", 1, "mousedown(1) mouseup(1) mousedown(1) mouseup(1) ");
testEvents("Middle Mouse Button", 1, "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) ");
testEvents("Right Mouse Button", 2, "mousedown(2) mouseup(2) mousedown(2) mouseup(2) ");
}
4 changes: 0 additions & 4 deletions third_party/WebKit/Source/core/events/MouseEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,6 @@ DispatchEventResult MouseEventDispatchMediator::dispatchEvent(EventDispatcher& d
if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2)
return dispatchResult;

// Do not send dblclick event for non-primary button clicks.
if (mouseEvent.button() != MouseButton::LeftButton)
return dispatchResult;

// Special case: If it's a double click event, we also send the dblclick event. This is not part
// of the DOM specs, but is used for compatibility with the ondblclick="" attribute. This is treated
// as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
Expand Down
15 changes: 2 additions & 13 deletions third_party/WebKit/Source/core/input/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,19 +1444,8 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve
// because the mouseup dispatch above has already updated it
// correctly. Moreover, clickTargetNode is different from
// mev.innerNode at drag-release.

MouseEvent* event = MouseEvent::create(
EventTypeNames::click,
clickTargetNode->document().domWindow(),
mev.event(), m_clickCount, nullptr);

// This is to suppress sending click events for non-primary buttons.
// But still doing default action like opening a new tab for middle
// click (crbug.com/255).
if (mev.event().button() != MouseButton::LeftButton)
event->stopPropagation();

clickEventResult = toWebInputEventResult(clickTargetNode->dispatchEvent(event));
clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMouseEvent(mev.event(),
EventTypeNames::click, m_clickCount));
}
}

Expand Down

0 comments on commit eaaefc2

Please sign in to comment.