Changeset 87932 in webkit
- Timestamp:
- Jun 2, 2011 11:08:02 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87931 r87932 1 2011-06-02 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r87920. 4 http://trac.webkit.org/changeset/87920 5 https://bugs.webkit.org/show_bug.cgi?id=61943 6 7 This patch does not build in Win Builder (dbg)(shared) 8 downstream (Requested by abarth|gardener on #webkit). 9 10 * platform/chromium/PopupMenuChromium.cpp: 11 (WebCore::PopupContainer::showPopup): 12 (WebCore::PopupListBox::handleMouseReleaseEvent): 13 (WebCore::PopupListBox::acceptIndex): 14 1 15 2011-06-02 Dimitri Glazkov <dglazkov@chromium.org> 2 16 -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
r87920 r87932 189 189 190 190 // Accepts the selected index as the value to be displayed in the <select> widget on 191 // the web page, and closes the popup. Returns true if index is accepted.192 boolacceptIndex(int index);191 // the web page, and closes the popup. 192 void acceptIndex(int index); 193 193 194 194 // Clears the selection (so no row appears selected). … … 278 278 // If width exeeds screen width, we have to clip it. 279 279 int m_maxWindowWidth; 280 281 // To forward last mouse release event.282 RefPtr<Node> m_focusedNode;283 280 }; 284 281 … … 411 408 { 412 409 m_frameView = view; 413 listBox()->m_focusedNode = m_frameView->frame()->document()->focusedNode();414 410 415 411 ChromeClientChromium* chromeClient = chromeClientChromium(); … … 677 673 return true; 678 674 679 // Need to check before calling acceptIndex(), because m_popupClient might be removed in acceptIndex() calling because of event handler. 680 bool isSelectPopup = m_popupClient->menuStyle().menuType() == PopupMenuStyle::SelectPopup; 681 if (acceptIndex(pointToRowIndex(event.pos())) && m_focusedNode && isSelectPopup) { 682 m_focusedNode->dispatchMouseEvent(event, eventNames().mouseupEvent); 683 m_focusedNode->dispatchMouseEvent(event, eventNames().clickEvent); 684 685 // Clear m_focusedNode here, because we cannot clear in hidePopup() which is called before dispatchMouseEvent() is called. 686 m_focusedNode = 0; 687 } 688 675 acceptIndex(pointToRowIndex(event.pos())); 689 676 return true; 690 677 } … … 1082 1069 } 1083 1070 1084 boolPopupListBox::acceptIndex(int index)1071 void PopupListBox::acceptIndex(int index) 1085 1072 { 1086 1073 // Clear m_acceptedIndexOnAbandon once user accepts the selected index. … … 1089 1076 1090 1077 if (index >= numItems()) 1091 return false;1078 return; 1092 1079 1093 1080 if (index < 0) { … … 1096 1083 hidePopup(); 1097 1084 } 1098 return false;1085 return; 1099 1086 } 1100 1087 … … 1107 1094 // Tell the <select> PopupMenuClient what index was selected. 1108 1095 m_popupClient->valueChanged(index); 1109 1110 return true; 1111 } 1112 1113 return false; 1096 } 1114 1097 } 1115 1098 -
trunk/Source/WebKit/chromium/ChangeLog
r87931 r87932 1 2011-06-02 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r87920. 4 http://trac.webkit.org/changeset/87920 5 https://bugs.webkit.org/show_bug.cgi?id=61943 6 7 This patch does not build in Win Builder (dbg)(shared) 8 downstream (Requested by abarth|gardener on #webkit). 9 10 * tests/PopupMenuTest.cpp: 11 (WebKit::TestPopupMenuClient::TestPopupMenuClient): 12 (WebKit::TestPopupMenuClient::valueChanged): 13 (WebKit::TestPopupMenuClient::itemIsEnabled): 14 (WebKit::SelectPopupMenuTest::TearDown): 15 * tests/data/popup/select_event.html: Removed. 16 * tests/data/popup/select_event_remove_on_change.html: Removed. 17 * tests/data/popup/select_event_remove_on_click.html: Removed. 18 1 19 2011-06-02 Dimitri Glazkov <dglazkov@chromium.org> 2 20 -
trunk/Source/WebKit/chromium/tests/PopupMenuTest.cpp
r87920 r87932 32 32 33 33 #include <gtest/gtest.h> 34 #include <webkit/support/webkit_support.h>35 34 36 35 #include "Color.h" 37 #include "Element.h"38 #include "FrameView.h"39 36 #include "KeyboardCodes.h" 40 37 #include "PopupMenu.h" 41 38 #include "PopupMenuClient.h" 42 39 #include "PopupMenuChromium.h" 43 #include "SelectElement.h"44 #include "WebDocument.h"45 #include "WebElement.h"46 #include "WebFrame.h"47 40 #include "WebFrameClient.h" 48 41 #include "WebFrameImpl.h" … … 50 43 #include "WebPopupMenuImpl.h" 51 44 #include "WebScreenInfo.h" 52 #include "WebSettings.h"53 #include "WebString.h"54 #include "WebURL.h"55 #include "WebURLRequest.h"56 #include "WebURLResponse.h"57 #include "WebView.h"58 45 #include "WebViewClient.h" 59 46 #include "WebViewImpl.h" 60 #include "v8.h"61 47 62 48 using namespace WebCore; … … 68 54 public: 69 55 // Item at index 0 is selected by default. 70 TestPopupMenuClient() : m_selectIndex(0) , m_node(0){ }56 TestPopupMenuClient() : m_selectIndex(0) { } 71 57 virtual ~TestPopupMenuClient() {} 72 58 virtual void valueChanged(unsigned listIndex, bool fireEvents = true) 73 59 { 74 60 m_selectIndex = listIndex; 75 if (m_node) {76 SelectElement* select = toSelectElement(static_cast<Element*>(m_node));77 select->setSelectedIndexByUser(select->listToOptionIndex(listIndex), true, fireEvents);78 }79 61 } 80 62 virtual void selectionChanged(unsigned, bool) {} … … 91 73 virtual String itemToolTip(unsigned listIndex) const { return itemText(listIndex); } 92 74 virtual String itemAccessibilityText(unsigned listIndex) const { return itemText(listIndex); } 93 virtual bool itemIsEnabled(unsigned listIndex) const { return m_disabledIndexSet.find(listIndex) == m_disabledIndexSet.end(); }75 virtual bool itemIsEnabled(unsigned listIndex) const { return true; } 94 76 virtual PopupMenuStyle itemStyle(unsigned listIndex) const 95 77 { … … 111 93 virtual bool valueShouldChangeOnHotTrack() const { return false; } 112 94 virtual void setTextFromItem(unsigned listIndex) { } 113 95 114 96 virtual FontSelector* fontSelector() const { return 0; } 115 97 virtual HostWindow* hostWindow() const { return 0; } 116 98 117 99 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) { return 0; } 118 119 void setDisabledIndex(unsigned index) { m_disabledIndexSet.insert(index); }120 void setFocusedNode(Node* node) { m_node = node; }121 100 122 101 private: 123 102 unsigned m_selectIndex; 124 std::set<unsigned> m_disabledIndexSet;125 Node* m_node;126 103 }; 127 104 … … 174 151 public: 175 152 SelectPopupMenuTest() 176 : baseURL("http://www.test.com/")177 153 { 178 154 } … … 190 166 m_popupMenu = 0; 191 167 m_webView->close(); 192 webkit_support::UnregisterAllMockedURLs();193 168 } 194 169 … … 244 219 1, false, false, false, false, 0); 245 220 m_webView->selectPopup()->handleMouseReleaseEvent(mouseEvent); 246 }247 248 void registerMockedURLLoad(const std::string& fileName)249 {250 WebURLResponse response;251 response.initialize();252 response.setMIMEType("text/html");253 254 std::string filePath = webkit_support::GetWebKitRootDir().utf8();255 filePath += "/Source/WebKit/chromium/tests/data/popup/";256 filePath += fileName;257 258 webkit_support::RegisterMockedURL(WebURL(GURL(baseURL + fileName)), response, WebString::fromUTF8(filePath));259 }260 261 void serveRequests()262 {263 webkit_support::ServeAsynchronousMockedRequests();264 }265 266 void loadFrame(WebFrame* frame, const std::string& fileName)267 {268 WebURLRequest urlRequest;269 urlRequest.initialize();270 urlRequest.setURL(WebURL(GURL(baseURL + fileName)));271 frame->loadRequest(urlRequest);272 221 } 273 222 … … 278 227 TestPopupMenuClient m_popupMenuClient; 279 228 RefPtr<PopupMenu> m_popupMenu; 280 std::string baseURL;281 229 }; 282 230 … … 403 351 } 404 352 405 TEST_F(SelectPopupMenuTest, SelectItemEventFire)406 {407 registerMockedURLLoad("select_event.html");408 m_webView->settings()->setJavaScriptEnabled(true);409 loadFrame(m_webView->mainFrame(), "select_event.html");410 serveRequests();411 412 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainFrame())->frameView()->frame()->document()->focusedNode());413 414 showPopup();415 416 int menuHeight = m_webView->selectPopup()->menuItemHeight();417 // menuHeight * 0.5 means the Y position on the item at index 0.418 IntPoint row1Point(2, menuHeight * 0.5);419 simulateLeftMouseDownEvent(row1Point);420 simulateLeftMouseUpEvent(row1Point);421 422 WebElement element = m_webView->mainFrame()->document().getElementById("message");423 424 // mousedown event is held by select node, and we don't simulate the event for the node.425 // So we can only see mouseup and click event.426 EXPECT_STREQ("upclick", std::string(element.innerText().utf8()).c_str());427 428 // Disable the item at index 1.429 m_popupMenuClient.setDisabledIndex(1);430 431 showPopup();432 // menuHeight * 1.5 means the Y position on the item at index 1.433 row1Point.setY(menuHeight * 1.5);434 simulateLeftMouseDownEvent(row1Point);435 simulateLeftMouseUpEvent(row1Point);436 437 // The item at index 1 is disabled, so the text should not be changed.438 EXPECT_STREQ("upclick", std::string(element.innerText().utf8()).c_str());439 440 showPopup();441 // menuHeight * 2.5 means the Y position on the item at index 2.442 row1Point.setY(menuHeight * 2.5);443 simulateLeftMouseDownEvent(row1Point);444 simulateLeftMouseUpEvent(row1Point);445 446 // The item is changed to the item at index 2, from index 0, so change event is fired.447 EXPECT_STREQ("upclickchangeupclick", std::string(element.innerText().utf8()).c_str());448 }449 450 TEST_F(SelectPopupMenuTest, SelectItemKeyEvent)451 {452 registerMockedURLLoad("select_event.html");453 m_webView->settings()->setJavaScriptEnabled(true);454 loadFrame(m_webView->mainFrame(), "select_event.html");455 serveRequests();456 457 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainFrame())->frameView()->frame()->document()->focusedNode());458 459 showPopup();460 461 // Siumulate to choose the item at index 1 with keyboard.462 simulateKeyDownEvent(VKEY_DOWN);463 simulateKeyDownEvent(VKEY_DOWN);464 simulateKeyDownEvent(VKEY_RETURN);465 466 WebElement element = m_webView->mainFrame()->document().getElementById("message");467 // We only can see change event but no other mouse related events.468 EXPECT_STREQ("change", std::string(element.innerText().utf8()).c_str());469 }470 471 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnChange)472 {473 // Make sure no crash, even if select node is removed on 'change' event handler.474 registerMockedURLLoad("select_event_remove_on_change.html");475 m_webView->settings()->setJavaScriptEnabled(true);476 loadFrame(m_webView->mainFrame(), "select_event_remove_on_change.html");477 serveRequests();478 479 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainFrame())->frameView()->frame()->document()->focusedNode());480 481 showPopup();482 483 int menuHeight = m_webView->selectPopup()->menuItemHeight();484 // menuHeight * 1.5 means the Y position on the item at index 1.485 IntPoint row1Point(2, menuHeight * 1.5);486 simulateLeftMouseDownEvent(row1Point);487 simulateLeftMouseUpEvent(row1Point);488 489 WebElement element = m_webView->mainFrame()->document().getElementById("message");490 EXPECT_STREQ("change", std::string(element.innerText().utf8()).c_str());491 }492 493 TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick)494 {495 // Make sure no crash, even if select node is removed on 'click' event handler.496 registerMockedURLLoad("select_event_remove_on_click.html");497 m_webView->settings()->setJavaScriptEnabled(true);498 loadFrame(m_webView->mainFrame(), "select_event_remove_on_click.html");499 serveRequests();500 501 m_popupMenuClient.setFocusedNode(static_cast<WebFrameImpl*>(m_webView->mainFrame())->frameView()->frame()->document()->focusedNode());502 503 showPopup();504 505 int menuHeight = m_webView->selectPopup()->menuItemHeight();506 // menuHeight * 1.5 means the Y position on the item at index 1.507 IntPoint row1Point(2, menuHeight * 1.5);508 simulateLeftMouseDownEvent(row1Point);509 simulateLeftMouseUpEvent(row1Point);510 511 WebElement element = m_webView->mainFrame()->document().getElementById("message");512 EXPECT_STREQ("click", std::string(element.innerText().utf8()).c_str());513 }514 515 353 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.