Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 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 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 #include "core/editing/EditingUtilities.h" | 26 #include "core/editing/EditingUtilities.h" |
| 27 | 27 |
| 28 #include "core/HTMLElementFactory.h" | 28 #include "core/HTMLElementFactory.h" |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ElementTraversal.h" | 31 #include "core/dom/ElementTraversal.h" |
| 32 #include "core/dom/Range.h" | 32 #include "core/dom/Range.h" |
| 33 #include "core/dom/Text.h" | 33 #include "core/dom/Text.h" |
| 34 #include "core/dom/shadow/ShadowRoot.h" | 34 #include "core/dom/shadow/ShadowRoot.h" |
| 35 #include "core/editing/BackspaceStateMachine.h" | |
| 35 #include "core/editing/EditingStrategy.h" | 36 #include "core/editing/EditingStrategy.h" |
| 36 #include "core/editing/Editor.h" | 37 #include "core/editing/Editor.h" |
| 37 #include "core/editing/PlainTextRange.h" | 38 #include "core/editing/PlainTextRange.h" |
| 38 #include "core/editing/PositionIterator.h" | 39 #include "core/editing/PositionIterator.h" |
| 39 #include "core/editing/VisiblePosition.h" | 40 #include "core/editing/VisiblePosition.h" |
| 40 #include "core/editing/VisibleSelection.h" | 41 #include "core/editing/VisibleSelection.h" |
| 41 #include "core/editing/VisibleUnits.h" | 42 #include "core/editing/VisibleUnits.h" |
| 42 #include "core/editing/iterators/TextIterator.h" | 43 #include "core/editing/iterators/TextIterator.h" |
| 43 #include "core/editing/serializers/HTMLInterchange.h" | 44 #include "core/editing/serializers/HTMLInterchange.h" |
| 44 #include "core/frame/LocalFrame.h" | 45 #include "core/frame/LocalFrame.h" |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 PositionInFlatTree lastEditablePositionBeforePositionInRoot(const PositionInFlat Tree& position, Node& highestRoot) | 541 PositionInFlatTree lastEditablePositionBeforePositionInRoot(const PositionInFlat Tree& position, Node& highestRoot) |
| 541 { | 542 { |
| 542 return lastEditablePositionBeforePositionInRootAlgorithm<EditingInFlatTreeSt rategy>(position, highestRoot); | 543 return lastEditablePositionBeforePositionInRootAlgorithm<EditingInFlatTreeSt rategy>(position, highestRoot); |
| 543 } | 544 } |
| 544 | 545 |
| 545 int uncheckedPreviousOffset(const Node* n, int current) | 546 int uncheckedPreviousOffset(const Node* n, int current) |
| 546 { | 547 { |
| 547 return n->layoutObject() ? n->layoutObject()->previousOffset(current) : curr ent - 1; | 548 return n->layoutObject() ? n->layoutObject()->previousOffset(current) : curr ent - 1; |
| 548 } | 549 } |
| 549 | 550 |
| 550 static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current ) | 551 static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current ) |
|
yosin_UTC9
2016/03/25 04:37:23
Please avoid to use one letter variable name.
Seigo Nonaka
2016/03/25 06:59:06
Done.
| |
| 551 { | 552 { |
| 552 return n->layoutObject() ? n->layoutObject()->previousOffsetForBackwardDelet ion(current) : current - 1; | 553 if (current <= 1) |
| 554 return 0; | |
| 555 if (!n->isTextNode()) | |
| 556 return current - 1; | |
| 557 | |
| 558 const String& text = toText(n)->data(); | |
| 559 CHECK(static_cast<unsigned>(current - 1) < text.length()); | |
| 560 BackspaceStateMachine machine; | |
| 561 for (int i = current - 1; i >= 0; --i) { | |
| 562 if (machine.ComputeNextState(text[i])) { | |
|
yosin_UTC9
2016/03/25 04:37:23
nit: no need to have braces for single line statem
Seigo Nonaka
2016/03/25 06:59:06
Done.
| |
| 563 break; | |
| 564 } | |
| 565 } | |
| 566 return current - machine.FinalizeAndGetCodeUnitCountToBeDeleted(); | |
| 553 } | 567 } |
| 554 | 568 |
| 555 int uncheckedNextOffset(const Node* n, int current) | 569 int uncheckedNextOffset(const Node* n, int current) |
| 556 { | 570 { |
| 557 return n->layoutObject() ? n->layoutObject()->nextOffset(current) : current + 1; | 571 return n->layoutObject() ? n->layoutObject()->nextOffset(current) : current + 1; |
| 558 } | 572 } |
| 559 | 573 |
| 560 template <typename Strategy> | 574 template <typename Strategy> |
| 561 PositionTemplate<Strategy> previousPositionOfAlgorithm(const PositionTemplate<St rategy>& position, PositionMoveType moveType) | 575 PositionTemplate<Strategy> previousPositionOfAlgorithm(const PositionTemplate<St rategy>& position, PositionMoveType moveType) |
| 562 { | 576 { |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 // instead of possibly at the end of the last node before the selection | 1660 // instead of possibly at the end of the last node before the selection |
| 1647 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1661 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
| 1648 } | 1662 } |
| 1649 | 1663 |
| 1650 bool isTextSecurityNode(const Node* node) | 1664 bool isTextSecurityNode(const Node* node) |
| 1651 { | 1665 { |
| 1652 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE; | 1666 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE; |
| 1653 } | 1667 } |
| 1654 | 1668 |
| 1655 } // namespace blink | 1669 } // namespace blink |
| OLD | NEW |