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

Side by Side Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp

Issue 2872423002: Tweak PaintInvalidationReasons (Closed)
Patch Set: Rebaseline-cl Created 3 years, 7 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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const DocumentMarker::MarkerType new_marker_type = new_marker->GetType(); 222 const DocumentMarker::MarkerType new_marker_type = new_marker->GetType();
223 if (!ListForType(markers, new_marker_type)) 223 if (!ListForType(markers, new_marker_type))
224 ListForType(markers, new_marker_type) = CreateListForType(new_marker_type); 224 ListForType(markers, new_marker_type) = CreateListForType(new_marker_type);
225 225
226 DocumentMarkerList* const list = ListForType(markers, new_marker_type); 226 DocumentMarkerList* const list = ListForType(markers, new_marker_type);
227 list->Add(new_marker); 227 list->Add(new_marker);
228 228
229 // repaint the affected node 229 // repaint the affected node
230 if (node->GetLayoutObject()) { 230 if (node->GetLayoutObject()) {
231 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( 231 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation(
232 kPaintInvalidationDocumentMarkerChange); 232 PaintInvalidationReason::kDocumentMarker);
233 } 233 }
234 } 234 }
235 235
236 // Moves markers from src_node to dst_node. Markers are moved if their start 236 // Moves markers from src_node to dst_node. Markers are moved if their start
237 // offset is less than length. Markers that run past that point are truncated. 237 // offset is less than length. Markers that run past that point are truncated.
238 void DocumentMarkerController::MoveMarkers(Node* src_node, 238 void DocumentMarkerController::MoveMarkers(Node* src_node,
239 int length, 239 int length,
240 Node* dst_node) { 240 Node* dst_node) {
241 if (length <= 0) 241 if (length <= 0)
242 return; 242 return;
(...skipping 22 matching lines...) Expand all
265 ListForType(dst_markers, type) = CreateListForType(type); 265 ListForType(dst_markers, type) = CreateListForType(type);
266 266
267 DocumentMarkerList* const dst_list = ListForType(dst_markers, type); 267 DocumentMarkerList* const dst_list = ListForType(dst_markers, type);
268 if (src_list->MoveMarkers(length, dst_list)) 268 if (src_list->MoveMarkers(length, dst_list))
269 doc_dirty = true; 269 doc_dirty = true;
270 } 270 }
271 271
272 // repaint the affected node 272 // repaint the affected node
273 if (doc_dirty && dst_node->GetLayoutObject()) { 273 if (doc_dirty && dst_node->GetLayoutObject()) {
274 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( 274 dst_node->GetLayoutObject()->SetShouldDoFullPaintInvalidation(
275 kPaintInvalidationDocumentMarkerChange); 275 PaintInvalidationReason::kDocumentMarker);
276 } 276 }
277 } 277 }
278 278
279 void DocumentMarkerController::RemoveMarkersInternal( 279 void DocumentMarkerController::RemoveMarkersInternal(
280 Node* node, 280 Node* node,
281 unsigned start_offset, 281 unsigned start_offset,
282 int length, 282 int length,
283 DocumentMarker::MarkerTypes marker_types) { 283 DocumentMarker::MarkerTypes marker_types) {
284 if (length <= 0) 284 if (length <= 0)
285 return; 285 return;
(...skipping 30 matching lines...) Expand all
316 316
317 if (empty_lists_count == DocumentMarker::kMarkerTypeIndexesCount) { 317 if (empty_lists_count == DocumentMarker::kMarkerTypeIndexesCount) {
318 markers_.erase(node); 318 markers_.erase(node);
319 if (markers_.IsEmpty()) 319 if (markers_.IsEmpty())
320 possibly_existing_marker_types_ = 0; 320 possibly_existing_marker_types_ = 0;
321 } 321 }
322 322
323 // repaint the affected node 323 // repaint the affected node
324 if (doc_dirty && node->GetLayoutObject()) { 324 if (doc_dirty && node->GetLayoutObject()) {
325 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( 325 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation(
326 kPaintInvalidationDocumentMarkerChange); 326 PaintInvalidationReason::kDocumentMarker);
327 } 327 }
328 } 328 }
329 329
330 DocumentMarkerVector DocumentMarkerController::MarkersFor( 330 DocumentMarkerVector DocumentMarkerController::MarkersFor(
331 Node* node, 331 Node* node,
332 DocumentMarker::MarkerTypes marker_types) { 332 DocumentMarker::MarkerTypes marker_types) {
333 DocumentMarkerVector result; 333 DocumentMarkerVector result;
334 334
335 MarkerLists* markers = markers_.at(node); 335 MarkerLists* markers = markers_.at(node);
336 if (!markers) 336 if (!markers)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 569 }
570 570
571 node_can_be_removed = 571 node_can_be_removed =
572 empty_lists_count == DocumentMarker::kMarkerTypeIndexesCount; 572 empty_lists_count == DocumentMarker::kMarkerTypeIndexesCount;
573 } 573 }
574 574
575 if (needs_repainting) { 575 if (needs_repainting) {
576 const Node& node = *iterator->key; 576 const Node& node = *iterator->key;
577 if (LayoutObject* layout_object = node.GetLayoutObject()) { 577 if (LayoutObject* layout_object = node.GetLayoutObject()) {
578 layout_object->SetShouldDoFullPaintInvalidation( 578 layout_object->SetShouldDoFullPaintInvalidation(
579 kPaintInvalidationDocumentMarkerChange); 579 PaintInvalidationReason::kDocumentMarker);
580 } 580 }
581 InvalidatePaintForTickmarks(node); 581 InvalidatePaintForTickmarks(node);
582 } 582 }
583 583
584 if (node_can_be_removed) { 584 if (node_can_be_removed) {
585 markers_.erase(iterator); 585 markers_.erase(iterator);
586 if (markers_.IsEmpty()) 586 if (markers_.IsEmpty())
587 possibly_existing_marker_types_ = 0; 587 possibly_existing_marker_types_ = 0;
588 } 588 }
589 } 589 }
(...skipping 12 matching lines...) Expand all
602 // inner loop: process each marker in the current node 602 // inner loop: process each marker in the current node
603 MarkerLists* markers = i->value.Get(); 603 MarkerLists* markers = i->value.Get();
604 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { 604 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) {
605 DocumentMarkerList* const list = ListForType(markers, type); 605 DocumentMarkerList* const list = ListForType(markers, type);
606 if (!list || list->IsEmpty() || !marker_types.Contains(type)) 606 if (!list || list->IsEmpty() || !marker_types.Contains(type))
607 continue; 607 continue;
608 608
609 // cause the node to be redrawn 609 // cause the node to be redrawn
610 if (LayoutObject* layout_object = node->GetLayoutObject()) { 610 if (LayoutObject* layout_object = node->GetLayoutObject()) {
611 layout_object->SetShouldDoFullPaintInvalidation( 611 layout_object->SetShouldDoFullPaintInvalidation(
612 kPaintInvalidationDocumentMarkerChange); 612 PaintInvalidationReason::kDocumentMarker);
613 break; 613 break;
614 } 614 }
615 } 615 }
616 } 616 }
617 } 617 }
618 618
619 bool DocumentMarkerController::SetMarkersActive(const EphemeralRange& range, 619 bool DocumentMarkerController::SetMarkersActive(const EphemeralRange& range,
620 bool active) { 620 bool active) {
621 if (!PossiblyHasMarkers(DocumentMarker::AllMarkers())) 621 if (!PossiblyHasMarkers(DocumentMarker::AllMarkers()))
622 return false; 622 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 if ((*marker)->StartOffset() >= end_offset) 673 if ((*marker)->StartOffset() >= end_offset)
674 break; 674 break;
675 675
676 (*marker)->SetIsActiveMatch(active); 676 (*marker)->SetIsActiveMatch(active);
677 doc_dirty = true; 677 doc_dirty = true;
678 } 678 }
679 679
680 // repaint the affected node 680 // repaint the affected node
681 if (doc_dirty && node->GetLayoutObject()) { 681 if (doc_dirty && node->GetLayoutObject()) {
682 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation( 682 node->GetLayoutObject()->SetShouldDoFullPaintInvalidation(
683 kPaintInvalidationDocumentMarkerChange); 683 PaintInvalidationReason::kDocumentMarker);
684 } 684 }
685 return doc_dirty; 685 return doc_dirty;
686 } 686 }
687 687
688 #ifndef NDEBUG 688 #ifndef NDEBUG
689 void DocumentMarkerController::ShowMarkers() const { 689 void DocumentMarkerController::ShowMarkers() const {
690 StringBuilder builder; 690 StringBuilder builder;
691 MarkerMap::const_iterator end = markers_.end(); 691 MarkerMap::const_iterator end = markers_.end();
692 for (MarkerMap::const_iterator node_iterator = markers_.begin(); 692 for (MarkerMap::const_iterator node_iterator = markers_.begin();
693 node_iterator != end; ++node_iterator) { 693 node_iterator != end; ++node_iterator) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 749 }
750 750
751 } // namespace blink 751 } // namespace blink
752 752
753 #ifndef NDEBUG 753 #ifndef NDEBUG
754 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { 754 void showDocumentMarkers(const blink::DocumentMarkerController* controller) {
755 if (controller) 755 if (controller)
756 controller->ShowMarkers(); 756 controller->ShowMarkers();
757 } 757 }
758 #endif 758 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698