Chromium Code Reviews| 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 RenderObject* renderer; | |
| 1386 if (Element* editable = selection->rootEditableElement()) | |
| 1387 renderer = editable->renderer(); | |
| 1388 else | |
| 1389 renderer = frame()->document()->renderer(); | |
| 1390 | |
| 1391 VisiblePosition basePosition = visiblePositionForWindowPoint(base, renderer) ; | |
| 1392 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent, rende rer); | |
| 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) { | |
| 1388 Element* editable = frame()->selection()->rootEditableElement(); | 1399 Element* editable = frame()->selection()->rootEditableElement(); |
| 1389 if (!editable) | 1400 if (!editable) |
| 1390 return; | 1401 return; |
| 1391 | 1402 |
| 1392 IntPoint contentsPoint = frame()->view()->windowToContents(unscaledPoint); | 1403 VisiblePosition position = visiblePositionForWindowPoint(point, editable->re nderer()); |
| 1393 LayoutPoint localPoint(editable->convertFromPage(contentsPoint)); | 1404 |
| 1394 VisiblePosition position = editable->renderer()->positionForPoint(localPoint ); | |
| 1395 if (frame()->selection()->shouldChangeSelection(position)) | 1405 if (frame()->selection()->shouldChangeSelection(position)) |
| 1396 frame()->selection()->moveTo(position, UserTriggered); | 1406 frame()->selection()->moveTo(position, UserTriggered); |
| 1397 } | 1407 } |
| 1398 | 1408 |
| 1399 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin t) | 1409 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin t, RenderObject* renderer) |
|
leviw_travelin_and_unemployed
2013/05/06 22:38:47
I'd give this a more descriptive name than rendere
| |
| 1400 { | 1410 { |
| 1401 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Disallo wShadowContent; | 1411 FloatPoint unscaledPoint(point); |
| 1402 HitTestResult result(frame()->view()->windowToContents(IntPoint(point))); | 1412 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact or()); |
| 1403 | 1413 IntPoint contentsPoint = frame()->view()->windowToContents(roundedIntPoint(u nscaledPoint)); |
| 1404 frame()->document()->renderView()->layer()->hitTest(request, result); | 1414 LayoutPoint localPoint(renderer->absoluteToLocal(contentsPoint, UseTransform s)); |
| 1405 | 1415 return renderer->positionForPoint(localPoint); |
|
leviw_travelin_and_unemployed
2013/05/06 22:38:47
Your issue is that positionForPoint isn't really m
| |
| 1406 Node* node = result.targetNode(); | |
| 1407 if (!node) | |
| 1408 return VisiblePosition(); | |
| 1409 return node->renderer()->positionForPoint(result.localPoint()); | |
| 1410 } | 1416 } |
| 1411 | 1417 |
| 1412 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c onstrainToNode, bool* useBrowserOverlays) | 1418 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c onstrainToNode, bool* useBrowserOverlays) |
| 1413 { | 1419 { |
| 1414 ASSERT(!frame()->document()->isFrameSet()); | 1420 ASSERT(!frame()->document()->isFrameSet()); |
| 1415 WebPluginContainerImpl* pluginContainer = 0; | 1421 WebPluginContainerImpl* pluginContainer = 0; |
| 1416 if (constrainToNode.isNull()) { | 1422 if (constrainToNode.isNull()) { |
| 1417 // If this is a plugin document, check if the plugin supports its own | 1423 // 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. | 1424 // printing. If it does, we will delegate all printing to that. |
| 1419 pluginContainer = pluginContainerFromFrame(frame()); | 1425 pluginContainer = pluginContainerFromFrame(frame()); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2499 | 2505 |
| 2500 // There is a possibility that the frame being detached was the only | 2506 // 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. | 2507 // pending one. We need to make sure final replies can be sent. |
| 2502 flushCurrentScopingEffort(m_findRequestIdentifier); | 2508 flushCurrentScopingEffort(m_findRequestIdentifier); |
| 2503 | 2509 |
| 2504 cancelPendingScopingEffort(); | 2510 cancelPendingScopingEffort(); |
| 2505 } | 2511 } |
| 2506 } | 2512 } |
| 2507 | 2513 |
| 2508 } // namespace WebKit | 2514 } // namespace WebKit |
| OLD | NEW |