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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 for (size_t marker_list_index = 0; marker_list_index < src_markers->size(); | 315 for (size_t marker_list_index = 0; marker_list_index < src_markers->size(); |
316 ++marker_list_index) { | 316 ++marker_list_index) { |
317 MarkerList* src_list = src_markers->at(marker_list_index); | 317 MarkerList* src_list = src_markers->at(marker_list_index); |
318 if (!src_list) | 318 if (!src_list) |
319 continue; | 319 continue; |
320 | 320 |
321 if (!dst_markers->at(marker_list_index)) | 321 if (!dst_markers->at(marker_list_index)) |
322 dst_markers->at(marker_list_index) = new MarkerList; | 322 dst_markers->at(marker_list_index) = new MarkerList; |
323 MarkerList* dst_list = dst_markers->at(marker_list_index); | 323 MarkerList* dst_list = dst_markers->at(marker_list_index); |
324 | 324 |
325 unsigned end_offset = length - 1; | 325 if (DocumentMarkerListEditor::MoveMarkers(src_list, length, dst_list)) |
326 MarkerList::iterator it; | |
327 for (it = src_list->begin(); it != src_list->end(); ++it) { | |
328 DocumentMarker* marker = it->Get(); | |
329 | |
330 // stop if we are now past the specified range | |
331 if (marker->StartOffset() > end_offset) | |
332 break; | |
333 | |
334 // pin the marker to the specified range | |
335 doc_dirty = true; | 326 doc_dirty = true; |
336 if (marker->EndOffset() > end_offset) | |
337 marker->SetEndOffset(end_offset); | |
338 | |
339 DocumentMarkerListEditor::AddMarker(dst_list, marker); | |
340 } | |
341 | |
342 // Remove the range of markers that were moved to dst_node | |
343 src_list->erase(0, it - src_list->begin()); | |
344 } | 327 } |
345 | 328 |
346 // repaint the affected node | 329 // repaint the affected node |
347 if (doc_dirty && dst_node->GetLayoutObject()) { | 330 if (doc_dirty && dst_node->GetLayoutObject()) { |
348 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( | 331 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( |
349 kPaintInvalidationDocumentMarkerChange); | 332 kPaintInvalidationDocumentMarkerChange); |
350 } | 333 } |
351 } | 334 } |
352 | 335 |
336 // TODO(rlanday): move DocumentMarkerListEditor into its own .h/.cpp files | |
337 bool DocumentMarkerListEditor::MoveMarkers(MarkerList* src_list, | |
338 int length, | |
339 MarkerList* dst_list) { | |
340 DCHECK_GT(length, 0); | |
341 bool doc_dirty = false; | |
342 unsigned end_offset = length - 1; | |
yosin_UTC9
2017/04/20 01:26:56
nit: s/unsigned/const unsigned/
| |
343 MarkerList::iterator it; | |
344 for (it = src_list->begin(); it != src_list->end(); ++it) { | |
345 DocumentMarker* marker = it->Get(); | |
346 | |
347 // stop if we are now past the specified range | |
348 if (marker->StartOffset() > end_offset) | |
349 break; | |
350 | |
351 // pin the marker to the specified range | |
352 doc_dirty = true; | |
353 if (marker->EndOffset() > end_offset) | |
354 marker->SetEndOffset(end_offset); | |
355 | |
356 DocumentMarkerListEditor::AddMarker(dst_list, marker); | |
357 } | |
358 | |
359 // Remove the range of markers that were moved to dst_node | |
360 src_list->erase(0, it - src_list->begin()); | |
361 | |
362 return doc_dirty; | |
363 } | |
364 | |
353 void DocumentMarkerController::RemoveMarkers( | 365 void DocumentMarkerController::RemoveMarkers( |
354 Node* node, | 366 Node* node, |
355 unsigned start_offset, | 367 unsigned start_offset, |
356 int length, | 368 int length, |
357 DocumentMarker::MarkerTypes marker_types) { | 369 DocumentMarker::MarkerTypes marker_types) { |
358 if (length <= 0) | 370 if (length <= 0) |
359 return; | 371 return; |
360 | 372 |
361 if (!PossiblyHasMarkers(marker_types)) | 373 if (!PossiblyHasMarkers(marker_types)) |
362 return; | 374 return; |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 } | 897 } |
886 | 898 |
887 } // namespace blink | 899 } // namespace blink |
888 | 900 |
889 #ifndef NDEBUG | 901 #ifndef NDEBUG |
890 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 902 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
891 if (controller) | 903 if (controller) |
892 controller->ShowMarkers(); | 904 controller->ShowMarkers(); |
893 } | 905 } |
894 #endif | 906 #endif |
OLD | NEW |