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

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

Issue 318803002: Rename Repaint to Paint Invalidation part 3 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/editing/Caret.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (toInsert.type() != DocumentMarker::TextMatch) { 206 if (toInsert.type() != DocumentMarker::TextMatch) {
207 mergeOverlapping(list.get(), toInsert); 207 mergeOverlapping(list.get(), toInsert);
208 } else { 208 } else {
209 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), toInsert, startsFurther); 209 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), toInsert, startsFurther);
210 list->insert(pos - list->begin(), RenderedDocumentMarker(toInsert)); 210 list->insert(pos - list->begin(), RenderedDocumentMarker(toInsert));
211 } 211 }
212 } 212 }
213 213
214 // repaint the affected node 214 // repaint the affected node
215 if (node->renderer()) 215 if (node->renderer())
216 node->renderer()->repaint(); 216 node->renderer()->paintInvalidationForWholeRenderer();
217 } 217 }
218 218
219 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert) 219 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert)
220 { 220 {
221 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), toInsert, doesNotOverlap); 221 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), toInsert, doesNotOverlap);
222 size_t index = firstOverlapping - list->begin(); 222 size_t index = firstOverlapping - list->begin();
223 list->insert(index, RenderedDocumentMarker(toInsert)); 223 list->insert(index, RenderedDocumentMarker(toInsert));
224 MarkerList::iterator inserted = list->begin() + index; 224 MarkerList::iterator inserted = list->begin() + index;
225 firstOverlapping = inserted + 1; 225 firstOverlapping = inserted + 1;
226 for (MarkerList::iterator i = firstOverlapping; i != list->end() && i->start Offset() <= inserted->endOffset(); ) { 226 for (MarkerList::iterator i = firstOverlapping; i != list->end() && i->start Offset() <= inserted->endOffset(); ) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (marker.endOffset() > endOffset) 267 if (marker.endOffset() > endOffset)
268 marker.setEndOffset(endOffset); 268 marker.setEndOffset(endOffset);
269 marker.shiftOffsets(delta); 269 marker.shiftOffsets(delta);
270 270
271 addMarker(dstNode, marker); 271 addMarker(dstNode, marker);
272 } 272 }
273 } 273 }
274 274
275 // repaint the affected node 275 // repaint the affected node
276 if (docDirty && dstNode->renderer()) 276 if (docDirty && dstNode->renderer())
277 dstNode->renderer()->repaint(); 277 dstNode->renderer()->paintInvalidationForWholeRenderer();
278 } 278 }
279 279
280 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker) 280 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker)
281 { 281 {
282 if (length <= 0) 282 if (length <= 0)
283 return; 283 return;
284 284
285 if (!possiblyHasMarkers(markerTypes)) 285 if (!possiblyHasMarkers(markerTypes))
286 return; 286 return;
287 ASSERT(!(m_markers.isEmpty())); 287 ASSERT(!(m_markers.isEmpty()));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 349
350 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { 350 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) {
351 m_markers.remove(node); 351 m_markers.remove(node);
352 if (m_markers.isEmpty()) 352 if (m_markers.isEmpty())
353 m_possiblyExistingMarkerTypes = 0; 353 m_possiblyExistingMarkerTypes = 0;
354 } 354 }
355 355
356 // repaint the affected node 356 // repaint the affected node
357 if (docDirty && node->renderer()) 357 if (docDirty && node->renderer())
358 node->renderer()->repaint(); 358 node->renderer()->paintInvalidationForWholeRenderer();
359 } 359 }
360 360
361 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType) 361 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType)
362 { 362 {
363 if (!possiblyHasMarkers(markerType)) 363 if (!possiblyHasMarkers(markerType))
364 return 0; 364 return 0;
365 ASSERT(!(m_markers.isEmpty())); 365 ASSERT(!(m_markers.isEmpty()));
366 366
367 // outer loop: process each node that contains any markers 367 // outer loop: process each node that contains any markers
368 MarkerMap::iterator end = m_markers.end(); 368 MarkerMap::iterator end = m_markers.end();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ++emptyListsCount; 539 ++emptyListsCount;
540 needsRepainting = true; 540 needsRepainting = true;
541 } 541 }
542 } 542 }
543 543
544 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount; 544 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount;
545 } 545 }
546 546
547 if (needsRepainting) { 547 if (needsRepainting) {
548 if (RenderObject* renderer = iterator->key->renderer()) 548 if (RenderObject* renderer = iterator->key->renderer())
549 renderer->repaint(); 549 renderer->paintInvalidationForWholeRenderer();
550 } 550 }
551 551
552 if (nodeCanBeRemoved) { 552 if (nodeCanBeRemoved) {
553 m_markers.remove(iterator); 553 m_markers.remove(iterator);
554 if (m_markers.isEmpty()) 554 if (m_markers.isEmpty())
555 m_possiblyExistingMarkerTypes = 0; 555 m_possiblyExistingMarkerTypes = 0;
556 } 556 }
557 } 557 }
558 558
559 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types) 559 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types)
560 { 560 {
561 if (!possiblyHasMarkers(markerTypes)) 561 if (!possiblyHasMarkers(markerTypes))
562 return; 562 return;
563 ASSERT(!m_markers.isEmpty()); 563 ASSERT(!m_markers.isEmpty());
564 564
565 // outer loop: process each markered node in the document 565 // outer loop: process each markered node in the document
566 MarkerMap::iterator end = m_markers.end(); 566 MarkerMap::iterator end = m_markers.end();
567 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { 567 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) {
568 const Node* node = i->key; 568 const Node* node = i->key;
569 569
570 // inner loop: process each marker in the current node 570 // inner loop: process each marker in the current node
571 MarkerLists* markers = i->value.get(); 571 MarkerLists* markers = i->value.get();
572 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { 572 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) {
573 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; 573 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex];
574 if (!list || list->isEmpty() || !markerTypes.contains(list->begin()- >type())) 574 if (!list || list->isEmpty() || !markerTypes.contains(list->begin()- >type()))
575 continue; 575 continue;
576 576
577 // cause the node to be redrawn 577 // cause the node to be redrawn
578 if (RenderObject* renderer = node->renderer()) { 578 if (RenderObject* renderer = node->renderer()) {
579 renderer->repaint(); 579 renderer->paintInvalidationForWholeRenderer();
580 break; 580 break;
581 } 581 }
582 } 582 }
583 } 583 }
584 } 584 }
585 585
586 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r) 586 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r)
587 { 587 {
588 // outer loop: process each markered node in the document 588 // outer loop: process each markered node in the document
589 MarkerMap::iterator end = m_markers.end(); 589 MarkerMap::iterator end = m_markers.end();
(...skipping 30 matching lines...) Expand all
620 marker->shiftOffsets(delta); 620 marker->shiftOffsets(delta);
621 docDirty = true; 621 docDirty = true;
622 622
623 // Marker moved, so previously-computed rendered rectangle is now in valid 623 // Marker moved, so previously-computed rendered rectangle is now in valid
624 marker->invalidate(); 624 marker->invalidate();
625 } 625 }
626 } 626 }
627 627
628 // repaint the affected node 628 // repaint the affected node
629 if (docDirty && node->renderer()) 629 if (docDirty && node->renderer())
630 node->renderer()->repaint(); 630 node->renderer()->paintInvalidationForWholeRenderer();
631 } 631 }
632 632
633 void DocumentMarkerController::setMarkersActive(Range* range, bool active) 633 void DocumentMarkerController::setMarkersActive(Range* range, bool active)
634 { 634 {
635 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) 635 if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
636 return; 636 return;
637 ASSERT(!m_markers.isEmpty()); 637 ASSERT(!m_markers.isEmpty());
638 638
639 Node* startContainer = range->startContainer(); 639 Node* startContainer = range->startContainer();
640 Node* endContainer = range->endContainer(); 640 Node* endContainer = range->endContainer();
(...skipping 23 matching lines...) Expand all
664 // Markers are returned in order, so stop if we are now past the specifi ed range. 664 // Markers are returned in order, so stop if we are now past the specifi ed range.
665 if (marker->startOffset() >= endOffset) 665 if (marker->startOffset() >= endOffset)
666 break; 666 break;
667 667
668 marker->setActiveMatch(active); 668 marker->setActiveMatch(active);
669 docDirty = true; 669 docDirty = true;
670 } 670 }
671 671
672 // repaint the affected node 672 // repaint the affected node
673 if (docDirty && node->renderer()) 673 if (docDirty && node->renderer())
674 node->renderer()->repaint(); 674 node->renderer()->paintInvalidationForWholeRenderer();
675 } 675 }
676 676
677 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy pes markerTypes) 677 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy pes markerTypes)
678 { 678 {
679 if (!possiblyHasMarkers(markerTypes)) 679 if (!possiblyHasMarkers(markerTypes))
680 return false; 680 return false;
681 ASSERT(!m_markers.isEmpty()); 681 ASSERT(!m_markers.isEmpty());
682 682
683 Node* startContainer = range->startContainer(); 683 Node* startContainer = range->startContainer();
684 ASSERT(startContainer); 684 ASSERT(startContainer);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 727
728 } // namespace WebCore 728 } // namespace WebCore
729 729
730 #ifndef NDEBUG 730 #ifndef NDEBUG
731 void showDocumentMarkers(const WebCore::DocumentMarkerController* controller) 731 void showDocumentMarkers(const WebCore::DocumentMarkerController* controller)
732 { 732 {
733 if (controller) 733 if (controller)
734 controller->showMarkers(); 734 controller->showMarkers();
735 } 735 }
736 #endif 736 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/Caret.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698