| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/editing/VisiblePosition.h" | 30 #include "core/editing/VisiblePosition.h" |
| 31 #include "core/editing/VisibleUnits.h" | 31 #include "core/editing/VisibleUnits.h" |
| 32 #include "core/editing/iterators/CharacterIterator.h" | 32 #include "core/editing/iterators/CharacterIterator.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 static EphemeralRange expandToParagraphBoundary(const EphemeralRange& range) | 36 static EphemeralRange expandToParagraphBoundary(const EphemeralRange& range) |
| 37 { | 37 { |
| 38 const VisiblePosition& start = createVisiblePosition(range.startPosition()); | 38 const VisiblePosition& start = createVisiblePosition(range.startPosition()); |
| 39 DCHECK(start.isNotNull()) << range.startPosition(); | 39 DCHECK(start.isNotNull()) << range.startPosition(); |
| 40 const VisiblePosition& paragraphStart = startOfParagraph(start); | 40 const Position& paragraphStart = startOfParagraph(start).deepEquivalent(); |
| 41 DCHECK(paragraphStart.isNotNull()) << range.startPosition(); | 41 DCHECK(paragraphStart.isNotNull()) << range.startPosition(); |
| 42 | 42 |
| 43 const VisiblePosition& end = createVisiblePosition(range.endPosition()); | 43 const VisiblePosition& end = createVisiblePosition(range.endPosition()); |
| 44 DCHECK(end.isNotNull()) << range.endPosition(); | 44 DCHECK(end.isNotNull()) << range.endPosition(); |
| 45 const VisiblePosition& paragraphEnd = endOfParagraph(end); | 45 const Position& paragraphEnd = endOfParagraph(end).deepEquivalent(); |
| 46 DCHECK(paragraphEnd.isNotNull()) << range.endPosition(); | 46 DCHECK(paragraphEnd.isNotNull()) << range.endPosition(); |
| 47 | 47 |
| 48 return EphemeralRange(paragraphStart.deepEquivalent(), paragraphEnd.deepEqui
valent()); | 48 // TODO(xiaochengh): There are some cases (crbug.com/640112) where we get |
| 49 // |paragraphStart > paragraphEnd|, which is the reason we cannot directly |
| 50 // return |EphemeralRange(paragraphStart, paragraphEnd)|. This is not |
| 51 // desired, though. We should do more investigation to ensure that why |
| 52 // |paragraphStart <= paragraphEnd| is violated. |
| 53 const Position& resultStart = paragraphStart.isNotNull() && paragraphStart <
= range.startPosition() ? paragraphStart : range.startPosition(); |
| 54 const Position& resultEnd = paragraphEnd.isNotNull() && paragraphEnd >= rang
e.endPosition() ? paragraphEnd : range.endPosition(); |
| 55 return EphemeralRange(resultStart, resultEnd); |
| 49 } | 56 } |
| 50 | 57 |
| 51 TextCheckingParagraph::TextCheckingParagraph(const EphemeralRange& checkingRange
) | 58 TextCheckingParagraph::TextCheckingParagraph(const EphemeralRange& checkingRange
) |
| 52 : m_checkingRange(checkingRange) | 59 : m_checkingRange(checkingRange) |
| 53 , m_checkingStart(-1) | 60 , m_checkingStart(-1) |
| 54 , m_checkingEnd(-1) | 61 , m_checkingEnd(-1) |
| 55 , m_checkingLength(-1) | 62 , m_checkingLength(-1) |
| 56 { | 63 { |
| 57 } | 64 } |
| 58 | 65 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 179 |
| 173 int TextCheckingParagraph::checkingLength() const | 180 int TextCheckingParagraph::checkingLength() const |
| 174 { | 181 { |
| 175 DCHECK(m_checkingRange.isNotNull()); | 182 DCHECK(m_checkingRange.isNotNull()); |
| 176 if (-1 == m_checkingLength) | 183 if (-1 == m_checkingLength) |
| 177 m_checkingLength = TextIterator::rangeLength(checkingRange().startPositi
on(), checkingRange().endPosition()); | 184 m_checkingLength = TextIterator::rangeLength(checkingRange().startPositi
on(), checkingRange().endPosition()); |
| 178 return m_checkingLength; | 185 return m_checkingLength; |
| 179 } | 186 } |
| 180 | 187 |
| 181 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |