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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 939603002: Adding support for Smart GO NEXT feature in Android Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Made all test case as deterministic with EXPECT_EQ Created 5 years, 4 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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "web/WebViewImpl.h" 32 #include "web/WebViewImpl.h"
33 33
34 #include "core/CSSValueKeywords.h" 34 #include "core/CSSValueKeywords.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/InputTypeNames.h" 36 #include "core/InputTypeNames.h"
37 #include "core/clipboard/DataObject.h" 37 #include "core/clipboard/DataObject.h"
38 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
39 #include "core/dom/DocumentMarkerController.h" 39 #include "core/dom/DocumentMarkerController.h"
40 #include "core/dom/ElementTraversal.h"
40 #include "core/dom/Fullscreen.h" 41 #include "core/dom/Fullscreen.h"
41 #include "core/dom/LayoutTreeBuilderTraversal.h" 42 #include "core/dom/LayoutTreeBuilderTraversal.h"
42 #include "core/dom/Text.h" 43 #include "core/dom/Text.h"
43 #include "core/editing/Editor.h" 44 #include "core/editing/Editor.h"
44 #include "core/editing/FrameSelection.h" 45 #include "core/editing/FrameSelection.h"
45 #include "core/editing/HTMLInterchange.h" 46 #include "core/editing/HTMLInterchange.h"
46 #include "core/editing/InputMethodController.h" 47 #include "core/editing/InputMethodController.h"
47 #include "core/editing/iterators/TextIterator.h" 48 #include "core/editing/iterators/TextIterator.h"
48 #include "core/editing/markup.h" 49 #include "core/editing/markup.h"
49 #include "core/events/KeyboardEvent.h" 50 #include "core/events/KeyboardEvent.h"
50 #include "core/events/UIEventWithKeyState.h" 51 #include "core/events/UIEventWithKeyState.h"
51 #include "core/events/WheelEvent.h" 52 #include "core/events/WheelEvent.h"
52 #include "core/fetch/UniqueIdentifier.h" 53 #include "core/fetch/UniqueIdentifier.h"
53 #include "core/frame/EventHandlerRegistry.h" 54 #include "core/frame/EventHandlerRegistry.h"
54 #include "core/frame/FrameHost.h" 55 #include "core/frame/FrameHost.h"
55 #include "core/frame/FrameView.h" 56 #include "core/frame/FrameView.h"
56 #include "core/frame/LocalFrame.h" 57 #include "core/frame/LocalFrame.h"
57 #include "core/frame/PageScaleConstraintsSet.h" 58 #include "core/frame/PageScaleConstraintsSet.h"
58 #include "core/frame/RemoteFrame.h" 59 #include "core/frame/RemoteFrame.h"
59 #include "core/frame/Settings.h" 60 #include "core/frame/Settings.h"
60 #include "core/frame/SmartClip.h" 61 #include "core/frame/SmartClip.h"
61 #include "core/frame/TopControls.h" 62 #include "core/frame/TopControls.h"
62 #include "core/frame/VisualViewport.h" 63 #include "core/frame/VisualViewport.h"
64 #include "core/html/HTMLFormElement.h"
63 #include "core/html/HTMLInputElement.h" 65 #include "core/html/HTMLInputElement.h"
64 #include "core/html/HTMLMediaElement.h" 66 #include "core/html/HTMLMediaElement.h"
65 #include "core/html/HTMLPlugInElement.h" 67 #include "core/html/HTMLPlugInElement.h"
66 #include "core/html/HTMLTextAreaElement.h" 68 #include "core/html/HTMLTextAreaElement.h"
67 #include "core/html/forms/PopupMenuClient.h" 69 #include "core/html/forms/PopupMenuClient.h"
68 #include "core/input/EventHandler.h" 70 #include "core/input/EventHandler.h"
69 #include "core/layout/LayoutPart.h" 71 #include "core/layout/LayoutPart.h"
70 #include "core/layout/LayoutView.h" 72 #include "core/layout/LayoutView.h"
71 #include "core/layout/TextAutosizer.h" 73 #include "core/layout/TextAutosizer.h"
72 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 74 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 flags |= WebTextInputFlagAutocapitalizeCharacters; 2507 flags |= WebTextInputFlagAutocapitalizeCharacters;
2506 else if (autocapitalize == words) 2508 else if (autocapitalize == words)
2507 flags |= WebTextInputFlagAutocapitalizeWords; 2509 flags |= WebTextInputFlagAutocapitalizeWords;
2508 else if (autocapitalize == sentences) 2510 else if (autocapitalize == sentences)
2509 flags |= WebTextInputFlagAutocapitalizeSentences; 2511 flags |= WebTextInputFlagAutocapitalizeSentences;
2510 else 2512 else
2511 ASSERT_NOT_REACHED(); 2513 ASSERT_NOT_REACHED();
2512 } 2514 }
2513 } 2515 }
2514 2516
2517 if (isListeningToKeyboardEvents(element))
2518 flags |= WebTextInputFlagListeningToKeyboardEvents;
2519
2520 if (nextFocusableElementInForm(element, WebFocusTypeForward))
2521 flags |= WebTextInputFlagHaveNextFocusableElement;
2522
2523 if (nextFocusableElementInForm(element, WebFocusTypeBackward))
2524 flags |= WebTextInputFlagHavePreviousFocusableElement;
2525
2515 return flags; 2526 return flags;
2516 } 2527 }
2517 2528
2529 Element* WebViewImpl::nextFocusableElementInForm(Element* element, WebFocusType focusType)
2530 {
2531 if (!element->isFormControlElement() && !element->isContentEditable())
2532 return nullptr;
2533
2534 HTMLFormElement* formOwner = nullptr;
2535 if (element->isContentEditable())
2536 formOwner = Traversal<HTMLFormElement>::firstAncestor(*element);
2537 else
2538 formOwner = toHTMLFormControlElement(element)->formOwner();
2539
2540 if (!formOwner)
2541 return nullptr;
2542
2543 Element* nextElement = element;
2544 while ((nextElement = page()->focusController().findFocusableElement(focusTy pe, *nextElement))) {
2545 if (nextElement->isContentEditable() && nextElement->isDescendantOf(form Owner))
2546 return nextElement;
2547 if (!nextElement->isFormControlElement())
2548 continue;
2549 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextEleme nt);
2550 if (formElement->formOwner() != formOwner)
2551 continue;
2552 // Skip disabled or readonly editable elements.
2553 if (formElement->isDisabledOrReadOnly())
2554 continue;
2555 LayoutObject* layout = nextElement->layoutObject();
2556 if (layout && layout->isTextControl()) {
2557 // TODO(ajith.v) Extend it for Select element, Radio button and Chec k boxes
2558 return nextElement;
2559 }
2560 }
2561 return nullptr;
2562 }
2563
2564 bool WebViewImpl::isListeningToKeyboardEvents(Element* element)
2565 {
2566 if (!element->isFormControlElement() && !element->isContentEditable())
2567 return false;
2568 Node* node = element;
2569 do {
2570 if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventLi steners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::key up))
2571 return true;
2572 } while ((node = node->parentNode()));
2573 return false;
2574 }
2575
2576 void WebViewImpl::advanceFocusInForm(WebFocusType focusType)
2577 {
2578 Element* element = focusedElement();
2579 if (!element)
2580 return;
2581
2582 RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element , focusType);
2583 if (!nextElement)
2584 return;
2585
2586 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/);
2587 nextElement->focus(false, focusType);
2588 }
2589
2518 WebString WebViewImpl::inputModeOfFocusedElement() 2590 WebString WebViewImpl::inputModeOfFocusedElement()
2519 { 2591 {
2520 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) 2592 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled())
2521 return WebString(); 2593 return WebString();
2522 2594
2523 Element* element = focusedElement(); 2595 Element* element = focusedElement();
2524 if (!element) 2596 if (!element)
2525 return WebString(); 2597 return WebString();
2526 2598
2527 if (isHTMLInputElement(*element)) { 2599 if (isHTMLInputElement(*element)) {
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
4431 { 4503 {
4432 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4504 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4433 } 4505 }
4434 4506
4435 void WebViewImpl::forceNextDrawingBufferCreationToFail() 4507 void WebViewImpl::forceNextDrawingBufferCreationToFail()
4436 { 4508 {
4437 DrawingBuffer::forceNextDrawingBufferCreationToFail(); 4509 DrawingBuffer::forceNextDrawingBufferCreationToFail();
4438 } 4510 }
4439 4511
4440 } // namespace blink 4512 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698