| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (forward_range.IsNull() || | 85 if (forward_range.IsNull() || |
| 86 !Range::Create(*document, end_position, forward_range.StartPosition()) | 86 !Range::Create(*document, end_position, forward_range.StartPosition()) |
| 87 ->GetText() | 87 ->GetText() |
| 88 .length()) | 88 .length()) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 // Same as with the forward range but with the backward range. The range | 91 // Same as with the forward range but with the backward range. The range |
| 92 // starts at the document's or input element's start and ends at the selection | 92 // starts at the document's or input element's start and ends at the selection |
| 93 // start and will be updated. | 93 // start and will be updated. |
| 94 BackwardsCharacterIterator backwards_iterator( | 94 BackwardsCharacterIterator backwards_iterator( |
| 95 Position::FirstPositionInNode(root_element).ParentAnchoredEquivalent(), | 95 Position::FirstPositionInNode(*root_element).ParentAnchoredEquivalent(), |
| 96 start_position, | 96 start_position, |
| 97 TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build()); | 97 TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build()); |
| 98 if (!backwards_iterator.AtEnd()) | 98 if (!backwards_iterator.AtEnd()) |
| 99 backwards_iterator.Advance(half_max_length); | 99 backwards_iterator.Advance(half_max_length); |
| 100 | 100 |
| 101 const TextIteratorBehavior behavior = | 101 const TextIteratorBehavior behavior = |
| 102 TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior(); | 102 TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior(); |
| 103 start_offset_in_content_ = TextIterator::RangeLength( | 103 start_offset_in_content_ = TextIterator::RangeLength( |
| 104 backwards_iterator.EndPosition(), start_position, behavior); | 104 backwards_iterator.EndPosition(), start_position, behavior); |
| 105 end_offset_in_content_ = TextIterator::RangeLength( | 105 end_offset_in_content_ = TextIterator::RangeLength( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 | 121 |
| 122 unsigned SurroundingText::StartOffsetInContent() const { | 122 unsigned SurroundingText::StartOffsetInContent() const { |
| 123 return start_offset_in_content_; | 123 return start_offset_in_content_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 unsigned SurroundingText::EndOffsetInContent() const { | 126 unsigned SurroundingText::EndOffsetInContent() const { |
| 127 return end_offset_in_content_; | 127 return end_offset_in_content_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |