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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 618 } |
619 | 619 |
620 bool DocumentMarkerController::SetTextMatchMarkersActive(Node* node, | 620 bool DocumentMarkerController::SetTextMatchMarkersActive(Node* node, |
621 unsigned start_offset, | 621 unsigned start_offset, |
622 unsigned end_offset, | 622 unsigned end_offset, |
623 bool active) { | 623 bool active) { |
624 MarkerLists* markers = markers_.at(node); | 624 MarkerLists* markers = markers_.at(node); |
625 if (!markers) | 625 if (!markers) |
626 return false; | 626 return false; |
627 | 627 |
628 bool doc_dirty = false; | |
629 DocumentMarkerList* const list = | 628 DocumentMarkerList* const list = |
630 ListForType(markers, DocumentMarker::kTextMatch); | 629 ListForType(markers, DocumentMarker::kTextMatch); |
631 | |
632 if (!list) | 630 if (!list) |
633 return false; | 631 return false; |
634 | 632 |
635 const HeapVector<Member<DocumentMarker>>& markers_in_list = | 633 bool doc_dirty = ToTextMatchMarkerListImpl(list)->SetTextMatchMarkersActive( |
636 list->GetMarkers(); | 634 start_offset, end_offset, active); |
637 // TODO(rlanday): this assumes that the markers are stored in sorted order. | |
638 // This method should probably eventually be implemented by a | |
639 // TextMatch-specific marker list | |
640 const auto start_pos = std::upper_bound( | |
641 markers_in_list.begin(), markers_in_list.end(), start_offset, | |
642 [](size_t start_offset, const Member<DocumentMarker>& marker) { | |
643 return start_offset < marker->EndOffset(); | |
644 }); | |
645 for (auto marker = start_pos; marker != markers_in_list.end(); ++marker) { | |
646 // Markers are returned in order, so stop if we are now past the specified | |
647 // range. | |
648 if ((*marker)->StartOffset() >= end_offset) | |
649 break; | |
650 | |
651 (*marker)->SetIsActiveMatch(active); | |
652 doc_dirty = true; | |
653 } | |
654 | 635 |
655 // repaint the affected node | 636 // repaint the affected node |
656 if (doc_dirty && node->GetLayoutObject()) { | 637 if (doc_dirty && node->GetLayoutObject()) { |
657 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( | 638 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( |
658 PaintInvalidationReason::kDocumentMarker); | 639 PaintInvalidationReason::kDocumentMarker); |
659 } | 640 } |
660 return doc_dirty; | 641 return doc_dirty; |
661 } | 642 } |
662 | 643 |
663 #ifndef NDEBUG | 644 #ifndef NDEBUG |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 } | 705 } |
725 | 706 |
726 } // namespace blink | 707 } // namespace blink |
727 | 708 |
728 #ifndef NDEBUG | 709 #ifndef NDEBUG |
729 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 710 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
730 if (controller) | 711 if (controller) |
731 controller->ShowMarkers(); | 712 controller->ShowMarkers(); |
732 } | 713 } |
733 #endif | 714 #endif |
OLD | NEW |