Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: Source/core/page/DOMSelection.cpp

Issue 22417002: Rename ASSERT_NO_EXCEPTION_STATE and IGNORE_EXCEPTION_STATE (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.cpp ('k') | Source/core/page/DOMWindow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 return; 393 return;
394 394
395 FrameSelection* selection = m_frame->selection(); 395 FrameSelection* selection = m_frame->selection();
396 396
397 if (selection->isNone()) { 397 if (selection->isNone()) {
398 selection->setSelection(VisibleSelection(r)); 398 selection->setSelection(VisibleSelection(r));
399 return; 399 return;
400 } 400 }
401 401
402 RefPtr<Range> range = selection->selection().toNormalizedRange(); 402 RefPtr<Range> range = selection->selection().toNormalizedRange();
403 if (r->compareBoundaryPoints(Range::START_TO_START, range.get(), IGNORE_EXCE PTION_STATE) == -1) { 403 if (r->compareBoundaryPoints(Range::START_TO_START, range.get(), IGNORE_EXCE PTION) == -1) {
404 // We don't support discontiguous selection. We don't do anything if r a nd range don't intersect. 404 // We don't support discontiguous selection. We don't do anything if r a nd range don't intersect.
405 if (r->compareBoundaryPoints(Range::START_TO_END, range.get(), IGNORE_EX CEPTION_STATE) > -1) { 405 if (r->compareBoundaryPoints(Range::START_TO_END, range.get(), IGNORE_EX CEPTION) > -1) {
406 if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_ EXCEPTION_STATE) == -1) 406 if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_ EXCEPTION) == -1)
407 // The original range and r intersect. 407 // The original range and r intersect.
408 selection->setSelection(VisibleSelection(r->startPosition(), ran ge->endPosition(), DOWNSTREAM)); 408 selection->setSelection(VisibleSelection(r->startPosition(), ran ge->endPosition(), DOWNSTREAM));
409 else 409 else
410 // r contains the original range. 410 // r contains the original range.
411 selection->setSelection(VisibleSelection(r)); 411 selection->setSelection(VisibleSelection(r));
412 } 412 }
413 } else { 413 } else {
414 // We don't support discontiguous selection. We don't do anything if r a nd range don't intersect. 414 // We don't support discontiguous selection. We don't do anything if r a nd range don't intersect.
415 TrackExceptionState es; 415 TrackExceptionState es;
416 if (r->compareBoundaryPoints(Range::END_TO_START, range.get(), es) < 1 & & !es.hadException()) { 416 if (r->compareBoundaryPoints(Range::END_TO_START, range.get(), es) < 1 & & !es.hadException()) {
417 if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_ EXCEPTION_STATE) == -1) 417 if (r->compareBoundaryPoints(Range::END_TO_END, range.get(), IGNORE_ EXCEPTION) == -1)
418 // The original range contains r. 418 // The original range contains r.
419 selection->setSelection(VisibleSelection(range.get())); 419 selection->setSelection(VisibleSelection(range.get()));
420 else 420 else
421 // The original range and r intersect. 421 // The original range and r intersect.
422 selection->setSelection(VisibleSelection(range->startPosition(), r->endPosition(), DOWNSTREAM)); 422 selection->setSelection(VisibleSelection(range->startPosition(), r->endPosition(), DOWNSTREAM));
423 } 423 }
424 } 424 }
425 } 425 }
426 426
427 void DOMSelection::deleteFromDocument() 427 void DOMSelection::deleteFromDocument()
428 { 428 {
429 if (!m_frame) 429 if (!m_frame)
430 return; 430 return;
431 431
432 FrameSelection* selection = m_frame->selection(); 432 FrameSelection* selection = m_frame->selection();
433 433
434 if (selection->isNone()) 434 if (selection->isNone())
435 return; 435 return;
436 436
437 if (isCollapsed()) 437 if (isCollapsed())
438 selection->modify(FrameSelection::AlterationExtend, DirectionBackward, C haracterGranularity); 438 selection->modify(FrameSelection::AlterationExtend, DirectionBackward, C haracterGranularity);
439 439
440 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); 440 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
441 if (!selectedRange) 441 if (!selectedRange)
442 return; 442 return;
443 443
444 selectedRange->deleteContents(ASSERT_NO_EXCEPTION_STATE); 444 selectedRange->deleteContents(ASSERT_NO_EXCEPTION);
445 445
446 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION_STATE), s electedRange->startOffset(), selectedRange->startContainer(), selectedRange->sta rtOffset(), ASSERT_NO_EXCEPTION_STATE); 446 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selecte dRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffs et(), ASSERT_NO_EXCEPTION);
447 } 447 }
448 448
449 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const 449 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
450 { 450 {
451 if (!m_frame) 451 if (!m_frame)
452 return false; 452 return false;
453 453
454 FrameSelection* selection = m_frame->selection(); 454 FrameSelection* selection = m_frame->selection();
455 455
456 if (!n || m_frame->document() != n->document() || selection->isNone()) 456 if (!n || m_frame->document() != n->document() || selection->isNone())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 bool DOMSelection::isValidForPosition(Node* node) const 533 bool DOMSelection::isValidForPosition(Node* node) const
534 { 534 {
535 ASSERT(m_frame); 535 ASSERT(m_frame);
536 if (!node) 536 if (!node)
537 return true; 537 return true;
538 return node->document() == m_frame->document(); 538 return node->document() == m_frame->document();
539 } 539 }
540 540
541 } // namespace WebCore 541 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorStyleSheet.cpp ('k') | Source/core/page/DOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698