OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #include "core/editing/markers/DocumentMarker.h" | 31 #include "core/editing/markers/DocumentMarker.h" |
32 | 32 |
33 #include "platform/wtf/StdLibExtras.h" | 33 #include "platform/wtf/StdLibExtras.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 DocumentMarker::~DocumentMarker() {} | 37 DocumentMarker::~DocumentMarker() {} |
38 | 38 |
39 DocumentMarker::DocumentMarker(MarkerType type, | 39 DocumentMarker::DocumentMarker(unsigned start_offset, unsigned end_offset) |
40 unsigned start_offset, | 40 : start_offset_(start_offset), end_offset_(end_offset) {} |
41 unsigned end_offset) | |
42 : type_(type), start_offset_(start_offset), end_offset_(end_offset) {} | |
43 | 41 |
44 Optional<DocumentMarker::MarkerOffsets> | 42 Optional<DocumentMarker::MarkerOffsets> |
45 DocumentMarker::ComputeOffsetsAfterShift(unsigned offset, | 43 DocumentMarker::ComputeOffsetsAfterShift(unsigned offset, |
46 unsigned old_length, | 44 unsigned old_length, |
47 unsigned new_length) const { | 45 unsigned new_length) const { |
48 MarkerOffsets result; | 46 MarkerOffsets result; |
49 result.start_offset = StartOffset(); | 47 result.start_offset = StartOffset(); |
50 result.end_offset = EndOffset(); | 48 result.end_offset = EndOffset(); |
51 | 49 |
52 // algorithm inspired by https://dom.spec.whatwg.org/#concept-cd-replace | 50 // algorithm inspired by https://dom.spec.whatwg.org/#concept-cd-replace |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 84 |
87 return result; | 85 return result; |
88 } | 86 } |
89 | 87 |
90 void DocumentMarker::ShiftOffsets(int delta) { | 88 void DocumentMarker::ShiftOffsets(int delta) { |
91 start_offset_ += delta; | 89 start_offset_ += delta; |
92 end_offset_ += delta; | 90 end_offset_ += delta; |
93 } | 91 } |
94 | 92 |
95 } // namespace blink | 93 } // namespace blink |
OLD | NEW |