| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/editing/VisibleUnits.h" | 27 #include "core/editing/VisibleUnits.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionState.h" | |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | |
| 31 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 32 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 33 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
| 34 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
| 35 #include "core/dom/Text.h" | 33 #include "core/dom/Text.h" |
| 36 #include "core/editing/EditingUtilities.h" | 34 #include "core/editing/EditingUtilities.h" |
| 37 #include "core/editing/FrameSelection.h" | 35 #include "core/editing/FrameSelection.h" |
| 38 #include "core/editing/Position.h" | 36 #include "core/editing/Position.h" |
| 39 #include "core/editing/PositionIterator.h" | 37 #include "core/editing/PositionIterator.h" |
| 40 #include "core/editing/RenderedPosition.h" | 38 #include "core/editing/RenderedPosition.h" |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 662 |
| 665 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); | 663 typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsign
ed offset, BoundarySearchContextAvailability, bool& needMoreContext); |
| 666 | 664 |
| 667 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) | 665 static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
Function searchFunction) |
| 668 { | 666 { |
| 669 Position pos = c.deepEquivalent(); | 667 Position pos = c.deepEquivalent(); |
| 670 Node* boundary = parentEditingBoundary(pos); | 668 Node* boundary = parentEditingBoundary(pos); |
| 671 if (!boundary) | 669 if (!boundary) |
| 672 return VisiblePosition(); | 670 return VisiblePosition(); |
| 673 | 671 |
| 674 Document& d = boundary->document(); | |
| 675 Position start = Position::editingPositionOf(boundary, 0).parentAnchoredEqui
valent(); | 672 Position start = Position::editingPositionOf(boundary, 0).parentAnchoredEqui
valent(); |
| 676 Position end = pos.parentAnchoredEquivalent(); | 673 Position end = pos.parentAnchoredEquivalent(); |
| 677 | 674 |
| 678 Vector<UChar, 1024> string; | 675 Vector<UChar, 1024> string; |
| 679 unsigned suffixLength = 0; | 676 unsigned suffixLength = 0; |
| 680 | 677 |
| 681 TrackExceptionState exceptionState; | |
| 682 if (requiresContextForWordBoundary(characterBefore(c))) { | 678 if (requiresContextForWordBoundary(characterBefore(c))) { |
| 683 RefPtrWillBeRawPtr<Range> forwardsScanRange(d.createRange()); | 679 TextIterator forwardsIterator(end, Position::afterNode(boundary)); |
| 684 forwardsScanRange->setEndAfter(boundary, exceptionState); | |
| 685 forwardsScanRange->setStart(end.anchorNode(), end.offsetInContainerNode(
), exceptionState); | |
| 686 TextIterator forwardsIterator(forwardsScanRange->startPosition(), forwar
dsScanRange->endPosition()); | |
| 687 while (!forwardsIterator.atEnd()) { | 680 while (!forwardsIterator.atEnd()) { |
| 688 Vector<UChar, 1024> characters; | 681 Vector<UChar, 1024> characters; |
| 689 forwardsIterator.text().appendTextTo(characters); | 682 forwardsIterator.text().appendTextTo(characters); |
| 690 int i = endOfFirstWordBoundaryContext(characters.data(), characters.
size()); | 683 int i = endOfFirstWordBoundaryContext(characters.data(), characters.
size()); |
| 691 string.append(characters.data(), i); | 684 string.append(characters.data(), i); |
| 692 suffixLength += i; | 685 suffixLength += i; |
| 693 if (static_cast<unsigned>(i) < characters.size()) | 686 if (static_cast<unsigned>(i) < characters.size()) |
| 694 break; | 687 break; |
| 695 forwardsIterator.advance(); | 688 forwardsIterator.advance(); |
| 696 } | 689 } |
| 697 } | 690 } |
| 698 | 691 |
| 699 ASSERT(!exceptionState.hadException()); | |
| 700 if (exceptionState.hadException()) | |
| 701 return VisiblePosition(); | |
| 702 | |
| 703 SimplifiedBackwardsTextIterator it(start, end); | 692 SimplifiedBackwardsTextIterator it(start, end); |
| 704 unsigned next = 0; | 693 unsigned next = 0; |
| 705 bool needMoreContext = false; | 694 bool needMoreContext = false; |
| 706 while (!it.atEnd()) { | 695 while (!it.atEnd()) { |
| 707 bool inTextSecurityMode = it.node() && it.node()->layoutObject() && it.n
ode()->layoutObject()->style()->textSecurity() != TSNONE; | 696 bool inTextSecurityMode = it.node() && it.node()->layoutObject() && it.n
ode()->layoutObject()->style()->textSecurity() != TSNONE; |
| 708 // iterate to get chunks until the searchFunction returns a non-zero val
ue. | 697 // iterate to get chunks until the searchFunction returns a non-zero val
ue. |
| 709 if (!inTextSecurityMode) { | 698 if (!inTextSecurityMode) { |
| 710 it.prependTextTo(string); | 699 it.prependTextTo(string); |
| 711 } else { | 700 } else { |
| 712 // Treat bullets used in the text security mode as regular character
s when looking for boundaries | 701 // Treat bullets used in the text security mode as regular character
s when looking for boundaries |
| (...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2968 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale
nt()); | 2957 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale
nt()); |
| 2969 case CanSkipOverEditingBoundary: | 2958 case CanSkipOverEditingBoundary: |
| 2970 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent
()); | 2959 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent
()); |
| 2971 } | 2960 } |
| 2972 | 2961 |
| 2973 ASSERT_NOT_REACHED(); | 2962 ASSERT_NOT_REACHED(); |
| 2974 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent()
); | 2963 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent()
); |
| 2975 } | 2964 } |
| 2976 | 2965 |
| 2977 } // namespace blink | 2966 } // namespace blink |
| OLD | NEW |