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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 228 |
229 // repaint the affected node | 229 // repaint the affected node |
230 if (node->renderer()) | 230 if (node->renderer()) |
231 node->renderer()->setShouldDoFullPaintInvalidation(true); | 231 node->renderer()->invalidatePaintForWholeRenderer(); |
232 } | 232 } |
233 | 233 |
234 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker
& toInsert) | 234 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker
& toInsert) |
235 { | 235 { |
236 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list
->end(), &toInsert, doesNotOverlap); | 236 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list
->end(), &toInsert, doesNotOverlap); |
237 size_t index = firstOverlapping - list->begin(); | 237 size_t index = firstOverlapping - list->begin(); |
238 list->insert(index, RenderedDocumentMarker::create(toInsert)); | 238 list->insert(index, RenderedDocumentMarker::create(toInsert)); |
239 MarkerList::iterator inserted = list->begin() + index; | 239 MarkerList::iterator inserted = list->begin() + index; |
240 firstOverlapping = inserted + 1; | 240 firstOverlapping = inserted + 1; |
241 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st
artOffset() <= (*inserted)->endOffset(); ) { | 241 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st
artOffset() <= (*inserted)->endOffset(); ) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (marker->endOffset() > endOffset) | 282 if (marker->endOffset() > endOffset) |
283 marker->setEndOffset(endOffset); | 283 marker->setEndOffset(endOffset); |
284 marker->shiftOffsets(delta); | 284 marker->shiftOffsets(delta); |
285 | 285 |
286 addMarker(dstNode, *marker); | 286 addMarker(dstNode, *marker); |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
290 // repaint the affected node | 290 // repaint the affected node |
291 if (docDirty && dstNode->renderer()) | 291 if (docDirty && dstNode->renderer()) |
292 dstNode->renderer()->setShouldDoFullPaintInvalidation(true); | 292 dstNode->renderer()->invalidatePaintForWholeRenderer(); |
293 } | 293 } |
294 | 294 |
295 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i
nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa
rkerOrNot shouldRemovePartiallyOverlappingMarker) | 295 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i
nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa
rkerOrNot shouldRemovePartiallyOverlappingMarker) |
296 { | 296 { |
297 if (length <= 0) | 297 if (length <= 0) |
298 return; | 298 return; |
299 | 299 |
300 if (!possiblyHasMarkers(markerTypes)) | 300 if (!possiblyHasMarkers(markerTypes)) |
301 return; | 301 return; |
302 ASSERT(!(m_markers.isEmpty())); | 302 ASSERT(!(m_markers.isEmpty())); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { | 365 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { |
366 m_markers.remove(node); | 366 m_markers.remove(node); |
367 if (m_markers.isEmpty()) | 367 if (m_markers.isEmpty()) |
368 m_possiblyExistingMarkerTypes = 0; | 368 m_possiblyExistingMarkerTypes = 0; |
369 } | 369 } |
370 | 370 |
371 // repaint the affected node | 371 // repaint the affected node |
372 if (docDirty && node->renderer()) | 372 if (docDirty && node->renderer()) |
373 node->renderer()->setShouldDoFullPaintInvalidation(true); | 373 node->renderer()->invalidatePaintForWholeRenderer(); |
374 } | 374 } |
375 | 375 |
376 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin
t& point, DocumentMarker::MarkerType markerType) | 376 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin
t& point, DocumentMarker::MarkerType markerType) |
377 { | 377 { |
378 if (!possiblyHasMarkers(markerType)) | 378 if (!possiblyHasMarkers(markerType)) |
379 return 0; | 379 return 0; |
380 ASSERT(!(m_markers.isEmpty())); | 380 ASSERT(!(m_markers.isEmpty())); |
381 | 381 |
382 // outer loop: process each node that contains any markers | 382 // outer loop: process each node that contains any markers |
383 MarkerMap::iterator end = m_markers.end(); | 383 MarkerMap::iterator end = m_markers.end(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 ++emptyListsCount; | 572 ++emptyListsCount; |
573 needsRepainting = true; | 573 needsRepainting = true; |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC
ount; | 577 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC
ount; |
578 } | 578 } |
579 | 579 |
580 if (needsRepainting) { | 580 if (needsRepainting) { |
581 if (RenderObject* renderer = iterator->key->renderer()) | 581 if (RenderObject* renderer = iterator->key->renderer()) |
582 renderer->setShouldDoFullPaintInvalidation(true); | 582 renderer->invalidatePaintForWholeRenderer(); |
583 } | 583 } |
584 | 584 |
585 if (nodeCanBeRemoved) { | 585 if (nodeCanBeRemoved) { |
586 m_markers.remove(iterator); | 586 m_markers.remove(iterator); |
587 if (m_markers.isEmpty()) | 587 if (m_markers.isEmpty()) |
588 m_possiblyExistingMarkerTypes = 0; | 588 m_possiblyExistingMarkerTypes = 0; |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker
Types) | 592 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker
Types) |
593 { | 593 { |
594 if (!possiblyHasMarkers(markerTypes)) | 594 if (!possiblyHasMarkers(markerTypes)) |
595 return; | 595 return; |
596 ASSERT(!m_markers.isEmpty()); | 596 ASSERT(!m_markers.isEmpty()); |
597 | 597 |
598 // outer loop: process each markered node in the document | 598 // outer loop: process each markered node in the document |
599 MarkerMap::iterator end = m_markers.end(); | 599 MarkerMap::iterator end = m_markers.end(); |
600 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { | 600 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { |
601 const Node* node = i->key; | 601 const Node* node = i->key; |
602 | 602 |
603 // inner loop: process each marker in the current node | 603 // inner loop: process each marker in the current node |
604 MarkerLists* markers = i->value.get(); | 604 MarkerLists* markers = i->value.get(); |
605 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke
rTypeIndexesCount; ++markerListIndex) { | 605 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke
rTypeIndexesCount; ++markerListIndex) { |
606 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; | 606 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; |
607 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin(
))->type())) | 607 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin(
))->type())) |
608 continue; | 608 continue; |
609 | 609 |
610 // cause the node to be redrawn | 610 // cause the node to be redrawn |
611 if (RenderObject* renderer = node->renderer()) { | 611 if (RenderObject* renderer = node->renderer()) { |
612 renderer->setShouldDoFullPaintInvalidation(true); | 612 renderer->invalidatePaintForWholeRenderer(); |
613 break; | 613 break; |
614 } | 614 } |
615 } | 615 } |
616 } | 616 } |
617 } | 617 } |
618 | 618 |
619 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay
outRect& r) | 619 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay
outRect& r) |
620 { | 620 { |
621 // outer loop: process each markered node in the document | 621 // outer loop: process each markered node in the document |
622 MarkerMap::iterator end = m_markers.end(); | 622 MarkerMap::iterator end = m_markers.end(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 (*marker)->shiftOffsets(delta); | 656 (*marker)->shiftOffsets(delta); |
657 docDirty = true; | 657 docDirty = true; |
658 | 658 |
659 // Marker moved, so previously-computed rendered rectangle is now in
valid | 659 // Marker moved, so previously-computed rendered rectangle is now in
valid |
660 (*marker)->invalidate(); | 660 (*marker)->invalidate(); |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 // repaint the affected node | 664 // repaint the affected node |
665 if (docDirty && node->renderer()) | 665 if (docDirty && node->renderer()) |
666 node->renderer()->setShouldDoFullPaintInvalidation(true); | 666 node->renderer()->invalidatePaintForWholeRenderer(); |
667 } | 667 } |
668 | 668 |
669 void DocumentMarkerController::setMarkersActive(Range* range, bool active) | 669 void DocumentMarkerController::setMarkersActive(Range* range, bool active) |
670 { | 670 { |
671 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) | 671 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) |
672 return; | 672 return; |
673 ASSERT(!m_markers.isEmpty()); | 673 ASSERT(!m_markers.isEmpty()); |
674 | 674 |
675 Node* startContainer = range->startContainer(); | 675 Node* startContainer = range->startContainer(); |
676 Node* endContainer = range->endContainer(); | 676 Node* endContainer = range->endContainer(); |
(...skipping 23 matching lines...) Expand all Loading... |
700 // Markers are returned in order, so stop if we are now past the specifi
ed range. | 700 // Markers are returned in order, so stop if we are now past the specifi
ed range. |
701 if ((*marker)->startOffset() >= endOffset) | 701 if ((*marker)->startOffset() >= endOffset) |
702 break; | 702 break; |
703 | 703 |
704 (*marker)->setActiveMatch(active); | 704 (*marker)->setActiveMatch(active); |
705 docDirty = true; | 705 docDirty = true; |
706 } | 706 } |
707 | 707 |
708 // repaint the affected node | 708 // repaint the affected node |
709 if (docDirty && node->renderer()) | 709 if (docDirty && node->renderer()) |
710 node->renderer()->setShouldDoFullPaintInvalidation(true); | 710 node->renderer()->invalidatePaintForWholeRenderer(); |
711 } | 711 } |
712 | 712 |
713 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy
pes markerTypes) | 713 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy
pes markerTypes) |
714 { | 714 { |
715 if (!possiblyHasMarkers(markerTypes)) | 715 if (!possiblyHasMarkers(markerTypes)) |
716 return false; | 716 return false; |
717 ASSERT(!m_markers.isEmpty()); | 717 ASSERT(!m_markers.isEmpty()); |
718 | 718 |
719 Node* startContainer = range->startContainer(); | 719 Node* startContainer = range->startContainer(); |
720 ASSERT(startContainer); | 720 ASSERT(startContainer); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 763 |
764 } // namespace blink | 764 } // namespace blink |
765 | 765 |
766 #ifndef NDEBUG | 766 #ifndef NDEBUG |
767 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 767 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
768 { | 768 { |
769 if (controller) | 769 if (controller) |
770 controller->showMarkers(); | 770 controller->showMarkers(); |
771 } | 771 } |
772 #endif | 772 #endif |
OLD | NEW |