Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: webkit/glue/webview_impl.cc

Issue 160065: Paste at the beginning of a middle click rather than after letting the page h... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 Google Inc. All Rights Reserved. 2 * Copyright 2007 Google Inc. All Rights Reserved.
3 * 3 *
4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
5 * 5 *
6 * ***** BEGIN LICENSE BLOCK ***** 6 * ***** BEGIN LICENSE BLOCK *****
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 target_frame->eventHandler()->sendContextMenuEvent(pme); 535 target_frame->eventHandler()->sendContextMenuEvent(pme);
536 context_menu_allowed_ = false; 536 context_menu_allowed_ = false;
537 // Actually showing the context menu is handled by the ContextMenuClient 537 // Actually showing the context menu is handled by the ContextMenuClient
538 // implementation... 538 // implementation...
539 } 539 }
540 540
541 void WebViewImpl::MouseUp(const WebMouseEvent& event) { 541 void WebViewImpl::MouseUp(const WebMouseEvent& event) {
542 if (!main_frame() || !main_frame()->frameview()) 542 if (!main_frame() || !main_frame()->frameview())
543 return; 543 return;
544 544
545 mouseCaptureLost();
546 main_frame()->frame()->eventHandler()->handleMouseReleaseEvent(
547 MakePlatformMouseEvent(main_frame()->frameview(), event));
548
549 #if defined(OS_WIN)
550 // Dispatch the contextmenu event regardless of if the click was swallowed.
551 // On Mac/Linux, we handle it on mouse down, not up.
552 if (event.button == WebMouseEvent::ButtonRight)
553 MouseContextMenu(event);
554 #endif
555
556 #if defined(OS_LINUX) 545 #if defined(OS_LINUX)
557 // If the event was a middle click, attempt to copy text into the focused 546 // If the event was a middle click, attempt to copy text into the focused
558 // frame. 547 // frame. We execute this before we let the page have a go at the event
548 // because the page may change what is focused during in its event handler.
559 // 549 //
560 // This code is in the mouse up handler. There is some debate about putting 550 // This code is in the mouse up handler. There is some debate about putting
561 // this here, as opposed to the mouse down handler. 551 // this here, as opposed to the mouse down handler.
562 // xterm: pastes on up. 552 // xterm: pastes on up.
563 // GTK: pastes on down. 553 // GTK: pastes on down.
564 // Firefox: pastes on up. 554 // Firefox: pastes on up.
565 // Midori: couldn't paste at all with 0.1.2 555 // Midori: couldn't paste at all with 0.1.2
566 // 556 //
567 // There is something of a webcompat angle to this well, as highlighted by 557 // There is something of a webcompat angle to this well, as highlighted by
568 // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on 558 // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
569 // down then the text is pasted just before the onclick handler runs and 559 // down then the text is pasted just before the onclick handler runs and
570 // clears the text box. So it's important this happens after the 560 // clears the text box. So it's important this happens after the
571 // handleMouseReleaseEvent() earlier in this function 561 // handleMouseReleaseEvent() earlier in this function
572 if (event.button == WebMouseEvent::ButtonMiddle) { 562 if (event.button == WebMouseEvent::ButtonMiddle) {
573 Frame* focused = GetFocusedWebCoreFrame(); 563 Frame* focused = GetFocusedWebCoreFrame();
574 if (!focused) 564 if (focused) {
575 return; 565 Editor* editor = focused->editor();
576 Editor* editor = focused->editor(); 566 if (editor && editor->canEdit())
577 if (!editor || !editor->canEdit()) 567 delegate_->PasteFromSelectionClipboard();
578 return; 568 }
569 }
570 #endif
579 571
580 delegate_->PasteFromSelectionClipboard(); 572 mouseCaptureLost();
581 } 573 main_frame()->frame()->eventHandler()->handleMouseReleaseEvent(
574 MakePlatformMouseEvent(main_frame()->frameview(), event));
575
576 #if defined(OS_WIN)
577 // Dispatch the contextmenu event regardless of if the click was swallowed.
578 // On Mac/Linux, we handle it on mouse down, not up.
579 if (event.button == WebMouseEvent::ButtonRight)
580 MouseContextMenu(event);
582 #endif 581 #endif
583 } 582 }
584 583
585 void WebViewImpl::MouseWheel(const WebMouseWheelEvent& event) { 584 void WebViewImpl::MouseWheel(const WebMouseWheelEvent& event) {
586 MakePlatformWheelEvent platform_event(main_frame()->frameview(), event); 585 MakePlatformWheelEvent platform_event(main_frame()->frameview(), event);
587 main_frame()->frame()->eventHandler()->handleWheelEvent(platform_event); 586 main_frame()->frame()->eventHandler()->handleWheelEvent(platform_event);
588 } 587 }
589 588
590 bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { 589 bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) {
591 DCHECK((event.type == WebInputEvent::RawKeyDown) || 590 DCHECK((event.type == WebInputEvent::RawKeyDown) ||
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 1920
1922 return document->focusedNode(); 1921 return document->focusedNode();
1923 } 1922 }
1924 1923
1925 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { 1924 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) {
1926 IntPoint doc_point( 1925 IntPoint doc_point(
1927 page_->mainFrame()->view()->windowToContents(pos)); 1926 page_->mainFrame()->view()->windowToContents(pos));
1928 return page_->mainFrame()->eventHandler()-> 1927 return page_->mainFrame()->eventHandler()->
1929 hitTestResultAtPoint(doc_point, false); 1928 hitTestResultAtPoint(doc_point, false);
1930 } 1929 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698