OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 void VisibleSelection::setExtent(const VisiblePosition& visiblePosition) | 175 void VisibleSelection::setExtent(const VisiblePosition& visiblePosition) |
176 { | 176 { |
177 Position oldExtent = m_extent; | 177 Position oldExtent = m_extent; |
178 m_extent = visiblePosition.deepEquivalent(); | 178 m_extent = visiblePosition.deepEquivalent(); |
179 validate(); | 179 validate(); |
180 if (m_extent != oldExtent) | 180 if (m_extent != oldExtent) |
181 didChange(); | 181 didChange(); |
182 } | 182 } |
183 | 183 |
184 PassRefPtr<Range> VisibleSelection::firstRange() const | 184 PassRefPtrWillBeRawPtr<Range> VisibleSelection::firstRange() const |
185 { | 185 { |
186 if (isNone()) | 186 if (isNone()) |
187 return nullptr; | 187 return nullptr; |
188 Position start = m_start.parentAnchoredEquivalent(); | 188 Position start = m_start.parentAnchoredEquivalent(); |
189 Position end = m_end.parentAnchoredEquivalent(); | 189 Position end = m_end.parentAnchoredEquivalent(); |
190 return Range::create(*start.document(), start, end); | 190 return Range::create(*start.document(), start, end); |
191 } | 191 } |
192 | 192 |
193 PassRefPtr<Range> VisibleSelection::toNormalizedRange() const | 193 PassRefPtrWillBeRawPtr<Range> VisibleSelection::toNormalizedRange() const |
194 { | 194 { |
195 if (isNone()) | 195 if (isNone()) |
196 return nullptr; | 196 return nullptr; |
197 | 197 |
198 // Make sure we have an updated layout since this function is called | 198 // Make sure we have an updated layout since this function is called |
199 // in the course of running edit commands which modify the DOM. | 199 // in the course of running edit commands which modify the DOM. |
200 // Failing to call this can result in equivalentXXXPosition calls returning | 200 // Failing to call this can result in equivalentXXXPosition calls returning |
201 // incorrect results. | 201 // incorrect results. |
202 m_start.document()->updateLayout(); | 202 m_start.document()->updateLayout(); |
203 | 203 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 Position oldBase = m_base; | 255 Position oldBase = m_base; |
256 Position oldExtent = m_extent; | 256 Position oldExtent = m_extent; |
257 Position oldStart = m_start; | 257 Position oldStart = m_start; |
258 Position oldEnd = m_end; | 258 Position oldEnd = m_end; |
259 validate(granularity); | 259 validate(granularity); |
260 if (m_base != oldBase || m_extent != oldExtent || m_start != oldStart || m_e
nd != oldEnd) | 260 if (m_base != oldBase || m_extent != oldExtent || m_start != oldStart || m_e
nd != oldEnd) |
261 didChange(); | 261 didChange(); |
262 return true; | 262 return true; |
263 } | 263 } |
264 | 264 |
265 static PassRefPtr<Range> makeSearchRange(const Position& pos) | 265 static PassRefPtrWillBeRawPtr<Range> makeSearchRange(const Position& pos) |
266 { | 266 { |
267 Node* n = pos.deprecatedNode(); | 267 Node* n = pos.deprecatedNode(); |
268 if (!n) | 268 if (!n) |
269 return nullptr; | 269 return nullptr; |
270 Document& d = n->document(); | 270 Document& d = n->document(); |
271 Node* de = d.documentElement(); | 271 Node* de = d.documentElement(); |
272 if (!de) | 272 if (!de) |
273 return nullptr; | 273 return nullptr; |
274 Node* boundary = n->enclosingBlockFlowElement(); | 274 Node* boundary = n->enclosingBlockFlowElement(); |
275 if (!boundary) | 275 if (!boundary) |
276 return nullptr; | 276 return nullptr; |
277 | 277 |
278 RefPtr<Range> searchRange(Range::create(d)); | 278 RefPtrWillBeRawPtr<Range> searchRange(Range::create(d)); |
279 TrackExceptionState exceptionState; | 279 TrackExceptionState exceptionState; |
280 | 280 |
281 Position start(pos.parentAnchoredEquivalent()); | 281 Position start(pos.parentAnchoredEquivalent()); |
282 searchRange->selectNodeContents(boundary, exceptionState); | 282 searchRange->selectNodeContents(boundary, exceptionState); |
283 searchRange->setStart(start.containerNode(), start.offsetInContainerNode(),
exceptionState); | 283 searchRange->setStart(start.containerNode(), start.offsetInContainerNode(),
exceptionState); |
284 | 284 |
285 ASSERT(!exceptionState.hadException()); | 285 ASSERT(!exceptionState.hadException()); |
286 if (exceptionState.hadException()) | 286 if (exceptionState.hadException()) |
287 return nullptr; | 287 return nullptr; |
288 | 288 |
289 return searchRange.release(); | 289 return searchRange.release(); |
290 } | 290 } |
291 | 291 |
292 void VisibleSelection::appendTrailingWhitespace() | 292 void VisibleSelection::appendTrailingWhitespace() |
293 { | 293 { |
294 RefPtr<Range> searchRange = makeSearchRange(m_end); | 294 RefPtrWillBeRawPtr<Range> searchRange = makeSearchRange(m_end); |
295 if (!searchRange) | 295 if (!searchRange) |
296 return; | 296 return; |
297 | 297 |
298 CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetwe
enAllVisiblePositions); | 298 CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetwe
enAllVisiblePositions); |
299 bool changed = false; | 299 bool changed = false; |
300 | 300 |
301 for (; charIt.length(); charIt.advance(1)) { | 301 for (; charIt.length(); charIt.advance(1)) { |
302 UChar c = charIt.characterAt(0); | 302 UChar c = charIt.characterAt(0); |
303 if ((!isSpaceOrNewline(c) && c != noBreakSpace) || c == '\n') | 303 if ((!isSpaceOrNewline(c) && c != noBreakSpace) || c == '\n') |
304 break; | 304 break; |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 sel.showTreeForThis(); | 824 sel.showTreeForThis(); |
825 } | 825 } |
826 | 826 |
827 void showTree(const WebCore::VisibleSelection* sel) | 827 void showTree(const WebCore::VisibleSelection* sel) |
828 { | 828 { |
829 if (sel) | 829 if (sel) |
830 sel->showTreeForThis(); | 830 sel->showTreeForThis(); |
831 } | 831 } |
832 | 832 |
833 #endif | 833 #endif |
OLD | NEW |