| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma
ndSource, const String&) | 387 static bool executeDeleteToEndOfParagraph(LocalFrame& frame, Event*, EditorComma
ndSource, const String&) |
| 388 { | 388 { |
| 389 // Despite its name, this command should delete the newline at the end of | 389 // Despite its name, this command should delete the newline at the end of |
| 390 // a paragraph if you are at the end of a paragraph. | 390 // a paragraph if you are at the end of a paragraph. |
| 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 const EphemeralRange mark = frame.editor().mark().toNormalizedEphemeralRange
(); |
| 398 // |VisibleSelection::toNormalizedRange()|. | 398 if (mark.isNotNull()) { |
| 399 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | 399 bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(
mark, frame.editor().selectedRange()), TextAffinity::Downstream, FrameSelection:
:NonDirectional, FrameSelection::CloseTyping); |
| 400 if (mark) { | |
| 401 bool selected = frame.selection().setSelectedRange(unionEphemeralRanges(
EphemeralRange(mark.get()), frame.editor().selectedRange()), TextAffinity::Downs
tream, FrameSelection::NonDirectional, FrameSelection::CloseTyping); | |
| 402 ASSERT(selected); | 400 ASSERT(selected); |
| 403 if (!selected) | 401 if (!selected) |
| 404 return false; | 402 return false; |
| 405 } | 403 } |
| 406 frame.editor().performDelete(); | 404 frame.editor().performDelete(); |
| 407 frame.editor().setMark(frame.selection().selection()); | 405 frame.editor().setMark(frame.selection().selection()); |
| 408 return true; | 406 return true; |
| 409 } | 407 } |
| 410 | 408 |
| 411 static bool executeDeleteWordBackward(LocalFrame& frame, Event*, EditorCommandSo
urce, const String&) | 409 static bool executeDeleteWordBackward(LocalFrame& frame, Event*, EditorCommandSo
urce, const String&) |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 return expandSelectionToGranularity(frame, ParagraphGranularity); | 1033 return expandSelectionToGranularity(frame, ParagraphGranularity); |
| 1036 } | 1034 } |
| 1037 | 1035 |
| 1038 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource
, const String&) | 1036 static bool executeSelectSentence(LocalFrame& frame, Event*, EditorCommandSource
, const String&) |
| 1039 { | 1037 { |
| 1040 return expandSelectionToGranularity(frame, SentenceGranularity); | 1038 return expandSelectionToGranularity(frame, SentenceGranularity); |
| 1041 } | 1039 } |
| 1042 | 1040 |
| 1043 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) | 1041 static bool executeSelectToMark(LocalFrame& frame, Event*, EditorCommandSource,
const String&) |
| 1044 { | 1042 { |
| 1045 // TODO(yosin) We should use |EphemeralRange| version of | 1043 const EphemeralRange mark = frame.editor().mark().toNormalizedEphemeralRange
(); |
| 1046 // |VisibleSelection::toNormalizedRange()|. | |
| 1047 RefPtrWillBeRawPtr<Range> mark = frame.editor().mark().toNormalizedRange(); | |
| 1048 EphemeralRange selection = frame.editor().selectedRange(); | 1044 EphemeralRange selection = frame.editor().selectedRange(); |
| 1049 if (!mark || selection.isNull()) | 1045 if (mark.isNull() || selection.isNull()) |
| 1050 return false; | 1046 return false; |
| 1051 frame.selection().setSelectedRange(unionEphemeralRanges(EphemeralRange(mark.
get()), selection), TextAffinity::Downstream, FrameSelection::NonDirectional, Fr
ameSelection::CloseTyping); | 1047 frame.selection().setSelectedRange(unionEphemeralRanges(mark, selection), Te
xtAffinity::Downstream, FrameSelection::NonDirectional, FrameSelection::CloseTyp
ing); |
| 1052 return true; | 1048 return true; |
| 1053 } | 1049 } |
| 1054 | 1050 |
| 1055 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co
nst String&) | 1051 static bool executeSelectWord(LocalFrame& frame, Event*, EditorCommandSource, co
nst String&) |
| 1056 { | 1052 { |
| 1057 return expandSelectionToGranularity(frame, WordGranularity); | 1053 return expandSelectionToGranularity(frame, WordGranularity); |
| 1058 } | 1054 } |
| 1059 | 1055 |
| 1060 static bool executeSetMark(LocalFrame& frame, Event*, EditorCommandSource, const
String&) | 1056 static bool executeSetMark(LocalFrame& frame, Event*, EditorCommandSource, const
String&) |
| 1061 { | 1057 { |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 { | 1787 { |
| 1792 return m_command && m_command->isTextInsertion; | 1788 return m_command && m_command->isTextInsertion; |
| 1793 } | 1789 } |
| 1794 | 1790 |
| 1795 int Editor::Command::idForHistogram() const | 1791 int Editor::Command::idForHistogram() const |
| 1796 { | 1792 { |
| 1797 return isSupported() ? m_command->idForUserMetrics : 0; | 1793 return isSupported() ? m_command->idForUserMetrics : 0; |
| 1798 } | 1794 } |
| 1799 | 1795 |
| 1800 } // namespace blink | 1796 } // namespace blink |
| OLD | NEW |