| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); | 281 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf
fset) + " is not a valid extent offset."); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 if (!baseNode || !extentNode) | 285 if (!baseNode || !extentNode) |
| 286 UseCounter::count(m_frame, UseCounter::SelectionSetBaseAndExtentNull); | 286 UseCounter::count(m_frame, UseCounter::SelectionSetBaseAndExtentNull); |
| 287 | 287 |
| 288 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 288 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
| 289 return; | 289 return; |
| 290 | 290 |
| 291 // We check |DocumentTypeNode| here instead of |isValidForPosition()|, |
| 292 // since, |collapse()| throws error for |DocumentTypeNode|, but |
| 293 // |setBaseAndExtent()| doesn't. |
| 294 if (baseNode && baseNode->isDocumentTypeNode()) |
| 295 return; |
| 296 if (extentNode && extentNode->isDocumentTypeNode()) |
| 297 return; |
| 298 |
| 291 VisiblePosition visibleBase = createVisiblePosition(createPosition(baseNode,
baseOffset)); | 299 VisiblePosition visibleBase = createVisiblePosition(createPosition(baseNode,
baseOffset)); |
| 292 VisiblePosition visibleExtent = createVisiblePosition(createPosition(extentN
ode, extentOffset)); | 300 VisiblePosition visibleExtent = createVisiblePosition(createPosition(extentN
ode, extentOffset)); |
| 293 | 301 |
| 294 m_frame->selection().moveTo(visibleBase, visibleExtent); | 302 m_frame->selection().moveTo(visibleBase, visibleExtent); |
| 295 } | 303 } |
| 296 | 304 |
| 297 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) | 305 void DOMSelection::modify(const String& alterString, const String& directionStri
ng, const String& granularityString) |
| 298 { | 306 { |
| 299 if (!m_frame) | 307 if (!m_frame) |
| 300 return; | 308 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 return; | 364 return; |
| 357 } | 365 } |
| 358 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { | 366 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { |
| 359 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); | 367 exceptionState.throwDOMException(IndexSizeError, String::number(offset)
+ " is larger than the given node's length."); |
| 360 return; | 368 return; |
| 361 } | 369 } |
| 362 | 370 |
| 363 if (!isValidForPosition(node)) | 371 if (!isValidForPosition(node)) |
| 364 return; | 372 return; |
| 365 | 373 |
| 374 // We check |DocumentTypeNode| here instead of |isValidForPosition()|, |
| 375 // since, |collapse()| throws error for |DocumentTypeNode|, but |
| 376 // |setBaseAndExtent()| doesn't. |
| 377 if (node && node->isDocumentTypeNode()) |
| 378 return; |
| 379 |
| 366 m_frame->selection().setExtent(createVisiblePosition(createPosition(node, of
fset))); | 380 m_frame->selection().setExtent(createVisiblePosition(createPosition(node, of
fset))); |
| 367 } | 381 } |
| 368 | 382 |
| 369 Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) | 383 Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) |
| 370 { | 384 { |
| 371 if (!m_frame) | 385 if (!m_frame) |
| 372 return nullptr; | 386 return nullptr; |
| 373 | 387 |
| 374 if (index < 0 || index >= rangeCount()) { | 388 if (index < 0 || index >= rangeCount()) { |
| 375 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); | 389 exceptionState.throwDOMException(IndexSizeError, String::number(index) +
" is not a valid index."); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); | 583 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa
geSource, ErrorMessageLevel, message)); |
| 570 } | 584 } |
| 571 | 585 |
| 572 DEFINE_TRACE(DOMSelection) | 586 DEFINE_TRACE(DOMSelection) |
| 573 { | 587 { |
| 574 visitor->trace(m_treeScope); | 588 visitor->trace(m_treeScope); |
| 575 DOMWindowProperty::trace(visitor); | 589 DOMWindowProperty::trace(visitor); |
| 576 } | 590 } |
| 577 | 591 |
| 578 } // namespace blink | 592 } // namespace blink |
| OLD | NEW |