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

Side by Side Diff: webkit/tools/test_shell/event_sending_controller.cc

Issue 5363002: Revert 67248 - TestShell: Backported EventSender.contextClick() improvement t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 | webkit/tools/test_shell/mock_spellcheck.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the definition for EventSendingController. 5 // This file contains the definition for EventSendingController.
6 // 6 //
7 // Some notes about drag and drop handling: 7 // Some notes about drag and drop handling:
8 // Windows drag and drop goes through a system call to DoDragDrop. At that 8 // Windows drag and drop goes through a system call to DoDragDrop. At that
9 // point, program control is given to Windows which then periodically makes 9 // point, program control is given to Windows which then periodically makes
10 // callbacks into the webview. This won't work for layout tests, so instead, 10 // callbacks into the webview. This won't work for layout tests, so instead,
(...skipping 17 matching lines...) Expand all
28 #include "base/time.h" 28 #include "base/time.h"
29 #include "base/string_number_conversions.h" 29 #include "base/string_number_conversions.h"
30 #include "base/string_util.h" 30 #include "base/string_util.h"
31 #include "base/utf_string_conversions.h" 31 #include "base/utf_string_conversions.h"
32 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" 32 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
33 #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" 33 #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
34 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" 34 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
35 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 35 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
36 #include "third_party/WebKit/WebKit/chromium/public/WebTouchPoint.h" 36 #include "third_party/WebKit/WebKit/chromium/public/WebTouchPoint.h"
37 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" 37 #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
38 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
39 #include "webkit/glue/webkit_glue.h" 38 #include "webkit/glue/webkit_glue.h"
40 #include "webkit/tools/test_shell/test_shell.h" 39 #include "webkit/tools/test_shell/test_shell.h"
41 #include "webkit/tools/test_shell/test_webview_delegate.h" 40 #include "webkit/tools/test_shell/test_webview_delegate.h"
42 41
43 #if defined(OS_WIN) 42 #if defined(OS_WIN)
44 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" 43 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h"
45 using WebKit::WebInputEventFactory; 44 using WebKit::WebInputEventFactory;
46 #endif 45 #endif
47 46
48 // TODO(mpcomplete): layout before each event? 47 // TODO(mpcomplete): layout before each event?
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 break; 763 break;
765 } 764 }
766 default: 765 default:
767 NOTREACHED(); 766 NOTREACHED();
768 } 767 }
769 } 768 }
770 769
771 replaying_saved_events = false; 770 replaying_saved_events = false;
772 } 771 }
773 772
774 // Because actual context menu is implemented by the browser side,
775 // this function does only what LayoutTests are expecting:
776 // - Many test checks the count of items. So returning non-zero value
777 // makes sense.
778 // - Some test compares the count before and after some action. So
779 // changing the count based on flags also makes sense. This function
780 // is doing such for some flags.
781 // - Some test even checks actual string content. So providing it
782 // would be also helpful.
783 static std::vector<WebString>
784 MakeMenuItemStringsFor(const WebKit::WebContextMenuData* context_menu,
785 MockSpellCheck* spellcheck) {
786 // These constants are based on Safari's context menu because tests
787 // are made for it.
788 static const char* kNonEditableMenuStrings[] = {
789 "Back", "Reload Page", "Open in Dashbaord", "<separator>",
790 "View Source", "Save Page As", "Print Page", "Inspect Element",
791 0 };
792 static const char* kEditableMenuStrings[] = {
793 "Cut", "Copy", "<separator>", "Paste", "Spelling and Grammar",
794 "Substitutions, Transformations", "Font", "Speech",
795 "Paragraph Direction", "<separator>", 0 };
796
797 // This is possible because mouse events are cancelleable.
798 if (!context_menu)
799 return std::vector<WebString>();
800
801 std::vector<WebString> strings;
802
803 if (context_menu->isEditable) {
804 for (const char** item = kEditableMenuStrings; *item; ++item)
805 strings.push_back(WebString::fromUTF8(*item));
806 std::vector<string16> suggestions;
807 spellcheck->FillSuggestions(context_menu->misspelledWord, &suggestions);
808 for (size_t i = 0; i < suggestions.size(); ++i)
809 strings.push_back(WebString(suggestions[i]));
810 } else {
811 for (const char** item = kNonEditableMenuStrings; *item; ++item)
812 strings.push_back(WebString::fromUTF8(*item));
813 }
814
815 return strings;
816 }
817
818 void EventSendingController::contextClick( 773 void EventSendingController::contextClick(
819 const CppArgumentList& args, CppVariant* result) { 774 const CppArgumentList& args, CppVariant* result) {
820 result->SetNull(); 775 result->SetNull();
821 776
822 webview()->layout(); 777 webview()->layout();
823 778
824 // Clears last context menu data because we need to know if the
825 // context menu be requested after following mouse events.
826 shell_->delegate()->ClearContextMenuData();
827
828 UpdateClickCountForButton(WebMouseEvent::ButtonRight); 779 UpdateClickCountForButton(WebMouseEvent::ButtonRight);
829 780
830 // Generate right mouse down and up. 781 // Generate right mouse down and up.
831 782
832 WebMouseEvent event; 783 WebMouseEvent event;
833 pressed_button_ = WebMouseEvent::ButtonRight; 784 pressed_button_ = WebMouseEvent::ButtonRight;
834 InitMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight, 785 InitMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight,
835 last_mouse_pos_, &event); 786 last_mouse_pos_, &event);
836 webview()->handleInputEvent(event); 787 webview()->handleInputEvent(event);
837 788
838 InitMouseEvent(WebInputEvent::MouseUp, WebMouseEvent::ButtonRight, 789 InitMouseEvent(WebInputEvent::MouseUp, WebMouseEvent::ButtonRight,
839 last_mouse_pos_, &event); 790 last_mouse_pos_, &event);
840 webview()->handleInputEvent(event); 791 webview()->handleInputEvent(event);
841 792
842 pressed_button_ = WebMouseEvent::ButtonNone; 793 pressed_button_ = WebMouseEvent::ButtonNone;
843
844 result->Set(WebKit::WebBindings::makeStringArray(
845 MakeMenuItemStringsFor(
846 shell_->delegate()->last_context_menu_data(),
847 shell_->delegate()->mock_spellcheck())));
848
849 } 794 }
850 795
851 void EventSendingController::scheduleAsynchronousClick( 796 void EventSendingController::scheduleAsynchronousClick(
852 const CppArgumentList& args, CppVariant* result) { 797 const CppArgumentList& args, CppVariant* result) {
853 result->SetNull(); 798 result->SetNull();
854 799
855 MessageLoop::current()->PostTask(FROM_HERE, 800 MessageLoop::current()->PostTask(FROM_HERE,
856 method_factory_.NewRunnableMethod(&EventSendingController::mouseDown, 801 method_factory_.NewRunnableMethod(&EventSendingController::mouseDown,
857 args, static_cast<CppVariant*>(NULL))); 802 args, static_cast<CppVariant*>(NULL)));
858 MessageLoop::current()->PostTask(FROM_HERE, 803 MessageLoop::current()->PostTask(FROM_HERE,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1017
1073 void EventSendingController::fireKeyboardEventsToElement( 1018 void EventSendingController::fireKeyboardEventsToElement(
1074 const CppArgumentList& args, CppVariant* result) { 1019 const CppArgumentList& args, CppVariant* result) {
1075 result->SetNull(); 1020 result->SetNull();
1076 } 1021 }
1077 1022
1078 void EventSendingController::clearKillRing( 1023 void EventSendingController::clearKillRing(
1079 const CppArgumentList& args, CppVariant* result) { 1024 const CppArgumentList& args, CppVariant* result) {
1080 result->SetNull(); 1025 result->SetNull();
1081 } 1026 }
OLDNEW
« no previous file with comments | « no previous file | webkit/tools/test_shell/mock_spellcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698