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

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

Issue 2693863003: [InputEvent] Change |getTargetRanges()| to return current selection by default (Closed)
Patch Set: yosin's review: Use const Node&, add null checks Created 3 years, 10 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 | « third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp ('k') | 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) 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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (markerRange.isNull()) 839 if (markerRange.isNull())
840 return; 840 return;
841 841
842 frame().selection().setSelection( 842 frame().selection().setSelection(
843 SelectionInDOMTree::Builder().setBaseAndExtent(markerRange).build()); 843 SelectionInDOMTree::Builder().setBaseAndExtent(markerRange).build());
844 844
845 Document& currentDocument = *frame().document(); 845 Document& currentDocument = *frame().document();
846 846
847 // Dispatch 'beforeinput'. 847 // Dispatch 'beforeinput'.
848 Element* const target = frame().editor().findEventTargetFromSelection(); 848 Element* const target = frame().editor().findEventTargetFromSelection();
849 Range* const range = createRange(markerRange);
850 RangeVector* const ranges = new RangeVector(1, range);
851 DataTransfer* const dataTransfer = DataTransfer::create( 849 DataTransfer* const dataTransfer = DataTransfer::create(
852 DataTransfer::DataTransferType::InsertReplacementText, 850 DataTransfer::DataTransferType::InsertReplacementText,
853 DataTransferAccessPolicy::DataTransferReadable, 851 DataTransferAccessPolicy::DataTransferReadable,
854 DataObject::createFromString(text)); 852 DataObject::createFromString(text));
855 853
856 const bool cancel = 854 const bool cancel = dispatchBeforeInputDataTransfer(
857 dispatchBeforeInputDataTransfer( 855 target, InputEvent::InputType::InsertReplacementText,
858 target, InputEvent::InputType::InsertReplacementText, dataTransfer, 856 dataTransfer) != DispatchEventResult::NotCanceled;
859 ranges) != DispatchEventResult::NotCanceled;
860 857
861 // 'beforeinput' event handler may destroy target frame. 858 // 'beforeinput' event handler may destroy target frame.
862 if (currentDocument != frame().document()) 859 if (currentDocument != frame().document())
863 return; 860 return;
864 861
865 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 862 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
866 // needs to be audited. See http://crbug.com/590369 for more details. 863 // needs to be audited. See http://crbug.com/590369 for more details.
867 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); 864 frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
868 865
869 if (cancel) 866 if (cancel)
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 startOfNextParagraph(createVisiblePosition(paragraphEnd)); 1177 startOfNextParagraph(createVisiblePosition(paragraphEnd));
1181 paragraphStart = newParagraphStart.toParentAnchoredPosition(); 1178 paragraphStart = newParagraphStart.toParentAnchoredPosition();
1182 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); 1179 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition();
1183 firstIteration = false; 1180 firstIteration = false;
1184 totalLengthProcessed += currentLength; 1181 totalLengthProcessed += currentLength;
1185 } 1182 }
1186 return std::make_pair(firstFoundItem, firstFoundOffset); 1183 return std::make_pair(firstFoundItem, firstFoundOffset);
1187 } 1184 }
1188 1185
1189 } // namespace blink 1186 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698