OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 { | 66 { |
67 } | 67 } |
68 | 68 |
69 void DOMSelection::clearTreeScope() | 69 void DOMSelection::clearTreeScope() |
70 { | 70 { |
71 m_treeScope = nullptr; | 71 m_treeScope = nullptr; |
72 } | 72 } |
73 | 73 |
74 const VisibleSelection& DOMSelection::visibleSelection() const | 74 const VisibleSelection& DOMSelection::visibleSelection() const |
75 { | 75 { |
76 ASSERT(m_frame); | 76 ASSERT(localFrame()); |
77 return m_frame->selection().selection(); | 77 return localFrame()->selection().selection(); |
78 } | 78 } |
79 | 79 |
80 static Position anchorPosition(const VisibleSelection& selection) | 80 static Position anchorPosition(const VisibleSelection& selection) |
81 { | 81 { |
82 Position anchor = selection.isBaseFirst() ? selection.start() : selection.en
d(); | 82 Position anchor = selection.isBaseFirst() ? selection.start() : selection.en
d(); |
83 return anchor.parentAnchoredEquivalent(); | 83 return anchor.parentAnchoredEquivalent(); |
84 } | 84 } |
85 | 85 |
86 static Position focusPosition(const VisibleSelection& selection) | 86 static Position focusPosition(const VisibleSelection& selection) |
87 { | 87 { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 int DOMSelection::extentOffset() const | 158 int DOMSelection::extentOffset() const |
159 { | 159 { |
160 if (!m_frame) | 160 if (!m_frame) |
161 return 0; | 161 return 0; |
162 | 162 |
163 return shadowAdjustedOffset(extentPosition(visibleSelection())); | 163 return shadowAdjustedOffset(extentPosition(visibleSelection())); |
164 } | 164 } |
165 | 165 |
166 bool DOMSelection::isCollapsed() const | 166 bool DOMSelection::isCollapsed() const |
167 { | 167 { |
168 if (!m_frame || selectionShadowAncestor(m_frame)) | 168 if (!localFrame() || selectionShadowAncestor(localFrame())) |
169 return true; | 169 return true; |
170 return !m_frame->selection().isRange(); | 170 return !localFrame()->selection().isRange(); |
171 } | 171 } |
172 | 172 |
173 String DOMSelection::type() const | 173 String DOMSelection::type() const |
174 { | 174 { |
175 if (!m_frame) | 175 if (!localFrame()) |
176 return String(); | 176 return String(); |
177 | 177 |
178 FrameSelection& selection = m_frame->selection(); | 178 FrameSelection& selection = localFrame()->selection(); |
179 | 179 |
180 // This is a WebKit DOM extension, incompatible with an IE extension | 180 // This is a WebKit DOM extension, incompatible with an IE extension |
181 // IE has this same attribute, but returns "none", "text" and "control" | 181 // IE has this same attribute, but returns "none", "text" and "control" |
182 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx | 182 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx |
183 if (selection.isNone()) | 183 if (selection.isNone()) |
184 return "None"; | 184 return "None"; |
185 if (selection.isCaret()) | 185 if (selection.isCaret()) |
186 return "Caret"; | 186 return "Caret"; |
187 return "Range"; | 187 return "Range"; |
188 } | 188 } |
189 | 189 |
190 int DOMSelection::rangeCount() const | 190 int DOMSelection::rangeCount() const |
191 { | 191 { |
192 if (!m_frame) | 192 if (!localFrame()) |
193 return 0; | 193 return 0; |
194 return m_frame->selection().isNone() ? 0 : 1; | 194 return localFrame()->selection().isNone() ? 0 : 1; |
195 } | 195 } |
196 | 196 |
197 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) | 197 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) |
198 { | 198 { |
199 if (!m_frame) | 199 if (!localFrame()) |
200 return; | 200 return; |
201 | 201 |
202 if (!node) { | 202 if (!node) { |
203 m_frame->selection().clear(); | 203 localFrame()->selection().clear(); |
204 return; | 204 return; |
205 } | 205 } |
206 | 206 |
207 if (offset < 0) { | 207 if (offset < 0) { |
208 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 208 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
209 return; | 209 return; |
210 } | 210 } |
211 | 211 |
212 if (!isValidForPosition(node)) | 212 if (!isValidForPosition(node)) |
213 return; | 213 return; |
214 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); | 214 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); |
215 range->setStart(node, offset, exceptionState); | 215 range->setStart(node, offset, exceptionState); |
216 if (exceptionState.hadException()) | 216 if (exceptionState.hadException()) |
217 return; | 217 return; |
218 range->setEnd(node, offset, exceptionState); | 218 range->setEnd(node, offset, exceptionState); |
219 if (exceptionState.hadException()) | 219 if (exceptionState.hadException()) |
220 return; | 220 return; |
221 m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->sele
ction().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirec
tional); | 221 localFrame()->selection().setSelectedRange(range.get(), DOWNSTREAM, localFra
me()->selection().isDirectional() ? FrameSelection::Directional : FrameSelection
::NonDirectional); |
222 } | 222 } |
223 | 223 |
224 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) | 224 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) |
225 { | 225 { |
226 if (!m_frame) | 226 if (!localFrame()) |
227 return; | 227 return; |
228 | 228 |
229 const VisibleSelection& selection = m_frame->selection().selection(); | 229 const VisibleSelection& selection = localFrame()->selection().selection(); |
230 | 230 |
231 if (selection.isNone()) { | 231 if (selection.isNone()) { |
232 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); | 232 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 m_frame->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM)); | 236 localFrame()->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM
)); |
237 } | 237 } |
238 | 238 |
239 void DOMSelection::collapseToStart(ExceptionState& exceptionState) | 239 void DOMSelection::collapseToStart(ExceptionState& exceptionState) |
240 { | 240 { |
241 if (!m_frame) | 241 if (!localFrame()) |
242 return; | 242 return; |
243 | 243 |
244 const VisibleSelection& selection = m_frame->selection().selection(); | 244 const VisibleSelection& selection = localFrame()->selection().selection(); |
245 | 245 |
246 if (selection.isNone()) { | 246 if (selection.isNone()) { |
247 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); | 247 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); |
248 return; | 248 return; |
249 } | 249 } |
250 | 250 |
251 m_frame->selection().moveTo(VisiblePosition(selection.start(), DOWNSTREAM)); | 251 localFrame()->selection().moveTo(VisiblePosition(selection.start(), DOWNSTRE
AM)); |
252 } | 252 } |
253 | 253 |
254 void DOMSelection::empty() | 254 void DOMSelection::empty() |
255 { | 255 { |
256 if (!m_frame) | 256 if (!localFrame()) |
257 return; | 257 return; |
258 m_frame->selection().clear(); | 258 localFrame()->selection().clear(); |
259 } | 259 } |
260 | 260 |
261 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
Node, int extentOffset, ExceptionState& exceptionState) | 261 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
Node, int extentOffset, ExceptionState& exceptionState) |
262 { | 262 { |
263 if (!m_frame) | 263 if (!localFrame()) |
264 return; | 264 return; |
265 | 265 |
266 if (baseOffset < 0) { | 266 if (baseOffset < 0) { |
267 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs
et) + " is not a valid base offset."); | 267 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs
et) + " is not a valid base offset."); |
268 return; | 268 return; |
269 } | 269 } |
270 | 270 |
271 if (extentOffset < 0) { | 271 if (extentOffset < 0) { |
272 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); | 272 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); |
273 return; | 273 return; |
274 } | 274 } |
275 | 275 |
276 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 276 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
277 return; | 277 return; |
278 | 278 |
279 // FIXME: Eliminate legacy editing positions | 279 // FIXME: Eliminate legacy editing positions |
280 VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(ba
seNode, baseOffset), DOWNSTREAM); | 280 VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(ba
seNode, baseOffset), DOWNSTREAM); |
281 VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(
extentNode, extentOffset), DOWNSTREAM); | 281 VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(
extentNode, extentOffset), DOWNSTREAM); |
282 | 282 |
283 m_frame->selection().moveTo(visibleBase, visibleExtent); | 283 localFrame()->selection().moveTo(visibleBase, visibleExtent); |
284 } | 284 } |
285 | 285 |
286 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) | 286 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) |
287 { | 287 { |
288 if (!m_frame) | 288 if (!localFrame()) |
289 return; | 289 return; |
290 | 290 |
291 FrameSelection::EAlteration alter; | 291 FrameSelection::EAlteration alter; |
292 if (equalIgnoringCase(alterString, "extend")) | 292 if (equalIgnoringCase(alterString, "extend")) |
293 alter = FrameSelection::AlterationExtend; | 293 alter = FrameSelection::AlterationExtend; |
294 else if (equalIgnoringCase(alterString, "move")) | 294 else if (equalIgnoringCase(alterString, "move")) |
295 alter = FrameSelection::AlterationMove; | 295 alter = FrameSelection::AlterationMove; |
296 else | 296 else |
297 return; | 297 return; |
298 | 298 |
(...skipping 24 matching lines...) Expand all Loading... |
323 granularity = LineBoundary; | 323 granularity = LineBoundary; |
324 else if (equalIgnoringCase(granularityString, "sentenceboundary")) | 324 else if (equalIgnoringCase(granularityString, "sentenceboundary")) |
325 granularity = SentenceBoundary; | 325 granularity = SentenceBoundary; |
326 else if (equalIgnoringCase(granularityString, "paragraphboundary")) | 326 else if (equalIgnoringCase(granularityString, "paragraphboundary")) |
327 granularity = ParagraphBoundary; | 327 granularity = ParagraphBoundary; |
328 else if (equalIgnoringCase(granularityString, "documentboundary")) | 328 else if (equalIgnoringCase(granularityString, "documentboundary")) |
329 granularity = DocumentBoundary; | 329 granularity = DocumentBoundary; |
330 else | 330 else |
331 return; | 331 return; |
332 | 332 |
333 m_frame->selection().modify(alter, direction, granularity); | 333 localFrame()->selection().modify(alter, direction, granularity); |
334 } | 334 } |
335 | 335 |
336 void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
) | 336 void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
) |
337 { | 337 { |
338 ASSERT(node); | 338 ASSERT(node); |
339 | 339 |
340 if (!m_frame) | 340 if (!localFrame()) |
341 return; | 341 return; |
342 | 342 |
343 if (offset < 0) { | 343 if (offset < 0) { |
344 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 344 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
345 return; | 345 return; |
346 } | 346 } |
347 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { | 347 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { |
348 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); | 348 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); |
349 return; | 349 return; |
350 } | 350 } |
351 | 351 |
352 if (!isValidForPosition(node)) | 352 if (!isValidForPosition(node)) |
353 return; | 353 return; |
354 | 354 |
355 // FIXME: Eliminate legacy editing positions | 355 // FIXME: Eliminate legacy editing positions |
356 m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(n
ode, offset), DOWNSTREAM)); | 356 localFrame()->selection().setExtent(VisiblePosition(createLegacyEditingPosit
ion(node, offset), DOWNSTREAM)); |
357 } | 357 } |
358 | 358 |
359 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
& exceptionState) | 359 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
& exceptionState) |
360 { | 360 { |
361 if (!m_frame) | 361 if (!localFrame()) |
362 return nullptr; | 362 return nullptr; |
363 | 363 |
364 if (index < 0 || index >= rangeCount()) { | 364 if (index < 0 || index >= rangeCount()) { |
365 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); | 365 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); |
366 return nullptr; | 366 return nullptr; |
367 } | 367 } |
368 | 368 |
369 // If you're hitting this, you've added broken multi-range selection support | 369 // If you're hitting this, you've added broken multi-range selection support |
370 ASSERT(rangeCount() == 1); | 370 ASSERT(rangeCount() == 1); |
371 | 371 |
372 Position anchor = anchorPosition(visibleSelection()); | 372 Position anchor = anchorPosition(visibleSelection()); |
373 if (!anchor.anchorNode()->isInShadowTree()) | 373 if (!anchor.anchorNode()->isInShadowTree()) |
374 return m_frame->selection().firstRange(); | 374 return localFrame()->selection().firstRange(); |
375 | 375 |
376 if (!visibleSelection().isBaseFirst()) | 376 if (!visibleSelection().isBaseFirst()) |
377 return Range::create(*anchor.document(), focusNode(), focusOffset(), sha
dowAdjustedNode(anchor), anchorOffset()); | 377 return Range::create(*anchor.document(), focusNode(), focusOffset(), sha
dowAdjustedNode(anchor), anchorOffset()); |
378 return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorO
ffset(), focusNode(), focusOffset()); | 378 return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorO
ffset(), focusNode(), focusOffset()); |
379 } | 379 } |
380 | 380 |
381 void DOMSelection::removeAllRanges() | 381 void DOMSelection::removeAllRanges() |
382 { | 382 { |
383 if (!m_frame) | 383 if (!localFrame()) |
384 return; | 384 return; |
385 m_frame->selection().clear(); | 385 localFrame()->selection().clear(); |
386 } | 386 } |
387 | 387 |
388 void DOMSelection::addRange(Range* newRange) | 388 void DOMSelection::addRange(Range* newRange) |
389 { | 389 { |
390 if (!m_frame) | 390 if (!localFrame()) |
391 return; | 391 return; |
392 | 392 |
393 // FIXME: Should we throw DOMException for error cases below? | 393 // FIXME: Should we throw DOMException for error cases below? |
394 if (!newRange) { | 394 if (!newRange) { |
395 addConsoleError("The given range is null."); | 395 addConsoleError("The given range is null."); |
396 return; | 396 return; |
397 } | 397 } |
398 | 398 |
399 if (!newRange->startContainer()) { | 399 if (!newRange->startContainer()) { |
400 addConsoleError("The given range has no container. Perhaps 'detach()' ha
s been invoked on it?"); | 400 addConsoleError("The given range has no container. Perhaps 'detach()' ha
s been invoked on it?"); |
401 return; | 401 return; |
402 } | 402 } |
403 | 403 |
404 FrameSelection& selection = m_frame->selection(); | 404 FrameSelection& selection = localFrame()->selection(); |
405 | 405 |
406 if (selection.isNone()) { | 406 if (selection.isNone()) { |
407 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); | 407 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); |
408 return; | 408 return; |
409 } | 409 } |
410 | 410 |
411 RefPtrWillBeRawPtr<Range> originalRange = selection.firstRange(); | 411 RefPtrWillBeRawPtr<Range> originalRange = selection.firstRange(); |
412 | 412 |
413 if (originalRange->startContainer()->document() != newRange->startContainer(
)->document()) { | 413 if (originalRange->startContainer()->document() != newRange->startContainer(
)->document()) { |
414 addConsoleError("The given range does not belong to the current selectio
n's document."); | 414 addConsoleError("The given range does not belong to the current selectio
n's document."); |
(...skipping 17 matching lines...) Expand all Loading... |
432 | 432 |
433 Range* start = originalRange->compareBoundaryPoints(Range::START_TO_START, n
ewRange, ASSERT_NO_EXCEPTION) < 0 ? originalRange.get() : newRange; | 433 Range* start = originalRange->compareBoundaryPoints(Range::START_TO_START, n
ewRange, ASSERT_NO_EXCEPTION) < 0 ? originalRange.get() : newRange; |
434 Range* end = originalRange->compareBoundaryPoints(Range::END_TO_END, newRang
e, ASSERT_NO_EXCEPTION) < 0 ? newRange : originalRange.get(); | 434 Range* end = originalRange->compareBoundaryPoints(Range::END_TO_END, newRang
e, ASSERT_NO_EXCEPTION) < 0 ? newRange : originalRange.get(); |
435 RefPtrWillBeRawPtr<Range> merged = Range::create(originalRange->startContain
er()->document(), start->startContainer(), start->startOffset(), end->endContain
er(), end->endOffset()); | 435 RefPtrWillBeRawPtr<Range> merged = Range::create(originalRange->startContain
er()->document(), start->startContainer(), start->startOffset(), end->endContain
er(), end->endOffset()); |
436 EAffinity affinity = selection.selection().affinity(); | 436 EAffinity affinity = selection.selection().affinity(); |
437 selection.setSelectedRange(merged.get(), affinity); | 437 selection.setSelectedRange(merged.get(), affinity); |
438 } | 438 } |
439 | 439 |
440 void DOMSelection::deleteFromDocument() | 440 void DOMSelection::deleteFromDocument() |
441 { | 441 { |
442 if (!m_frame) | 442 if (!localFrame()) |
443 return; | 443 return; |
444 | 444 |
445 FrameSelection& selection = m_frame->selection(); | 445 FrameSelection& selection = localFrame()->selection(); |
446 | 446 |
447 if (selection.isNone()) | 447 if (selection.isNone()) |
448 return; | 448 return; |
449 | 449 |
450 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized
Range(); | 450 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized
Range(); |
451 if (!selectedRange) | 451 if (!selectedRange) |
452 return; | 452 return; |
453 | 453 |
454 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); | 454 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); |
455 | 455 |
456 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset
(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC
EPTION); | 456 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset
(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC
EPTION); |
457 } | 457 } |
458 | 458 |
459 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const | 459 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const |
460 { | 460 { |
461 if (!m_frame) | 461 if (!localFrame()) |
462 return false; | 462 return false; |
463 | 463 |
464 FrameSelection& selection = m_frame->selection(); | 464 FrameSelection& selection = localFrame()->selection(); |
465 | 465 |
466 if (!n || m_frame->document() != n->document() || selection.isNone()) | 466 if (!n || localFrame()->document() != n->document() || selection.isNone()) |
467 return false; | 467 return false; |
468 | 468 |
469 unsigned nodeIndex = n->nodeIndex(); | 469 unsigned nodeIndex = n->nodeIndex(); |
470 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized
Range(); | 470 RefPtrWillBeRawPtr<Range> selectedRange = selection.selection().toNormalized
Range(); |
471 | 471 |
472 ContainerNode* parentNode = n->parentNode(); | 472 ContainerNode* parentNode = n->parentNode(); |
473 if (!parentNode) | 473 if (!parentNode) |
474 return false; | 474 return false; |
475 | 475 |
476 TrackExceptionState exceptionState; | 476 TrackExceptionState exceptionState; |
(...skipping 16 matching lines...) Expand all Loading... |
493 void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState) | 493 void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState) |
494 { | 494 { |
495 ASSERT(n); | 495 ASSERT(n); |
496 | 496 |
497 // This doesn't (and shouldn't) select text node characters. | 497 // This doesn't (and shouldn't) select text node characters. |
498 setBaseAndExtent(n, 0, n, n->countChildren(), exceptionState); | 498 setBaseAndExtent(n, 0, n, n->countChildren(), exceptionState); |
499 } | 499 } |
500 | 500 |
501 String DOMSelection::toString() | 501 String DOMSelection::toString() |
502 { | 502 { |
503 if (!m_frame) | 503 if (!localFrame()) |
504 return String(); | 504 return String(); |
505 | 505 |
506 Position start, end; | 506 Position start, end; |
507 if (m_frame->selection().selection().toNormalizedPositions(start, end)) | 507 if (localFrame()->selection().selection().toNormalizedPositions(start, end)) |
508 return plainText(start, end); | 508 return plainText(start, end); |
509 return emptyString(); | 509 return emptyString(); |
510 } | 510 } |
511 | 511 |
512 Node* DOMSelection::shadowAdjustedNode(const Position& position) const | 512 Node* DOMSelection::shadowAdjustedNode(const Position& position) const |
513 { | 513 { |
514 if (position.isNull()) | 514 if (position.isNull()) |
515 return 0; | 515 return 0; |
516 | 516 |
517 Node* containerNode = position.containerNode(); | 517 Node* containerNode = position.containerNode(); |
(...skipping 21 matching lines...) Expand all Loading... |
539 return 0; | 539 return 0; |
540 | 540 |
541 if (containerNode == adjustedNode) | 541 if (containerNode == adjustedNode) |
542 return position.computeOffsetInContainerNode(); | 542 return position.computeOffsetInContainerNode(); |
543 | 543 |
544 return adjustedNode->nodeIndex(); | 544 return adjustedNode->nodeIndex(); |
545 } | 545 } |
546 | 546 |
547 bool DOMSelection::isValidForPosition(Node* node) const | 547 bool DOMSelection::isValidForPosition(Node* node) const |
548 { | 548 { |
549 ASSERT(m_frame); | 549 ASSERT(localFrame()); |
550 if (!node) | 550 if (!node) |
551 return true; | 551 return true; |
552 return node->document() == m_frame->document(); | 552 return node->document() == localFrame()->document(); |
553 } | 553 } |
554 | 554 |
555 void DOMSelection::addConsoleError(const String& message) | 555 void DOMSelection::addConsoleError(const String& message) |
556 { | 556 { |
557 if (m_treeScope) | 557 if (m_treeScope) |
558 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); | 558 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); |
559 } | 559 } |
560 | 560 |
561 void DOMSelection::trace(Visitor* visitor) | 561 void DOMSelection::trace(Visitor* visitor) |
562 { | 562 { |
563 visitor->trace(m_treeScope); | 563 visitor->trace(m_treeScope); |
564 DOMWindowProperty::trace(visitor); | 564 DOMWindowProperty::trace(visitor); |
565 } | 565 } |
566 | 566 |
567 } // namespace blink | 567 } // namespace blink |
OLD | NEW |