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

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

Issue 1299873002: ALL-IN-ONE Introduce enum class TextAffinity (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-19T18:08:52 Created 5 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
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/editing/EditingUtilities.h » ('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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 if (!isValidForPosition(node)) 212 if (!isValidForPosition(node))
213 return; 213 return;
214 RefPtrWillBeRawPtr<Range> range = Range::create(node->document()); 214 RefPtrWillBeRawPtr<Range> range = Range::create(node->document());
215 range->setStart(node, offset, exceptionState); 215 range->setStart(node, offset, exceptionState);
216 if (exceptionState.hadException()) 216 if (exceptionState.hadException())
217 return; 217 return;
218 range->setEnd(node, offset, exceptionState); 218 range->setEnd(node, offset, exceptionState);
219 if (exceptionState.hadException()) 219 if (exceptionState.hadException())
220 return; 220 return;
221 m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->sele ction().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirec tional); 221 m_frame->selection().setSelectedRange(range.get(), TextAffinity::Downstream, m_frame->selection().isDirectional() ? FrameSelection::Directional : FrameSelec tion::NonDirectional);
222 } 222 }
223 223
224 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) 224 void DOMSelection::collapseToEnd(ExceptionState& exceptionState)
225 { 225 {
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()) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 // FIXME: "Merge the ranges if they intersect" is Blink-specific behavior; o ther browsers supporting discontiguous 426 // FIXME: "Merge the ranges if they intersect" is Blink-specific behavior; o ther browsers supporting discontiguous
427 // selection (obviously) keep each Range added and return it in getRangeAt() . But it's unclear if we can really 427 // selection (obviously) keep each Range added and return it in getRangeAt() . But it's unclear if we can really
428 // do the same, since we don't support discontiguous selection. Further disc ussions at 428 // do the same, since we don't support discontiguous selection. Further disc ussions at
429 // <https://code.google.com/p/chromium/issues/detail?id=353069>. 429 // <https://code.google.com/p/chromium/issues/detail?id=353069>.
430 430
431 Range* start = originalRange->compareBoundaryPoints(Range::START_TO_START, n ewRange, ASSERT_NO_EXCEPTION) < 0 ? originalRange.get() : newRange; 431 Range* start = originalRange->compareBoundaryPoints(Range::START_TO_START, n ewRange, ASSERT_NO_EXCEPTION) < 0 ? originalRange.get() : newRange;
432 Range* end = originalRange->compareBoundaryPoints(Range::END_TO_END, newRang e, ASSERT_NO_EXCEPTION) < 0 ? newRange : originalRange.get(); 432 Range* end = originalRange->compareBoundaryPoints(Range::END_TO_END, newRang e, ASSERT_NO_EXCEPTION) < 0 ? newRange : originalRange.get();
433 RefPtrWillBeRawPtr<Range> merged = Range::create(originalRange->startContain er()->document(), start->startContainer(), start->startOffset(), end->endContain er(), end->endOffset()); 433 RefPtrWillBeRawPtr<Range> merged = Range::create(originalRange->startContain er()->document(), start->startContainer(), start->startOffset(), end->endContain er(), end->endOffset());
434 EAffinity affinity = selection.selection().affinity(); 434 TextAffinity affinity = selection.selection().affinity();
435 selection.setSelectedRange(merged.get(), affinity); 435 selection.setSelectedRange(merged.get(), affinity);
436 } 436 }
437 437
438 void DOMSelection::deleteFromDocument() 438 void DOMSelection::deleteFromDocument()
439 { 439 {
440 if (!m_frame) 440 if (!m_frame)
441 return; 441 return;
442 442
443 FrameSelection& selection = m_frame->selection(); 443 FrameSelection& selection = m_frame->selection();
444 444
(...skipping 111 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/Element.cpp ('k') | Source/core/editing/EditingUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698