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

Side by Side Diff: third_party/WebKit/Source/core/input/KeyboardEventManager.cpp

Issue 2947523002: Delete backspace-for-back RuntimeFeature. (Closed)
Patch Set: Fix layout test Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "KeyboardEventManager.h" 5 #include "KeyboardEventManager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/UserGestureIndicator.h" 10 #include "core/dom/UserGestureIndicator.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 frame_->GetEditor().HandleKeyboardEvent(event); 293 frame_->GetEditor().HandleKeyboardEvent(event);
294 if (event->DefaultHandled()) 294 if (event->DefaultHandled())
295 return; 295 return;
296 296
297 // Do not perform the default action when inside a IME composition context. 297 // Do not perform the default action when inside a IME composition context.
298 // TODO(dtapuska): Replace this with isComposing support. crbug.com/625686 298 // TODO(dtapuska): Replace this with isComposing support. crbug.com/625686
299 if (event->keyCode() == kVKeyProcessKey) 299 if (event->keyCode() == kVKeyProcessKey)
300 return; 300 return;
301 if (event->key() == "Tab") { 301 if (event->key() == "Tab") {
302 DefaultTabEventHandler(event); 302 DefaultTabEventHandler(event);
303 } else if (event->key() == "Backspace") {
304 DefaultBackspaceEventHandler(event);
305 } else if (event->key() == "Escape") { 303 } else if (event->key() == "Escape") {
306 DefaultEscapeEventHandler(event); 304 DefaultEscapeEventHandler(event);
307 } else { 305 } else {
308 DefaultArrowEventHandler(event, possible_focused_node); 306 DefaultArrowEventHandler(event, possible_focused_node);
309 } 307 }
310 } 308 }
311 if (event->type() == EventTypeNames::keypress) { 309 if (event->type() == EventTypeNames::keypress) {
312 frame_->GetEditor().HandleKeyboardEvent(event); 310 frame_->GetEditor().HandleKeyboardEvent(event);
313 if (event->DefaultHandled()) 311 if (event->DefaultHandled())
314 return; 312 return;
(...skipping 16 matching lines...) Expand all
331 // FIXME: enable scroll customization in this case. See crbug.com/410974. 329 // FIXME: enable scroll customization in this case. See crbug.com/410974.
332 if (scroll_manager_->LogicalScroll(direction, kScrollByPage, nullptr, 330 if (scroll_manager_->LogicalScroll(direction, kScrollByPage, nullptr,
333 possible_focused_node)) { 331 possible_focused_node)) {
334 UseCounter::Count(frame_->GetDocument(), 332 UseCounter::Count(frame_->GetDocument(),
335 WebFeature::kScrollByKeyboardSpacebarKey); 333 WebFeature::kScrollByKeyboardSpacebarKey);
336 event->SetDefaultHandled(); 334 event->SetDefaultHandled();
337 return; 335 return;
338 } 336 }
339 } 337 }
340 338
341 void KeyboardEventManager::DefaultBackspaceEventHandler(KeyboardEvent* event) {
342 DCHECK_EQ(event->type(), EventTypeNames::keydown);
343
344 if (!RuntimeEnabledFeatures::BackspaceDefaultHandlerEnabled())
345 return;
346
347 if (event->ctrlKey() || event->metaKey() || event->altKey())
348 return;
349
350 if (!frame_->GetEditor().Behavior().ShouldNavigateBackOnBackspace())
351 return;
352 UseCounter::Count(frame_->GetDocument(), WebFeature::kBackspaceNavigatedBack);
353 if (frame_->GetPage()->GetChromeClient().HadFormInteraction()) {
354 UseCounter::Count(frame_->GetDocument(),
355 WebFeature::kBackspaceNavigatedBackAfterFormInteraction);
356 }
357 bool handled_event = frame_->Loader().Client()->NavigateBackForward(
358 event->shiftKey() ? 1 : -1);
359 if (handled_event)
360 event->SetDefaultHandled();
361 }
362
363 void KeyboardEventManager::DefaultArrowEventHandler( 339 void KeyboardEventManager::DefaultArrowEventHandler(
364 KeyboardEvent* event, 340 KeyboardEvent* event,
365 Node* possible_focused_node) { 341 Node* possible_focused_node) {
366 DCHECK_EQ(event->type(), EventTypeNames::keydown); 342 DCHECK_EQ(event->type(), EventTypeNames::keydown);
367 343
368 Page* page = frame_->GetPage(); 344 Page* page = frame_->GetPage();
369 if (!page) 345 if (!page)
370 return; 346 return;
371 347
372 WebFocusType type = FocusDirectionForKey(event); 348 WebFocusType type = FocusDirectionForKey(event);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (current_modifiers & ::cmdKey) 462 if (current_modifiers & ::cmdKey)
487 modifiers |= WebInputEvent::kMetaKey; 463 modifiers |= WebInputEvent::kMetaKey;
488 #else 464 #else
489 // TODO(crbug.com/538289): Implement on other platforms. 465 // TODO(crbug.com/538289): Implement on other platforms.
490 return static_cast<WebInputEvent::Modifiers>(0); 466 return static_cast<WebInputEvent::Modifiers>(0);
491 #endif 467 #endif
492 return static_cast<WebInputEvent::Modifiers>(modifiers); 468 return static_cast<WebInputEvent::Modifiers>(modifiers);
493 } 469 }
494 470
495 } // namespace blink 471 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698