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 22 matching lines...) Expand all Loading... | |
33 #include "core/dom/RenderedDocumentMarker.h" | 33 #include "core/dom/RenderedDocumentMarker.h" |
34 #include "core/editing/TextIterator.h" | 34 #include "core/editing/TextIterator.h" |
35 #include "core/rendering/RenderObject.h" | 35 #include "core/rendering/RenderObject.h" |
36 | 36 |
37 #ifndef NDEBUG | 37 #ifndef NDEBUG |
38 #include <stdio.h> | 38 #include <stdio.h> |
39 #endif | 39 #endif |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 MarkerRemoverPredicate::MarkerRemoverPredicate(Document& document, | |
44 const Vector<String>& words) | |
45 : m_document(document), m_words(words) | |
46 { | |
47 } | |
48 | |
49 bool MarkerRemoverPredicate::operator()(const DocumentMarker& documentMarker, | |
50 const Node* node) const { | |
51 RefPtr<Range> markerRange = Range::create(m_document, | |
yosin_UTC9
2014/08/12 01:18:08
Let's avoid to use temporary Range object for Oilp
yosin_UTC9
2014/08/12 01:18:08
nit: s/RefPtr/RefPtrWIllBeRawPtr/
Klemen Forstnerič
2014/08/12 18:38:02
Done.
Klemen Forstnerič
2014/08/12 18:38:02
I removed the Range altogether, so no need to this
| |
52 const_cast<Node*>(node), documentMarker.startOffset(), | |
53 const_cast<Node*>(node), documentMarker.endOffset()); | |
54 | |
55 return m_words.contains(markerRange->text()); | |
56 } | |
57 | |
43 namespace { | 58 namespace { |
44 | 59 |
45 DocumentMarker::MarkerTypeIndex MarkerTypeToMarkerIndex(DocumentMarker::MarkerTy pe type) | 60 DocumentMarker::MarkerTypeIndex MarkerTypeToMarkerIndex(DocumentMarker::MarkerTy pe type) |
46 { | 61 { |
47 switch (type) { | 62 switch (type) { |
48 case DocumentMarker::Spelling: | 63 case DocumentMarker::Spelling: |
49 return DocumentMarker::SpellingMarkerIndex; | 64 return DocumentMarker::SpellingMarkerIndex; |
50 case DocumentMarker::Grammar: | 65 case DocumentMarker::Grammar: |
51 return DocumentMarker::GramarMarkerIndex; | 66 return DocumentMarker::GramarMarkerIndex; |
52 case DocumentMarker::TextMatch: | 67 case DocumentMarker::TextMatch: |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 { | 502 { |
488 if (!possiblyHasMarkers(markerTypes)) | 503 if (!possiblyHasMarkers(markerTypes)) |
489 return; | 504 return; |
490 ASSERT(!m_markers.isEmpty()); | 505 ASSERT(!m_markers.isEmpty()); |
491 | 506 |
492 MarkerMap::iterator iterator = m_markers.find(node); | 507 MarkerMap::iterator iterator = m_markers.find(node); |
493 if (iterator != m_markers.end()) | 508 if (iterator != m_markers.end()) |
494 removeMarkersFromList(iterator, markerTypes); | 509 removeMarkersFromList(iterator, markerTypes); |
495 } | 510 } |
496 | 511 |
512 void DocumentMarkerController::removeMarkers(const MarkerRemoverPredicate& shoul dRemoveMarker) | |
513 { | |
514 for (MarkerMap::iterator i = m_markers.begin(); i != m_markers.end(); ++i) { | |
515 MarkerLists* markers = i->value.get(); | |
516 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { | |
517 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; | |
518 | |
519 Vector<RenderedDocumentMarker *> markersToBeRemoved; | |
520 for (size_t j = 0; list.get() && j < list->size(); ++j) { | |
521 if (shouldRemoveMarker(*list->at(j).get(), i->key)) | |
522 markersToBeRemoved.append(list->at(j).get()); | |
523 } | |
524 | |
525 for (size_t j = 0; j < markersToBeRemoved.size(); ++j) | |
526 list->remove(list->find(markersToBeRemoved[j])); | |
527 } | |
528 } | |
529 } | |
530 | |
497 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes) | 531 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes) |
498 { | 532 { |
499 if (!possiblyHasMarkers(markerTypes)) | 533 if (!possiblyHasMarkers(markerTypes)) |
500 return; | 534 return; |
501 ASSERT(!m_markers.isEmpty()); | 535 ASSERT(!m_markers.isEmpty()); |
502 | 536 |
503 Vector<const Node*> nodesWithMarkers; | 537 Vector<const Node*> nodesWithMarkers; |
504 copyKeysToVector(m_markers, nodesWithMarkers); | 538 copyKeysToVector(m_markers, nodesWithMarkers); |
505 unsigned size = nodesWithMarkers.size(); | 539 unsigned size = nodesWithMarkers.size(); |
506 for (unsigned i = 0; i < size; ++i) { | 540 for (unsigned i = 0; i < size; ++i) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 | 763 |
730 } // namespace blink | 764 } // namespace blink |
731 | 765 |
732 #ifndef NDEBUG | 766 #ifndef NDEBUG |
733 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 767 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
734 { | 768 { |
735 if (controller) | 769 if (controller) |
736 controller->showMarkers(); | 770 controller->showMarkers(); |
737 } | 771 } |
738 #endif | 772 #endif |
OLD | NEW |