OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2009 Igalia S.L. | 4 * Copyright (C) 2009 Igalia S.L. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran
ularity) | 214 static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran
ularity) |
215 { | 215 { |
216 VisibleSelection selection = frame.selection().selection(); | 216 VisibleSelection selection = frame.selection().selection(); |
217 selection.expandUsingGranularity(granularity); | 217 selection.expandUsingGranularity(granularity); |
218 const EphemeralRange newRange = selection.toNormalizedEphemeralRange(); | 218 const EphemeralRange newRange = selection.toNormalizedEphemeralRange(); |
219 if (newRange.isNull()) | 219 if (newRange.isNull()) |
220 return false; | 220 return false; |
221 if (newRange.isCollapsed()) | 221 if (newRange.isCollapsed()) |
222 return false; | 222 return false; |
223 EAffinity affinity = frame.selection().affinity(); | 223 TextAffinity affinity = frame.selection().affinity(); |
224 frame.selection().setSelectedRange(newRange, affinity, FrameSelection::NonDi
rectional, FrameSelection::CloseTyping); | 224 frame.selection().setSelectedRange(newRange, affinity, FrameSelection::NonDi
rectional, FrameSelection::CloseTyping); |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 static TriState selectionListState(const FrameSelection& selection, const Qualif
iedName& tagName) | 228 static TriState selectionListState(const FrameSelection& selection, const Qualif
iedName& tagName) |
229 { | 229 { |
230 if (selection.isCaret()) { | 230 if (selection.isCaret()) { |
231 if (enclosingElementWithTag(selection.selection().start(), tagName)) | 231 if (enclosingElementWithTag(selection.selection().start(), tagName)) |
232 return TrueTriState; | 232 return TrueTriState; |
233 } else if (selection.isRange()) { | 233 } else if (selection.isRange()) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true
, false); | 391 frame.editor().deleteWithDirection(DirectionForward, ParagraphBoundary, true
, false); |
392 return true; | 392 return true; |
393 } | 393 } |
394 | 394 |
395 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) | 395 static bool executeDeleteToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) |
396 { | 396 { |
397 // TODO(yosin) We should use |EphemeralRange| version of | 397 // TODO(yosin) We should use |EphemeralRange| version of |
398 // |VisibleSelection::toNormalizedRange()|. | 398 // |VisibleSelection::toNormalizedRange()|. |
399 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | 399 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); |
400 if (mark) { | 400 if (mark) { |
401 bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(
EphemeralRange(mark.get()), frame.editor().selectedRange()), DOWNSTREAM, FrameSe
lection::NonDirectional, FrameSelection::CloseTyping); | 401 bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(
EphemeralRange(mark.get()), frame.editor().selectedRange()), TextAffinity::Downs
tream, FrameSelection::NonDirectional, FrameSelection::CloseTyping); |
402 ASSERT(selected); | 402 ASSERT(selected); |
403 if (!selected) | 403 if (!selected) |
404 return false; | 404 return false; |
405 } | 405 } |
406 frame.editor().performDelete(); | 406 frame.editor().performDelete(); |
407 frame.editor().setMark(frame.selection().selection()); | 407 frame.editor().setMark(frame.selection().selection()); |
408 return true; | 408 return true; |
409 } | 409 } |
410 | 410 |
411 static bool executeDeleteWordBackward(LocalFrame& frame, Event*, EditorCommandSo
urce, const String&) | 411 static bool executeDeleteWordBackward(LocalFrame& frame, Event*, EditorCommandSo
urce, const String&) |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 } | 1041 } |
1042 | 1042 |
1043 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) | 1043 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) |
1044 { | 1044 { |
1045 // TODO(yosin) We should use |EphemeralRange| version of | 1045 // TODO(yosin) We should use |EphemeralRange| version of |
1046 // |VisibleSelection::toNormalizedRange()|. | 1046 // |VisibleSelection::toNormalizedRange()|. |
1047 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | 1047 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); |
1048 EphemeralRange selection = frame.editor().selectedRange(); | 1048 EphemeralRange selection = frame.editor().selectedRange(); |
1049 if (!mark || selection.isNull()) | 1049 if (!mark || selection.isNull()) |
1050 return false; | 1050 return false; |
1051 frame.selection().setSelectedRange(unionEphemeralRanges(EphemeralRange(mark.
get()), selection), DOWNSTREAM, FrameSelection::NonDirectional, FrameSelection::
CloseTyping); | 1051 frame.selection().setSelectedRange(unionEphemeralRanges(EphemeralRange(mark.
get()), selection), TextAffinity::Downstream, FrameSelection::NonDirectional, Fr
ameSelection::CloseTyping); |
1052 return true; | 1052 return true; |
1053 } | 1053 } |
1054 | 1054 |
1055 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co
nst String&) | 1055 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co
nst String&) |
1056 { | 1056 { |
1057 return expandSelectionToGranularity(frame, WordGranularity); | 1057 return expandSelectionToGranularity(frame, WordGranularity); |
1058 } | 1058 } |
1059 | 1059 |
1060 static bool executeSetMark(LocalFrame& frame, Event*, EditorCommandSource, const
String&) | 1060 static bool executeSetMark(LocalFrame& frame, Event*, EditorCommandSource, const
String&) |
1061 { | 1061 { |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 { | 1791 { |
1792 return m_command && m_command->isTextInsertion; | 1792 return m_command && m_command->isTextInsertion; |
1793 } | 1793 } |
1794 | 1794 |
1795 int Editor::Command::idForHistogram() const | 1795 int Editor::Command::idForHistogram() const |
1796 { | 1796 { |
1797 return isSupported() ? m_command->idForUserMetrics : 0; | 1797 return isSupported() ? m_command->idForUserMetrics : 0; |
1798 } | 1798 } |
1799 | 1799 |
1800 } // namespace blink | 1800 } // namespace blink |
OLD | NEW |