Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. |
| 3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 resultEnd = textRunStartPosition; | 141 resultEnd = textRunStartPosition; |
| 142 else | 142 else |
| 143 resultEnd = textRunEndPosition; | 143 resultEnd = textRunEndPosition; |
| 144 } | 144 } |
| 145 docTextPosition += len; | 145 docTextPosition += len; |
| 146 break; | 146 break; |
| 147 } | 147 } |
| 148 docTextPosition += len; | 148 docTextPosition += len; |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (!startRangeFound) | 151 if (!startRangeFound) { |
| 152 return EphemeralRange(); | 152 // startRangeFound = start() >= docTextPosition && start() <= docTextPos ition + len. |
| 153 // The former condition is related to the left boundary, and the latter to the right boundary. | |
| 154 // Since we assert that end()>=start()>=0, and docTextPosition==0 before the loop starts, | |
| 155 // so startRangeFound is false if and only if new cursor position exceed s the right boundary. | |
| 156 // In that case, the cursor should stay at the right boundary, because E ditText, the component | |
| 157 // in Android, behaves in that way. | |
|
Changwan Ryu
2016/04/05 07:50:37
how about renaming startRangeFound as startOutOfBo
yabinh
2016/04/05 08:06:41
Acknowledged.
| |
| 158 resultStart = textRunEndPosition; | |
| 159 resultEnd = textRunEndPosition; | |
| 160 } | |
| 153 | 161 |
| 154 if (length() && end() > docTextPosition) { // end() is out of bounds | 162 if (length() && end() > docTextPosition) { // end() is out of bounds |
| 155 resultEnd = textRunEndPosition; | 163 resultEnd = textRunEndPosition; |
| 156 } | 164 } |
| 157 | 165 |
| 158 return EphemeralRange(resultStart.toOffsetInAnchor(), resultEnd.toOffsetInAn chor()); | 166 return EphemeralRange(resultStart.toOffsetInAnchor(), resultEnd.toOffsetInAn chor()); |
| 159 } | 167 } |
| 160 | 168 |
| 161 PlainTextRange PlainTextRange::create(const ContainerNode& scope, const Ephemera lRange& range) | 169 PlainTextRange PlainTextRange::create(const ContainerNode& scope, const Ephemera lRange& range) |
| 162 { | 170 { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 180 | 188 |
| 181 return PlainTextRange(start, end); | 189 return PlainTextRange(start, end); |
| 182 } | 190 } |
| 183 | 191 |
| 184 PlainTextRange PlainTextRange::create(const ContainerNode& scope, const Range& r ange) | 192 PlainTextRange PlainTextRange::create(const ContainerNode& scope, const Range& r ange) |
| 185 { | 193 { |
| 186 return create(scope, EphemeralRange(&range)); | 194 return create(scope, EphemeralRange(&range)); |
| 187 } | 195 } |
| 188 | 196 |
| 189 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |