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

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

Issue 2785333002: Revert of Get rid of computeVisibleSelectionInDOMTreeDeprecated() in InputMethodController (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ++deletionEnd; 254 ++deletionEnd;
255 } 255 }
256 if (!forwardMachine.atCodePointBoundary()) 256 if (!forwardMachine.atCodePointBoundary())
257 return invalidDeletionLength; 257 return invalidDeletionLength;
258 258
259 const int offset = forwardMachine.getBoundaryOffset(); 259 const int offset = forwardMachine.getBoundaryOffset();
260 DCHECK_EQ(offset, deletionEnd - selectionEnd); 260 DCHECK_EQ(offset, deletionEnd - selectionEnd);
261 return offset; 261 return offset;
262 } 262 }
263 263
264 Element* rootEditableElementOfSelection(const FrameSelection& selection) {
265 return rootEditableElementOf(selection.selectionInDOMTree().base());
266 }
267
268 } // anonymous namespace 264 } // anonymous namespace
269 265
270 InputMethodController* InputMethodController::create(LocalFrame& frame) { 266 InputMethodController* InputMethodController::create(LocalFrame& frame) {
271 return new InputMethodController(frame); 267 return new InputMethodController(frame);
272 } 268 }
273 269
274 InputMethodController::InputMethodController(LocalFrame& frame) 270 InputMethodController::InputMethodController(LocalFrame& frame)
275 : m_frame(&frame), m_hasComposition(false) {} 271 : m_frame(&frame), m_hasComposition(false) {}
276 272
277 InputMethodController::~InputMethodController() = default; 273 InputMethodController::~InputMethodController() = default;
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1023
1028 WebTextInputInfo InputMethodController::textInputInfo() const { 1024 WebTextInputInfo InputMethodController::textInputInfo() const {
1029 WebTextInputInfo info; 1025 WebTextInputInfo info;
1030 if (!isAvailable()) 1026 if (!isAvailable())
1031 return info; 1027 return info;
1032 1028
1033 if (!frame().selection().isAvailable()) { 1029 if (!frame().selection().isAvailable()) {
1034 // plugins/mouse-capture-inside-shadow.html reaches here. 1030 // plugins/mouse-capture-inside-shadow.html reaches here.
1035 return info; 1031 return info;
1036 } 1032 }
1037 Element* element = rootEditableElementOfSelection(frame().selection()); 1033 Element* element = frame()
1034 .selection()
1035 .computeVisibleSelectionInDOMTreeDeprecated()
1036 .rootEditableElement();
1038 if (!element) 1037 if (!element)
1039 return info; 1038 return info;
1040 1039
1041 info.inputMode = inputModeOfFocusedElement(); 1040 info.inputMode = inputModeOfFocusedElement();
1042 info.type = textInputType(); 1041 info.type = textInputType();
1043 info.flags = textInputFlags(); 1042 info.flags = textInputFlags();
1044 if (info.type == WebTextInputTypeNone) 1043 if (info.type == WebTextInputTypeNone)
1045 return info; 1044 return info;
1046 1045
1047 if (!frame().editor().canEdit()) 1046 if (!frame().editor().canEdit())
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1175
1177 WebTextInputType InputMethodController::textInputType() const { 1176 WebTextInputType InputMethodController::textInputType() const {
1178 if (!frame().selection().isAvailable()) { 1177 if (!frame().selection().isAvailable()) {
1179 // "mouse-capture-inside-shadow.html" reaches here. 1178 // "mouse-capture-inside-shadow.html" reaches here.
1180 return WebTextInputTypeNone; 1179 return WebTextInputTypeNone;
1181 } 1180 }
1182 1181
1183 // It's important to preserve the equivalence of textInputInfo().type and 1182 // It's important to preserve the equivalence of textInputInfo().type and
1184 // textInputType(), so perform the same rootEditableElement() existence check 1183 // textInputType(), so perform the same rootEditableElement() existence check
1185 // here for consistency. 1184 // here for consistency.
1186 if (!rootEditableElementOfSelection(frame().selection())) 1185 if (!frame()
1186 .selection()
1187 .computeVisibleSelectionInDOMTreeDeprecated()
1188 .rootEditableElement())
1187 return WebTextInputTypeNone; 1189 return WebTextInputTypeNone;
1188 1190
1189 if (!isAvailable()) 1191 if (!isAvailable())
1190 return WebTextInputTypeNone; 1192 return WebTextInputTypeNone;
1191 1193
1192 Element* element = document().focusedElement(); 1194 Element* element = document().focusedElement();
1193 if (!element) 1195 if (!element)
1194 return WebTextInputTypeNone; 1196 return WebTextInputTypeNone;
1195 1197
1196 if (isHTMLInputElement(*element)) { 1198 if (isHTMLInputElement(*element)) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 finishComposingText(KeepSelection); 1242 finishComposingText(KeepSelection);
1241 } 1243 }
1242 1244
1243 DEFINE_TRACE(InputMethodController) { 1245 DEFINE_TRACE(InputMethodController) {
1244 visitor->trace(m_frame); 1246 visitor->trace(m_frame);
1245 visitor->trace(m_compositionRange); 1247 visitor->trace(m_compositionRange);
1246 SynchronousMutationObserver::trace(visitor); 1248 SynchronousMutationObserver::trace(visitor);
1247 } 1249 }
1248 1250
1249 } // namespace blink 1251 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698