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