| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "core/html/HTMLSelectElement.h" | 65 #include "core/html/HTMLSelectElement.h" |
| 66 #include "core/input/EventHandler.h" | 66 #include "core/input/EventHandler.h" |
| 67 #include "core/layout/HitTestRequest.h" | 67 #include "core/layout/HitTestRequest.h" |
| 68 #include "core/layout/HitTestResult.h" | 68 #include "core/layout/HitTestResult.h" |
| 69 #include "core/layout/LayoutPart.h" | 69 #include "core/layout/LayoutPart.h" |
| 70 #include "core/loader/DocumentLoader.h" | 70 #include "core/loader/DocumentLoader.h" |
| 71 #include "core/page/EditorClient.h" | 71 #include "core/page/EditorClient.h" |
| 72 #include "core/page/FocusController.h" | 72 #include "core/page/FocusController.h" |
| 73 #include "core/page/FrameTree.h" | 73 #include "core/page/FrameTree.h" |
| 74 #include "core/page/Page.h" | 74 #include "core/page/Page.h" |
| 75 #include "core/page/SpatialNavigation.h" |
| 75 #include "core/paint/PaintLayer.h" | 76 #include "core/paint/PaintLayer.h" |
| 76 #include "platform/SecureTextInput.h" | 77 #include "platform/SecureTextInput.h" |
| 77 #include "platform/geometry/FloatQuad.h" | 78 #include "platform/geometry/FloatQuad.h" |
| 78 #include "platform/graphics/GraphicsContext.h" | 79 #include "platform/graphics/GraphicsContext.h" |
| 79 #include "platform/text/UnicodeUtilities.h" | 80 #include "platform/text/UnicodeUtilities.h" |
| 80 #include "wtf/PtrUtil.h" | 81 #include "wtf/PtrUtil.h" |
| 81 #include "wtf/text/CString.h" | 82 #include "wtf/text/CString.h" |
| 82 #include <stdio.h> | 83 #include <stdio.h> |
| 83 | 84 |
| 84 #define EDIT_DEBUG 0 | 85 #define EDIT_DEBUG 0 |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 604 |
| 604 static DispatchEventResult dispatchSelectStart(const VisibleSelection& selection
) | 605 static DispatchEventResult dispatchSelectStart(const VisibleSelection& selection
) |
| 605 { | 606 { |
| 606 Node* selectStartTarget = selection.extent().computeContainerNode(); | 607 Node* selectStartTarget = selection.extent().computeContainerNode(); |
| 607 if (!selectStartTarget) | 608 if (!selectStartTarget) |
| 608 return DispatchEventResult::NotCanceled; | 609 return DispatchEventResult::NotCanceled; |
| 609 | 610 |
| 610 return selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventT
ypeNames::selectstart)); | 611 return selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventT
ypeNames::selectstart)); |
| 611 } | 612 } |
| 612 | 613 |
| 614 // The return value of |FrameSelection::modify()| is different based on |
| 615 // value of |userTriggered| parameter. |
| 616 // When |userTriggered| is |userTriggered|, |modify()| returns false if |
| 617 // "selectstart" event is dispatched and canceled, otherwise returns true. |
| 618 // When |userTriggered| is |NotUserTrigged|, return value specifies whether |
| 619 // selection is modified or not. |
| 613 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
tGranularity granularity, EUserTriggered userTriggered) | 620 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
tGranularity granularity, EUserTriggered userTriggered) |
| 614 { | 621 { |
| 615 SelectionModifier selectionModifier(*frame(), selection(), m_xPosForVertical
ArrowNavigation); | 622 SelectionModifier selectionModifier(*frame(), selection(), m_xPosForVertical
ArrowNavigation); |
| 616 const bool modified = selectionModifier.modify(alter, direction, granularity
); | 623 const bool modified = selectionModifier.modify(alter, direction, granularity
); |
| 617 if (userTriggered == UserTriggered | 624 if (userTriggered == UserTriggered |
| 618 && selectionModifier.selection().isRange() | 625 && selectionModifier.selection().isRange() |
| 619 && selection().isCaret() | 626 && selection().isCaret() |
| 620 && dispatchSelectStart(selection()) != DispatchEventResult::NotCanceled)
{ | 627 && dispatchSelectStart(selection()) != DispatchEventResult::NotCanceled)
{ |
| 621 return false; | 628 return false; |
| 622 } | 629 } |
| 623 if (!modified) | 630 if (!modified) { |
| 624 return false; | 631 if (userTriggered == NotUserTriggered) |
| 632 return false; |
| 633 // If spatial navigation enabled, focus navigator will move focus to |
| 634 // another element. See snav-input.html and snav-textarea.html |
| 635 if (isSpatialNavigationEnabled(m_frame)) |
| 636 return false; |
| 637 // Even if selection isn't changed, we prevent to default action, e.g. |
| 638 // scroll window when caret is at end of content editable. |
| 639 return true; |
| 640 } |
| 625 | 641 |
| 626 const SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTri
ggered; | 642 const SetSelectionOptions options = CloseTyping | ClearTypingStyle | userTri
ggered; |
| 627 setSelection(selectionModifier.selection(), options); | 643 setSelection(selectionModifier.selection(), options); |
| 628 | 644 |
| 629 if (granularity == LineGranularity || granularity == ParagraphGranularity) | 645 if (granularity == LineGranularity || granularity == ParagraphGranularity) |
| 630 m_xPosForVerticalArrowNavigation = selectionModifier.xPosForVerticalArro
wNavigation(); | 646 m_xPosForVerticalArrowNavigation = selectionModifier.xPosForVerticalArro
wNavigation(); |
| 631 | 647 |
| 632 if (userTriggered == UserTriggered) | 648 if (userTriggered == UserTriggered) |
| 633 m_granularity = CharacterGranularity; | 649 m_granularity = CharacterGranularity; |
| 634 | 650 |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 | 1388 |
| 1373 void showTree(const blink::FrameSelection* sel) | 1389 void showTree(const blink::FrameSelection* sel) |
| 1374 { | 1390 { |
| 1375 if (sel) | 1391 if (sel) |
| 1376 sel->showTreeForThis(); | 1392 sel->showTreeForThis(); |
| 1377 else | 1393 else |
| 1378 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1394 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1379 } | 1395 } |
| 1380 | 1396 |
| 1381 #endif | 1397 #endif |
| OLD | NEW |