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

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

Issue 1412713003: Reland 'Use FrameSelection::selectedText where possible.' Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reimplement setSelectionInTextFormControl: use setSelection. Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 850
851 if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCanc elableBubble(EventTypeNames::selectstart))) 851 if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCanc elableBubble(EventTypeNames::selectstart)))
852 return; 852 return;
853 853
854 VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode( root.get())); 854 VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode( root.get()));
855 setSelection(newSelection); 855 setSelection(newSelection);
856 selectFrameElementInParentIfFullySelected(); 856 selectFrameElementInParentIfFullySelected();
857 notifyLayoutObjectOfSelectionChange(UserTriggered); 857 notifyLayoutObjectOfSelectionChange(UserTriggered);
858 } 858 }
859 859
860 void FrameSelection::setSelectionInTextFormControl(const VisibleSelection& selec tion, SetSelectionOptions options)
861 {
862 setSelection(selection, options);
yosin_UTC9 2015/10/29 06:44:47 FrameSelection::setSelection() calls SelectionEdit
863 m_selectionEditor->setSelectionInTextFormControl(selection.base(), selection .extent());
864 }
865
860 bool FrameSelection::setSelectedRange(Range* range, TextAffinity affinity, Selec tionDirectionalMode directional, SetSelectionOptions options) 866 bool FrameSelection::setSelectedRange(Range* range, TextAffinity affinity, Selec tionDirectionalMode directional, SetSelectionOptions options)
861 { 867 {
862 if (!range || !range->startContainer() || !range->endContainer()) 868 if (!range || !range->startContainer() || !range->endContainer())
863 return false; 869 return false;
864 ASSERT(range->startContainer()->document() == range->endContainer()->documen t()); 870 ASSERT(range->startContainer()->document() == range->endContainer()->documen t());
865 return setSelectedRange(EphemeralRange(range), affinity, directional, option s); 871 return setSelectedRange(EphemeralRange(range), affinity, directional, option s);
866 } 872 }
867 873
868 bool FrameSelection::setSelectedRange(const EphemeralRange& range, TextAffinity affinity, SelectionDirectionalMode directional, SetSelectionOptions options) 874 bool FrameSelection::setSelectedRange(const EphemeralRange& range, TextAffinity affinity, SelectionDirectionalMode directional, SetSelectionOptions options)
869 { 875 {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 1142 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
1137 } 1143 }
1138 1144
1139 String FrameSelection::selectedHTMLForClipboard() const 1145 String FrameSelection::selectedHTMLForClipboard() const
1140 { 1146 {
1141 if (!RuntimeEnabledFeatures::selectionForComposedTreeEnabled()) 1147 if (!RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
1142 return extractSelectedHTMLAlgorithm<EditingStrategy>(*this); 1148 return extractSelectedHTMLAlgorithm<EditingStrategy>(*this);
1143 return extractSelectedHTMLAlgorithm<EditingInComposedTreeStrategy>(*this); 1149 return extractSelectedHTMLAlgorithm<EditingInComposedTreeStrategy>(*this);
1144 } 1150 }
1145 1151
1146 String FrameSelection::selectedText() const 1152 String FrameSelection::selectedText(TextIteratorBehavior behavior) const
1147 { 1153 {
1148 return extractSelectedText(*this, TextIteratorDefaultBehavior); 1154 return extractSelectedText(*this, behavior);
1149 } 1155 }
1150 1156
1151 String FrameSelection::selectedTextForClipboard() const 1157 String FrameSelection::selectedTextForClipboard() const
1152 { 1158 {
1153 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t()) 1159 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t())
1154 return extractSelectedText(*this, TextIteratorEmitsImageAltText); 1160 return extractSelectedText(*this, TextIteratorEmitsImageAltText);
1155 return selectedText(); 1161 return selectedText();
1156 } 1162 }
1157 1163
1158 LayoutRect FrameSelection::bounds() const 1164 LayoutRect FrameSelection::bounds() const
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1415
1410 void showTree(const blink::FrameSelection* sel) 1416 void showTree(const blink::FrameSelection* sel)
1411 { 1417 {
1412 if (sel) 1418 if (sel)
1413 sel->showTreeForThis(); 1419 sel->showTreeForThis();
1414 else 1420 else
1415 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1421 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1416 } 1422 }
1417 1423
1418 #endif 1424 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/editing/SelectionEditor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698