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

Side by Side Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp

Issue 2781623010: Add DocumentMarker::clone() (Closed)
Patch Set: Remove dependency that's messing with trybots Created 3 years, 8 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) 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 backgroundColor); 122 backgroundColor);
123 } 123 }
124 124
125 inline TextCompositionMarkerDetails* toTextCompositionMarkerDetails( 125 inline TextCompositionMarkerDetails* toTextCompositionMarkerDetails(
126 DocumentMarkerDetails* details) { 126 DocumentMarkerDetails* details) {
127 if (details && details->isComposition()) 127 if (details && details->isComposition())
128 return static_cast<TextCompositionMarkerDetails*>(details); 128 return static_cast<TextCompositionMarkerDetails*>(details);
129 return nullptr; 129 return nullptr;
130 } 130 }
131 131
132 DocumentMarker* DocumentMarker::clone() const {
133 return new DocumentMarker(*this);
134 }
135
136 DocumentMarker* DocumentMarker::cloneWithNewOffsets(unsigned startOffset,
137 unsigned endOffset) const {
138 DocumentMarker* clonedMarker = clone();
139 clonedMarker->setStartOffset(startOffset);
140 clonedMarker->setEndOffset(endOffset);
141
142 return clonedMarker;
143 }
144
132 DocumentMarker::DocumentMarker(MarkerType type, 145 DocumentMarker::DocumentMarker(MarkerType type,
133 unsigned startOffset, 146 unsigned startOffset,
134 unsigned endOffset, 147 unsigned endOffset,
135 const String& description) 148 const String& description)
136 : m_type(type), 149 : m_type(type),
137 m_startOffset(startOffset), 150 m_startOffset(startOffset),
138 m_endOffset(endOffset), 151 m_endOffset(endOffset),
139 m_details(description.isEmpty() 152 m_details(description.isEmpty()
140 ? nullptr 153 ? nullptr
141 : DocumentMarkerDescription::create(description)) {} 154 : DocumentMarkerDescription::create(description)) {}
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 toTextCompositionMarkerDetails(m_details.get())) 221 toTextCompositionMarkerDetails(m_details.get()))
209 return details->backgroundColor(); 222 return details->backgroundColor();
210 return Color::transparent; 223 return Color::transparent;
211 } 224 }
212 225
213 DEFINE_TRACE(DocumentMarker) { 226 DEFINE_TRACE(DocumentMarker) {
214 visitor->trace(m_details); 227 visitor->trace(m_details);
215 } 228 }
216 229
217 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698