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

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

Issue 2900573002: [DMC #12] Move some method impls from DocumentMarkerController.cpp to final place (Closed)
Patch Set: Fix rebase 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/TextMatchMarkerListImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 * 26 *
27 */ 27 */
28 28
29 #include "core/editing/markers/DocumentMarkerController.h" 29 #include "core/editing/markers/DocumentMarkerController.h"
30 30
31 #include <algorithm> 31 #include <algorithm>
32 #include "core/dom/Node.h" 32 #include "core/dom/Node.h"
33 #include "core/dom/NodeTraversal.h" 33 #include "core/dom/NodeTraversal.h"
34 #include "core/dom/Range.h"
35 #include "core/dom/Text.h" 34 #include "core/dom/Text.h"
36 #include "core/editing/VisibleUnits.h" 35 #include "core/editing/VisibleUnits.h"
37 #include "core/editing/iterators/TextIterator.h" 36 #include "core/editing/iterators/TextIterator.h"
38 #include "core/editing/markers/CompositionMarkerListImpl.h" 37 #include "core/editing/markers/CompositionMarkerListImpl.h"
39 #include "core/editing/markers/DocumentMarkerListEditor.h" 38 #include "core/editing/markers/DocumentMarkerListEditor.h"
40 #include "core/editing/markers/GrammarMarkerListImpl.h" 39 #include "core/editing/markers/GrammarMarkerListImpl.h"
41 #include "core/editing/markers/RenderedDocumentMarker.h" 40 #include "core/editing/markers/RenderedDocumentMarker.h"
42 #include "core/editing/markers/SpellingMarkerListImpl.h" 41 #include "core/editing/markers/SpellingMarkerListImpl.h"
43 #include "core/editing/markers/TextMatchMarkerListImpl.h" 42 #include "core/editing/markers/TextMatchMarkerListImpl.h"
44 #include "core/frame/FrameView.h" 43 #include "core/frame/FrameView.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 192
194 void DocumentMarkerController::RemoveMarkersInRange( 193 void DocumentMarkerController::RemoveMarkersInRange(
195 const EphemeralRange& range, 194 const EphemeralRange& range,
196 DocumentMarker::MarkerTypes marker_types) { 195 DocumentMarker::MarkerTypes marker_types) {
197 DCHECK(!document_->NeedsLayoutTreeUpdate()); 196 DCHECK(!document_->NeedsLayoutTreeUpdate());
198 197
199 TextIterator marked_text(range.StartPosition(), range.EndPosition()); 198 TextIterator marked_text(range.StartPosition(), range.EndPosition());
200 DocumentMarkerController::RemoveMarkers(marked_text, marker_types); 199 DocumentMarkerController::RemoveMarkers(marked_text, marker_types);
201 } 200 }
202 201
203 static void UpdateMarkerRenderedRect(const Node& node,
204 RenderedDocumentMarker& marker) {
205 const Position startPosition(&const_cast<Node&>(node), marker.StartOffset());
206 const Position endPostion(&const_cast<Node&>(node), marker.EndOffset());
207 EphemeralRange range(startPosition, endPostion);
208 marker.SetRenderedRect(LayoutRect(ComputeTextRect(range)));
209 }
210
211 // Markers are stored in order sorted by their start offset. 202 // Markers are stored in order sorted by their start offset.
212 // Markers of the same type do not overlap each other. 203 // Markers of the same type do not overlap each other.
213 204
214 void DocumentMarkerController::AddMarker(Node* node, 205 void DocumentMarkerController::AddMarker(Node* node,
215 DocumentMarker* new_marker) { 206 DocumentMarker* new_marker) {
216 DCHECK_GE(new_marker->EndOffset(), new_marker->StartOffset()); 207 DCHECK_GE(new_marker->EndOffset(), new_marker->StartOffset());
217 if (new_marker->EndOffset() == new_marker->StartOffset()) 208 if (new_marker->EndOffset() == new_marker->StartOffset())
218 return; 209 return;
219 210
220 possibly_existing_marker_types_.Add(new_marker->GetType()); 211 possibly_existing_marker_types_.Add(new_marker->GetType());
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 DocumentMarkerList* const list = 408 DocumentMarkerList* const list =
418 ListForType(markers, DocumentMarker::kTextMatch); 409 ListForType(markers, DocumentMarker::kTextMatch);
419 if (!list) 410 if (!list)
420 continue; 411 continue;
421 result.AppendVector(ToTextMatchMarkerListImpl(list)->RenderedRects(node)); 412 result.AppendVector(ToTextMatchMarkerListImpl(list)->RenderedRects(node));
422 } 413 }
423 414
424 return result; 415 return result;
425 } 416 }
426 417
427 // TODO(rlanday): move this to TextMatchMarkerListImpl.cpp
428 Vector<IntRect> TextMatchMarkerListImpl::RenderedRects(const Node& node) const {
429 Vector<IntRect> result;
430
431 for (DocumentMarker* marker : markers_) {
432 RenderedDocumentMarker* const rendered_marker =
433 ToRenderedDocumentMarker(marker);
434 if (!rendered_marker->IsValid())
435 UpdateMarkerRenderedRect(node, *rendered_marker);
436 if (!rendered_marker->IsRendered())
437 continue;
438 result.push_back(rendered_marker->RenderedRect());
439 }
440
441 return result;
442 }
443
444 static void InvalidatePaintForTickmarks(const Node& node) { 418 static void InvalidatePaintForTickmarks(const Node& node) {
445 if (FrameView* frame_view = node.GetDocument().View()) 419 if (FrameView* frame_view = node.GetDocument().View())
446 frame_view->InvalidatePaintForTickmarks(); 420 frame_view->InvalidatePaintForTickmarks();
447 } 421 }
448 422
449 void DocumentMarkerController::InvalidateRectsForTextMatchMarkersInNode( 423 void DocumentMarkerController::InvalidateRectsForTextMatchMarkersInNode(
450 const Node& node) { 424 const Node& node) {
451 MarkerLists* markers = markers_.at(&node); 425 MarkerLists* markers = markers_.at(&node);
452 426
453 const DocumentMarkerList* const marker_list = 427 const DocumentMarkerList* const marker_list =
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } 710 }
737 711
738 } // namespace blink 712 } // namespace blink
739 713
740 #ifndef NDEBUG 714 #ifndef NDEBUG
741 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { 715 void showDocumentMarkers(const blink::DocumentMarkerController* controller) {
742 if (controller) 716 if (controller)
743 controller->ShowMarkers(); 717 controller->ShowMarkers();
744 } 718 }
745 #endif 719 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/markers/TextMatchMarkerListImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698