Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: third_party/WebKit/Source/web/WebRange.cpp

Issue 2260283002: Adapt WebRange to only deal with EphemeralRanges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back the isNull case, sorry. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.cpp ('k') | third_party/WebKit/public/web/WebRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698