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 | 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 15 matching lines...) Expand all Loading... |
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" | 34 #include "core/dom/Range.h" |
35 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
| 36 #include "core/editing/VisibleUnits.h" |
36 #include "core/editing/iterators/TextIterator.h" | 37 #include "core/editing/iterators/TextIterator.h" |
37 #include "core/editing/markers/CompositionMarkerListImpl.h" | 38 #include "core/editing/markers/CompositionMarkerListImpl.h" |
38 #include "core/editing/markers/DocumentMarkerListEditor.h" | 39 #include "core/editing/markers/DocumentMarkerListEditor.h" |
39 #include "core/editing/markers/GrammarMarkerListImpl.h" | 40 #include "core/editing/markers/GrammarMarkerListImpl.h" |
40 #include "core/editing/markers/RenderedDocumentMarker.h" | 41 #include "core/editing/markers/RenderedDocumentMarker.h" |
41 #include "core/editing/markers/SpellingMarkerListImpl.h" | 42 #include "core/editing/markers/SpellingMarkerListImpl.h" |
42 #include "core/editing/markers/TextMatchMarkerListImpl.h" | 43 #include "core/editing/markers/TextMatchMarkerListImpl.h" |
43 #include "core/frame/FrameView.h" | 44 #include "core/frame/FrameView.h" |
44 #include "core/layout/LayoutObject.h" | 45 #include "core/layout/LayoutObject.h" |
45 | 46 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const EphemeralRange& range, | 195 const EphemeralRange& range, |
195 DocumentMarker::MarkerTypes marker_types) { | 196 DocumentMarker::MarkerTypes marker_types) { |
196 DCHECK(!document_->NeedsLayoutTreeUpdate()); | 197 DCHECK(!document_->NeedsLayoutTreeUpdate()); |
197 | 198 |
198 TextIterator marked_text(range.StartPosition(), range.EndPosition()); | 199 TextIterator marked_text(range.StartPosition(), range.EndPosition()); |
199 DocumentMarkerController::RemoveMarkers(marked_text, marker_types); | 200 DocumentMarkerController::RemoveMarkers(marked_text, marker_types); |
200 } | 201 } |
201 | 202 |
202 static void UpdateMarkerRenderedRect(const Node& node, | 203 static void UpdateMarkerRenderedRect(const Node& node, |
203 RenderedDocumentMarker& marker) { | 204 RenderedDocumentMarker& marker) { |
204 Range* range = Range::Create(node.GetDocument()); | 205 const Position startPosition(&const_cast<Node&>(node), marker.StartOffset()); |
205 // The offsets of the marker may be out-dated, so check for exceptions. | 206 const Position endPostion(&const_cast<Node&>(node), marker.EndOffset()); |
206 DummyExceptionStateForTesting exception_state; | 207 EphemeralRange range(startPosition, endPostion); |
207 range->setStart(&const_cast<Node&>(node), marker.StartOffset(), | 208 marker.SetRenderedRect(LayoutRect(ComputeTextRect(range))); |
208 exception_state); | |
209 if (!exception_state.HadException()) { | |
210 range->setEnd(&const_cast<Node&>(node), marker.EndOffset(), | |
211 IGNORE_EXCEPTION_FOR_TESTING); | |
212 } | |
213 if (!exception_state.HadException()) { | |
214 // TODO(yosin): Once we have a |EphemeralRange| version of |boundingBox()|, | |
215 // we should use it instead of |Range| version. | |
216 marker.SetRenderedRect(LayoutRect(range->BoundingBox())); | |
217 } else { | |
218 marker.NullifyRenderedRect(); | |
219 } | |
220 range->Dispose(); | |
221 } | 209 } |
222 | 210 |
223 // Markers are stored in order sorted by their start offset. | 211 // Markers are stored in order sorted by their start offset. |
224 // Markers of the same type do not overlap each other. | 212 // Markers of the same type do not overlap each other. |
225 | 213 |
226 void DocumentMarkerController::AddMarker(Node* node, | 214 void DocumentMarkerController::AddMarker(Node* node, |
227 DocumentMarker* new_marker) { | 215 DocumentMarker* new_marker) { |
228 DCHECK_GE(new_marker->EndOffset(), new_marker->StartOffset()); | 216 DCHECK_GE(new_marker->EndOffset(), new_marker->StartOffset()); |
229 if (new_marker->EndOffset() == new_marker->StartOffset()) | 217 if (new_marker->EndOffset() == new_marker->StartOffset()) |
230 return; | 218 return; |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 732 } |
745 | 733 |
746 } // namespace blink | 734 } // namespace blink |
747 | 735 |
748 #ifndef NDEBUG | 736 #ifndef NDEBUG |
749 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 737 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
750 if (controller) | 738 if (controller) |
751 controller->ShowMarkers(); | 739 controller->ShowMarkers(); |
752 } | 740 } |
753 #endif | 741 #endif |
OLD | NEW |