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
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 updateMarkerRenderedRect(node, **marker); | 668 updateMarkerRenderedRect(node, **marker); |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 // repaint the affected node | 672 // repaint the affected node |
673 if (docDirty && node->layoutObject()) | 673 if (docDirty && node->layoutObject()) |
674 node->layoutObject()->setShouldDoFullPaintInvalidation(); | 674 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
675 } | 675 } |
676 | 676 |
677 void DocumentMarkerController::setMarkersActive(Range* range, bool active) | 677 bool DocumentMarkerController::setMarkersActive(Range* range, bool active) |
678 { | 678 { |
679 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) | 679 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) |
680 return; | 680 return false; |
| 681 |
681 ASSERT(!m_markers.isEmpty()); | 682 ASSERT(!m_markers.isEmpty()); |
682 | 683 |
683 Node* startContainer = range->startContainer(); | 684 Node* startContainer = range->startContainer(); |
684 Node* endContainer = range->endContainer(); | 685 Node* endContainer = range->endContainer(); |
685 | 686 |
686 Node* pastLastNode = range->pastLastNode(); | 687 Node* pastLastNode = range->pastLastNode(); |
687 | 688 |
| 689 bool markerFound = false; |
688 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave
rsal::next(*node)) { | 690 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave
rsal::next(*node)) { |
689 int startOffset = node == startContainer ? range->startOffset() : 0; | 691 int startOffset = node == startContainer ? range->startOffset() : 0; |
690 int endOffset = node == endContainer ? range->endOffset() : INT_MAX; | 692 int endOffset = node == endContainer ? range->endOffset() : INT_MAX; |
691 setMarkersActive(node, startOffset, endOffset, active); | 693 markerFound |= setMarkersActive(node, startOffset, endOffset, active); |
692 } | 694 } |
| 695 return markerFound; |
693 } | 696 } |
694 | 697 |
695 void DocumentMarkerController::setMarkersActive(Node* node, unsigned startOffset
, unsigned endOffset, bool active) | 698 bool DocumentMarkerController::setMarkersActive(Node* node, unsigned startOffset
, unsigned endOffset, bool active) |
696 { | 699 { |
697 MarkerLists* markers = m_markers.get(node); | 700 MarkerLists* markers = m_markers.get(node); |
698 if (!markers) | 701 if (!markers) |
699 return; | 702 return false; |
700 | 703 |
701 bool docDirty = false; | 704 bool docDirty = false; |
702 OwnPtrWillBeMember<MarkerList>& list = (*markers)[MarkerTypeToMarkerIndex(Do
cumentMarker::TextMatch)]; | 705 OwnPtrWillBeMember<MarkerList>& list = (*markers)[MarkerTypeToMarkerIndex(Do
cumentMarker::TextMatch)]; |
703 if (!list) | 706 if (!list) |
704 return; | 707 return false; |
705 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(),
startOffset, endsBefore); | 708 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(),
startOffset, endsBefore); |
706 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker
) { | 709 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker
) { |
707 | 710 |
708 // Markers are returned in order, so stop if we are now past the specifi
ed range. | 711 // Markers are returned in order, so stop if we are now past the specifi
ed range. |
709 if ((*marker)->startOffset() >= endOffset) | 712 if ((*marker)->startOffset() >= endOffset) |
710 break; | 713 break; |
711 | 714 |
712 (*marker)->setActiveMatch(active); | 715 (*marker)->setActiveMatch(active); |
713 docDirty = true; | 716 docDirty = true; |
714 } | 717 } |
715 | 718 |
716 // repaint the affected node | 719 // repaint the affected node |
717 if (docDirty && node->layoutObject()) | 720 if (docDirty && node->layoutObject()) |
718 node->layoutObject()->setShouldDoFullPaintInvalidation(); | 721 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
| 722 return docDirty; |
719 } | 723 } |
720 | 724 |
721 #ifndef NDEBUG | 725 #ifndef NDEBUG |
722 void DocumentMarkerController::showMarkers() const | 726 void DocumentMarkerController::showMarkers() const |
723 { | 727 { |
724 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); | 728 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); |
725 MarkerMap::const_iterator end = m_markers.end(); | 729 MarkerMap::const_iterator end = m_markers.end(); |
726 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato
r != end; ++nodeIterator) { | 730 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato
r != end; ++nodeIterator) { |
727 const Node* node = nodeIterator->key; | 731 const Node* node = nodeIterator->key; |
728 fprintf(stderr, "%p", node); | 732 fprintf(stderr, "%p", node); |
(...skipping 13 matching lines...) Expand all Loading... |
742 | 746 |
743 } // namespace blink | 747 } // namespace blink |
744 | 748 |
745 #ifndef NDEBUG | 749 #ifndef NDEBUG |
746 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 750 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
747 { | 751 { |
748 if (controller) | 752 if (controller) |
749 controller->showMarkers(); | 753 controller->showMarkers(); |
750 } | 754 } |
751 #endif | 755 #endif |
OLD | NEW |