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

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

Issue 23703016: [blink] Use functions for AllMarkers and MisspellingMarkers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 node->renderer()->repaint(); 194 node->renderer()->repaint();
195 } 195 }
196 196
197 // copies markers from srcNode to dstNode, applying the specified shift delta to the copies. The shift is 197 // copies markers from srcNode to dstNode, applying the specified shift delta to the copies. The shift is
198 // useful if, e.g., the caller has created the dstNode from a non-prefix substri ng of the srcNode. 198 // useful if, e.g., the caller has created the dstNode from a non-prefix substri ng of the srcNode.
199 void DocumentMarkerController::copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta) 199 void DocumentMarkerController::copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta)
200 { 200 {
201 if (length <= 0) 201 if (length <= 0)
202 return; 202 return;
203 203
204 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) 204 if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
205 return; 205 return;
206 ASSERT(!m_markers.isEmpty()); 206 ASSERT(!m_markers.isEmpty());
207 207
208 MarkerList* list = m_markers.get(srcNode); 208 MarkerList* list = m_markers.get(srcNode);
209 if (!list) 209 if (!list)
210 return; 210 return;
211 211
212 bool docDirty = false; 212 bool docDirty = false;
213 unsigned endOffset = startOffset + length - 1; 213 unsigned endOffset = startOffset + length - 1;
214 for (size_t i = 0; i != list->size(); ++i) { 214 for (size_t i = 0; i != list->size(); ++i) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 445
446 m_possiblyExistingMarkerTypes.remove(markerTypes); 446 m_possiblyExistingMarkerTypes.remove(markerTypes);
447 } 447 }
448 448
449 void DocumentMarkerController::removeMarkersFromList(MarkerMap::iterator iterato r, DocumentMarker::MarkerTypes markerTypes) 449 void DocumentMarkerController::removeMarkersFromList(MarkerMap::iterator iterato r, DocumentMarker::MarkerTypes markerTypes)
450 { 450 {
451 bool needsRepainting = false; 451 bool needsRepainting = false;
452 bool listCanBeRemoved; 452 bool listCanBeRemoved;
453 453
454 if (markerTypes == DocumentMarker::AllMarkers()) { 454 if (markerTypes == DocumentMarker::allMarkers()) {
455 needsRepainting = true; 455 needsRepainting = true;
456 listCanBeRemoved = true; 456 listCanBeRemoved = true;
457 } else { 457 } else {
458 MarkerList* list = iterator->value.get(); 458 MarkerList* list = iterator->value.get();
459 459
460 for (size_t i = 0; i != list->size(); ) { 460 for (size_t i = 0; i != list->size(); ) {
461 DocumentMarker marker = list->at(i); 461 DocumentMarker marker = list->at(i);
462 462
463 // skip nodes that are not of the specified type 463 // skip nodes that are not of the specified type
464 if (!markerTypes.contains(marker.type())) { 464 if (!markerTypes.contains(marker.type())) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 // inner loop: process each rect in the current node 529 // inner loop: process each rect in the current node
530 MarkerList* list = i->value.get(); 530 MarkerList* list = i->value.get();
531 for (size_t listIndex = 0; listIndex < list->size(); ++listIndex) 531 for (size_t listIndex = 0; listIndex < list->size(); ++listIndex)
532 list->at(listIndex).invalidate(r); 532 list->at(listIndex).invalidate(r);
533 } 533 }
534 } 534 }
535 535
536 void DocumentMarkerController::shiftMarkers(Node* node, unsigned startOffset, in t delta) 536 void DocumentMarkerController::shiftMarkers(Node* node, unsigned startOffset, in t delta)
537 { 537 {
538 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) 538 if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
539 return; 539 return;
540 ASSERT(!m_markers.isEmpty()); 540 ASSERT(!m_markers.isEmpty());
541 541
542 MarkerList* list = m_markers.get(node); 542 MarkerList* list = m_markers.get(node);
543 if (!list) 543 if (!list)
544 return; 544 return;
545 545
546 bool docDirty = false; 546 bool docDirty = false;
547 for (size_t i = 0; i != list->size(); ++i) { 547 for (size_t i = 0; i != list->size(); ++i) {
548 RenderedDocumentMarker& marker = list->at(i); 548 RenderedDocumentMarker& marker = list->at(i);
549 if (marker.startOffset() >= startOffset) { 549 if (marker.startOffset() >= startOffset) {
550 ASSERT((int)marker.startOffset() + delta >= 0); 550 ASSERT((int)marker.startOffset() + delta >= 0);
551 marker.shiftOffsets(delta); 551 marker.shiftOffsets(delta);
552 docDirty = true; 552 docDirty = true;
553 553
554 // Marker moved, so previously-computed rendered rectangle is now in valid 554 // Marker moved, so previously-computed rendered rectangle is now in valid
555 marker.invalidate(); 555 marker.invalidate();
556 } 556 }
557 } 557 }
558 558
559 // repaint the affected node 559 // repaint the affected node
560 if (docDirty && node->renderer()) 560 if (docDirty && node->renderer())
561 node->renderer()->repaint(); 561 node->renderer()->repaint();
562 } 562 }
563 563
564 void DocumentMarkerController::setMarkersActive(Range* range, bool active) 564 void DocumentMarkerController::setMarkersActive(Range* range, bool active)
565 { 565 {
566 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) 566 if (!possiblyHasMarkers(DocumentMarker::allMarkers()))
567 return; 567 return;
568 ASSERT(!m_markers.isEmpty()); 568 ASSERT(!m_markers.isEmpty());
569 569
570 Node* startContainer = range->startContainer(); 570 Node* startContainer = range->startContainer();
571 Node* endContainer = range->endContainer(); 571 Node* endContainer = range->endContainer();
572 572
573 Node* pastLastNode = range->pastLastNode(); 573 Node* pastLastNode = range->pastLastNode();
574 574
575 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave rsal::next(node)) { 575 for (Node* node = range->firstNode(); node != pastLastNode; node = NodeTrave rsal::next(node)) {
576 int startOffset = node == startContainer ? range->startOffset() : 0; 576 int startOffset = node == startContainer ? range->startOffset() : 0;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 } // namespace WebCore 657 } // namespace WebCore
658 658
659 #ifndef NDEBUG 659 #ifndef NDEBUG
660 void showDocumentMarkers(const WebCore::DocumentMarkerController* controller) 660 void showDocumentMarkers(const WebCore::DocumentMarkerController* controller)
661 { 661 {
662 if (controller) 662 if (controller)
663 controller->showMarkers(); 663 controller->showMarkers();
664 } 664 }
665 #endif 665 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698