Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: Source/core/dom/DocumentMarkerController.cpp

Issue 419563003: Adding a word to dictionary should remove spelling markers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comment Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA. 23 * Boston, MA 02110-1301, USA.
24 * 24 *
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/dom/DocumentMarkerController.h" 28 #include "core/dom/DocumentMarkerController.h"
29 29
30 #include "core/dom/Node.h" 30 #include "core/dom/Node.h"
31 #include "core/dom/NodeTraversal.h" 31 #include "core/dom/NodeTraversal.h"
32 #include "core/dom/Range.h"
33 #include "core/dom/RenderedDocumentMarker.h" 32 #include "core/dom/RenderedDocumentMarker.h"
34 #include "core/editing/TextIterator.h" 33 #include "core/editing/TextIterator.h"
35 #include "core/rendering/RenderObject.h" 34 #include "core/rendering/RenderObject.h"
36 35
37 #ifndef NDEBUG 36 #ifndef NDEBUG
38 #include <stdio.h> 37 #include <stdio.h>
39 #endif 38 #endif
40 39
41 namespace blink { 40 namespace blink {
42 41
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 { 486 {
488 if (!possiblyHasMarkers(markerTypes)) 487 if (!possiblyHasMarkers(markerTypes))
489 return; 488 return;
490 ASSERT(!m_markers.isEmpty()); 489 ASSERT(!m_markers.isEmpty());
491 490
492 MarkerMap::iterator iterator = m_markers.find(node); 491 MarkerMap::iterator iterator = m_markers.find(node);
493 if (iterator != m_markers.end()) 492 if (iterator != m_markers.end())
494 removeMarkersFromList(iterator, markerTypes); 493 removeMarkersFromList(iterator, markerTypes);
495 } 494 }
496 495
496 void DocumentMarkerController::removeMarkers(const MarkerRemoverPredicate& shoul dRemoveMarker)
497 {
498 for (MarkerMap::iterator i = m_markers.begin(); i != m_markers.end(); ++i) {
499 MarkerLists* markers = i->value.get();
500 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) {
501 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex];
dcheng 2014/08/05 20:30:38 It looks a little weird to have a stack reference
502
503 Vector<RenderedDocumentMarker *> markersToBeRemoved;
504 for (size_t j = 0; list.get() && j < list->size(); ++j) {
505 if (shouldRemoveMarker(*list->at(j).get(), i->key))
506 markersToBeRemoved.append(list->at(j).get());
507 }
508
509 for (size_t j = 0; j < markersToBeRemoved.size(); ++j)
510 list->remove(list->find(markersToBeRemoved[j]));
511 }
512 }
513 }
514
497 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes) 515 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes)
498 { 516 {
499 if (!possiblyHasMarkers(markerTypes)) 517 if (!possiblyHasMarkers(markerTypes))
500 return; 518 return;
501 ASSERT(!m_markers.isEmpty()); 519 ASSERT(!m_markers.isEmpty());
502 520
503 Vector<const Node*> nodesWithMarkers; 521 Vector<const Node*> nodesWithMarkers;
504 copyKeysToVector(m_markers, nodesWithMarkers); 522 copyKeysToVector(m_markers, nodesWithMarkers);
505 unsigned size = nodesWithMarkers.size(); 523 unsigned size = nodesWithMarkers.size();
506 for (unsigned i = 0; i < size; ++i) { 524 for (unsigned i = 0; i < size; ++i) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 747
730 } // namespace blink 748 } // namespace blink
731 749
732 #ifndef NDEBUG 750 #ifndef NDEBUG
733 void showDocumentMarkers(const blink::DocumentMarkerController* controller) 751 void showDocumentMarkers(const blink::DocumentMarkerController* controller)
734 { 752 {
735 if (controller) 753 if (controller)
736 controller->showMarkers(); 754 controller->showMarkers();
737 } 755 }
738 #endif 756 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698