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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 if (toInsert.type() != DocumentMarker::TextMatch) { | 228 if (toInsert.type() != DocumentMarker::TextMatch) { |
229 mergeOverlapping(list.get(), toInsert); | 229 mergeOverlapping(list.get(), toInsert); |
230 } else { | 230 } else { |
231 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end
(), &toInsert, startsFurther); | 231 MarkerList::iterator pos = std::lower_bound(list->begin(), list->end
(), &toInsert, startsFurther); |
232 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI
nsert)); | 232 list->insert(pos - list->begin(), RenderedDocumentMarker::create(toI
nsert)); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 // repaint the affected node | 236 // repaint the affected node |
237 if (node->renderer()) | 237 if (node->renderer()) |
238 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously()
; | 238 node->renderer()->setShouldDoFullPaintInvalidation(true); |
239 } | 239 } |
240 | 240 |
241 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker
& toInsert) | 241 void DocumentMarkerController::mergeOverlapping(MarkerList* list, DocumentMarker
& toInsert) |
242 { | 242 { |
243 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list
->end(), &toInsert, doesNotOverlap); | 243 MarkerList::iterator firstOverlapping = std::lower_bound(list->begin(), list
->end(), &toInsert, doesNotOverlap); |
244 size_t index = firstOverlapping - list->begin(); | 244 size_t index = firstOverlapping - list->begin(); |
245 list->insert(index, RenderedDocumentMarker::create(toInsert)); | 245 list->insert(index, RenderedDocumentMarker::create(toInsert)); |
246 MarkerList::iterator inserted = list->begin() + index; | 246 MarkerList::iterator inserted = list->begin() + index; |
247 firstOverlapping = inserted + 1; | 247 firstOverlapping = inserted + 1; |
248 for (MarkerList::iterator i = firstOverlapping; i != list->end() && (*i)->st
artOffset() <= (*inserted)->endOffset(); ) { | 248 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... |
289 if (marker->endOffset() > endOffset) | 289 if (marker->endOffset() > endOffset) |
290 marker->setEndOffset(endOffset); | 290 marker->setEndOffset(endOffset); |
291 marker->shiftOffsets(delta); | 291 marker->shiftOffsets(delta); |
292 | 292 |
293 addMarker(dstNode, *marker); | 293 addMarker(dstNode, *marker); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 // repaint the affected node | 297 // repaint the affected node |
298 if (docDirty && dstNode->renderer()) | 298 if (docDirty && dstNode->renderer()) |
299 dstNode->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronousl
y(); | 299 dstNode->renderer()->setShouldDoFullPaintInvalidation(true); |
300 } | 300 } |
301 | 301 |
302 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i
nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa
rkerOrNot shouldRemovePartiallyOverlappingMarker) | 302 void DocumentMarkerController::removeMarkers(Node* node, unsigned startOffset, i
nt length, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMa
rkerOrNot shouldRemovePartiallyOverlappingMarker) |
303 { | 303 { |
304 if (length <= 0) | 304 if (length <= 0) |
305 return; | 305 return; |
306 | 306 |
307 if (!possiblyHasMarkers(markerTypes)) | 307 if (!possiblyHasMarkers(markerTypes)) |
308 return; | 308 return; |
309 ASSERT(!(m_markers.isEmpty())); | 309 ASSERT(!(m_markers.isEmpty())); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 } | 370 } |
371 | 371 |
372 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { | 372 if (emptyListsCount == DocumentMarker::MarkerTypeIndexesCount) { |
373 m_markers.remove(node); | 373 m_markers.remove(node); |
374 if (m_markers.isEmpty()) | 374 if (m_markers.isEmpty()) |
375 m_possiblyExistingMarkerTypes = 0; | 375 m_possiblyExistingMarkerTypes = 0; |
376 } | 376 } |
377 | 377 |
378 // repaint the affected node | 378 // repaint the affected node |
379 if (docDirty && node->renderer()) | 379 if (docDirty && node->renderer()) |
380 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously()
; | 380 node->renderer()->setShouldDoFullPaintInvalidation(true); |
381 } | 381 } |
382 | 382 |
383 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin
t& point, DocumentMarker::MarkerType markerType) | 383 DocumentMarker* DocumentMarkerController::markerContainingPoint(const LayoutPoin
t& point, DocumentMarker::MarkerType markerType) |
384 { | 384 { |
385 if (!possiblyHasMarkers(markerType)) | 385 if (!possiblyHasMarkers(markerType)) |
386 return 0; | 386 return 0; |
387 ASSERT(!(m_markers.isEmpty())); | 387 ASSERT(!(m_markers.isEmpty())); |
388 | 388 |
389 // outer loop: process each node that contains any markers | 389 // outer loop: process each node that contains any markers |
390 MarkerMap::iterator end = m_markers.end(); | 390 MarkerMap::iterator end = m_markers.end(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ++emptyListsCount; | 579 ++emptyListsCount; |
580 needsRepainting = true; | 580 needsRepainting = true; |
581 } | 581 } |
582 } | 582 } |
583 | 583 |
584 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC
ount; | 584 nodeCanBeRemoved = emptyListsCount == DocumentMarker::MarkerTypeIndexesC
ount; |
585 } | 585 } |
586 | 586 |
587 if (needsRepainting) { | 587 if (needsRepainting) { |
588 if (RenderObject* renderer = iterator->key->renderer()) | 588 if (RenderObject* renderer = iterator->key->renderer()) |
589 renderer->doNotUseInvalidatePaintForWholeRendererSynchronously(); | 589 renderer->setShouldDoFullPaintInvalidation(true); |
590 } | 590 } |
591 | 591 |
592 if (nodeCanBeRemoved) { | 592 if (nodeCanBeRemoved) { |
593 m_markers.remove(iterator); | 593 m_markers.remove(iterator); |
594 if (m_markers.isEmpty()) | 594 if (m_markers.isEmpty()) |
595 m_possiblyExistingMarkerTypes = 0; | 595 m_possiblyExistingMarkerTypes = 0; |
596 } | 596 } |
597 } | 597 } |
598 | 598 |
599 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker
Types) | 599 void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker
Types) |
600 { | 600 { |
601 if (!possiblyHasMarkers(markerTypes)) | 601 if (!possiblyHasMarkers(markerTypes)) |
602 return; | 602 return; |
603 ASSERT(!m_markers.isEmpty()); | 603 ASSERT(!m_markers.isEmpty()); |
604 | 604 |
605 // outer loop: process each markered node in the document | 605 // outer loop: process each markered node in the document |
606 MarkerMap::iterator end = m_markers.end(); | 606 MarkerMap::iterator end = m_markers.end(); |
607 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { | 607 for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) { |
608 const Node* node = i->key; | 608 const Node* node = i->key; |
609 | 609 |
610 // inner loop: process each marker in the current node | 610 // inner loop: process each marker in the current node |
611 MarkerLists* markers = i->value.get(); | 611 MarkerLists* markers = i->value.get(); |
612 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke
rTypeIndexesCount; ++markerListIndex) { | 612 for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::Marke
rTypeIndexesCount; ++markerListIndex) { |
613 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; | 613 OwnPtrWillBeMember<MarkerList>& list = (*markers)[markerListIndex]; |
614 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin(
))->type())) | 614 if (!list || list->isEmpty() || !markerTypes.contains((*list->begin(
))->type())) |
615 continue; | 615 continue; |
616 | 616 |
617 // cause the node to be redrawn | 617 // cause the node to be redrawn |
618 if (RenderObject* renderer = node->renderer()) { | 618 if (RenderObject* renderer = node->renderer()) { |
619 renderer->doNotUseInvalidatePaintForWholeRendererSynchronously()
; | 619 renderer->setShouldDoFullPaintInvalidation(true); |
620 break; | 620 break; |
621 } | 621 } |
622 } | 622 } |
623 } | 623 } |
624 } | 624 } |
625 | 625 |
626 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay
outRect& r) | 626 void DocumentMarkerController::invalidateRenderedRectsForMarkersInRect(const Lay
outRect& r) |
627 { | 627 { |
628 // outer loop: process each markered node in the document | 628 // outer loop: process each markered node in the document |
629 MarkerMap::iterator end = m_markers.end(); | 629 MarkerMap::iterator end = m_markers.end(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 (*marker)->shiftOffsets(delta); | 663 (*marker)->shiftOffsets(delta); |
664 docDirty = true; | 664 docDirty = true; |
665 | 665 |
666 // Marker moved, so previously-computed rendered rectangle is now in
valid | 666 // Marker moved, so previously-computed rendered rectangle is now in
valid |
667 (*marker)->invalidate(); | 667 (*marker)->invalidate(); |
668 } | 668 } |
669 } | 669 } |
670 | 670 |
671 // repaint the affected node | 671 // repaint the affected node |
672 if (docDirty && node->renderer()) | 672 if (docDirty && node->renderer()) |
673 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously()
; | 673 node->renderer()->setShouldDoFullPaintInvalidation(true); |
674 } | 674 } |
675 | 675 |
676 void DocumentMarkerController::setMarkersActive(Range* range, bool active) | 676 void DocumentMarkerController::setMarkersActive(Range* range, bool active) |
677 { | 677 { |
678 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) | 678 if (!possiblyHasMarkers(DocumentMarker::AllMarkers())) |
679 return; | 679 return; |
680 ASSERT(!m_markers.isEmpty()); | 680 ASSERT(!m_markers.isEmpty()); |
681 | 681 |
682 Node* startContainer = range->startContainer(); | 682 Node* startContainer = range->startContainer(); |
683 Node* endContainer = range->endContainer(); | 683 Node* endContainer = range->endContainer(); |
(...skipping 23 matching lines...) Expand all Loading... |
707 // Markers are returned in order, so stop if we are now past the specifi
ed range. | 707 // Markers are returned in order, so stop if we are now past the specifi
ed range. |
708 if ((*marker)->startOffset() >= endOffset) | 708 if ((*marker)->startOffset() >= endOffset) |
709 break; | 709 break; |
710 | 710 |
711 (*marker)->setActiveMatch(active); | 711 (*marker)->setActiveMatch(active); |
712 docDirty = true; | 712 docDirty = true; |
713 } | 713 } |
714 | 714 |
715 // repaint the affected node | 715 // repaint the affected node |
716 if (docDirty && node->renderer()) | 716 if (docDirty && node->renderer()) |
717 node->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously()
; | 717 node->renderer()->setShouldDoFullPaintInvalidation(true); |
718 } | 718 } |
719 | 719 |
720 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy
pes markerTypes) | 720 bool DocumentMarkerController::hasMarkers(Range* range, DocumentMarker::MarkerTy
pes markerTypes) |
721 { | 721 { |
722 if (!possiblyHasMarkers(markerTypes)) | 722 if (!possiblyHasMarkers(markerTypes)) |
723 return false; | 723 return false; |
724 ASSERT(!m_markers.isEmpty()); | 724 ASSERT(!m_markers.isEmpty()); |
725 | 725 |
726 Node* startContainer = range->startContainer(); | 726 Node* startContainer = range->startContainer(); |
727 ASSERT(startContainer); | 727 ASSERT(startContainer); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 770 |
771 } // namespace blink | 771 } // namespace blink |
772 | 772 |
773 #ifndef NDEBUG | 773 #ifndef NDEBUG |
774 void showDocumentMarkers(const blink::DocumentMarkerController* controller) | 774 void showDocumentMarkers(const blink::DocumentMarkerController* controller) |
775 { | 775 { |
776 if (controller) | 776 if (controller) |
777 controller->showMarkers(); | 777 controller->showMarkers(); |
778 } | 778 } |
779 #endif | 779 #endif |
OLD | NEW |