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 if (active) { |
681 addTextMatchMarker(range, true); | |
682 return false; | |
683 } | |
684 } | |
Finnur
2016/01/20 14:14:03
On the face of it, this looks a bit weird -- addin
dvadym
2016/01/29 09:44:17
At first I thought to add markers here when there
| |
681 ASSERT(!m_markers.isEmpty()); | 685 ASSERT(!m_markers.isEmpty()); |
682 | 686 |
683 Node* startContainer = range->startContainer(); | 687 Node* startContainer = range->startContainer(); |
684 Node* endContainer = range->endContainer(); | 688 Node* endContainer = range->endContainer(); |
685 | 689 |
686 Node* pastLastNode = range->pastLastNode(); | 690 Node* pastLastNode = range->pastLastNode(); |
687 | 691 |
692 bool markerFound = false; | |
688 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave rsal::next(*node)) { | 693 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave rsal::next(*node)) { |
689 int startOffset = node == startContainer ? range->startOffset() : 0; | 694 int startOffset = node == startContainer ? range->startOffset() : 0; |
690 int endOffset = node == endContainer ? range->endOffset() : INT_MAX; | 695 int endOffset = node == endContainer ? range->endOffset() : INT_MAX; |
691 setMarkersActive(node, startOffset, endOffset, active); | 696 markerFound |= setMarkersActive(node, startOffset, endOffset, active); |
692 } | 697 } |
698 if (!markerFound && active) { | |
699 addTextMatchMarker(range, true); | |
700 return false; | |
701 } | |
702 return true; | |
693 } | 703 } |
694 | 704 |
695 void DocumentMarkerController::setMarkersActive(Node* node, unsigned startOffset , unsigned endOffset, bool active) | 705 bool DocumentMarkerController::setMarkersActive(Node* node, unsigned startOffset , unsigned endOffset, bool active) |
696 { | 706 { |
697 MarkerLists* markers = m_markers.get(node); | 707 MarkerLists* markers = m_markers.get(node); |
698 if (!markers) | 708 if (!markers) |
699 return; | 709 return false; |
700 | 710 |
701 bool docDirty = false; | 711 bool docDirty = false; |
702 OwnPtrWillBeMember<MarkerList>& list = (*markers)[MarkerTypeToMarkerIndex(Do cumentMarker::TextMatch)]; | 712 OwnPtrWillBeMember<MarkerList>& list = (*markers)[MarkerTypeToMarkerIndex(Do cumentMarker::TextMatch)]; |
703 if (!list) | 713 if (!list) |
704 return; | 714 return true; |
Finnur
2016/01/20 14:14:03
Out of curiosity... why not return false here?
dvadym
2016/01/29 09:44:17
Agree, fixed.
| |
705 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); | 715 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); |
706 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker ) { | 716 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker ) { |
707 | 717 |
708 // Markers are returned in order, so stop if we are now past the specifi ed range. | 718 // Markers are returned in order, so stop if we are now past the specifi ed range. |
709 if ((*marker)->startOffset() >= endOffset) | 719 if ((*marker)->startOffset() >= endOffset) |
710 break; | 720 break; |
711 | 721 |
712 (*marker)->setActiveMatch(active); | 722 (*marker)->setActiveMatch(active); |
713 docDirty = true; | 723 docDirty = true; |
714 } | 724 } |
715 | 725 |
716 // repaint the affected node | 726 // repaint the affected node |
717 if (docDirty && node->layoutObject()) | 727 if (docDirty && node->layoutObject()) |
718 node->layoutObject()->setShouldDoFullPaintInvalidation(); | 728 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
729 return true; | |
719 } | 730 } |
720 | 731 |
721 #ifndef NDEBUG | 732 #ifndef NDEBUG |
722 void DocumentMarkerController::showMarkers() const | 733 void DocumentMarkerController::showMarkers() const |
723 { | 734 { |
724 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); | 735 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); |
725 MarkerMap::const_iterator end = m_markers.end(); | 736 MarkerMap::const_iterator end = m_markers.end(); |
726 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato r != end; ++nodeIterator) { | 737 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato r != end; ++nodeIterator) { |
727 const Node* node = nodeIterator->key; | 738 const Node* node = nodeIterator->key; |
728 fprintf(stderr, "%p", node); | 739 fprintf(stderr, "%p", node); |
(...skipping 13 matching lines...) Expand all Loading... | |
742 | 753 |
743 } // namespace blink | 754 } // namespace blink |
744 | 755 |
745 #ifndef NDEBUG | 756 #ifndef NDEBUG |
746 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 757 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
747 { | 758 { |
748 if (controller) | 759 if (controller) |
749 controller->showMarkers(); | 760 controller->showMarkers(); |
750 } | 761 } |
751 #endif | 762 #endif |
OLD | NEW |