| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 { | 74 { |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DOMSelection::clearTreeScope() | 77 void DOMSelection::clearTreeScope() |
| 78 { | 78 { |
| 79 m_treeScope = nullptr; | 79 m_treeScope = nullptr; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool DOMSelection::isAvailable() const | 82 bool DOMSelection::isAvailable() const |
| 83 { | 83 { |
| 84 return m_frame && m_frame->selection().isAvailable(); | 84 return frame() && frame()->selection().isAvailable(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 const VisibleSelection& DOMSelection::visibleSelection() const | 87 const VisibleSelection& DOMSelection::visibleSelection() const |
| 88 { | 88 { |
| 89 DCHECK(m_frame); | 89 DCHECK(frame()); |
| 90 return m_frame->selection().selection(); | 90 return frame()->selection().selection(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 static Position anchorPosition(const VisibleSelection& selection) | 93 static Position anchorPosition(const VisibleSelection& selection) |
| 94 { | 94 { |
| 95 Position anchor = selection.isBaseFirst() ? selection.start() : selection.en
d(); | 95 Position anchor = selection.isBaseFirst() ? selection.start() : selection.en
d(); |
| 96 return anchor.parentAnchoredEquivalent(); | 96 return anchor.parentAnchoredEquivalent(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 static Position focusPosition(const VisibleSelection& selection) | 99 static Position focusPosition(const VisibleSelection& selection) |
| 100 { | 100 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 int DOMSelection::extentOffset() const | 171 int DOMSelection::extentOffset() const |
| 172 { | 172 { |
| 173 if (!isAvailable()) | 173 if (!isAvailable()) |
| 174 return 0; | 174 return 0; |
| 175 | 175 |
| 176 return shadowAdjustedOffset(extentPosition(visibleSelection())); | 176 return shadowAdjustedOffset(extentPosition(visibleSelection())); |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool DOMSelection::isCollapsed() const | 179 bool DOMSelection::isCollapsed() const |
| 180 { | 180 { |
| 181 if (!isAvailable() || selectionShadowAncestor(m_frame)) | 181 if (!isAvailable() || selectionShadowAncestor(frame())) |
| 182 return true; | 182 return true; |
| 183 return !m_frame->selection().isRange(); | 183 return !frame()->selection().isRange(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 String DOMSelection::type() const | 186 String DOMSelection::type() const |
| 187 { | 187 { |
| 188 if (!isAvailable()) | 188 if (!isAvailable()) |
| 189 return String(); | 189 return String(); |
| 190 | 190 |
| 191 FrameSelection& selection = m_frame->selection(); | 191 FrameSelection& selection = frame()->selection(); |
| 192 | 192 |
| 193 // This is a WebKit DOM extension, incompatible with an IE extension | 193 // This is a WebKit DOM extension, incompatible with an IE extension |
| 194 // IE has this same attribute, but returns "none", "text" and "control" | 194 // IE has this same attribute, but returns "none", "text" and "control" |
| 195 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx | 195 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx |
| 196 if (selection.isNone()) | 196 if (selection.isNone()) |
| 197 return "None"; | 197 return "None"; |
| 198 if (selection.isCaret()) | 198 if (selection.isCaret()) |
| 199 return "Caret"; | 199 return "Caret"; |
| 200 return "Range"; | 200 return "Range"; |
| 201 } | 201 } |
| 202 | 202 |
| 203 int DOMSelection::rangeCount() const | 203 int DOMSelection::rangeCount() const |
| 204 { | 204 { |
| 205 if (!isAvailable()) | 205 if (!isAvailable()) |
| 206 return 0; | 206 return 0; |
| 207 return m_frame->selection().isNone() ? 0 : 1; | 207 return frame()->selection().isNone() ? 0 : 1; |
| 208 } | 208 } |
| 209 | 209 |
| 210 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) | 210 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
te) |
| 211 { | 211 { |
| 212 if (!isAvailable()) | 212 if (!isAvailable()) |
| 213 return; | 213 return; |
| 214 | 214 |
| 215 if (!node) { | 215 if (!node) { |
| 216 UseCounter::count(m_frame, UseCounter::SelectionCollapseNull); | 216 UseCounter::count(frame(), UseCounter::SelectionCollapseNull); |
| 217 m_frame->selection().clear(); | 217 frame()->selection().clear(); |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 | 220 |
| 221 if (offset < 0) { | 221 if (offset < 0) { |
| 222 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 222 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
| 223 return; | 223 return; |
| 224 } | 224 } |
| 225 | 225 |
| 226 if (!isValidForPosition(node)) | 226 if (!isValidForPosition(node)) |
| 227 return; | 227 return; |
| 228 Range::checkNodeWOffset(node, offset, exceptionState); | 228 Range::checkNodeWOffset(node, offset, exceptionState); |
| 229 if (exceptionState.hadException()) | 229 if (exceptionState.hadException()) |
| 230 return; | 230 return; |
| 231 m_frame->selection().setSelection(VisibleSelection(Position(node, offset), m
_frame->selection().isDirectional())); | 231 frame()->selection().setSelection(VisibleSelection(Position(node, offset), f
rame()->selection().isDirectional())); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) | 234 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) |
| 235 { | 235 { |
| 236 if (!isAvailable()) | 236 if (!isAvailable()) |
| 237 return; | 237 return; |
| 238 | 238 |
| 239 const VisibleSelection& selection = m_frame->selection().selection(); | 239 const VisibleSelection& selection = frame()->selection().selection(); |
| 240 | 240 |
| 241 if (selection.isNone()) { | 241 if (selection.isNone()) { |
| 242 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); | 242 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 | 245 |
| 246 m_frame->selection().moveTo(selection.end(), SelDefaultAffinity); | 246 frame()->selection().moveTo(selection.end(), SelDefaultAffinity); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void DOMSelection::collapseToStart(ExceptionState& exceptionState) | 249 void DOMSelection::collapseToStart(ExceptionState& exceptionState) |
| 250 { | 250 { |
| 251 if (!isAvailable()) | 251 if (!isAvailable()) |
| 252 return; | 252 return; |
| 253 | 253 |
| 254 const VisibleSelection& selection = m_frame->selection().selection(); | 254 const VisibleSelection& selection = frame()->selection().selection(); |
| 255 | 255 |
| 256 if (selection.isNone()) { | 256 if (selection.isNone()) { |
| 257 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); | 257 exceptionState.throwDOMException(InvalidStateError, "there is no selecti
on."); |
| 258 return; | 258 return; |
| 259 } | 259 } |
| 260 | 260 |
| 261 m_frame->selection().moveTo(selection.start(), SelDefaultAffinity); | 261 frame()->selection().moveTo(selection.start(), SelDefaultAffinity); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void DOMSelection::empty() | 264 void DOMSelection::empty() |
| 265 { | 265 { |
| 266 if (!isAvailable()) | 266 if (!isAvailable()) |
| 267 return; | 267 return; |
| 268 m_frame->selection().clear(); | 268 frame()->selection().clear(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
Node, int extentOffset, ExceptionState& exceptionState) | 271 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
Node, int extentOffset, ExceptionState& exceptionState) |
| 272 { | 272 { |
| 273 if (!isAvailable()) | 273 if (!isAvailable()) |
| 274 return; | 274 return; |
| 275 | 275 |
| 276 if (baseOffset < 0) { | 276 if (baseOffset < 0) { |
| 277 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs
et) + " is not a valid base offset."); | 277 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs
et) + " is not a valid base offset."); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| 281 if (extentOffset < 0) { | 281 if (extentOffset < 0) { |
| 282 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); | 282 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 | 285 |
| 286 if (!baseNode || !extentNode) | 286 if (!baseNode || !extentNode) |
| 287 UseCounter::count(m_frame, UseCounter::SelectionSetBaseAndExtentNull); | 287 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); |
| 288 | 288 |
| 289 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 289 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
| 290 return; | 290 return; |
| 291 | 291 |
| 292 Position base = createPosition(baseNode, baseOffset); | 292 Position base = createPosition(baseNode, baseOffset); |
| 293 Position extent = createPosition(extentNode, extentOffset); | 293 Position extent = createPosition(extentNode, extentOffset); |
| 294 const bool selectionHasDirection = true; | 294 const bool selectionHasDirection = true; |
| 295 m_frame->selection().setSelection(VisibleSelection(base, extent, SelDefaultA
ffinity, selectionHasDirection)); | 295 frame()->selection().setSelection(VisibleSelection(base, extent, SelDefaultA
ffinity, selectionHasDirection)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) | 298 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) |
| 299 { | 299 { |
| 300 if (!isAvailable()) | 300 if (!isAvailable()) |
| 301 return; | 301 return; |
| 302 | 302 |
| 303 FrameSelection::EAlteration alter; | 303 FrameSelection::EAlteration alter; |
| 304 if (equalIgnoringCase(alterString, "extend")) | 304 if (equalIgnoringCase(alterString, "extend")) |
| 305 alter = FrameSelection::AlterationExtend; | 305 alter = FrameSelection::AlterationExtend; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 335 granularity = LineBoundary; | 335 granularity = LineBoundary; |
| 336 else if (equalIgnoringCase(granularityString, "sentenceboundary")) | 336 else if (equalIgnoringCase(granularityString, "sentenceboundary")) |
| 337 granularity = SentenceBoundary; | 337 granularity = SentenceBoundary; |
| 338 else if (equalIgnoringCase(granularityString, "paragraphboundary")) | 338 else if (equalIgnoringCase(granularityString, "paragraphboundary")) |
| 339 granularity = ParagraphBoundary; | 339 granularity = ParagraphBoundary; |
| 340 else if (equalIgnoringCase(granularityString, "documentboundary")) | 340 else if (equalIgnoringCase(granularityString, "documentboundary")) |
| 341 granularity = DocumentBoundary; | 341 granularity = DocumentBoundary; |
| 342 else | 342 else |
| 343 return; | 343 return; |
| 344 | 344 |
| 345 m_frame->selection().modify(alter, direction, granularity); | 345 frame()->selection().modify(alter, direction, granularity); |
| 346 } | 346 } |
| 347 | 347 |
| 348 void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
) | 348 void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
) |
| 349 { | 349 { |
| 350 DCHECK(node); | 350 DCHECK(node); |
| 351 | 351 |
| 352 if (!isAvailable()) | 352 if (!isAvailable()) |
| 353 return; | 353 return; |
| 354 | 354 |
| 355 if (offset < 0) { | 355 if (offset < 0) { |
| 356 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); | 356 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is not a valid offset."); |
| 357 return; | 357 return; |
| 358 } | 358 } |
| 359 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { | 359 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { |
| 360 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); | 360 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); |
| 361 return; | 361 return; |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (!isValidForPosition(node)) | 364 if (!isValidForPosition(node)) |
| 365 return; | 365 return; |
| 366 | 366 |
| 367 const Position& base = m_frame->selection().base(); | 367 const Position& base = frame()->selection().base(); |
| 368 const Position& extent = createPosition(node, offset); | 368 const Position& extent = createPosition(node, offset); |
| 369 const bool selectionHasDirection = true; | 369 const bool selectionHasDirection = true; |
| 370 const VisibleSelection newSelection(base, extent, TextAffinity::Downstream,
selectionHasDirection); | 370 const VisibleSelection newSelection(base, extent, TextAffinity::Downstream,
selectionHasDirection); |
| 371 m_frame->selection().setSelection(newSelection); | 371 frame()->selection().setSelection(newSelection); |
| 372 } | 372 } |
| 373 | 373 |
| 374 Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) | 374 Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) |
| 375 { | 375 { |
| 376 if (!isAvailable()) | 376 if (!isAvailable()) |
| 377 return nullptr; | 377 return nullptr; |
| 378 | 378 |
| 379 if (index < 0 || index >= rangeCount()) { | 379 if (index < 0 || index >= rangeCount()) { |
| 380 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); | 380 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); |
| 381 return nullptr; | 381 return nullptr; |
| 382 } | 382 } |
| 383 | 383 |
| 384 // If you're hitting this, you've added broken multi-range selection support | 384 // If you're hitting this, you've added broken multi-range selection support |
| 385 DCHECK_EQ(rangeCount(), 1); | 385 DCHECK_EQ(rangeCount(), 1); |
| 386 | 386 |
| 387 Position anchor = anchorPosition(visibleSelection()); | 387 Position anchor = anchorPosition(visibleSelection()); |
| 388 if (!anchor.anchorNode()->isInShadowTree()) | 388 if (!anchor.anchorNode()->isInShadowTree()) |
| 389 return m_frame->selection().firstRange(); | 389 return frame()->selection().firstRange(); |
| 390 | 390 |
| 391 Node* node = shadowAdjustedNode(anchor); | 391 Node* node = shadowAdjustedNode(anchor); |
| 392 if (!node) // crbug.com/595100 | 392 if (!node) // crbug.com/595100 |
| 393 return nullptr; | 393 return nullptr; |
| 394 if (!visibleSelection().isBaseFirst()) | 394 if (!visibleSelection().isBaseFirst()) |
| 395 return Range::create(*anchor.document(), focusNode(), focusOffset(), nod
e, anchorOffset()); | 395 return Range::create(*anchor.document(), focusNode(), focusOffset(), nod
e, anchorOffset()); |
| 396 return Range::create(*anchor.document(), node, anchorOffset(), focusNode(),
focusOffset()); | 396 return Range::create(*anchor.document(), node, anchorOffset(), focusNode(),
focusOffset()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void DOMSelection::removeAllRanges() | 399 void DOMSelection::removeAllRanges() |
| 400 { | 400 { |
| 401 if (!isAvailable()) | 401 if (!isAvailable()) |
| 402 return; | 402 return; |
| 403 m_frame->selection().clear(); | 403 frame()->selection().clear(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void DOMSelection::addRange(Range* newRange) | 406 void DOMSelection::addRange(Range* newRange) |
| 407 { | 407 { |
| 408 DCHECK(newRange); | 408 DCHECK(newRange); |
| 409 | 409 |
| 410 if (!isAvailable()) | 410 if (!isAvailable()) |
| 411 return; | 411 return; |
| 412 | 412 |
| 413 if (newRange->ownerDocument() != m_frame->document()) | 413 if (newRange->ownerDocument() != frame()->document()) |
| 414 return; | 414 return; |
| 415 | 415 |
| 416 if (!newRange->isConnected()) { | 416 if (!newRange->isConnected()) { |
| 417 addConsoleError("The given range isn't in document."); | 417 addConsoleError("The given range isn't in document."); |
| 418 return; | 418 return; |
| 419 } | 419 } |
| 420 | 420 |
| 421 FrameSelection& selection = m_frame->selection(); | 421 FrameSelection& selection = frame()->selection(); |
| 422 | 422 |
| 423 if (newRange->ownerDocument() != selection.document()) { | 423 if (newRange->ownerDocument() != selection.document()) { |
| 424 // "editing/selection/selection-in-iframe-removed-crash.html" goes here. | 424 // "editing/selection/selection-in-iframe-removed-crash.html" goes here. |
| 425 return; | 425 return; |
| 426 } | 426 } |
| 427 | 427 |
| 428 if (selection.isNone()) { | 428 if (selection.isNone()) { |
| 429 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); | 429 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); |
| 430 return; | 430 return; |
| 431 } | 431 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 457 Range* merged = Range::create(originalRange->startContainer()->document(), s
tart->startContainer(), start->startOffset(), end->endContainer(), end->endOffse
t()); | 457 Range* merged = Range::create(originalRange->startContainer()->document(), s
tart->startContainer(), start->startOffset(), end->endContainer(), end->endOffse
t()); |
| 458 TextAffinity affinity = selection.selection().affinity(); | 458 TextAffinity affinity = selection.selection().affinity(); |
| 459 selection.setSelectedRange(merged, affinity); | 459 selection.setSelectedRange(merged, affinity); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void DOMSelection::deleteFromDocument() | 462 void DOMSelection::deleteFromDocument() |
| 463 { | 463 { |
| 464 if (!isAvailable()) | 464 if (!isAvailable()) |
| 465 return; | 465 return; |
| 466 | 466 |
| 467 FrameSelection& selection = m_frame->selection(); | 467 FrameSelection& selection = frame()->selection(); |
| 468 | 468 |
| 469 if (selection.isNone()) | 469 if (selection.isNone()) |
| 470 return; | 470 return; |
| 471 | 471 |
| 472 Range* selectedRange = createRange(selection.selection().toNormalizedEphemer
alRange()); | 472 Range* selectedRange = createRange(selection.selection().toNormalizedEphemer
alRange()); |
| 473 if (!selectedRange) | 473 if (!selectedRange) |
| 474 return; | 474 return; |
| 475 | 475 |
| 476 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); | 476 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); |
| 477 | 477 |
| 478 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset
(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC
EPTION); | 478 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset
(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC
EPTION); |
| 479 } | 479 } |
| 480 | 480 |
| 481 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const | 481 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const |
| 482 { | 482 { |
| 483 DCHECK(n); | 483 DCHECK(n); |
| 484 | 484 |
| 485 if (!isAvailable()) | 485 if (!isAvailable()) |
| 486 return false; | 486 return false; |
| 487 | 487 |
| 488 FrameSelection& selection = m_frame->selection(); | 488 FrameSelection& selection = frame()->selection(); |
| 489 | 489 |
| 490 if (m_frame->document() != n->document() || selection.isNone()) | 490 if (frame()->document() != n->document() || selection.isNone()) |
| 491 return false; | 491 return false; |
| 492 | 492 |
| 493 unsigned nodeIndex = n->nodeIndex(); | 493 unsigned nodeIndex = n->nodeIndex(); |
| 494 const EphemeralRange selectedRange = selection.selection().toNormalizedEphem
eralRange(); | 494 const EphemeralRange selectedRange = selection.selection().toNormalizedEphem
eralRange(); |
| 495 | 495 |
| 496 ContainerNode* parentNode = n->parentNode(); | 496 ContainerNode* parentNode = n->parentNode(); |
| 497 if (!parentNode) | 497 if (!parentNode) |
| 498 return false; | 498 return false; |
| 499 | 499 |
| 500 const Position startPosition = selectedRange.startPosition().toOffsetInAncho
r(); | 500 const Position startPosition = selectedRange.startPosition().toOffsetInAncho
r(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 524 setBaseAndExtent(n, 0, n, n->countChildren(), exceptionState); | 524 setBaseAndExtent(n, 0, n, n->countChildren(), exceptionState); |
| 525 } | 525 } |
| 526 | 526 |
| 527 String DOMSelection::toString() | 527 String DOMSelection::toString() |
| 528 { | 528 { |
| 529 if (!isAvailable()) | 529 if (!isAvailable()) |
| 530 return String(); | 530 return String(); |
| 531 | 531 |
| 532 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 532 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 533 // needs to be audited. See http://crbug.com/590369 for more details. | 533 // needs to be audited. See http://crbug.com/590369 for more details. |
| 534 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 534 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 535 | 535 |
| 536 DocumentLifecycle::DisallowTransitionScope disallowTransition(m_frame->docum
ent()->lifecycle()); | 536 DocumentLifecycle::DisallowTransitionScope disallowTransition(frame()->docum
ent()->lifecycle()); |
| 537 | 537 |
| 538 const EphemeralRange range = m_frame->selection().selection().toNormalizedEp
hemeralRange(); | 538 const EphemeralRange range = frame()->selection().selection().toNormalizedEp
hemeralRange(); |
| 539 return plainText(range, TextIteratorForSelectionToString); | 539 return plainText(range, TextIteratorForSelectionToString); |
| 540 } | 540 } |
| 541 | 541 |
| 542 Node* DOMSelection::shadowAdjustedNode(const Position& position) const | 542 Node* DOMSelection::shadowAdjustedNode(const Position& position) const |
| 543 { | 543 { |
| 544 if (position.isNull()) | 544 if (position.isNull()) |
| 545 return 0; | 545 return 0; |
| 546 | 546 |
| 547 Node* containerNode = position.computeContainerNode(); | 547 Node* containerNode = position.computeContainerNode(); |
| 548 Node* adjustedNode = m_treeScope->ancestorInThisScope(containerNode); | 548 Node* adjustedNode = m_treeScope->ancestorInThisScope(containerNode); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 569 return 0; | 569 return 0; |
| 570 | 570 |
| 571 if (containerNode == adjustedNode) | 571 if (containerNode == adjustedNode) |
| 572 return position.computeOffsetInContainerNode(); | 572 return position.computeOffsetInContainerNode(); |
| 573 | 573 |
| 574 return adjustedNode->nodeIndex(); | 574 return adjustedNode->nodeIndex(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 bool DOMSelection::isValidForPosition(Node* node) const | 577 bool DOMSelection::isValidForPosition(Node* node) const |
| 578 { | 578 { |
| 579 DCHECK(m_frame); | 579 DCHECK(frame()); |
| 580 if (!node) | 580 if (!node) |
| 581 return true; | 581 return true; |
| 582 return node->document() == m_frame->document() && node->isConnected(); | 582 return node->document() == frame()->document() && node->isConnected(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void DOMSelection::addConsoleError(const String& message) | 585 void DOMSelection::addConsoleError(const String& message) |
| 586 { | 586 { |
| 587 if (m_treeScope) | 587 if (m_treeScope) |
| 588 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); | 588 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); |
| 589 } | 589 } |
| 590 | 590 |
| 591 DEFINE_TRACE(DOMSelection) | 591 DEFINE_TRACE(DOMSelection) |
| 592 { | 592 { |
| 593 visitor->trace(m_treeScope); | 593 visitor->trace(m_treeScope); |
| 594 DOMWindowProperty::trace(visitor); | 594 DOMWindowProperty::trace(visitor); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace blink | 597 } // namespace blink |
| OLD | NEW |