Changeset 175160 in webkit
- Timestamp:
- Oct 24, 2014, 12:09:57 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r175159 r175160 1 2014-10-24 Marcos Chavarría Teijeiro <chavarria1991@gmail.com> 2 3 [GTK] Implement is_selected method on WebKitHitTestResult 4 https://bugs.webkit.org/show_bug.cgi?id=137110 5 6 Reviewed by Tim Horton. 7 8 Expose CONTEXT_SELECTION for WebKitHitTestResult. 9 10 * Shared/WebHitTestResult.cpp: Add is_selected field and getter for this field. 11 (WebKit::WebHitTestResult::Data::Data): 12 (WebKit::WebHitTestResult::Data::encode): 13 (WebKit::WebHitTestResult::Data::decode): 14 * Shared/WebHitTestResult.h: 15 (WebKit::WebHitTestResult::isSelected): 16 * UIProcess/API/gtk/WebKitHitTestResult.cpp: Add WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION context and method to check it. 17 (webkitHitTestResultCreate): 18 (webkitHitTestResultCompare): 19 (webkit_hit_test_result_context_is_selection): 20 * UIProcess/API/gtk/WebKitHitTestResult.h: 21 * UIProcess/API/gtk/WebKitWebView.cpp: Modify context-menu callback to set the new context option. 22 (webkitWebViewPopulateContextMenu): 23 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add documentation about new function. 24 1 25 2014-10-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 26 -
trunk/Source/WebKit2/Shared/WebHitTestResult.cpp
r161148 r175160 53 53 , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult)) 54 54 , isScrollbar(hitTestResult.scrollbar()) 55 , isSelected(hitTestResult.isSelected()) 55 56 { 56 57 } … … 71 72 encoder << elementBoundingBox; 72 73 encoder << isScrollbar; 74 encoder << isSelected; 73 75 } 74 76 … … 83 85 || !decoder.decode(hitTestResultData.isContentEditable) 84 86 || !decoder.decode(hitTestResultData.elementBoundingBox) 85 || !decoder.decode(hitTestResultData.isScrollbar)) 87 || !decoder.decode(hitTestResultData.isScrollbar) 88 || !decoder.decode(hitTestResultData.isSelected)) 86 89 return false; 87 90 -
trunk/Source/WebKit2/Shared/WebHitTestResult.h
r161148 r175160 53 53 WebCore::IntRect elementBoundingBox; 54 54 bool isScrollbar; 55 bool isSelected; 55 56 56 57 Data(); … … 80 81 bool isScrollbar() const { return m_data.isScrollbar; } 81 82 83 bool isSelected() const { return m_data.isSelected; } 84 82 85 private: 83 86 explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData) -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
r170702 r175160 241 241 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR; 242 242 243 if (hitTestResult.isSelected) 244 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION; 245 243 246 return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT, 244 247 "context", context, … … 261 264 return webHitTestResult.isContentEditable == webkit_hit_test_result_context_is_editable(hitTestResult) 262 265 && webHitTestResult.isScrollbar == webkit_hit_test_result_context_is_scrollbar(hitTestResult) 266 && webHitTestResult.isSelected == webkit_hit_test_result_context_is_selection(hitTestResult) 263 267 && stringIsEqualToCString(webHitTestResult.absoluteLinkURL, priv->linkURI) 264 268 && stringIsEqualToCString(webHitTestResult.linkTitle, priv->linkTitle) … … 352 356 353 357 /** 358 * webkit_hit_test_result_context_is_selection: 359 * @hit_test_result: a #WebKitHitTestResult 360 * 361 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION flag is present in 362 * #WebKitHitTestResult:context. 363 * 364 * Returns: %TRUE if there's a selected element at the coordinates of the @hit_test_result, 365 * or %FALSE otherwise 366 * 367 * Since: 2.8 368 */ 369 gboolean webkit_hit_test_result_context_is_selection(WebKitHitTestResult* hitTestResult) 370 { 371 g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE); 372 373 return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION; 374 } 375 376 /** 354 377 * webkit_hit_test_result_get_link_uri: 355 378 * @hit_test_result: a #WebKitHitTestResult -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
r150130 r175160 49 49 * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: an editable element 50 50 * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR: a scrollbar element. 51 * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION: a selected element. Since 2.8 51 52 * 52 53 * Enum values with flags representing the context of a #WebKitHitTestResult. … … 59 60 WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4, 60 61 WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 5, 61 WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR = 1 << 6 62 WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR = 1 << 6, 63 WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION = 1 << 7 62 64 } WebKitHitTestResultContext; 63 65 … … 95 97 webkit_hit_test_result_context_is_editable (WebKitHitTestResult *hit_test_result); 96 98 99 WEBKIT_API gboolean 100 webkit_hit_test_result_context_is_selection (WebKitHitTestResult *hit_test_result); 101 97 102 WEBKIT_API const gchar * 98 103 webkit_hit_test_result_get_link_uri (WebKitHitTestResult *hit_test_result); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r174861 r175160 1912 1912 data.elementBoundingBox = webHitTestResult->elementBoundingBox(); 1913 1913 data.isScrollbar = webHitTestResult->isScrollbar(); 1914 data.isSelected = webHitTestResult->isSelected(); 1914 1915 1915 1916 GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(data)); -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r174105 r175160 669 669 webkit_hit_test_result_context_is_media 670 670 webkit_hit_test_result_context_is_editable 671 webkit_hit_test_result_context_is_selection 671 672 webkit_hit_test_result_get_link_uri 672 673 webkit_hit_test_result_get_link_title -
trunk/Tools/ChangeLog
r175142 r175160 1 2014-10-24 Marcos Chavarría Teijeiro <chavarria1991@gmail.com> 2 3 [GTK] Implement is_selected method on WebKitHitTestResult 4 https://bugs.webkit.org/show_bug.cgi?id=137110 5 6 Reviewed by Tim Horton. 7 8 Add tests for new context SELECTION on WebKitHitTestResult. 9 10 * TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp: 11 (testContextMenuDefaultMenu): 12 * TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp: 13 (testWebViewMouseTarget): 14 1 15 2014-10-23 Roger Fong <roger_fong@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp
r162599 r175160 240 240 Video, 241 241 Audio, 242 Editable 242 Editable, 243 Selection 243 244 }; 244 245 … … 258 259 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 259 260 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 261 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 260 262 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_BACK, Visible); 261 263 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_GO_FORWARD, Visible); … … 268 270 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 269 271 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 272 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 270 273 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled); 271 274 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled); … … 278 281 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 279 282 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 283 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 280 284 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_IMAGE_IN_NEW_WINDOW, Visible | Enabled); 281 285 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_IMAGE_TO_DISK, Visible | Enabled); … … 288 292 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 289 293 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 294 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 290 295 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK, Visible | Enabled); 291 296 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_OPEN_LINK_IN_NEW_WINDOW, Visible | Enabled); … … 303 308 g_assert(webkit_hit_test_result_context_is_media(hitTestResult)); 304 309 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 310 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 305 311 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled); 306 312 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible); … … 318 324 g_assert(webkit_hit_test_result_context_is_media(hitTestResult)); 319 325 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 326 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 320 327 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY, Visible | Enabled); 321 328 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE, Visible); … … 333 340 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 334 341 g_assert(webkit_hit_test_result_context_is_editable(hitTestResult)); 342 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 335 343 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_CUT, Visible); 336 344 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY, Visible); … … 344 352 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_UNICODE, Visible | Enabled); 345 353 break; 354 case Selection: 355 g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); 356 g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); 357 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 358 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 359 g_assert(webkit_hit_test_result_context_is_selection(hitTestResult)); 360 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_COPY, Visible | Enabled); 361 break; 346 362 default: 347 363 g_assert_not_reached(); … … 367 383 368 384 const char* linksHTML = 369 "<html><body>" 385 "<html><head>" 386 " <script>" 387 " window.onload = function () {" 388 " window.getSelection().removeAllRanges();" 389 " var select_range = document.createRange();" 390 " select_range.selectNodeContents(document.getElementById('text_to_select'));" 391 " window.getSelection().addRange(select_range);" 392 " }" 393 " </script>" 394 "</head><body>" 370 395 " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>" 371 396 " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>" … … 374 399 " <video style='position:absolute; left:1; top:50' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>" 375 400 " <audio style='position:absolute; left:1; top:60' width='50' height='20' controls='controls' preload='none'><source src='track.mp3' type='audio/mp3' /></audio>" 401 " <p style='position:absolute; left:1; top:90' id='text_to_select'>Lorem ipsum.</p>" 376 402 "</body></html>"; 377 403 test->loadHtml(linksHTML, "file:///"); 378 404 test->waitUntilLoadFinished(); 405 406 // Context menu for selection. 407 // This test should always be the first because any other click removes the selection. 408 test->m_expectedMenuType = ContextMenuDefaultTest::Selection; 409 test->showContextMenuAtPositionAndWaitUntilFinished(2, 115); 379 410 380 411 // Context menu for document. -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp
r170702 r175160 510 510 511 511 const char* linksHoveredHTML = 512 "<html><body>" 512 "<html><head>" 513 " <script>" 514 " window.onload = function () {" 515 " window.getSelection().removeAllRanges();" 516 " var select_range = document.createRange();" 517 " select_range.selectNodeContents(document.getElementById('text_to_select'));" 518 " window.getSelection().addRange(select_range);" 519 " }" 520 " </script>" 521 "</head><body>" 513 522 " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>" 514 523 " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>" … … 517 526 " <div style='position:absolute; left:1; top:50; width:30; height:30; overflow:scroll'> </div>" 518 527 " <video style='position:absolute; left:1; top:100' width='300' height='300' controls='controls' preload='none'><source src='movie.ogg' type='video/ogg' /></video>" 528 " <p style='position:absolute; left:1; top:120' id='text_to_select'>Lorem ipsum.</p>" 519 529 "</body></html>"; 520 530 … … 528 538 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 529 539 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 540 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 530 541 g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/"); 531 542 g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title"); … … 539 550 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 540 551 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 552 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 541 553 g_assert(!test->m_mouseTargetModifiers); 542 554 … … 547 559 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 548 560 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 561 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 549 562 g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 550 563 g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); … … 558 571 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 559 572 g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 573 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 560 574 g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo"); 561 575 g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); … … 571 585 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 572 586 g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 587 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 573 588 g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg"); 574 589 g_assert(!test->m_mouseTargetModifiers); … … 581 596 g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 582 597 g_assert(webkit_hit_test_result_context_is_editable(hitTestResult)); 598 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 583 599 g_assert(!test->m_mouseTargetModifiers); 584 600 … … 590 606 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 591 607 g_assert(webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 608 g_assert(!webkit_hit_test_result_context_is_selection(hitTestResult)); 592 609 g_assert(!test->m_mouseTargetModifiers); 610 611 // Move over selection. 612 hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(2, 145); 613 g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); 614 g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); 615 g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); 616 g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); 617 g_assert(!webkit_hit_test_result_context_is_scrollbar(hitTestResult)); 618 g_assert(webkit_hit_test_result_context_is_selection(hitTestResult)); 619 g_assert(!test->m_mouseTargetModifiers); 620 593 621 } 594 622
Note:
See TracChangeset
for help on using the changeset viewer.