| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 paragraph_range_ = range; | 92 paragraph_range_ = range; |
| 93 } | 93 } |
| 94 | 94 |
| 95 EphemeralRange TextCheckingParagraph::Subrange(int character_offset, | 95 EphemeralRange TextCheckingParagraph::Subrange(int character_offset, |
| 96 int character_count) const { | 96 int character_count) const { |
| 97 DCHECK(checking_range_.IsNotNull()); | 97 DCHECK(checking_range_.IsNotNull()); |
| 98 return CalculateCharacterSubrange(ParagraphRange(), character_offset, | 98 return CalculateCharacterSubrange(ParagraphRange(), character_offset, |
| 99 character_count); | 99 character_count); |
| 100 } | 100 } |
| 101 | 101 |
| 102 int TextCheckingParagraph::OffsetTo(const Position& position) const { | |
| 103 DCHECK(checking_range_.IsNotNull()); | |
| 104 return TextIterator::RangeLength(OffsetAsRange().StartPosition(), position); | |
| 105 } | |
| 106 | |
| 107 bool TextCheckingParagraph::IsEmpty() const { | 102 bool TextCheckingParagraph::IsEmpty() const { |
| 108 // Both predicates should have same result, but we check both just to be sure. | 103 // Both predicates should have same result, but we check both just to be sure. |
| 109 // We need to investigate to remove this redundancy. | 104 // We need to investigate to remove this redundancy. |
| 110 return IsRangeEmpty() || IsTextEmpty(); | 105 return IsRangeEmpty() || IsTextEmpty(); |
| 111 } | 106 } |
| 112 | 107 |
| 113 EphemeralRange TextCheckingParagraph::OffsetAsRange() const { | 108 EphemeralRange TextCheckingParagraph::OffsetAsRange() const { |
| 114 DCHECK(checking_range_.IsNotNull()); | 109 DCHECK(checking_range_.IsNotNull()); |
| 115 if (offset_as_range_.IsNotNull()) | 110 if (offset_as_range_.IsNotNull()) |
| 116 return offset_as_range_; | 111 return offset_as_range_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 146 |
| 152 int TextCheckingParagraph::CheckingLength() const { | 147 int TextCheckingParagraph::CheckingLength() const { |
| 153 DCHECK(checking_range_.IsNotNull()); | 148 DCHECK(checking_range_.IsNotNull()); |
| 154 if (-1 == checking_length_) | 149 if (-1 == checking_length_) |
| 155 checking_length_ = TextIterator::RangeLength( | 150 checking_length_ = TextIterator::RangeLength( |
| 156 CheckingRange().StartPosition(), CheckingRange().EndPosition()); | 151 CheckingRange().StartPosition(), CheckingRange().EndPosition()); |
| 157 return checking_length_; | 152 return checking_length_; |
| 158 } | 153 } |
| 159 | 154 |
| 160 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |