Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2015 Google Inc. All rights reserved. | 5 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection); | 101 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static bool expandSelectionUsingGranularity(VisibleSelection& selection, TextGra nularity granularity) | 104 static bool expandSelectionUsingGranularity(VisibleSelection& selection, TextGra nularity granularity) |
| 105 { | 105 { |
| 106 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled()) | 106 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled()) |
| 107 return selection.expandUsingGranularityInComposedTree(granularity); | 107 return selection.expandUsingGranularityInComposedTree(granularity); |
| 108 return selection.expandUsingGranularity(granularity); | 108 return selection.expandUsingGranularity(granularity); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node * targetNode, const VisibleSelection& selection, TextGranularity granularity) | 111 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node * targetNode, const VisibleSelection& visibleSelection, TextGranularity granular ity) |
|
yosin_UTC9
2015/06/24 09:26:39
We don't need to rename this parameter name, this
Miyoung Shin(c)
2015/06/24 10:51:03
Done. Thanks for your kind comment.
| |
| 112 { | 112 { |
| 113 if (Position::nodeIsUserSelectNone(targetNode)) | 113 if (Position::nodeIsUserSelectNone(targetNode)) |
| 114 return false; | 114 return false; |
| 115 | 115 |
| 116 if (!dispatchSelectStart(targetNode)) | 116 if (!dispatchSelectStart(targetNode)) |
| 117 return false; | 117 return false; |
| 118 | 118 |
| 119 if (selection.isRange()) { | 119 if (visibleSelection.isRange()) { |
| 120 m_selectionInitiationState = ExtendedSelection; | 120 m_selectionInitiationState = ExtendedSelection; |
| 121 } else { | 121 } else { |
| 122 granularity = CharacterGranularity; | 122 granularity = CharacterGranularity; |
| 123 m_selectionInitiationState = PlacedCaret; | 123 m_selectionInitiationState = PlacedCaret; |
| 124 } | 124 } |
| 125 | 125 |
| 126 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari ty); | 126 selection().setNonDirectionalSelectionIfNeeded(visibleSelection, granularity ); |
| 127 | 127 |
| 128 return true; | 128 return true; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace) | 131 void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace) |
| 132 { | 132 { |
| 133 Node* innerNode = result.innerNode(); | 133 Node* innerNode = result.innerNode(); |
| 134 VisibleSelection newSelection; | 134 VisibleSelection newSelection; |
| 135 | 135 |
| 136 if (innerNode && innerNode->layoutObject()) { | 136 if (innerNode && innerNode->layoutObject()) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH itTestResults& event) | 209 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH itTestResults& event) |
| 210 { | 210 { |
| 211 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick "); | 211 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick "); |
| 212 | 212 |
| 213 if (event.event().button() != LeftButton) | 213 if (event.event().button() != LeftButton) |
| 214 return false; | 214 return false; |
| 215 | 215 |
| 216 if (m_frame->selection().isRange()) { | 216 if (selection().isRange()) { |
| 217 // A double-click when range is already selected | 217 // A double-click when range is already selected |
| 218 // should not change the selection. So, do not call | 218 // should not change the selection. So, do not call |
| 219 // selectClosestWordFromMouseEvent, but do set | 219 // selectClosestWordFromMouseEvent, but do set |
| 220 // m_beganSelectingText to prevent handleMouseReleaseEvent | 220 // m_beganSelectingText to prevent handleMouseReleaseEvent |
| 221 // from setting caret selection. | 221 // from setting caret selection. |
| 222 m_selectionInitiationState = ExtendedSelection; | 222 m_selectionInitiationState = ExtendedSelection; |
| 223 } else { | 223 } else { |
| 224 selectClosestWordFromMouseEvent(event); | 224 selectClosestWordFromMouseEvent(event); |
| 225 } | 225 } |
| 226 return true; | 226 return true; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) | 271 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) |
| 272 return false; | 272 return false; |
| 273 | 273 |
| 274 // Extend the selection if the Shift key is down, unless the click is in a l ink. | 274 // Extend the selection if the Shift key is down, unless the click is in a l ink. |
| 275 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 275 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
| 276 | 276 |
| 277 // Don't restart the selection when the mouse is pressed on an | 277 // Don't restart the selection when the mouse is pressed on an |
| 278 // existing selection so we can allow for text dragging. | 278 // existing selection so we can allow for text dragging. |
| 279 if (FrameView* view = m_frame->view()) { | 279 if (FrameView* view = m_frame->view()) { |
| 280 LayoutPoint vPoint = view->rootFrameToContents(event.event().position()) ; | 280 LayoutPoint vPoint = view->rootFrameToContents(event.event().position()) ; |
| 281 if (!extendSelection && m_frame->selection().contains(vPoint)) { | 281 if (!extendSelection && selection().contains(vPoint)) { |
| 282 m_mouseDownWasSingleClickInSelection = true; | 282 m_mouseDownWasSingleClickInSelection = true; |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 PositionWithAffinity eventPos = innerNode->layoutObject()->positionForPoint( event.localPoint()); | 287 PositionWithAffinity eventPos = innerNode->layoutObject()->positionForPoint( event.localPoint()); |
| 288 VisiblePosition visiblePos(Strategy::toPositionType(eventPos.position()), ev entPos.affinity()); | 288 VisiblePosition visiblePos(Strategy::toPositionType(eventPos.position()), ev entPos.affinity()); |
| 289 if (visiblePos.isNull()) | 289 if (visiblePos.isNull()) |
| 290 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM); | 290 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM); |
| 291 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); | 291 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); |
| 292 | 292 |
| 293 VisibleSelection newSelection = m_frame->selection().selection(); | 293 VisibleSelection newSelection = selection().selection(); |
| 294 TextGranularity granularity = CharacterGranularity; | 294 TextGranularity granularity = CharacterGranularity; |
| 295 | 295 |
| 296 if (extendSelection && newSelection.isCaretOrRange()) { | 296 if (extendSelection && newSelection.isCaretOrRange()) { |
| 297 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); | 297 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); |
| 298 if (selectionInUserSelectAll.isRange()) { | 298 if (selectionInUserSelectAll.isRange()) { |
| 299 if (Strategy::selectionStart(selectionInUserSelectAll).compareTo(Str ategy::selectionStart(newSelection)) < 0) | 299 if (Strategy::selectionStart(selectionInUserSelectAll).compareTo(Str ategy::selectionStart(newSelection)) < 0) |
| 300 pos = Strategy::selectionStart(selectionInUserSelectAll); | 300 pos = Strategy::selectionStart(selectionInUserSelectAll); |
| 301 else if (Strategy::selectionEnd(newSelection).compareTo(Strategy::se lectionEnd(selectionInUserSelectAll)) < 0) | 301 else if (Strategy::selectionEnd(newSelection).compareTo(Strategy::se lectionEnd(selectionInUserSelectAll)) < 0) |
| 302 pos = Strategy::selectionEnd(selectionInUserSelectAll); | 302 pos = Strategy::selectionEnd(selectionInUserSelectAll); |
| 303 } | 303 } |
| 304 | 304 |
| 305 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional() ) { | 305 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional() ) { |
| 306 if (pos.isNotNull()) { | 306 if (pos.isNotNull()) { |
| 307 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click d eselects when selection | 307 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click d eselects when selection |
| 308 // was created right-to-left | 308 // was created right-to-left |
| 309 PositionType start = Strategy::selectionStart(newSelection); | 309 PositionType start = Strategy::selectionStart(newSelection); |
| 310 PositionType end = Strategy::selectionEnd(newSelection); | 310 PositionType end = Strategy::selectionEnd(newSelection); |
| 311 int distanceToStart = textDistance(start, pos); | 311 int distanceToStart = textDistance(start, pos); |
| 312 int distanceToEnd = textDistance(pos, end); | 312 int distanceToEnd = textDistance(pos, end); |
| 313 if (distanceToStart <= distanceToEnd) | 313 if (distanceToStart <= distanceToEnd) |
| 314 newSelection = VisibleSelection(end, pos); | 314 newSelection = VisibleSelection(end, pos); |
| 315 else | 315 else |
| 316 newSelection = VisibleSelection(start, pos); | 316 newSelection = VisibleSelection(start, pos); |
| 317 } | 317 } |
| 318 } else { | 318 } else { |
| 319 newSelection.setExtent(pos); | 319 newSelection.setExtent(pos); |
| 320 } | 320 } |
| 321 | 321 |
| 322 if (m_frame->selection().granularity() != CharacterGranularity) { | 322 if (selection().granularity() != CharacterGranularity) { |
| 323 granularity = m_frame->selection().granularity(); | 323 granularity = selection().granularity(); |
| 324 expandSelectionUsingGranularity(newSelection, m_frame->selection().g ranularity()); | 324 expandSelectionUsingGranularity(newSelection, selection().granularit y()); |
| 325 } | 325 } |
| 326 } else { | 326 } else { |
| 327 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); | 327 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. | 330 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. |
| 331 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); | 331 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); |
| 332 return false; | 332 return false; |
| 333 } | 333 } |
| 334 | 334 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 { | 390 { |
| 391 using PositionType = typename Strategy::PositionType; | 391 using PositionType = typename Strategy::PositionType; |
| 392 | 392 |
| 393 if (!m_mouseDownMayStartSelect) | 393 if (!m_mouseDownMayStartSelect) |
| 394 return; | 394 return; |
| 395 | 395 |
| 396 Node* target = hitTestResult.innerNode(); | 396 Node* target = hitTestResult.innerNode(); |
| 397 if (!target) | 397 if (!target) |
| 398 return; | 398 return; |
| 399 | 399 |
| 400 PositionWithAffinity rawTargetPosition = m_frame->selection().selection().po sitionRespectingEditingBoundary(hitTestResult.localPoint(), target); | 400 PositionWithAffinity rawTargetPosition = selection().selection().positionRes pectingEditingBoundary(hitTestResult.localPoint(), target); |
| 401 VisiblePosition targetPosition = VisiblePosition(Strategy::toPositionType(ra wTargetPosition.position()), rawTargetPosition.affinity()); | 401 VisiblePosition targetPosition = VisiblePosition(Strategy::toPositionType(ra wTargetPosition.position()), rawTargetPosition.affinity()); |
| 402 // Don't modify the selection if we're not on a node. | 402 // Don't modify the selection if we're not on a node. |
| 403 if (targetPosition.isNull()) | 403 if (targetPosition.isNull()) |
| 404 return; | 404 return; |
| 405 | 405 |
| 406 // Restart the selection if this is the first mouse move. This work is usual ly | 406 // Restart the selection if this is the first mouse move. This work is usual ly |
| 407 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection. | 407 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection. |
| 408 VisibleSelection newSelection = m_frame->selection().selection(); | 408 VisibleSelection newSelection = selection().selection(); |
| 409 | 409 |
| 410 // Special case to limit selection to the containing block for SVG text. | 410 // Special case to limit selection to the containing block for SVG text. |
| 411 // FIXME: Isn't there a better non-SVG-specific way to do this? | 411 // FIXME: Isn't there a better non-SVG-specific way to do this? |
| 412 if (Node* selectionBaseNode = Strategy::selectionBase(newSelection).deprecat edNode()) { | 412 if (Node* selectionBaseNode = Strategy::selectionBase(newSelection).deprecat edNode()) { |
| 413 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO bject()) { | 413 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO bject()) { |
| 414 if (selectionBaseLayoutObject->isSVGText()) { | 414 if (selectionBaseLayoutObject->isSVGText()) { |
| 415 if (target->layoutObject()->containingBlock() != selectionBaseLa youtObject->containingBlock()) | 415 if (target->layoutObject()->containingBlock() != selectionBaseLa youtObject->containingBlock()) |
| 416 return; | 416 return; |
| 417 } | 417 } |
| 418 } | 418 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 446 newSelection.setExtent(PositionType::beforeNode(rootUserSelectAl lForTarget).upstream(CanCrossEditingBoundary)); | 446 newSelection.setExtent(PositionType::beforeNode(rootUserSelectAl lForTarget).upstream(CanCrossEditingBoundary)); |
| 447 else if (rootUserSelectAllForTarget && mousePressNode->layoutObject( )) | 447 else if (rootUserSelectAllForTarget && mousePressNode->layoutObject( )) |
| 448 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll ForTarget).downstream(CanCrossEditingBoundary)); | 448 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll ForTarget).downstream(CanCrossEditingBoundary)); |
| 449 else | 449 else |
| 450 newSelection.setExtent(targetPosition); | 450 newSelection.setExtent(targetPosition); |
| 451 } | 451 } |
| 452 } else { | 452 } else { |
| 453 newSelection.setExtent(targetPosition); | 453 newSelection.setExtent(targetPosition); |
| 454 } | 454 } |
| 455 | 455 |
| 456 if (m_frame->selection().granularity() != CharacterGranularity) | 456 if (selection().granularity() != CharacterGranularity) |
| 457 expandSelectionUsingGranularity(newSelection, m_frame->selection().granu larity()); | 457 expandSelectionUsingGranularity(newSelection, selection().granularity()) ; |
| 458 | 458 |
| 459 m_frame->selection().setNonDirectionalSelectionIfNeeded(newSelection, m_fram e->selection().granularity(), | 459 selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().gra nularity(), |
| 460 FrameSelection::AdjustEndpointsAtBidiBoundary); | 460 FrameSelection::AdjustEndpointsAtBidiBoundary); |
| 461 } | 461 } |
| 462 | 462 |
| 463 bool SelectionController::handleMouseReleaseEvent(const MouseEventWithHitTestRes ults& event, const LayoutPoint& dragStartPos) | 463 bool SelectionController::handleMouseReleaseEvent(const MouseEventWithHitTestRes ults& event, const LayoutPoint& dragStartPos) |
| 464 { | 464 { |
| 465 bool handled = false; | 465 bool handled = false; |
| 466 m_mouseDownMayStartSelect = false; | 466 m_mouseDownMayStartSelect = false; |
| 467 // Clear the selection if the mouse didn't move after the last mouse | 467 // Clear the selection if the mouse didn't move after the last mouse |
| 468 // press and it's not a context menu click. We do this so when clicking | 468 // press and it's not a context menu click. We do this so when clicking |
| 469 // on the selection, the selection goes away. However, if we are | 469 // on the selection, the selection goes away. However, if we are |
| 470 // editing, place the caret. | 470 // editing, place the caret. |
| 471 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection | 471 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection |
| 472 && dragStartPos == event.event().position() | 472 && dragStartPos == event.event().position() |
| 473 && m_frame->selection().isRange() | 473 && selection().isRange() |
| 474 && event.event().button() != RightButton) { | 474 && event.event().button() != RightButton) { |
| 475 VisibleSelection newSelection; | 475 VisibleSelection newSelection; |
| 476 Node* node = event.innerNode(); | 476 Node* node = event.innerNode(); |
| 477 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); | 477 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); |
| 478 if (node && node->layoutObject() && (caretBrowsing || node->hasEditableS tyle())) { | 478 if (node && node->layoutObject() && (caretBrowsing || node->hasEditableS tyle())) { |
| 479 VisiblePosition pos = VisiblePosition(node->layoutObject()->position ForPoint(event.localPoint())); | 479 VisiblePosition pos = VisiblePosition(node->layoutObject()->position ForPoint(event.localPoint())); |
| 480 newSelection = VisibleSelection(pos); | 480 newSelection = VisibleSelection(pos); |
| 481 } | 481 } |
| 482 | 482 |
| 483 setSelectionIfNeeded(m_frame->selection(), newSelection); | 483 setSelectionIfNeeded(selection(), newSelection); |
| 484 | 484 |
| 485 handled = true; | 485 handled = true; |
| 486 } | 486 } |
| 487 | 487 |
| 488 m_frame->selection().notifyLayoutObjectOfSelectionChange(UserTriggered); | 488 selection().notifyLayoutObjectOfSelectionChange(UserTriggered); |
| 489 | 489 |
| 490 m_frame->selection().selectFrameElementInParentIfFullySelected(); | 490 selection().selectFrameElementInParentIfFullySelected(); |
| 491 | 491 |
| 492 if (event.event().button() == MiddleButton && !event.isOverLink()) { | 492 if (event.event().button() == MiddleButton && !event.isOverLink()) { |
| 493 // Ignore handled, since we want to paste to where the caret was placed anyway. | 493 // Ignore handled, since we want to paste to where the caret was placed anyway. |
| 494 handled = handlePasteGlobalSelection(event.event()) || handled; | 494 handled = handlePasteGlobalSelection(event.event()) || handled; |
| 495 } | 495 } |
| 496 | 496 |
| 497 return handled; | 497 return handled; |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 if (shouldLongPressSelectWord) { | 539 if (shouldLongPressSelectWord) { |
| 540 | 540 |
| 541 | 541 |
| 542 Node* innerNode = hitTestResult.innerNode(); | 542 Node* innerNode = hitTestResult.innerNode(); |
| 543 if (!hitTestResult.isLiveLink() && innerNode && (innerNode->isContentEdi table() || innerNode->isTextNode() | 543 if (!hitTestResult.isLiveLink() && innerNode && (innerNode->isContentEdi table() || innerNode->isTextNode() |
| 544 #if OS(ANDROID) | 544 #if OS(ANDROID) |
| 545 || innerNode->canStartSelection() | 545 || innerNode->canStartSelection() |
| 546 #endif | 546 #endif |
| 547 )) { | 547 )) { |
| 548 selectClosestWordFromHitTestResult(hitTestResult, DontAppendTrailing Whitespace); | 548 selectClosestWordFromHitTestResult(hitTestResult, DontAppendTrailing Whitespace); |
| 549 if (m_frame->selection().isRange()) | 549 if (selection().isRange()) |
| 550 return true; | 550 return true; |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 return false; | 553 return false; |
| 554 } | 554 } |
| 555 | 555 |
| 556 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position) | 556 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position) |
| 557 { | 557 { |
| 558 if (!m_frame->selection().contains(position) | 558 if (!selection().contains(position) |
| 559 && !mev.scrollbar() | 559 && !mev.scrollbar() |
| 560 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. | 560 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. |
| 561 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items | 561 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items |
| 562 // available for text selections. But only if we're above text. | 562 // available for text selections. But only if we're above text. |
| 563 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev. innerNode()->isTextNode()))) { | 563 && (selection().isContentEditable() || (mev.innerNode() && mev.innerNode ()->isTextNode()))) { |
| 564 m_mouseDownMayStartSelect = true; // context menu events are always allo wed to perform a selection | 564 m_mouseDownMayStartSelect = true; // context menu events are always allo wed to perform a selection |
| 565 | 565 |
| 566 if (mev.hitTestResult().isMisspelled()) | 566 if (mev.hitTestResult().isMisspelled()) |
| 567 selectClosestMisspellingFromMouseEvent(mev); | 567 selectClosestMisspellingFromMouseEvent(mev); |
| 568 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick( )) | 568 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick( )) |
| 569 selectClosestWordOrLinkFromMouseEvent(mev); | 569 selectClosestWordOrLinkFromMouseEvent(mev); |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 void SelectionController::passMousePressEventToSubframe(const MouseEventWithHitT estResults& mev) | 573 void SelectionController::passMousePressEventToSubframe(const MouseEventWithHitT estResults& mev) |
| 574 { | 574 { |
| 575 // If we're clicking into a frame that is selected, the frame will appear | 575 // If we're clicking into a frame that is selected, the frame will appear |
| 576 // greyed out even though we're clicking on the selection. This looks | 576 // greyed out even though we're clicking on the selection. This looks |
| 577 // really strange (having the whole frame be greyed out), so we deselect the | 577 // really strange (having the whole frame be greyed out), so we deselect the |
| 578 // selection. | 578 // selection. |
| 579 IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position()); | 579 IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position()); |
| 580 if (m_frame->selection().contains(p)) { | 580 if (selection().contains(p)) { |
| 581 VisiblePosition visiblePos( | 581 VisiblePosition visiblePos( |
| 582 mev.innerNode()->layoutObject()->positionForPoint(mev.localPoint())) ; | 582 mev.innerNode()->layoutObject()->positionForPoint(mev.localPoint())) ; |
| 583 VisibleSelection newSelection(visiblePos); | 583 VisibleSelection newSelection(visiblePos); |
| 584 m_frame->selection().setSelection(newSelection); | 584 selection().setSelection(newSelection); |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 | 587 |
| 588 void SelectionController::initializeSelectionState() | 588 void SelectionController::initializeSelectionState() |
| 589 { | 589 { |
| 590 m_selectionInitiationState = HaveNotStartedSelection; | 590 m_selectionInitiationState = HaveNotStartedSelection; |
| 591 } | 591 } |
| 592 | 592 |
| 593 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) | 593 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) |
| 594 { | 594 { |
| 595 m_mouseDownMayStartSelect = mayStartSelect; | 595 m_mouseDownMayStartSelect = mayStartSelect; |
| 596 } | 596 } |
| 597 | 597 |
| 598 bool SelectionController::mouseDownMayStartSelect() const | 598 bool SelectionController::mouseDownMayStartSelect() const |
| 599 { | 599 { |
| 600 return m_mouseDownMayStartSelect; | 600 return m_mouseDownMayStartSelect; |
| 601 } | 601 } |
| 602 | 602 |
| 603 bool SelectionController::mouseDownWasSingleClickInSelection() const | 603 bool SelectionController::mouseDownWasSingleClickInSelection() const |
| 604 { | 604 { |
| 605 return m_mouseDownWasSingleClickInSelection; | 605 return m_mouseDownWasSingleClickInSelection; |
| 606 } | 606 } |
| 607 | 607 |
| 608 FrameSelection& SelectionController::selection() const | |
| 609 { | |
| 610 return m_frame->selection(); | |
| 611 } | |
| 612 | |
| 608 } // namespace blink | 613 } // namespace blink |
| OLD | NEW |