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

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

Issue 560243002: Merge 181487 "Editing: Let Selection.collapse with null clears s..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2125/
Patch Set: Created 6 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 | Annotate | Revision Log
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 int DOMSelection::rangeCount() const 191 int DOMSelection::rangeCount() const
192 { 192 {
193 if (!m_frame) 193 if (!m_frame)
194 return 0; 194 return 0;
195 return m_frame->selection().isNone() ? 0 : 1; 195 return m_frame->selection().isNone() ? 0 : 1;
196 } 196 }
197 197
198 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta te) 198 void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta te)
199 { 199 {
200 ASSERT(node);
201 if (!m_frame) 200 if (!m_frame)
202 return; 201 return;
203 202
203 if (!node) {
204 m_frame->selection().clear();
205 return;
206 }
207
204 if (offset < 0) { 208 if (offset < 0) {
205 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset."); 209 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset.");
206 return; 210 return;
207 } 211 }
208 212
209 if (!isValidForPosition(node)) 213 if (!isValidForPosition(node))
210 return; 214 return;
211 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); 215 RefPtrWillBeRawPtr<Range> range = Range::create(node->document());
212 range->setStart(node, offset, exceptionState); 216 range->setStart(node, offset, exceptionState);
213 if (exceptionState.hadException()) 217 if (exceptionState.hadException())
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return node->document() == m_frame->document(); 564 return node->document() == m_frame->document();
561 } 565 }
562 566
563 void DOMSelection::addConsoleError(const String& message) 567 void DOMSelection::addConsoleError(const String& message)
564 { 568 {
565 if (m_treeScope) 569 if (m_treeScope)
566 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 570 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
567 } 571 }
568 572
569 } // namespace blink 573 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/collapse-null-expected.txt ('k') | Source/core/editing/Selection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698