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

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

Issue 1317053004: Make VisiblePosition constructor private (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-02T12:44:47 Rebase 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
« no previous file with comments | « Source/core/dom/Range.cpp ('k') | Source/core/editing/EditingUtilities.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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (!m_frame) 226 if (!m_frame)
227 return; 227 return;
228 228
229 const VisibleSelection& selection = m_frame->selection().selection(); 229 const VisibleSelection& selection = m_frame->selection().selection();
230 230
231 if (selection.isNone()) { 231 if (selection.isNone()) {
232 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on."); 232 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on.");
233 return; 233 return;
234 } 234 }
235 235
236 m_frame->selection().moveTo(VisiblePosition(selection.end())); 236 m_frame->selection().moveTo(createVisiblePosition(selection.end()));
237 } 237 }
238 238
239 void DOMSelection::collapseToStart(ExceptionState& exceptionState) 239 void DOMSelection::collapseToStart(ExceptionState& exceptionState)
240 { 240 {
241 if (!m_frame) 241 if (!m_frame)
242 return; 242 return;
243 243
244 const VisibleSelection& selection = m_frame->selection().selection(); 244 const VisibleSelection& selection = m_frame->selection().selection();
245 245
246 if (selection.isNone()) { 246 if (selection.isNone()) {
247 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on."); 247 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on.");
248 return; 248 return;
249 } 249 }
250 250
251 m_frame->selection().moveTo(VisiblePosition(selection.start())); 251 m_frame->selection().moveTo(createVisiblePosition(selection.start()));
252 } 252 }
253 253
254 void DOMSelection::empty() 254 void DOMSelection::empty()
255 { 255 {
256 if (!m_frame) 256 if (!m_frame)
257 return; 257 return;
258 m_frame->selection().clear(); 258 m_frame->selection().clear();
259 } 259 }
260 260
261 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent Node, int extentOffset, ExceptionState& exceptionState) 261 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent Node, int extentOffset, ExceptionState& exceptionState)
262 { 262 {
263 if (!m_frame) 263 if (!m_frame)
264 return; 264 return;
265 265
266 if (baseOffset < 0) { 266 if (baseOffset < 0) {
267 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs et) + " is not a valid base offset."); 267 exceptionState.throwDOMException(IndexSizeError, String::number(baseOffs et) + " is not a valid base offset.");
268 return; 268 return;
269 } 269 }
270 270
271 if (extentOffset < 0) { 271 if (extentOffset < 0) {
272 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf fset) + " is not a valid extent offset."); 272 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf fset) + " is not a valid extent offset.");
273 return; 273 return;
274 } 274 }
275 275
276 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) 276 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
277 return; 277 return;
278 278
279 VisiblePosition visibleBase = VisiblePosition(Position(baseNode, baseOffset) ); 279 VisiblePosition visibleBase = createVisiblePosition(Position(baseNode, baseO ffset));
280 VisiblePosition visibleExtent = VisiblePosition(Position(extentNode, extentO ffset)); 280 VisiblePosition visibleExtent = createVisiblePosition(Position(extentNode, e xtentOffset));
281 281
282 m_frame->selection().moveTo(visibleBase, visibleExtent); 282 m_frame->selection().moveTo(visibleBase, visibleExtent);
283 } 283 }
284 284
285 void DOMSelection::modify(const String& alterString, const String& directionStri ng, const String& granularityString) 285 void DOMSelection::modify(const String& alterString, const String& directionStri ng, const String& granularityString)
286 { 286 {
287 if (!m_frame) 287 if (!m_frame)
288 return; 288 return;
289 289
290 FrameSelection::EAlteration alter; 290 FrameSelection::EAlteration alter;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return; 344 return;
345 } 345 }
346 if (static_cast<unsigned>(offset) > node->lengthOfContents()) { 346 if (static_cast<unsigned>(offset) > node->lengthOfContents()) {
347 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length."); 347 exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length.");
348 return; 348 return;
349 } 349 }
350 350
351 if (!isValidForPosition(node)) 351 if (!isValidForPosition(node))
352 return; 352 return;
353 353
354 m_frame->selection().setExtent(VisiblePosition(Position(node, offset))); 354 m_frame->selection().setExtent(createVisiblePosition(Position(node, offset)) );
355 } 355 }
356 356
357 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState & exceptionState) 357 PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState & exceptionState)
358 { 358 {
359 if (!m_frame) 359 if (!m_frame)
360 return nullptr; 360 return nullptr;
361 361
362 if (index < 0 || index >= rangeCount()) { 362 if (index < 0 || index >= rangeCount()) {
363 exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); 363 exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index.");
364 return nullptr; 364 return nullptr;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 556 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
557 } 557 }
558 558
559 DEFINE_TRACE(DOMSelection) 559 DEFINE_TRACE(DOMSelection)
560 { 560 {
561 visitor->trace(m_treeScope); 561 visitor->trace(m_treeScope);
562 DOMWindowProperty::trace(visitor); 562 DOMWindowProperty::trace(visitor);
563 } 563 }
564 564
565 } // namespace blink 565 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Range.cpp ('k') | Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698