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