OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 WebRange::WebRange(int start, int length) | 41 WebRange::WebRange(int start, int length) |
42 : m_start(start) | 42 : m_start(start) |
43 , m_end(start + length) | 43 , m_end(start + length) |
44 { | 44 { |
45 DCHECK(start != -1 && length != 0) << "These values are reserved to indicate
that the range is null"; | 45 DCHECK(start != -1 && length != 0) << "These values are reserved to indicate
that the range is null"; |
46 } | 46 } |
47 | 47 |
48 WebRange::WebRange(Range* range) | 48 WebRange::WebRange(const EphemeralRange& range) |
49 { | 49 { |
50 if (!range) | 50 if (range.isNull()) |
51 return; | 51 return; |
52 | 52 |
53 m_start = range->startOffset(); | 53 m_start = range.startPosition().computeOffsetInContainerNode(); |
54 m_end = range->endOffset(); | 54 m_end =range.endPosition().computeOffsetInContainerNode(); |
55 } | 55 } |
56 | 56 |
57 Range* WebRange::createRange(LocalFrame* frame) const | 57 EphemeralRange WebRange::createEphemeralRange(LocalFrame* frame) const |
58 { | 58 { |
59 Element* selectionRoot = frame->selection().rootEditableElement(); | 59 Element* selectionRoot = frame->selection().rootEditableElement(); |
60 ContainerNode* scope = selectionRoot ? selectionRoot : frame->document()->do
cumentElement(); | 60 ContainerNode* scope = selectionRoot ? selectionRoot : frame->document()->do
cumentElement(); |
61 | 61 |
62 return blink::createRange(PlainTextRange(m_start, m_end).createRange(*scope)
); | 62 return PlainTextRange(m_start, m_end).createRange(*scope); |
63 } | 63 } |
64 | 64 |
65 } // namespace blink | 65 } // namespace blink |
OLD | NEW |