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

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

Issue 1053123007: Invalidate paint of tickmarks on document change (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 } // namespace 77 } // namespace
78 78
79 inline bool DocumentMarkerController::possiblyHasMarkers(DocumentMarker::MarkerT ypes types) 79 inline bool DocumentMarkerController::possiblyHasMarkers(DocumentMarker::MarkerT ypes types)
80 { 80 {
81 return m_possiblyExistingMarkerTypes.intersects(types); 81 return m_possiblyExistingMarkerTypes.intersects(types);
82 } 82 }
83 83
84 DocumentMarkerController::DocumentMarkerController() 84 DocumentMarkerController::DocumentMarkerController()
85 : m_possiblyExistingMarkerTypes(0) 85 : m_possiblyExistingMarkerTypes(0)
86 , m_textMatchMarkersRemovedOrChanged(false)
86 { 87 {
87 } 88 }
88 89
89 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DocumentMarkerController); 90 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DocumentMarkerController);
90 91
91 void DocumentMarkerController::clear() 92 void DocumentMarkerController::clear()
92 { 93 {
93 m_markers.clear(); 94 m_markers.clear();
94 m_possiblyExistingMarkerTypes = 0; 95 m_possiblyExistingMarkerTypes = 0;
95 } 96 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 static bool doesNotOverlap(const OwnPtrWillBeMember<RenderedDocumentMarker>& lhv , const DocumentMarker* rhv) 171 static bool doesNotOverlap(const OwnPtrWillBeMember<RenderedDocumentMarker>& lhv , const DocumentMarker* rhv)
171 { 172 {
172 return lhv->endOffset() < rhv->startOffset(); 173 return lhv->endOffset() < rhv->startOffset();
173 } 174 }
174 175
175 static bool doesNotInclude(const OwnPtrWillBeMember<RenderedDocumentMarker>& mar ker, size_t startOffset) 176 static bool doesNotInclude(const OwnPtrWillBeMember<RenderedDocumentMarker>& mar ker, size_t startOffset)
176 { 177 {
177 return marker->endOffset() < startOffset; 178 return marker->endOffset() < startOffset;
178 } 179 }
179 180
180 static void updateMarkerRenderedRect(Node* node, RenderedDocumentMarker& marker) 181 static bool updateMarkerRenderedRect(Node* node, RenderedDocumentMarker& marker)
181 { 182 {
182 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); 183 RefPtrWillBeRawPtr<Range> range = Range::create(node->document());
183 // The offsets of the marker may be out-dated, so check for exceptions. 184 // The offsets of the marker may be out-dated, so check for exceptions.
184 TrackExceptionState exceptionState; 185 TrackExceptionState exceptionState;
185 range->setStart(node, marker.startOffset(), exceptionState); 186 range->setStart(node, marker.startOffset(), exceptionState);
186 if (!exceptionState.hadException()) 187 if (!exceptionState.hadException())
187 range->setEnd(node, marker.endOffset(), IGNORE_EXCEPTION); 188 range->setEnd(node, marker.endOffset(), IGNORE_EXCEPTION);
188 if (exceptionState.hadException()) { 189 if (exceptionState.hadException())
189 marker.invalidateRenderedRect(); 190 return marker.invalidateRenderedRect();
190 return; 191 return marker.setRenderedRect(LayoutRect(range->boundingBox()));
191 }
192
193 marker.setRenderedRect(LayoutRect(range->boundingBox()));
194 } 192 }
195 193
196 // Markers are stored in order sorted by their start offset. 194 // Markers are stored in order sorted by their start offset.
197 // Markers of the same type do not overlap each other. 195 // Markers of the same type do not overlap each other.
198 196
199 void DocumentMarkerController::addMarker(Node* node, const DocumentMarker& newMa rker) 197 void DocumentMarkerController::addMarker(Node* node, const DocumentMarker& newMa rker)
200 { 198 {
201 ASSERT(newMarker.endOffset() >= newMarker.startOffset()); 199 ASSERT(newMarker.endOffset() >= newMarker.startOffset());
202 if (newMarker.endOffset() == newMarker.startOffset()) 200 if (newMarker.endOffset() == newMarker.startOffset())
203 return; 201 return;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return result; 489 return result;
492 } 490 }
493 491
494 void DocumentMarkerController::updateRenderedRectsForMarkers() 492 void DocumentMarkerController::updateRenderedRectsForMarkers()
495 { 493 {
496 for (auto& nodeMarkers : m_markers) { 494 for (auto& nodeMarkers : m_markers) {
497 const Node* node = nodeMarkers.key; 495 const Node* node = nodeMarkers.key;
498 for (auto& markerList : *nodeMarkers.value) { 496 for (auto& markerList : *nodeMarkers.value) {
499 if (!markerList) 497 if (!markerList)
500 continue; 498 continue;
499 bool markersChanged = false;
501 for (auto& marker : *markerList) 500 for (auto& marker : *markerList)
502 updateMarkerRenderedRect(const_cast<Node*>(node), *marker); 501 markersChanged |= updateMarkerRenderedRect(const_cast<Node*>(nod e), *marker);
502
503 if (markersChanged && markerList->first()->type() == DocumentMarker: :TextMatch)
504 m_textMatchMarkersRemovedOrChanged = true;
503 } 505 }
504 } 506 }
505 } 507 }
506 508
507 DEFINE_TRACE(DocumentMarkerController) 509 DEFINE_TRACE(DocumentMarkerController)
508 { 510 {
509 #if ENABLE(OILPAN) 511 #if ENABLE(OILPAN)
510 visitor->trace(m_markers); 512 visitor->trace(m_markers);
511 #endif 513 #endif
512 } 514 }
(...skipping 15 matching lines...) Expand all
528 MarkerLists* markers = i->value.get(); 530 MarkerLists* markers = i->value.get();
529 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { 531 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) {
530 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; 532 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex];
531 533
532 WillBeHeapVector<RawPtrWillBeMember<RenderedDocumentMarker>> markers ToBeRemoved; 534 WillBeHeapVector<RawPtrWillBeMember<RenderedDocumentMarker>> markers ToBeRemoved;
533 for (size_t j = 0; list.get() && j < list->size(); ++j) { 535 for (size_t j = 0; list.get() && j < list->size(); ++j) {
534 if (i->key->isTextNode() && shouldRemoveMarker(*list->at(j).get( ), static_cast<const Text&>(*i->key))) 536 if (i->key->isTextNode() && shouldRemoveMarker(*list->at(j).get( ), static_cast<const Text&>(*i->key)))
535 markersToBeRemoved.append(list->at(j).get()); 537 markersToBeRemoved.append(list->at(j).get());
536 } 538 }
537 539
540 if (markerListIndex == DocumentMarker::TextMatchMarkerIndex && !mark ersToBeRemoved.isEmpty())
541 m_textMatchMarkersRemovedOrChanged = true;
chrishtr 2015/04/17 23:21:42 Why not just invalidate the tickmarks within each
Xianzhu 2015/04/18 02:13:48 Was concerned about multiple calls of these functi
542
538 for (size_t j = 0; j < markersToBeRemoved.size(); ++j) 543 for (size_t j = 0; j < markersToBeRemoved.size(); ++j)
539 list->remove(list->find(markersToBeRemoved[j].get())); 544 list->remove(list->find(markersToBeRemoved[j].get()));
540 } 545 }
541 } 546 }
542 } 547 }
543 548
544 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes) 549 void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT ypes)
545 { 550 {
546 if (!possiblyHasMarkers(markerTypes)) 551 if (!possiblyHasMarkers(markerTypes))
547 return; 552 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 if (needsRepainting) { 598 if (needsRepainting) {
594 if (LayoutObject* renderer = iterator->key->layoutObject()) 599 if (LayoutObject* renderer = iterator->key->layoutObject())
595 renderer->setShouldDoFullPaintInvalidation(); 600 renderer->setShouldDoFullPaintInvalidation();
596 } 601 }
597 602
598 if (nodeCanBeRemoved) { 603 if (nodeCanBeRemoved) {
599 m_markers.remove(iterator); 604 m_markers.remove(iterator);
600 if (m_markers.isEmpty()) 605 if (m_markers.isEmpty())
601 m_possiblyExistingMarkerTypes = 0; 606 m_possiblyExistingMarkerTypes = 0;
602 } 607 }
608
609 if (markerTypes.contains(DocumentMarker::TextMatch))
610 m_textMatchMarkersRemovedOrChanged = true;
603 } 611 }
604 612
605 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types) 613 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types)
606 { 614 {
607 if (!possiblyHasMarkers(markerTypes)) 615 if (!possiblyHasMarkers(markerTypes))
608 return; 616 return;
609 ASSERT(!m_markers.isEmpty()); 617 ASSERT(!m_markers.isEmpty());
610 618
611 // outer loop: process each markered node in the document 619 // outer loop: process each markered node in the document
612 MarkerMap::iterator end = m_markers.end(); 620 MarkerMap::iterator end = m_markers.end();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 738
731 } // namespace blink 739 } // namespace blink
732 740
733 #ifndef NDEBUG 741 #ifndef NDEBUG
734 void showDocumentMarkers(const blink::DocumentMarkerController* controller) 742 void showDocumentMarkers(const blink::DocumentMarkerController* controller)
735 { 743 {
736 if (controller) 744 if (controller)
737 controller->showMarkers(); 745 controller->showMarkers();
738 } 746 }
739 #endif 747 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698