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) { |
| 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)) |
| 317 dst_markers->at(marker_list_index) = new MarkerList; |
| 318 MarkerList* dst_list = dst_markers->at(marker_list_index); |
| 319 |
308 unsigned end_offset = length - 1; | 320 unsigned end_offset = length - 1; |
309 MarkerList::iterator it; | 321 MarkerList::iterator it; |
310 for (it = list->begin(); it != list->end(); ++it) { | 322 for (it = src_list->begin(); it != src_list->end(); ++it) { |
311 DocumentMarker* marker = it->Get(); | 323 DocumentMarker* marker = it->Get(); |
312 | 324 |
313 // stop if we are now past the specified range | 325 // stop if we are now past the specified range |
314 if (marker->StartOffset() > end_offset) | 326 if (marker->StartOffset() > end_offset) |
315 break; | 327 break; |
316 | 328 |
317 // pin the marker to the specified range | 329 // pin the marker to the specified range |
318 doc_dirty = true; | 330 doc_dirty = true; |
319 if (marker->EndOffset() > end_offset) | 331 if (marker->EndOffset() > end_offset) |
320 marker->SetEndOffset(end_offset); | 332 marker->SetEndOffset(end_offset); |
321 | 333 |
322 AddMarker(dst_node, *marker); | 334 DocumentMarkerListEditor::AddMarker(dst_list, marker); |
323 } | 335 } |
324 | 336 |
325 // Remove the range of markers that were moved to dstNode | 337 // Remove the range of markers that were moved to dst_node |
326 list->erase(0, it - list->begin()); | 338 src_list->erase(0, it - src_list->begin()); |
327 } | 339 } |
328 | 340 |
329 // repaint the affected node | 341 // repaint the affected node |
330 if (doc_dirty && dst_node->GetLayoutObject()) { | 342 if (doc_dirty && dst_node->GetLayoutObject()) { |
331 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( | 343 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( |
332 kPaintInvalidationDocumentMarkerChange); | 344 kPaintInvalidationDocumentMarkerChange); |
333 } | 345 } |
334 } | 346 } |
335 | 347 |
336 void DocumentMarkerController::RemoveMarkers( | 348 void DocumentMarkerController::RemoveMarkers( |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 } | 881 } |
870 | 882 |
871 } // namespace blink | 883 } // namespace blink |
872 | 884 |
873 #ifndef NDEBUG | 885 #ifndef NDEBUG |
874 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 886 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
875 if (controller) | 887 if (controller) |
876 controller->ShowMarkers(); | 888 controller->ShowMarkers(); |
877 } | 889 } |
878 #endif | 890 #endif |
OLD | NEW |