OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
7 * reserved. | 7 * reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 void DocumentMarkerController::MoveMarkers(Node* src_node, | 289 void DocumentMarkerController::MoveMarkers(Node* src_node, |
290 int length, | 290 int length, |
291 Node* dst_node) { | 291 Node* dst_node) { |
292 if (length <= 0) | 292 if (length <= 0) |
293 return; | 293 return; |
294 | 294 |
295 if (!PossiblyHasMarkers(DocumentMarker::AllMarkers())) | 295 if (!PossiblyHasMarkers(DocumentMarker::AllMarkers())) |
296 return; | 296 return; |
297 DCHECK(!markers_.IsEmpty()); | 297 DCHECK(!markers_.IsEmpty()); |
298 | 298 |
299 MarkerLists* markers = markers_.at(src_node); | 299 MarkerLists* src_markers = markers_.at(src_node); |
300 if (!markers) | 300 if (!src_markers) |
301 return; | 301 return; |
302 | 302 |
303 if (!markers_.Contains(dst_node)) { | |
304 markers_.insert(dst_node, | |
305 new MarkerLists(DocumentMarker::kMarkerTypeIndexesCount)); | |
306 } | |
307 MarkerLists* dst_markers = markers_.at(dst_node); | |
308 | |
303 bool doc_dirty = false; | 309 bool doc_dirty = false; |
304 for (Member<MarkerList> list : *markers) { | 310 for (size_t marker_list_index = 0; marker_list_index < src_markers->size(); |
305 if (!list) | 311 marker_list_index++) { |
Xiaocheng
2017/04/17 21:37:45
nit: ++marker_list_index
Google coding style pref
| |
312 MarkerList* src_list = src_markers->at(marker_list_index); | |
313 if (!src_list) | |
306 continue; | 314 continue; |
307 | 315 |
316 if (!dst_markers->at(marker_list_index)) { | |
Xiaocheng
2017/04/17 21:37:45
nit: no need to have extra braces
| |
317 dst_markers->at(marker_list_index) = new MarkerList; | |
318 } | |
319 MarkerList* dst_list = dst_markers->at(marker_list_index); | |
320 | |
308 unsigned end_offset = length - 1; | 321 unsigned end_offset = length - 1; |
309 MarkerList::iterator it; | 322 MarkerList::iterator it; |
310 for (it = list->begin(); it != list->end(); ++it) { | 323 for (it = src_list->begin(); it != src_list->end(); ++it) { |
311 DocumentMarker* marker = it->Get(); | 324 DocumentMarker* marker = it->Get(); |
312 | 325 |
313 // stop if we are now past the specified range | 326 // stop if we are now past the specified range |
314 if (marker->StartOffset() > end_offset) | 327 if (marker->StartOffset() > end_offset) |
315 break; | 328 break; |
316 | 329 |
317 // pin the marker to the specified range | 330 // pin the marker to the specified range |
318 doc_dirty = true; | 331 doc_dirty = true; |
319 if (marker->EndOffset() > end_offset) | 332 if (marker->EndOffset() > end_offset) |
320 marker->SetEndOffset(end_offset); | 333 marker->SetEndOffset(end_offset); |
321 | 334 |
322 AddMarker(dst_node, *marker); | 335 DocumentMarkerListEditor::AddMarker(dst_list, marker); |
323 } | 336 } |
324 | 337 |
325 // Remove the range of markers that were moved to dstNode | 338 // Remove the range of markers that were moved to dst_node |
326 list->erase(0, it - list->begin()); | 339 src_list->erase(0, it - src_list->begin()); |
327 } | 340 } |
328 | 341 |
329 // repaint the affected node | 342 // repaint the affected node |
330 if (doc_dirty && dst_node->GetLayoutObject()) { | 343 if (doc_dirty && dst_node->GetLayoutObject()) { |
331 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( | 344 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( |
332 kPaintInvalidationDocumentMarkerChange); | 345 kPaintInvalidationDocumentMarkerChange); |
333 } | 346 } |
334 } | 347 } |
335 | 348 |
336 void DocumentMarkerController::RemoveMarkers( | 349 void DocumentMarkerController::RemoveMarkers( |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 } | 882 } |
870 | 883 |
871 } // namespace blink | 884 } // namespace blink |
872 | 885 |
873 #ifndef NDEBUG | 886 #ifndef NDEBUG |
874 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 887 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
875 if (controller) | 888 if (controller) |
876 controller->ShowMarkers(); | 889 controller->ShowMarkers(); |
877 } | 890 } |
878 #endif | 891 #endif |
OLD | NEW |