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

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

Issue 1308663003: The node and allowPartialContainment arguments for Selection API should not be optional (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 if (!selectedRange) 449 if (!selectedRange)
450 return; 450 return;
451 451
452 selectedRange->deleteContents(ASSERT_NO_EXCEPTION); 452 selectedRange->deleteContents(ASSERT_NO_EXCEPTION);
453 453
454 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset (), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC EPTION); 454 setBaseAndExtent(selectedRange->startContainer(), selectedRange->startOffset (), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXC EPTION);
455 } 455 }
456 456
457 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const 457 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
458 { 458 {
459 ASSERT(n);
460
459 if (!m_frame) 461 if (!m_frame)
460 return false; 462 return false;
461 463
462 FrameSelection& selection = m_frame->selection(); 464 FrameSelection& selection = m_frame->selection();
463 465
464 if (!n || m_frame->document() != n->document() || selection.isNone()) 466 if (m_frame->document() != n->document() || selection.isNone())
465 return false; 467 return false;
466 468
467 unsigned nodeIndex = n->nodeIndex(); 469 unsigned nodeIndex = n->nodeIndex();
468 const EphemeralRange selectedRange = selection.selection().toNormalizedEphem eralRange(); 470 const EphemeralRange selectedRange = selection.selection().toNormalizedEphem eralRange();
469 471
470 ContainerNode* parentNode = n->parentNode(); 472 ContainerNode* parentNode = n->parentNode();
471 if (!parentNode) 473 if (!parentNode)
472 return false; 474 return false;
473 475
474 const Position startPosition = selectedRange.startPosition().toOffsetInAncho r(); 476 const Position startPosition = selectedRange.startPosition().toOffsetInAncho r();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 558 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
557 } 559 }
558 560
559 DEFINE_TRACE(DOMSelection) 561 DEFINE_TRACE(DOMSelection)
560 { 562 {
561 visitor->trace(m_treeScope); 563 visitor->trace(m_treeScope);
562 DOMWindowProperty::trace(visitor); 564 DOMWindowProperty::trace(visitor);
563 } 565 }
564 566
565 } // namespace blink 567 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/containsNode-expected.txt ('k') | Source/core/editing/Selection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698