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

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

Issue 2373613005: Update DCHECK in WebRange constructor. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 #include "core/editing/FrameSelection.h" 35 #include "core/editing/FrameSelection.h"
36 #include "core/editing/PlainTextRange.h" 36 #include "core/editing/PlainTextRange.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
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(const EphemeralRange& range) 48 WebRange::WebRange(const EphemeralRange& range)
49 { 49 {
50 if (range.isNull()) 50 if (range.isNull())
51 return; 51 return;
52 52
53 m_start = range.startPosition().computeOffsetInContainerNode(); 53 m_start = range.startPosition().computeOffsetInContainerNode();
54 m_end =range.endPosition().computeOffsetInContainerNode(); 54 m_end =range.endPosition().computeOffsetInContainerNode();
55 } 55 }
56 56
57 WebRange::WebRange(const PlainTextRange& range) 57 WebRange::WebRange(const PlainTextRange& range)
58 { 58 {
59 if (range.isNull()) 59 if (range.isNull())
60 return; 60 return;
61 61
62 m_start = range.start(); 62 m_start = range.start();
63 m_end = range.end(); 63 m_end = range.end();
64 } 64 }
65 65
66 EphemeralRange WebRange::createEphemeralRange(LocalFrame* frame) const 66 EphemeralRange WebRange::createEphemeralRange(LocalFrame* frame) const
67 { 67 {
68 Element* selectionRoot = frame->selection().rootEditableElement(); 68 Element* selectionRoot = frame->selection().rootEditableElement();
69 ContainerNode* scope = selectionRoot ? selectionRoot : frame->document()->do cumentElement(); 69 ContainerNode* scope = selectionRoot ? selectionRoot : frame->document()->do cumentElement();
70 70
71 return PlainTextRange(m_start, m_end).createRange(*scope); 71 return PlainTextRange(m_start, m_end).createRange(*scope);
72 } 72 }
73 73
74 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698