| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 FrameSelection* selection = frame()->selection(); | 1361 FrameSelection* selection = frame()->selection(); |
| 1362 ASSERT(!selection->isNone()); | 1362 ASSERT(!selection->isNone()); |
| 1363 if (selection->isNone() || selection->isRange()) | 1363 if (selection->isNone() || selection->isRange()) |
| 1364 return false; | 1364 return false; |
| 1365 selectWordAroundPosition(frame(), selection->selection().visibleStart()); | 1365 selectWordAroundPosition(frame(), selection->selection().visibleStart()); |
| 1366 return true; | 1366 return true; |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) | 1369 void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) |
| 1370 { | 1370 { |
| 1371 IntPoint unscaledBase = base; | 1371 moveRangeSelection(base, extent); |
| 1372 IntPoint unscaledExtent = extent; | |
| 1373 unscaledExtent.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFac
tor()); | |
| 1374 unscaledBase.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFacto
r()); | |
| 1375 VisiblePosition basePosition = visiblePositionForWindowPoint(unscaledBase); | |
| 1376 VisiblePosition extentPosition = visiblePositionForWindowPoint(unscaledExten
t); | |
| 1377 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); | |
| 1378 if (frame()->selection()->shouldChangeSelection(newSelection)) | |
| 1379 frame()->selection()->setSelection(newSelection, CharacterGranularity); | |
| 1380 } | 1372 } |
| 1381 | 1373 |
| 1382 void WebFrameImpl::selectRange(const WebRange& webRange) | 1374 void WebFrameImpl::selectRange(const WebRange& webRange) |
| 1383 { | 1375 { |
| 1384 if (RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange)) | 1376 if (RefPtr<Range> range = static_cast<PassRefPtr<Range> >(webRange)) |
| 1385 frame()->selection()->setSelectedRange(range.get(), WebCore::VP_DEFAULT_
AFFINITY, false); | 1377 frame()->selection()->setSelectedRange(range.get(), WebCore::VP_DEFAULT_
AFFINITY, false); |
| 1386 } | 1378 } |
| 1387 | 1379 |
| 1388 void WebFrameImpl::moveCaretSelectionTowardsWindowPoint(const WebPoint& point) | 1380 void WebFrameImpl::moveCaretSelectionTowardsWindowPoint(const WebPoint& point) |
| 1389 { | 1381 { |
| 1390 IntPoint unscaledPoint(point); | 1382 moveCaretSelection(point); |
| 1391 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); | 1383 } |
| 1392 | 1384 |
| 1385 void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& exte
nt) |
| 1386 { |
| 1387 FrameSelection* selection = frame()->selection(); |
| 1388 if (!selection) |
| 1389 return; |
| 1390 |
| 1391 VisiblePosition basePosition = visiblePositionForWindowPoint(base); |
| 1392 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); |
| 1393 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); |
| 1394 if (frame()->selection()->shouldChangeSelection(newSelection)) |
| 1395 frame()->selection()->setSelection(newSelection, CharacterGranularity); |
| 1396 } |
| 1397 |
| 1398 void WebFrameImpl::moveCaretSelection(const WebPoint& point) |
| 1399 { |
| 1393 Element* editable = frame()->selection()->rootEditableElement(); | 1400 Element* editable = frame()->selection()->rootEditableElement(); |
| 1394 if (!editable) | 1401 if (!editable) |
| 1395 return; | 1402 return; |
| 1396 | 1403 |
| 1397 IntPoint contentsPoint = frame()->view()->windowToContents(unscaledPoint); | 1404 VisiblePosition position = visiblePositionForWindowPoint(point); |
| 1398 LayoutPoint localPoint(editable->convertFromPage(contentsPoint)); | |
| 1399 VisiblePosition position = editable->renderer()->positionForPoint(localPoint
); | |
| 1400 if (frame()->selection()->shouldChangeSelection(position)) | 1405 if (frame()->selection()->shouldChangeSelection(position)) |
| 1401 frame()->selection()->moveTo(position, UserTriggered); | 1406 frame()->selection()->moveTo(position, UserTriggered); |
| 1402 } | 1407 } |
| 1403 | 1408 |
| 1404 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin
t) | 1409 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin
t) |
| 1405 { | 1410 { |
| 1411 FloatPoint unscaledPoint(point); |
| 1412 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); |
| 1413 |
| 1406 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Disallo
wShadowContent; | 1414 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Disallo
wShadowContent; |
| 1407 HitTestResult result(frame()->view()->windowToContents(IntPoint(point))); | 1415 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); |
| 1408 | |
| 1409 frame()->document()->renderView()->layer()->hitTest(request, result); | 1416 frame()->document()->renderView()->layer()->hitTest(request, result); |
| 1410 | 1417 |
| 1411 Node* node = result.targetNode(); | 1418 Node* node = result.targetNode(); |
| 1412 if (!node) | 1419 if (!node) |
| 1413 return VisiblePosition(); | 1420 return VisiblePosition(); |
| 1414 return node->renderer()->positionForPoint(result.localPoint()); | 1421 return frame()->selection()->selection().visiblePositionRespectingEditingBou
ndary(result.localPoint(), node); |
| 1415 } | 1422 } |
| 1416 | 1423 |
| 1417 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c
onstrainToNode, bool* useBrowserOverlays) | 1424 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c
onstrainToNode, bool* useBrowserOverlays) |
| 1418 { | 1425 { |
| 1419 ASSERT(!frame()->document()->isFrameSet()); | 1426 ASSERT(!frame()->document()->isFrameSet()); |
| 1420 WebPluginContainerImpl* pluginContainer = 0; | 1427 WebPluginContainerImpl* pluginContainer = 0; |
| 1421 if (constrainToNode.isNull()) { | 1428 if (constrainToNode.isNull()) { |
| 1422 // If this is a plugin document, check if the plugin supports its own | 1429 // If this is a plugin document, check if the plugin supports its own |
| 1423 // printing. If it does, we will delegate all printing to that. | 1430 // printing. If it does, we will delegate all printing to that. |
| 1424 pluginContainer = pluginContainerFromFrame(frame()); | 1431 pluginContainer = pluginContainerFromFrame(frame()); |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 | 2509 |
| 2503 // There is a possibility that the frame being detached was the only | 2510 // There is a possibility that the frame being detached was the only |
| 2504 // pending one. We need to make sure final replies can be sent. | 2511 // pending one. We need to make sure final replies can be sent. |
| 2505 flushCurrentScopingEffort(m_findRequestIdentifier); | 2512 flushCurrentScopingEffort(m_findRequestIdentifier); |
| 2506 | 2513 |
| 2507 cancelPendingScopingEffort(); | 2514 cancelPendingScopingEffort(); |
| 2508 } | 2515 } |
| 2509 } | 2516 } |
| 2510 | 2517 |
| 2511 } // namespace WebKit | 2518 } // namespace WebKit |
| OLD | NEW |