OLD | NEW |
---|---|
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 Loading... | |
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/htmlediting.h" | 48 #include "core/editing/htmlediting.h" |
48 #include "core/editing/iterators/TextIterator.h" | 49 #include "core/editing/iterators/TextIterator.h" |
49 #include "core/editing/markup.h" | 50 #include "core/editing/markup.h" |
50 #include "core/events/KeyboardEvent.h" | 51 #include "core/events/KeyboardEvent.h" |
51 #include "core/events/UIEventWithKeyState.h" | 52 #include "core/events/UIEventWithKeyState.h" |
52 #include "core/events/WheelEvent.h" | 53 #include "core/events/WheelEvent.h" |
53 #include "core/fetch/UniqueIdentifier.h" | 54 #include "core/fetch/UniqueIdentifier.h" |
54 #include "core/frame/EventHandlerRegistry.h" | 55 #include "core/frame/EventHandlerRegistry.h" |
55 #include "core/frame/FrameHost.h" | 56 #include "core/frame/FrameHost.h" |
56 #include "core/frame/FrameView.h" | 57 #include "core/frame/FrameView.h" |
57 #include "core/frame/LocalFrame.h" | 58 #include "core/frame/LocalFrame.h" |
58 #include "core/frame/PageScaleConstraintsSet.h" | 59 #include "core/frame/PageScaleConstraintsSet.h" |
59 #include "core/frame/RemoteFrame.h" | 60 #include "core/frame/RemoteFrame.h" |
60 #include "core/frame/Settings.h" | 61 #include "core/frame/Settings.h" |
61 #include "core/frame/SmartClip.h" | 62 #include "core/frame/SmartClip.h" |
62 #include "core/frame/TopControls.h" | 63 #include "core/frame/TopControls.h" |
63 #include "core/frame/VisualViewport.h" | 64 #include "core/frame/VisualViewport.h" |
65 #include "core/html/HTMLFormElement.h" | |
64 #include "core/html/HTMLInputElement.h" | 66 #include "core/html/HTMLInputElement.h" |
65 #include "core/html/HTMLMediaElement.h" | 67 #include "core/html/HTMLMediaElement.h" |
66 #include "core/html/HTMLPlugInElement.h" | 68 #include "core/html/HTMLPlugInElement.h" |
67 #include "core/html/HTMLTextAreaElement.h" | 69 #include "core/html/HTMLTextAreaElement.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" |
73 #include "core/loader/DocumentLoader.h" | 75 #include "core/loader/DocumentLoader.h" |
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2512 flags |= WebTextInputFlagAutocapitalizeCharacters; | 2514 flags |= WebTextInputFlagAutocapitalizeCharacters; |
2513 else if (autocapitalize == words) | 2515 else if (autocapitalize == words) |
2514 flags |= WebTextInputFlagAutocapitalizeWords; | 2516 flags |= WebTextInputFlagAutocapitalizeWords; |
2515 else if (autocapitalize == sentences) | 2517 else if (autocapitalize == sentences) |
2516 flags |= WebTextInputFlagAutocapitalizeSentences; | 2518 flags |= WebTextInputFlagAutocapitalizeSentences; |
2517 else | 2519 else |
2518 ASSERT_NOT_REACHED(); | 2520 ASSERT_NOT_REACHED(); |
2519 } | 2521 } |
2520 } | 2522 } |
2521 | 2523 |
2524 if (isListeningToKeyboardEvents(element)) | |
2525 flags |= WebTextInputFlagListeningToKeyboardEvents; | |
2526 | |
2527 if (nextFocusableElementInForm(element, WebFocusTypeForward)) | |
2528 flags |= WebTextInputFlagHaveNextFocusableElement; | |
2529 | |
2530 if (nextFocusableElementInForm(element, WebFocusTypeBackward)) | |
2531 flags |= WebTextInputFlagHavePreviousFocusableElement; | |
2532 | |
2522 return flags; | 2533 return flags; |
2523 } | 2534 } |
2524 | 2535 |
2536 Element* WebViewImpl::nextFocusableElementInForm(Element* element, WebFocusType focusType) | |
2537 { | |
2538 if (!element->isFormControlElement() && !element->isContentEditable()) | |
2539 return nullptr; | |
2540 | |
2541 HTMLFormElement* formOwner = nullptr; | |
2542 if (element->isContentEditable()) | |
2543 formOwner = Traversal<HTMLFormElement>::firstAncestor(*element); | |
2544 else | |
2545 formOwner = toHTMLFormControlElement(element)->formOwner(); | |
2546 | |
2547 if (!formOwner) | |
2548 return nullptr; | |
2549 | |
2550 for (Element* nextElement = element; nextElement; nextElement = page()->focu sController().findFocusableElement(focusType, *nextElement)) { | |
kochi
2015/08/12 11:49:47
Oops - my previous comment was wrong.
For the fir
| |
2551 if (nextElement->isContentEditable() && nextElement->isDescendantOf(form Owner)) | |
2552 return nextElement; | |
2553 if (!nextElement->isFormControlElement()) | |
2554 continue; | |
2555 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextEleme nt); | |
2556 if (formElement->formOwner() != formOwner) | |
2557 continue; | |
2558 // Skip disabled or readonly editable elements. | |
2559 if (formElement->isDisabledOrReadOnly()) | |
2560 continue; | |
2561 LayoutObject* layout = nextElement->layoutObject(); | |
2562 if (layout && layout->isTextControl()) { | |
2563 // TODO(ajith.v) Extend it for Select element, Radio button and Chec k boxes | |
2564 return nextElement; | |
2565 } | |
2566 } | |
2567 return nullptr; | |
2568 } | |
2569 | |
2570 bool WebViewImpl::isListeningToKeyboardEvents(Element* element) | |
2571 { | |
2572 if (!element->isFormControlElement() && !element->isContentEditable()) | |
2573 return false; | |
2574 for (Node* node = element; node; node = node->parentNode()) { | |
2575 if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventLi steners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::key up)) | |
2576 return true; | |
2577 } | |
2578 return false; | |
2579 } | |
2580 | |
2581 void WebViewImpl::advanceFocusInForm(WebFocusType focusType) | |
2582 { | |
2583 Element* element = focusedElement(); | |
2584 if (!element) | |
2585 return; | |
2586 | |
2587 RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element , focusType); | |
2588 if (!nextElement) | |
2589 return; | |
2590 | |
2591 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); | |
2592 nextElement->focus(false, focusType); | |
2593 } | |
2594 | |
2525 WebString WebViewImpl::inputModeOfFocusedElement() | 2595 WebString WebViewImpl::inputModeOfFocusedElement() |
2526 { | 2596 { |
2527 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2597 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
2528 return WebString(); | 2598 return WebString(); |
2529 | 2599 |
2530 Element* element = focusedElement(); | 2600 Element* element = focusedElement(); |
2531 if (!element) | 2601 if (!element) |
2532 return WebString(); | 2602 return WebString(); |
2533 | 2603 |
2534 if (isHTMLInputElement(*element)) { | 2604 if (isHTMLInputElement(*element)) { |
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4420 if (m_pageColorOverlay) | 4490 if (m_pageColorOverlay) |
4421 m_pageColorOverlay->update(); | 4491 m_pageColorOverlay->update(); |
4422 if (m_inspectorOverlay) { | 4492 if (m_inspectorOverlay) { |
4423 PageOverlay* inspectorPageOverlay = m_inspectorOverlay->pageOverlay(); | 4493 PageOverlay* inspectorPageOverlay = m_inspectorOverlay->pageOverlay(); |
4424 if (inspectorPageOverlay) | 4494 if (inspectorPageOverlay) |
4425 inspectorPageOverlay->update(); | 4495 inspectorPageOverlay->update(); |
4426 } | 4496 } |
4427 } | 4497 } |
4428 | 4498 |
4429 } // namespace blink | 4499 } // namespace blink |
OLD | NEW |