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

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

Issue 2351533005: Prune CreateVisiblePositionDeprecated from DOMSelection (Closed)
Patch Set: Created 4 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 | « no previous file | no next file » | 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (!isAvailable()) 236 if (!isAvailable())
237 return; 237 return;
238 238
239 const VisibleSelection& selection = m_frame->selection().selection(); 239 const VisibleSelection& selection = m_frame->selection().selection();
240 240
241 if (selection.isNone()) { 241 if (selection.isNone()) {
242 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on."); 242 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on.");
243 return; 243 return;
244 } 244 }
245 245
246 m_frame->selection().moveTo(createVisiblePositionDeprecated(selection.end()) ); 246 m_frame->selection().moveTo(selection.end(), SelDefaultAffinity);
yosin_UTC9 2016/09/20 08:33:17 Please get rid of FrameSelection::moveTo(const Vis
Xiaocheng 2016/09/20 08:56:37 A TODO is added to FrameSelection::moveTo(VP).
247 } 247 }
248 248
249 void DOMSelection::collapseToStart(ExceptionState& exceptionState) 249 void DOMSelection::collapseToStart(ExceptionState& exceptionState)
250 { 250 {
251 if (!isAvailable()) 251 if (!isAvailable())
252 return; 252 return;
253 253
254 const VisibleSelection& selection = m_frame->selection().selection(); 254 const VisibleSelection& selection = m_frame->selection().selection();
255 255
256 if (selection.isNone()) { 256 if (selection.isNone()) {
257 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on."); 257 exceptionState.throwDOMException(InvalidStateError, "there is no selecti on.");
258 return; 258 return;
259 } 259 }
260 260
261 m_frame->selection().moveTo(createVisiblePositionDeprecated(selection.start( ))); 261 m_frame->selection().moveTo(selection.start(), SelDefaultAffinity);
262 } 262 }
263 263
264 void DOMSelection::empty() 264 void DOMSelection::empty()
265 { 265 {
266 if (!isAvailable()) 266 if (!isAvailable())
267 return; 267 return;
268 m_frame->selection().clear(); 268 m_frame->selection().clear();
269 } 269 }
270 270
271 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent Node, int extentOffset, ExceptionState& exceptionState) 271 void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent Node, int extentOffset, ExceptionState& exceptionState)
(...skipping 10 matching lines...) Expand all
282 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf fset) + " is not a valid extent offset."); 282 exceptionState.throwDOMException(IndexSizeError, String::number(extentOf fset) + " is not a valid extent offset.");
283 return; 283 return;
284 } 284 }
285 285
286 if (!baseNode || !extentNode) 286 if (!baseNode || !extentNode)
287 UseCounter::count(m_frame, UseCounter::SelectionSetBaseAndExtentNull); 287 UseCounter::count(m_frame, UseCounter::SelectionSetBaseAndExtentNull);
288 288
289 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) 289 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
290 return; 290 return;
291 291
292 VisiblePosition visibleBase = createVisiblePositionDeprecated(createPosition (baseNode, baseOffset)); 292 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
293 VisiblePosition visibleExtent = createVisiblePositionDeprecated(createPositi on(extentNode, extentOffset)); 293 // needs to be audited. See http://crbug.com/590369 for more details.
294 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
yosin_UTC9 2016/09/20 08:33:17 nit: It seems strange that making layout tree clea
Xiaocheng 2016/09/20 08:56:38 Reasonable. Done.
Xiaocheng 2016/09/20 08:56:38 Done.
295
296 Position base = createPosition(baseNode, baseOffset);
297 Position extent = createPosition(extentNode, extentOffset);
294 const bool selectionHasDirection = true; 298 const bool selectionHasDirection = true;
295 m_frame->selection().setSelection(VisibleSelection(visibleBase, visibleExten t, selectionHasDirection)); 299 m_frame->selection().setSelection(VisibleSelection(base, extent, SelDefaultA ffinity, selectionHasDirection));
296 } 300 }
297 301
298 void DOMSelection::modify(const String& alterString, const String& directionStri ng, const String& granularityString) 302 void DOMSelection::modify(const String& alterString, const String& directionStri ng, const String& granularityString)
299 { 303 {
300 if (!isAvailable()) 304 if (!isAvailable())
301 return; 305 return;
302 306
303 FrameSelection::EAlteration alter; 307 FrameSelection::EAlteration alter;
304 if (equalIgnoringCase(alterString, "extend")) 308 if (equalIgnoringCase(alterString, "extend"))
305 alter = FrameSelection::AlterationExtend; 309 alter = FrameSelection::AlterationExtend;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); 592 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message));
589 } 593 }
590 594
591 DEFINE_TRACE(DOMSelection) 595 DEFINE_TRACE(DOMSelection)
592 { 596 {
593 visitor->trace(m_treeScope); 597 visitor->trace(m_treeScope);
594 DOMWindowProperty::trace(visitor); 598 DOMWindowProperty::trace(visitor);
595 } 599 }
596 600
597 } // namespace blink 601 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698