| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 break; | 823 break; |
| 824 } | 824 } |
| 825 default: | 825 default: |
| 826 WEBKIT_ASSERT_NOT_REACHED(); | 826 WEBKIT_ASSERT_NOT_REACHED(); |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 | 829 |
| 830 replayingSavedEvents = false; | 830 replayingSavedEvents = false; |
| 831 } | 831 } |
| 832 | 832 |
| 833 // Because actual context menu is implemented by the browser side, | 833 // Because actual context menu is implemented by the browser side, |
| 834 // this function does only what LayoutTests are expecting: | 834 // this function does only what LayoutTests are expecting: |
| 835 // - Many test checks the count of items. So returning non-zero value makes sens
e. | 835 // - Many test checks the count of items. So returning non-zero value makes sens
e. |
| 836 // - Some test compares the count before and after some action. So changing the
count based on flags | 836 // - Some test compares the count before and after some action. So changing the
count based on flags |
| 837 // also makes sense. This function is doing such for some flags. | 837 // also makes sense. This function is doing such for some flags. |
| 838 // - Some test even checks actual string content. So providing it would be also
helpful. | 838 // - Some test even checks actual string content. So providing it would be also
helpful. |
| 839 // | 839 // |
| 840 static vector<WebString> makeMenuItemStringsFor(WebContextMenuData* contextMenu,
WebTestDelegate* delegate) | 840 static vector<WebString> makeMenuItemStringsFor(WebContextMenuData* contextMenu,
WebTestDelegate* delegate) |
| 841 { | 841 { |
| 842 // These constants are based on Safari's context menu because tests are made
for it. | 842 // These constants are based on Safari's context menu because tests are made
for it. |
| 843 static const char* nonEditableMenuStrings[] = { "Back", "Reload Page", "Open
in Dashbaord", "<separator>", "View Source", "Save Page As", "Print Page", "Ins
pect Element", 0 }; | 843 static const char* nonEditableMenuStrings[] = { "Back", "Reload Page", "Open
in Dashbaord", "<separator>", "View Source", "Save Page As", "Print Page", "Ins
pect Element", 0 }; |
| 844 static const char* editableMenuStrings[] = { "Cut", "Copy", "<separator>", "
Paste", "Spelling and Grammar", "Substitutions, Transformations", "Font", "Speec
h", "Paragraph Direction", "<separator>", 0 }; | 844 static const char* editableMenuStrings[] = { "Cut", "Copy", "<separator>", "
Paste", "Spelling and Grammar", "Substitutions, Transformations", "Font", "Speec
h", "Paragraph Direction", "<separator>", 0 }; |
| 845 | 845 |
| 846 // This is possible because mouse events are cancelleable. | 846 // This is possible because mouse events are cancelleable. |
| 847 if (!contextMenu) | 847 if (!contextMenu) |
| 848 return vector<WebString>(); | 848 return vector<WebString>(); |
| 849 | 849 |
| 850 vector<WebString> strings; | 850 vector<WebString> strings; |
| 851 | 851 |
| 852 if (contextMenu->isEditable) { | 852 if (contextMenu->isEditable) { |
| 853 for (const char** item = editableMenuStrings; *item; ++item) | 853 for (const char** item = editableMenuStrings; *item; ++item) |
| 854 strings.push_back(WebString::fromUTF8(*item)); | 854 strings.push_back(WebString::fromUTF8(*item)); |
| 855 WebVector<WebString> suggestions; | 855 WebVector<WebString> suggestions; |
| 856 MockSpellCheck::fillSuggestionList(contextMenu->misspelledWord, &suggest
ions); | 856 MockSpellCheck::fillSuggestionList(contextMenu->misspelledWord, &suggest
ions); |
| 857 for (size_t i = 0; i < suggestions.size(); ++i) | 857 for (size_t i = 0; i < suggestions.size(); ++i) |
| 858 strings.push_back(suggestions[i]); | 858 strings.push_back(suggestions[i]); |
| 859 } else { | 859 } else { |
| 860 for (const char** item = nonEditableMenuStrings; *item; ++item) | 860 for (const char** item = nonEditableMenuStrings; *item; ++item) |
| 861 strings.push_back(WebString::fromUTF8(*item)); | 861 strings.push_back(WebString::fromUTF8(*item)); |
| 862 } | 862 } |
| 863 | 863 |
| 864 return strings; | 864 return strings; |
| 865 } | 865 } |
| 866 | 866 |
| 867 void EventSender::contextClick(const CppArgumentList& arguments, CppVariant* res
ult) | 867 void EventSender::contextClick(const CppArgumentList& arguments, CppVariant* res
ult) |
| 868 { | 868 { |
| 869 if (shouldForceLayoutOnEvents()) | 869 if (shouldForceLayoutOnEvents()) |
| 870 webview()->layout(); | 870 webview()->layout(); |
| 871 | 871 |
| 872 updateClickCountForButton(WebMouseEvent::ButtonRight); | 872 updateClickCountForButton(WebMouseEvent::ButtonRight); |
| 873 | 873 |
| 874 // Clears last context menu data because we need to know if the context menu
be requested | 874 // Clears last context menu data because we need to know if the context menu
be requested |
| 875 // after following mouse events. | 875 // after following mouse events. |
| 876 m_lastContextMenuData.reset(); | 876 m_lastContextMenuData.reset(); |
| 877 | 877 |
| 878 // Generate right mouse down and up. | 878 // Generate right mouse down and up. |
| 879 WebMouseEvent event; | 879 WebMouseEvent event; |
| 880 // This is a hack to work around only allowing a single pressed button since
we want to | 880 // This is a hack to work around only allowing a single pressed button since
we want to |
| 881 // test the case where both the left and right mouse buttons are pressed. | 881 // test the case where both the left and right mouse buttons are pressed. |
| 882 if (pressedButton == WebMouseEvent::ButtonNone) | 882 if (pressedButton == WebMouseEvent::ButtonNone) |
| 883 pressedButton = WebMouseEvent::ButtonRight; | 883 pressedButton = WebMouseEvent::ButtonRight; |
| 884 initMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight, lastMou
sePos, &event, getCurrentEventTimeSec(m_delegate)); | 884 initMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight, lastMou
sePos, &event, getCurrentEventTimeSec(m_delegate)); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 { | 1374 { |
| 1375 result->setNull(); | 1375 result->setNull(); |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 void EventSender::clearKillRing(const CppArgumentList&, CppVariant* result) | 1378 void EventSender::clearKillRing(const CppArgumentList&, CppVariant* result) |
| 1379 { | 1379 { |
| 1380 result->setNull(); | 1380 result->setNull(); |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 } | 1383 } |
| OLD | NEW |