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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ++deletion_end; | 256 ++deletion_end; |
257 } | 257 } |
258 if (!forward_machine.AtCodePointBoundary()) | 258 if (!forward_machine.AtCodePointBoundary()) |
259 return kInvalidDeletionLength; | 259 return kInvalidDeletionLength; |
260 | 260 |
261 const int offset = forward_machine.GetBoundaryOffset(); | 261 const int offset = forward_machine.GetBoundaryOffset(); |
262 DCHECK_EQ(offset, deletion_end - selection_end); | 262 DCHECK_EQ(offset, deletion_end - selection_end); |
263 return offset; | 263 return offset; |
264 } | 264 } |
265 | 265 |
266 Element* RootEditableElementOfSelection(const FrameSelection& selection) { | |
267 return RootEditableElementOf(selection.GetSelectionInDOMTree().Base()); | |
268 } | |
269 | |
270 } // anonymous namespace | 266 } // anonymous namespace |
271 | 267 |
272 InputMethodController* InputMethodController::Create(LocalFrame& frame) { | 268 InputMethodController* InputMethodController::Create(LocalFrame& frame) { |
273 return new InputMethodController(frame); | 269 return new InputMethodController(frame); |
274 } | 270 } |
275 | 271 |
276 InputMethodController::InputMethodController(LocalFrame& frame) | 272 InputMethodController::InputMethodController(LocalFrame& frame) |
277 : frame_(&frame), has_composition_(false) {} | 273 : frame_(&frame), has_composition_(false) {} |
278 | 274 |
279 InputMethodController::~InputMethodController() = default; | 275 InputMethodController::~InputMethodController() = default; |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1012 |
1017 WebTextInputInfo InputMethodController::TextInputInfo() const { | 1013 WebTextInputInfo InputMethodController::TextInputInfo() const { |
1018 WebTextInputInfo info; | 1014 WebTextInputInfo info; |
1019 if (!IsAvailable()) | 1015 if (!IsAvailable()) |
1020 return info; | 1016 return info; |
1021 | 1017 |
1022 if (!GetFrame().Selection().IsAvailable()) { | 1018 if (!GetFrame().Selection().IsAvailable()) { |
1023 // plugins/mouse-capture-inside-shadow.html reaches here. | 1019 // plugins/mouse-capture-inside-shadow.html reaches here. |
1024 return info; | 1020 return info; |
1025 } | 1021 } |
1026 Element* element = RootEditableElementOfSelection(GetFrame().Selection()); | 1022 Element* element = GetFrame() |
| 1023 .Selection() |
| 1024 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 1025 .RootEditableElement(); |
1027 if (!element) | 1026 if (!element) |
1028 return info; | 1027 return info; |
1029 | 1028 |
1030 info.input_mode = InputModeOfFocusedElement(); | 1029 info.input_mode = InputModeOfFocusedElement(); |
1031 info.type = TextInputType(); | 1030 info.type = TextInputType(); |
1032 info.flags = TextInputFlags(); | 1031 info.flags = TextInputFlags(); |
1033 if (info.type == kWebTextInputTypeNone) | 1032 if (info.type == kWebTextInputTypeNone) |
1034 return info; | 1033 return info; |
1035 | 1034 |
1036 if (!GetFrame().GetEditor().CanEdit()) | 1035 if (!GetFrame().GetEditor().CanEdit()) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 | 1165 |
1167 WebTextInputType InputMethodController::TextInputType() const { | 1166 WebTextInputType InputMethodController::TextInputType() const { |
1168 if (!GetFrame().Selection().IsAvailable()) { | 1167 if (!GetFrame().Selection().IsAvailable()) { |
1169 // "mouse-capture-inside-shadow.html" reaches here. | 1168 // "mouse-capture-inside-shadow.html" reaches here. |
1170 return kWebTextInputTypeNone; | 1169 return kWebTextInputTypeNone; |
1171 } | 1170 } |
1172 | 1171 |
1173 // It's important to preserve the equivalence of textInputInfo().type and | 1172 // It's important to preserve the equivalence of textInputInfo().type and |
1174 // textInputType(), so perform the same rootEditableElement() existence check | 1173 // textInputType(), so perform the same rootEditableElement() existence check |
1175 // here for consistency. | 1174 // here for consistency. |
1176 if (!RootEditableElementOfSelection(GetFrame().Selection())) | 1175 if (!GetFrame() |
| 1176 .Selection() |
| 1177 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 1178 .RootEditableElement()) |
1177 return kWebTextInputTypeNone; | 1179 return kWebTextInputTypeNone; |
1178 | 1180 |
1179 if (!IsAvailable()) | 1181 if (!IsAvailable()) |
1180 return kWebTextInputTypeNone; | 1182 return kWebTextInputTypeNone; |
1181 | 1183 |
1182 Element* element = GetDocument().FocusedElement(); | 1184 Element* element = GetDocument().FocusedElement(); |
1183 if (!element) | 1185 if (!element) |
1184 return kWebTextInputTypeNone; | 1186 return kWebTextInputTypeNone; |
1185 | 1187 |
1186 if (isHTMLInputElement(*element)) { | 1188 if (isHTMLInputElement(*element)) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 FinishComposingText(kKeepSelection); | 1232 FinishComposingText(kKeepSelection); |
1231 } | 1233 } |
1232 | 1234 |
1233 DEFINE_TRACE(InputMethodController) { | 1235 DEFINE_TRACE(InputMethodController) { |
1234 visitor->Trace(frame_); | 1236 visitor->Trace(frame_); |
1235 visitor->Trace(composition_range_); | 1237 visitor->Trace(composition_range_); |
1236 SynchronousMutationObserver::Trace(visitor); | 1238 SynchronousMutationObserver::Trace(visitor); |
1237 } | 1239 } |
1238 | 1240 |
1239 } // namespace blink | 1241 } // namespace blink |
OLD | NEW |