OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 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 * | 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 } | 937 } |
938 | 938 |
939 bool Editor::insertLineBreak() | 939 bool Editor::insertLineBreak() |
940 { | 940 { |
941 if (!canEdit()) | 941 if (!canEdit()) |
942 return false; | 942 return false; |
943 | 943 |
944 if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(),
EditorInsertActionTyped)) | 944 if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(),
EditorInsertActionTyped)) |
945 return true; | 945 return true; |
946 | 946 |
| 947 VisiblePosition caret = m_frame->selection()->selection().visibleStart(); |
| 948 bool alignToEdge = isEndOfDocument(caret); |
947 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrect
ionBeforeTypingIfAppropriate(); | 949 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrect
ionBeforeTypingIfAppropriate(); |
948 TypingCommand::insertLineBreak(m_frame->document(), autocorrectionIsApplied
? TypingCommand::RetainAutocorrectionIndicator : 0); | 950 TypingCommand::insertLineBreak(m_frame->document(), autocorrectionIsApplied
? TypingCommand::RetainAutocorrectionIndicator : 0); |
949 revealSelectionAfterEditingOperation(); | 951 revealSelectionAfterEditingOperation(alignToEdge ? ScrollAlignment::alignToE
dgeIfNeeded : ScrollAlignment::alignCenterIfNeeded); |
950 | 952 |
951 return true; | 953 return true; |
952 } | 954 } |
953 | 955 |
954 bool Editor::insertParagraphSeparator() | 956 bool Editor::insertParagraphSeparator() |
955 { | 957 { |
956 if (!canEdit()) | 958 if (!canEdit()) |
957 return false; | 959 return false; |
958 | 960 |
959 if (!canEditRichly()) | 961 if (!canEditRichly()) |
960 return insertLineBreak(); | 962 return insertLineBreak(); |
961 | 963 |
962 if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(),
EditorInsertActionTyped)) | 964 if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(),
EditorInsertActionTyped)) |
963 return true; | 965 return true; |
964 | 966 |
| 967 VisiblePosition caret = m_frame->selection()->selection().visibleStart(); |
| 968 bool alignToEdge = isEndOfDocument(caret); |
965 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrect
ionBeforeTypingIfAppropriate(); | 969 bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrect
ionBeforeTypingIfAppropriate(); |
966 TypingCommand::insertParagraphSeparator(m_frame->document(), autocorrectionI
sApplied ? TypingCommand::RetainAutocorrectionIndicator : 0); | 970 TypingCommand::insertParagraphSeparator(m_frame->document(), autocorrectionI
sApplied ? TypingCommand::RetainAutocorrectionIndicator : 0); |
967 revealSelectionAfterEditingOperation(); | 971 revealSelectionAfterEditingOperation(alignToEdge ? ScrollAlignment::alignToE
dgeIfNeeded : ScrollAlignment::alignCenterIfNeeded); |
968 | 972 |
969 return true; | 973 return true; |
970 } | 974 } |
971 | 975 |
972 void Editor::cut() | 976 void Editor::cut() |
973 { | 977 { |
974 if (tryDHTMLCut()) | 978 if (tryDHTMLCut()) |
975 return; // DHTML did the whole operation | 979 return; // DHTML did the whole operation |
976 if (!canCut()) { | 980 if (!canCut()) { |
977 systemBeep(); | 981 systemBeep(); |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2275 Frame* frame = document->frame(); | 2279 Frame* frame = document->frame(); |
2276 ASSERT(frame); | 2280 ASSERT(frame); |
2277 FrameView* frameView = frame->view(); | 2281 FrameView* frameView = frame->view(); |
2278 if (!frameView) | 2282 if (!frameView) |
2279 return 0; | 2283 return 0; |
2280 IntPoint framePoint = frameView->windowToContents(windowPoint); | 2284 IntPoint framePoint = frameView->windowToContents(windowPoint); |
2281 VisibleSelection selection(frame->visiblePositionForPoint(framePoint)); | 2285 VisibleSelection selection(frame->visiblePositionForPoint(framePoint)); |
2282 return avoidIntersectionWithNode(selection.toNormalizedRange().get(), m_dele
teButtonController->containerElement()); | 2286 return avoidIntersectionWithNode(selection.toNormalizedRange().get(), m_dele
teButtonController->containerElement()); |
2283 } | 2287 } |
2284 | 2288 |
2285 void Editor::revealSelectionAfterEditingOperation() | 2289 void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignme
nt) |
2286 { | 2290 { |
2287 if (m_ignoreCompositionSelectionChange) | 2291 if (m_ignoreCompositionSelectionChange) |
2288 return; | 2292 return; |
2289 | 2293 |
2290 m_frame->selection()->revealSelection(ScrollAlignment::alignCenterIfNeeded); | 2294 m_frame->selection()->revealSelection(alignment); |
2291 } | 2295 } |
2292 | 2296 |
2293 void Editor::setIgnoreCompositionSelectionChange(bool ignore) | 2297 void Editor::setIgnoreCompositionSelectionChange(bool ignore) |
2294 { | 2298 { |
2295 if (m_ignoreCompositionSelectionChange == ignore) | 2299 if (m_ignoreCompositionSelectionChange == ignore) |
2296 return; | 2300 return; |
2297 | 2301 |
2298 m_ignoreCompositionSelectionChange = ignore; | 2302 m_ignoreCompositionSelectionChange = ignore; |
2299 if (!ignore) | 2303 if (!ignore) |
2300 revealSelectionAfterEditingOperation(); | 2304 revealSelectionAfterEditingOperation(); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 { | 3057 { |
3054 m_deleteButtonController->deviceScaleFactorChanged(); | 3058 m_deleteButtonController->deviceScaleFactorChanged(); |
3055 } | 3059 } |
3056 | 3060 |
3057 bool Editor::unifiedTextCheckerEnabled() const | 3061 bool Editor::unifiedTextCheckerEnabled() const |
3058 { | 3062 { |
3059 return WebCore::unifiedTextCheckerEnabled(m_frame); | 3063 return WebCore::unifiedTextCheckerEnabled(m_frame); |
3060 } | 3064 } |
3061 | 3065 |
3062 } // namespace WebCore | 3066 } // namespace WebCore |
OLD | NEW |