OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 BackwardsCharacterIterator backwardsIterator(firstPositionInNode(document->d
ocumentElement()).parentAnchoredEquivalent(), startPosition, TextIteratorStopsOn
FormControls); | 82 BackwardsCharacterIterator backwardsIterator(firstPositionInNode(document->d
ocumentElement()).parentAnchoredEquivalent(), startPosition, TextIteratorStopsOn
FormControls); |
83 if (!backwardsIterator.atEnd()) | 83 if (!backwardsIterator.atEnd()) |
84 backwardsIterator.advance(halfMaxLength); | 84 backwardsIterator.advance(halfMaxLength); |
85 | 85 |
86 m_startOffsetInContent = Range::create(*document, backwardsIterator.endPosit
ion(), startPosition)->text().length(); | 86 m_startOffsetInContent = Range::create(*document, backwardsIterator.endPosit
ion(), startPosition)->text().length(); |
87 m_endOffsetInContent = Range::create(*document, backwardsIterator.endPositio
n(), endPosition)->text().length(); | 87 m_endOffsetInContent = Range::create(*document, backwardsIterator.endPositio
n(), endPosition)->text().length(); |
88 m_contentRange = Range::create(*document, backwardsIterator.endPosition(), f
orwardRange.startPosition()); | 88 m_contentRange = Range::create(*document, backwardsIterator.endPosition(), f
orwardRange.startPosition()); |
89 ASSERT(m_contentRange); | 89 ASSERT(m_contentRange); |
90 } | 90 } |
91 | 91 |
92 RawPtr<Range> SurroundingText::rangeFromContentOffsets(unsigned startOffsetInCon
tent, unsigned endOffsetInContent) | 92 Range* SurroundingText::rangeFromContentOffsets(unsigned startOffsetInContent, u
nsigned endOffsetInContent) |
93 { | 93 { |
94 if (startOffsetInContent >= endOffsetInContent || endOffsetInContent > conte
nt().length()) | 94 if (startOffsetInContent >= endOffsetInContent || endOffsetInContent > conte
nt().length()) |
95 return nullptr; | 95 return nullptr; |
96 | 96 |
97 CharacterIterator iterator(m_contentRange->startPosition(), m_contentRange->
endPosition()); | 97 CharacterIterator iterator(m_contentRange->startPosition(), m_contentRange->
endPosition()); |
98 | 98 |
99 ASSERT(!iterator.atEnd()); | 99 ASSERT(!iterator.atEnd()); |
100 iterator.advance(startOffsetInContent); | 100 iterator.advance(startOffsetInContent); |
101 | 101 |
102 Position start = iterator.startPosition(); | 102 Position start = iterator.startPosition(); |
(...skipping 18 matching lines...) Expand all Loading... |
121 { | 121 { |
122 return m_startOffsetInContent; | 122 return m_startOffsetInContent; |
123 } | 123 } |
124 | 124 |
125 unsigned SurroundingText::endOffsetInContent() const | 125 unsigned SurroundingText::endOffsetInContent() const |
126 { | 126 { |
127 return m_endOffsetInContent; | 127 return m_endOffsetInContent; |
128 } | 128 } |
129 | 129 |
130 } // namespace blink | 130 } // namespace blink |
OLD | NEW |