| OLD | NEW |
| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { | 440 void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { |
| 441 if (!main_frame() || !main_frame()->frameview()) | 441 if (!main_frame() || !main_frame()->frameview()) |
| 442 return; | 442 return; |
| 443 | 443 |
| 444 page_->contextMenuController()->clearContextMenu(); | 444 page_->contextMenuController()->clearContextMenu(); |
| 445 | 445 |
| 446 MakePlatformMouseEvent pme(main_frame()->frameview(), event); | 446 MakePlatformMouseEvent pme(main_frame()->frameview(), event); |
| 447 | 447 |
| 448 // Find the right target frame. See issue 1186900. | 448 // Find the right target frame. See issue 1186900. |
| 449 IntPoint doc_point( | 449 HitTestResult result = HitTestResultForWindowPos(pme.pos()); |
| 450 page_->mainFrame()->view()->windowToContents(pme.pos())); | |
| 451 HitTestResult result = | |
| 452 page_->mainFrame()->eventHandler()->hitTestResultAtPoint( | |
| 453 doc_point, false); | |
| 454 Frame* target_frame; | 450 Frame* target_frame; |
| 455 if (result.innerNonSharedNode()) | 451 if (result.innerNonSharedNode()) |
| 456 target_frame = result.innerNonSharedNode()->document()->frame(); | 452 target_frame = result.innerNonSharedNode()->document()->frame(); |
| 457 else | 453 else |
| 458 target_frame = page_->focusController()->focusedOrMainFrame(); | 454 target_frame = page_->focusController()->focusedOrMainFrame(); |
| 459 | 455 |
| 460 #if defined(OS_WIN) | 456 #if defined(OS_WIN) |
| 461 target_frame->view()->setCursor(pointerCursor()); | 457 target_frame->view()->setCursor(pointerCursor()); |
| 462 #endif | 458 #endif |
| 463 | 459 |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 zoom_level_ = 0; | 1374 zoom_level_ = 0; |
| 1379 main_frame()->frame()->setZoomFactor( | 1375 main_frame()->frame()->setZoomFactor( |
| 1380 1.0f, | 1376 1.0f, |
| 1381 main_frame()->frame()->isZoomFactorTextOnly()); | 1377 main_frame()->frame()->isZoomFactorTextOnly()); |
| 1382 } | 1378 } |
| 1383 | 1379 |
| 1384 void WebViewImpl::CopyImageAt(int x, int y) { | 1380 void WebViewImpl::CopyImageAt(int x, int y) { |
| 1385 if (!page_.get()) | 1381 if (!page_.get()) |
| 1386 return; | 1382 return; |
| 1387 | 1383 |
| 1388 IntPoint point = IntPoint(x, y); | 1384 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); |
| 1389 | |
| 1390 Frame* frame = page_->mainFrame(); | |
| 1391 | |
| 1392 HitTestResult result = | |
| 1393 frame->eventHandler()->hitTestResultAtPoint(point, false); | |
| 1394 | 1385 |
| 1395 if (result.absoluteImageURL().isEmpty()) { | 1386 if (result.absoluteImageURL().isEmpty()) { |
| 1396 // There isn't actually an image at these coordinates. Might be because | 1387 // There isn't actually an image at these coordinates. Might be because |
| 1397 // the window scrolled while the context menu was open or because the page | 1388 // the window scrolled while the context menu was open or because the page |
| 1398 // changed itself between when we thought there was an image here and when | 1389 // changed itself between when we thought there was an image here and when |
| 1399 // we actually tried to retreive the image. | 1390 // we actually tried to retreive the image. |
| 1400 // | 1391 // |
| 1401 // TODO: implement a cache of the most recent HitTestResult to avoid having | 1392 // TODO: implement a cache of the most recent HitTestResult to avoid having |
| 1402 // to do two hit tests. | 1393 // to do two hit tests. |
| 1403 return; | 1394 return; |
| 1404 } | 1395 } |
| 1405 | 1396 |
| 1406 frame->editor()->copyImage(result); | 1397 page_->mainFrame()->editor()->copyImage(result); |
| 1407 } | 1398 } |
| 1408 | 1399 |
| 1409 void WebViewImpl::InspectElement(int x, int y) { | 1400 void WebViewImpl::InspectElement(int x, int y) { |
| 1410 if (!page_.get()) | 1401 if (!page_.get()) |
| 1411 return; | 1402 return; |
| 1412 | 1403 |
| 1413 if (x == -1 || y == -1) { | 1404 if (x == -1 || y == -1) { |
| 1414 page_->inspectorController()->inspect(NULL); | 1405 page_->inspectorController()->inspect(NULL); |
| 1415 } else { | 1406 } else { |
| 1416 IntPoint point = IntPoint(x, y); | 1407 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); |
| 1417 HitTestResult result(point); | |
| 1418 | |
| 1419 result = page_->mainFrame()->eventHandler()->hitTestResultAtPoint(point, fal
se); | |
| 1420 | 1408 |
| 1421 if (!result.innerNonSharedNode()) | 1409 if (!result.innerNonSharedNode()) |
| 1422 return; | 1410 return; |
| 1423 | 1411 |
| 1424 page_->inspectorController()->inspect(result.innerNonSharedNode()); | 1412 page_->inspectorController()->inspect(result.innerNonSharedNode()); |
| 1425 } | 1413 } |
| 1426 } | 1414 } |
| 1427 | 1415 |
| 1428 void WebViewImpl::ShowJavaScriptConsole() { | 1416 void WebViewImpl::ShowJavaScriptConsole() { |
| 1429 page_->inspectorController()->showPanel(InspectorController::ConsolePanel); | 1417 page_->inspectorController()->showPanel(InspectorController::ConsolePanel); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 Frame* frame = page_->focusController()->focusedFrame(); | 1694 Frame* frame = page_->focusController()->focusedFrame(); |
| 1707 if (!frame) | 1695 if (!frame) |
| 1708 return NULL; | 1696 return NULL; |
| 1709 | 1697 |
| 1710 Document* document = frame->document(); | 1698 Document* document = frame->document(); |
| 1711 if (!document) | 1699 if (!document) |
| 1712 return NULL; | 1700 return NULL; |
| 1713 | 1701 |
| 1714 return document->focusedNode(); | 1702 return document->focusedNode(); |
| 1715 } | 1703 } |
| 1704 |
| 1705 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { |
| 1706 IntPoint doc_point( |
| 1707 page_->mainFrame()->view()->windowToContents(pos)); |
| 1708 return page_->mainFrame()->eventHandler()-> |
| 1709 hitTestResultAtPoint(doc_point, false); |
| 1710 } |
| OLD | NEW |