OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
6 * Copyright (C) 2015 Google Inc. All rights reserved. | 6 * Copyright (C) 2015 Google Inc. All rights reserved. |
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 basePosition = selection().computeVisibleSelectionInFlatTree().base(); | 388 basePosition = selection().computeVisibleSelectionInFlatTree().base(); |
389 } | 389 } |
390 const SelectionInFlatTree& appliedSelection = applySelectAll( | 390 const SelectionInFlatTree& appliedSelection = applySelectAll( |
391 basePosition, targetPosition.deepEquivalent(), mousePressNode, | 391 basePosition, targetPosition.deepEquivalent(), mousePressNode, |
392 dragStartPos, target, hitTestResult.localPoint()); | 392 dragStartPos, target, hitTestResult.localPoint()); |
393 SelectionInFlatTree::Builder builder(appliedSelection); | 393 SelectionInFlatTree::Builder builder(appliedSelection); |
394 | 394 |
395 if (selection().granularity() != CharacterGranularity) | 395 if (selection().granularity() != CharacterGranularity) |
396 builder.setGranularity(selection().granularity()); | 396 builder.setGranularity(selection().granularity()); |
397 | 397 |
398 setNonDirectionalSelectionIfNeeded( | 398 setNonDirectionalSelectionIfNeeded(builder.build(), selection().granularity(), |
399 createVisibleSelection(builder.build()), selection().granularity(), | 399 AdjustEndpointsAtBidiBoundary, |
400 AdjustEndpointsAtBidiBoundary, HandleVisibility::NotVisible); | 400 HandleVisibility::NotVisible); |
401 } | 401 } |
402 | 402 |
403 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart( | 403 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart( |
404 Node* targetNode, | 404 Node* targetNode, |
405 const VisibleSelectionInFlatTree& selection, | 405 const VisibleSelectionInFlatTree& selection, |
406 TextGranularity granularity, | 406 TextGranularity granularity, |
407 HandleVisibility handleVisibility) { | 407 HandleVisibility handleVisibility) { |
408 if (targetNode && targetNode->layoutObject() && | 408 if (targetNode && targetNode->layoutObject() && |
409 !targetNode->layoutObject()->isSelectable()) | 409 !targetNode->layoutObject()->isSelectable()) |
410 return false; | 410 return false; |
411 | 411 |
412 if (dispatchSelectStart(targetNode) != DispatchEventResult::NotCanceled) | 412 if (dispatchSelectStart(targetNode) != DispatchEventResult::NotCanceled) |
413 return false; | 413 return false; |
414 | 414 |
415 // |dispatchSelectStart()| can change document hosted by |m_frame|. | 415 // |dispatchSelectStart()| can change document hosted by |m_frame|. |
416 if (!this->selection().isAvailable()) | 416 if (!this->selection().isAvailable()) |
417 return false; | 417 return false; |
418 | 418 |
419 if (!selection.isValidFor(this->selection().document())) | 419 if (!selection.isValidFor(this->selection().document())) |
420 return false; | 420 return false; |
421 | 421 |
422 if (selection.isRange()) { | 422 if (selection.isRange()) { |
423 m_selectionState = SelectionState::ExtendedSelection; | 423 m_selectionState = SelectionState::ExtendedSelection; |
424 } else { | 424 } else { |
425 granularity = CharacterGranularity; | 425 granularity = CharacterGranularity; |
426 m_selectionState = SelectionState::PlacedCaret; | 426 m_selectionState = SelectionState::PlacedCaret; |
427 } | 427 } |
428 | 428 |
429 setNonDirectionalSelectionIfNeeded(selection, granularity, | 429 setNonDirectionalSelectionIfNeeded(selection.asSelection(), granularity, |
430 DoNotAdjustEndpoints, handleVisibility); | 430 DoNotAdjustEndpoints, handleVisibility); |
431 | 431 |
432 return true; | 432 return true; |
433 } | 433 } |
434 | 434 |
435 bool SelectionController::selectClosestWordFromHitTestResult( | 435 bool SelectionController::selectClosestWordFromHitTestResult( |
436 const HitTestResult& result, | 436 const HitTestResult& result, |
437 AppendTrailingWhitespace appendTrailingWhitespace, | 437 AppendTrailingWhitespace appendTrailingWhitespace, |
438 SelectInputEventType selectInputEventType) { | 438 SelectInputEventType selectInputEventType) { |
439 Node* innerNode = result.innerNode(); | 439 Node* innerNode = result.innerNode(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 628 |
629 if (extent.atRightBoundaryOfBidiRun() && | 629 if (extent.atRightBoundaryOfBidiRun() && |
630 extent.isEquivalent( | 630 extent.isEquivalent( |
631 base.rightBoundaryOfBidiRun(extent.bidiLevelOnLeft()))) { | 631 base.rightBoundaryOfBidiRun(extent.bidiLevelOnLeft()))) { |
632 visibleExtent = createVisiblePosition( | 632 visibleExtent = createVisiblePosition( |
633 toPositionInFlatTree(extent.positionAtRightBoundaryOfBiDiRun())); | 633 toPositionInFlatTree(extent.positionAtRightBoundaryOfBiDiRun())); |
634 return; | 634 return; |
635 } | 635 } |
636 } | 636 } |
637 | 637 |
638 // TODO(yosin): We should make |setNonDirectionalSelectionIfNeeded()| to take | 638 // TODO(yosin): We should take |granularity| and |handleVisibility| from |
639 // |SelectionInFlatTree| instead of |VisibleSelectionInFlatTree|. | 639 // |newSelection|. |
640 void SelectionController::setNonDirectionalSelectionIfNeeded( | 640 void SelectionController::setNonDirectionalSelectionIfNeeded( |
641 const VisibleSelectionInFlatTree& newSelection, | 641 const SelectionInFlatTree& passedSelection, |
642 TextGranularity granularity, | 642 TextGranularity granularity, |
643 EndPointsAdjustmentMode endpointsAdjustmentMode, | 643 EndPointsAdjustmentMode endpointsAdjustmentMode, |
644 HandleVisibility handleVisibility) { | 644 HandleVisibility handleVisibility) { |
645 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 645 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
646 // needs to be audited. See http://crbug.com/590369 for more details. | 646 // needs to be audited. See http://crbug.com/590369 for more details. |
647 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 647 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
648 | 648 |
| 649 const VisibleSelectionInFlatTree& newSelection = |
| 650 createVisibleSelection(passedSelection); |
649 const PositionInFlatTree& basePosition = | 651 const PositionInFlatTree& basePosition = |
650 m_originalBaseInFlatTree.deepEquivalent(); | 652 m_originalBaseInFlatTree.deepEquivalent(); |
651 const VisiblePositionInFlatTree& originalBase = | 653 const VisiblePositionInFlatTree& originalBase = |
652 basePosition.isConnected() ? createVisiblePosition(basePosition) | 654 basePosition.isConnected() ? createVisiblePosition(basePosition) |
653 : VisiblePositionInFlatTree(); | 655 : VisiblePositionInFlatTree(); |
654 const VisiblePositionInFlatTree& base = | 656 const VisiblePositionInFlatTree& base = |
655 originalBase.isNotNull() ? originalBase | 657 originalBase.isNotNull() ? originalBase |
656 : createVisiblePosition(newSelection.base()); | 658 : createVisiblePosition(newSelection.base()); |
657 VisiblePositionInFlatTree newBase = base; | 659 VisiblePositionInFlatTree newBase = base; |
658 const VisiblePositionInFlatTree& extent = | 660 const VisiblePositionInFlatTree& extent = |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 | 1088 |
1087 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { | 1089 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { |
1088 bool isMouseDownOnLinkOrImage = | 1090 bool isMouseDownOnLinkOrImage = |
1089 event.isOverLink() || event.hitTestResult().image(); | 1091 event.isOverLink() || event.hitTestResult().image(); |
1090 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) != | 1092 return (event.event().modifiers() & WebInputEvent::Modifiers::ShiftKey) != |
1091 0 && | 1093 0 && |
1092 !isMouseDownOnLinkOrImage; | 1094 !isMouseDownOnLinkOrImage; |
1093 } | 1095 } |
1094 | 1096 |
1095 } // namespace blink | 1097 } // namespace blink |
OLD | NEW |