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

Side by Side Diff: sky/engine/core/dom/DocumentMarkerController.cpp

Issue 840403003: First pass at deleting paint invalidation code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/dom/DocumentMarkerController.h ('k') | sky/engine/core/editing/Editor.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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 list->append(RenderedDocumentMarker::create(newMarker)); 218 list->append(RenderedDocumentMarker::create(newMarker));
219 } else { 219 } else {
220 DocumentMarker toInsert(newMarker); 220 DocumentMarker toInsert(newMarker);
221 if (toInsert.type() != DocumentMarker::TextMatch) { 221 if (toInsert.type() != DocumentMarker::TextMatch) {
222 mergeOverlapping(list.get(), toInsert); 222 mergeOverlapping(list.get(), toInsert);
223 } else { 223 } else {
224 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), &toInsert, startsFurther); 224 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), &toInsert, startsFurther);
225 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI nsert)); 225 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI nsert));
226 } 226 }
227 } 227 }
228
229 // repaint the affected node
230 if (node->renderer())
231 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously() ;
232 } 228 }
233 229
234 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert) 230 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert)
235 { 231 {
236 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), &toInsert, doesNotOverlap); 232 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), &toInsert, doesNotOverlap);
237 size_t index = firstOverlapping - list->begin(); 233 size_t index = firstOverlapping - list->begin();
238 list->insert(index, RenderedDocumentMarker::create(toInsert)); 234 list->insert(index, RenderedDocumentMarker::create(toInsert));
239 MarkerList::iterator inserted = list->begin() + index; 235 MarkerList::iterator inserted = list->begin() + index;
240 firstOverlapping = inserted + 1; 236 firstOverlapping = inserted + 1;
241 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st artOffset() <= (*inserted)->endOffset(); ) { 237 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st artOffset() <= (*inserted)->endOffset(); ) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 docDirty = true; 275 docDirty = true;
280 if (marker->startOffset() < startOffset) 276 if (marker->startOffset() < startOffset)
281 marker->setStartOffset(startOffset); 277 marker->setStartOffset(startOffset);
282 if (marker->endOffset() > endOffset) 278 if (marker->endOffset() > endOffset)
283 marker->setEndOffset(endOffset); 279 marker->setEndOffset(endOffset);
284 marker->shiftOffsets(delta); 280 marker->shiftOffsets(delta);
285 281
286 addMarker(dstNode, *marker); 282 addMarker(dstNode, *marker);
287 } 283 }
288 } 284 }
289
290 // repaint the affected node
291 if (docDirty && dstNode->renderer())
292 dstNode->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronousl y();
293 } 285 }
294 286
295 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker) 287 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker)
296 { 288 {
297 if (length <= 0) 289 if (length <= 0)
298 return; 290 return;
299 291
300 if (!possiblyHasMarkers(markerTypes)) 292 if (!possiblyHasMarkers(markerTypes))
301 return; 293 return;
302 ASSERT(!(m_markers.isEmpty())); 294 ASSERT(!(m_markers.isEmpty()));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 list.clear(); 352 list.clear();
361 ++emptyListsCount; 353 ++emptyListsCount;
362 } 354 }
363 } 355 }
364 356
365 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { 357 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) {
366 m_markers.remove(node); 358 m_markers.remove(node);
367 if (m_markers.isEmpty()) 359 if (m_markers.isEmpty())
368 m_possiblyExistingMarkerTypes = 0; 360 m_possiblyExistingMarkerTypes = 0;
369 } 361 }
370
371 // repaint the affected node
372 if (docDirty && node->renderer())
373 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously() ;
374 } 362 }
375 363
376 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType) 364 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType)
377 { 365 {
378 if (!possiblyHasMarkers(markerType)) 366 if (!possiblyHasMarkers(markerType))
379 return 0; 367 return 0;
380 ASSERT(!(m_markers.isEmpty())); 368 ASSERT(!(m_markers.isEmpty()));
381 369
382 // outer loop: process each node that contains any markers 370 // outer loop: process each node that contains any markers
383 MarkerMap::iterator end = m_markers.end(); 371 MarkerMap::iterator end = m_markers.end();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 list->clear(); 551 list->clear();
564 list.clear(); 552 list.clear();
565 ++emptyListsCount; 553 ++emptyListsCount;
566 needsRepainting = true; 554 needsRepainting = true;
567 } 555 }
568 } 556 }
569 557
570 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount; 558 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount;
571 } 559 }
572 560
573 if (needsRepainting) {
574 if (RenderObject* renderer = iterator->key->renderer())
575 renderer->doNotUseInvalidatePaintForWholeRendererSynchronously();
576 }
577
578 if (nodeCanBeRemoved) { 561 if (nodeCanBeRemoved) {
579 m_markers.remove(iterator); 562 m_markers.remove(iterator);
580 if (m_markers.isEmpty()) 563 if (m_markers.isEmpty())
581 m_possiblyExistingMarkerTypes = 0; 564 m_possiblyExistingMarkerTypes = 0;
582 } 565 }
583 } 566 }
584 567
585 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types)
586 {
587 if (!possiblyHasMarkers(markerTypes))
588 return;
589 ASSERT(!m_markers.isEmpty());
590
591 // outer loop: process each markered node in the document
592 MarkerMap::iterator end = m_markers.end();
593 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) {
594 const Node* node = i->key;
595
596 // inner loop: process each marker in the current node
597 MarkerLists* markers = i->value.get();
598 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) {
599 OwnPtr<MarkerList>& list = (*markers)[markerListIndex];
600 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin( ))->type()))
601 continue;
602
603 // cause the node to be redrawn
604 if (RenderObject* renderer = node->renderer()) {
605 renderer->doNotUseInvalidatePaintForWholeRendererSynchronously() ;
606 break;
607 }
608 }
609 }
610 }
611
612 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r) 568 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r)
613 { 569 {
614 // outer loop: process each markered node in the document 570 // outer loop: process each markered node in the document
615 MarkerMap::iterator end = m_markers.end(); 571 MarkerMap::iterator end = m_markers.end();
616 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { 572 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) {
617 573
618 // inner loop: process each rect in the current node 574 // inner loop: process each rect in the current node
619 MarkerLists* markers = i->value.get(); 575 MarkerLists* markers = i->value.get();
620 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { 576 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) {
621 OwnPtr<MarkerList>& list = (*markers)[markerListIndex]; 577 OwnPtr<MarkerList>& list = (*markers)[markerListIndex];
(...skipping 24 matching lines...) Expand all
646 int startOffset = (*marker)->startOffset(); 602 int startOffset = (*marker)->startOffset();
647 ASSERT(startOffset + delta >= 0); 603 ASSERT(startOffset + delta >= 0);
648 #endif 604 #endif
649 (*marker)->shiftOffsets(delta); 605 (*marker)->shiftOffsets(delta);
650 docDirty = true; 606 docDirty = true;
651 607
652 // Marker moved, so previously-computed rendered rectangle is now in valid 608 // Marker moved, so previously-computed rendered rectangle is now in valid
653 (*marker)->invalidate(); 609 (*marker)->invalidate();
654 } 610 }
655 } 611 }
656
657 // repaint the affected node
658 if (docDirty && node->renderer())
659 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously() ;
660 } 612 }
661 613
662 void DocumentMarkerController::setMarkersActive(Range* range, bool active) 614 void DocumentMarkerController::setMarkersActive(Range* range, bool active)
663 { 615 {
664 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) 616 if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
665 return; 617 return;
666 ASSERT(!m_markers.isEmpty()); 618 ASSERT(!m_markers.isEmpty());
667 619
668 Node* startContainer = range->startContainer(); 620 Node* startContainer = range->startContainer();
669 Node* endContainer = range->endContainer(); 621 Node* endContainer = range->endContainer();
(...skipping 20 matching lines...) Expand all
690 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); 642 MarkerList::iterator startPos = std::upper_bound(list->begin(), list->end(), startOffset, endsBefore);
691 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker ) { 643 for (MarkerList::iterator marker = startPos; marker != list->end(); ++marker ) {
692 644
693 // Markers are returned in order, so stop if we are now past the specifi ed range. 645 // Markers are returned in order, so stop if we are now past the specifi ed range.
694 if ((*marker)->startOffset() >= endOffset) 646 if ((*marker)->startOffset() >= endOffset)
695 break; 647 break;
696 648
697 (*marker)->setActiveMatch(active); 649 (*marker)->setActiveMatch(active);
698 docDirty = true; 650 docDirty = true;
699 } 651 }
700
701 // repaint the affected node
702 if (docDirty && node->renderer())
703 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously() ;
704 } 652 }
705 653
706 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy pes markerTypes) 654 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy pes markerTypes)
707 { 655 {
708 if (!possiblyHasMarkers(markerTypes)) 656 if (!possiblyHasMarkers(markerTypes))
709 return false; 657 return false;
710 ASSERT(!m_markers.isEmpty()); 658 ASSERT(!m_markers.isEmpty());
711 659
712 Node* startContainer = range->startContainer(); 660 Node* startContainer = range->startContainer();
713 ASSERT(startContainer); 661 ASSERT(startContainer);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 704
757 } // namespace blink 705 } // namespace blink
758 706
759 #ifndef NDEBUG 707 #ifndef NDEBUG
760 void showDocumentMarkers(const blink::DocumentMarkerController* controller) 708 void showDocumentMarkers(const blink::DocumentMarkerController* controller)
761 { 709 {
762 if (controller) 710 if (controller)
763 controller->showMarkers(); 711 controller->showMarkers();
764 } 712 }
765 #endif 713 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/DocumentMarkerController.h ('k') | sky/engine/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698