OLD | NEW |
---|---|
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 Loading... | |
218 DocumentMarker toInsert(newMarker); | 218 DocumentMarker toInsert(newMarker); |
219 if (toInsert.type() != DocumentMarker::TextMatch) { | 219 if (toInsert.type() != DocumentMarker::TextMatch) { |
220 mergeOverlapping(list.get(), toInsert); | 220 mergeOverlapping(list.get(), toInsert); |
221 } else { | 221 } else { |
222 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), &toInsert, startsFurther); | 222 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end (), &toInsert, startsFurther); |
223 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI nsert)); | 223 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI nsert)); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 // repaint the affected node | 227 // repaint the affected node |
228 if (node->renderer()) | 228 if (node->layoutObject()) |
229 node->renderer()->setShouldDoFullPaintInvalidation(); | 229 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
230 } | 230 } |
231 | 231 |
232 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert) | 232 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker & toInsert) |
233 { | 233 { |
234 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), &toInsert, doesNotOverlap); | 234 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list ->end(), &toInsert, doesNotOverlap); |
235 size_t index = firstOverlapping - list->begin(); | 235 size_t index = firstOverlapping - list->begin(); |
236 list->insert(index, RenderedDocumentMarker::create(toInsert)); | 236 list->insert(index, RenderedDocumentMarker::create(toInsert)); |
237 MarkerList::iterator inserted = list->begin() + index; | 237 MarkerList::iterator inserted = list->begin() + index; |
238 firstOverlapping = inserted + 1; | 238 firstOverlapping = inserted + 1; |
239 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st artOffset() <= (*inserted)->endOffset(); ) { | 239 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st artOffset() <= (*inserted)->endOffset(); ) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 marker->setStartOffset(startOffset); | 279 marker->setStartOffset(startOffset); |
280 if (marker->endOffset() > endOffset) | 280 if (marker->endOffset() > endOffset) |
281 marker->setEndOffset(endOffset); | 281 marker->setEndOffset(endOffset); |
282 marker->shiftOffsets(delta); | 282 marker->shiftOffsets(delta); |
283 | 283 |
284 addMarker(dstNode, *marker); | 284 addMarker(dstNode, *marker); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 // repaint the affected node | 288 // repaint the affected node |
289 if (docDirty && dstNode->renderer()) | 289 if (docDirty && dstNode->layoutObject()) |
290 dstNode->renderer()->setShouldDoFullPaintInvalidation(); | 290 dstNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
291 } | 291 } |
292 | 292 |
293 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker) | 293 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa rkerOrNot shouldRemovePartiallyOverlappingMarker) |
294 { | 294 { |
295 if (length <= 0) | 295 if (length <= 0) |
296 return; | 296 return; |
297 | 297 |
298 if (!possiblyHasMarkers(markerTypes)) | 298 if (!possiblyHasMarkers(markerTypes)) |
299 return; | 299 return; |
300 ASSERT(!(m_markers.isEmpty())); | 300 ASSERT(!(m_markers.isEmpty())); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
363 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { | 363 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { |
364 m_markers.remove(node); | 364 m_markers.remove(node); |
365 if (m_markers.isEmpty()) | 365 if (m_markers.isEmpty()) |
366 m_possiblyExistingMarkerTypes = 0; | 366 m_possiblyExistingMarkerTypes = 0; |
367 } | 367 } |
368 | 368 |
369 // repaint the affected node | 369 // repaint the affected node |
370 if (docDirty && node->renderer()) | 370 if (docDirty && node->layoutObject()) |
371 node->renderer()->setShouldDoFullPaintInvalidation(); | 371 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
372 } | 372 } |
373 | 373 |
374 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType) | 374 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin t& point, DocumentMarker::MarkerType markerType) |
375 { | 375 { |
376 if (!possiblyHasMarkers(markerType)) | 376 if (!possiblyHasMarkers(markerType)) |
377 return 0; | 377 return 0; |
378 ASSERT(!(m_markers.isEmpty())); | 378 ASSERT(!(m_markers.isEmpty())); |
379 | 379 |
380 // outer loop: process each node that contains any markers | 380 // outer loop: process each node that contains any markers |
381 MarkerMap::iterator end = m_markers.end(); | 381 MarkerMap::iterator end = m_markers.end(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 list.clear(); | 566 list.clear(); |
567 ++emptyListsCount; | 567 ++emptyListsCount; |
568 needsRepainting = true; | 568 needsRepainting = true; |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount; | 572 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC ount; |
573 } | 573 } |
574 | 574 |
575 if (needsRepainting) { | 575 if (needsRepainting) { |
576 if (LayoutObject* renderer = iterator->key->renderer()) | 576 if (LayoutObject* renderer = iterator->key->layoutObject()) |
Julien - ping for review
2015/03/05 16:19:15
s/renderer/layoutObject/
| |
577 renderer->setShouldDoFullPaintInvalidation(); | 577 renderer->setShouldDoFullPaintInvalidation(); |
578 } | 578 } |
579 | 579 |
580 if (nodeCanBeRemoved) { | 580 if (nodeCanBeRemoved) { |
581 m_markers.remove(iterator); | 581 m_markers.remove(iterator); |
582 if (m_markers.isEmpty()) | 582 if (m_markers.isEmpty()) |
583 m_possiblyExistingMarkerTypes = 0; | 583 m_possiblyExistingMarkerTypes = 0; |
584 } | 584 } |
585 } | 585 } |
586 | 586 |
587 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types) | 587 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker Types) |
588 { | 588 { |
589 if (!possiblyHasMarkers(markerTypes)) | 589 if (!possiblyHasMarkers(markerTypes)) |
590 return; | 590 return; |
591 ASSERT(!m_markers.isEmpty()); | 591 ASSERT(!m_markers.isEmpty()); |
592 | 592 |
593 // outer loop: process each markered node in the document | 593 // outer loop: process each markered node in the document |
594 MarkerMap::iterator end = m_markers.end(); | 594 MarkerMap::iterator end = m_markers.end(); |
595 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { | 595 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { |
596 const Node* node = i->key; | 596 const Node* node = i->key; |
597 | 597 |
598 // inner loop: process each marker in the current node | 598 // inner loop: process each marker in the current node |
599 MarkerLists* markers = i->value.get(); | 599 MarkerLists* markers = i->value.get(); |
600 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { | 600 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke rTypeIndexesCount; ++markerListIndex) { |
601 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; | 601 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; |
602 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin( ))->type())) | 602 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin( ))->type())) |
603 continue; | 603 continue; |
604 | 604 |
605 // cause the node to be redrawn | 605 // cause the node to be redrawn |
606 if (LayoutObject* renderer = node->renderer()) { | 606 if (LayoutObject* renderer = node->layoutObject()) { |
Julien - ping for review
2015/03/05 16:19:15
Ditto.
| |
607 renderer->setShouldDoFullPaintInvalidation(); | 607 renderer->setShouldDoFullPaintInvalidation(); |
608 break; | 608 break; |
609 } | 609 } |
610 } | 610 } |
611 } | 611 } |
612 } | 612 } |
613 | 613 |
614 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r) | 614 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay outRect& r) |
615 { | 615 { |
616 // outer loop: process each markered node in the document | 616 // outer loop: process each markered node in the document |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 #endif | 650 #endif |
651 (*marker)->shiftOffsets(delta); | 651 (*marker)->shiftOffsets(delta); |
652 docDirty = true; | 652 docDirty = true; |
653 | 653 |
654 // Marker moved, so previously-computed rendered rectangle is now in valid | 654 // Marker moved, so previously-computed rendered rectangle is now in valid |
655 (*marker)->invalidate(); | 655 (*marker)->invalidate(); |
656 } | 656 } |
657 } | 657 } |
658 | 658 |
659 // repaint the affected node | 659 // repaint the affected node |
660 if (docDirty && node->renderer()) | 660 if (docDirty && node->layoutObject()) |
661 node->renderer()->setShouldDoFullPaintInvalidation(); | 661 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
662 } | 662 } |
663 | 663 |
664 void DocumentMarkerController::setMarkersActive(Range* range, bool active) | 664 void DocumentMarkerController::setMarkersActive(Range* range, bool active) |
665 { | 665 { |
666 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) | 666 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) |
667 return; | 667 return; |
668 ASSERT(!m_markers.isEmpty()); | 668 ASSERT(!m_markers.isEmpty()); |
669 | 669 |
670 Node* startContainer = range->startContainer(); | 670 Node* startContainer = range->startContainer(); |
671 Node* endContainer = range->endContainer(); | 671 Node* endContainer = range->endContainer(); |
(...skipping 22 matching lines...) Expand all Loading... | |
694 | 694 |
695 // Markers are returned in order, so stop if we are now past the specifi ed range. | 695 // Markers are returned in order, so stop if we are now past the specifi ed range. |
696 if ((*marker)->startOffset() >= endOffset) | 696 if ((*marker)->startOffset() >= endOffset) |
697 break; | 697 break; |
698 | 698 |
699 (*marker)->setActiveMatch(active); | 699 (*marker)->setActiveMatch(active); |
700 docDirty = true; | 700 docDirty = true; |
701 } | 701 } |
702 | 702 |
703 // repaint the affected node | 703 // repaint the affected node |
704 if (docDirty && node->renderer()) | 704 if (docDirty && node->layoutObject()) |
705 node->renderer()->setShouldDoFullPaintInvalidation(); | 705 node->layoutObject()->setShouldDoFullPaintInvalidation(); |
706 } | 706 } |
707 | 707 |
708 #ifndef NDEBUG | 708 #ifndef NDEBUG |
709 void DocumentMarkerController::showMarkers() const | 709 void DocumentMarkerController::showMarkers() const |
710 { | 710 { |
711 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); | 711 fprintf(stderr, "%d nodes have markers:\n", m_markers.size()); |
712 MarkerMap::const_iterator end = m_markers.end(); | 712 MarkerMap::const_iterator end = m_markers.end(); |
713 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato r != end; ++nodeIterator) { | 713 for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterato r != end; ++nodeIterator) { |
714 const Node* node = nodeIterator->key; | 714 const Node* node = nodeIterator->key; |
715 fprintf(stderr, "%p", node); | 715 fprintf(stderr, "%p", node); |
(...skipping 13 matching lines...) Expand all Loading... | |
729 | 729 |
730 } // namespace blink | 730 } // namespace blink |
731 | 731 |
732 #ifndef NDEBUG | 732 #ifndef NDEBUG |
733 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 733 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
734 { | 734 { |
735 if (controller) | 735 if (controller) |
736 controller->showMarkers(); | 736 controller->showMarkers(); |
737 } | 737 } |
738 #endif | 738 #endif |
OLD | NEW |