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/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/PinchViewport.h" | 59 #include "core/frame/PinchViewport.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" |
| 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 2410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 flags |= WebTextInputFlagAutocapitalizeCharacters; | 2485 flags |= WebTextInputFlagAutocapitalizeCharacters; |
2484 else if (autocapitalize == words) | 2486 else if (autocapitalize == words) |
2485 flags |= WebTextInputFlagAutocapitalizeWords; | 2487 flags |= WebTextInputFlagAutocapitalizeWords; |
2486 else if (autocapitalize == sentences) | 2488 else if (autocapitalize == sentences) |
2487 flags |= WebTextInputFlagAutocapitalizeSentences; | 2489 flags |= WebTextInputFlagAutocapitalizeSentences; |
2488 else | 2490 else |
2489 ASSERT_NOT_REACHED(); | 2491 ASSERT_NOT_REACHED(); |
2490 } | 2492 } |
2491 } | 2493 } |
2492 | 2494 |
| 2495 if (isListeningToKeyboardEvents(element)) |
| 2496 flags |= WebTextInputFlagListeningToKeyboardEvents; |
| 2497 |
| 2498 if (nextFocusableElementInForm(element, WebFocusTypeForward)) |
| 2499 flags |= WebTextInputFlagHaveNextFocusableElement; |
| 2500 |
| 2501 if (nextFocusableElementInForm(element, WebFocusTypeBackward)) |
| 2502 flags |= WebTextInputFlagHavePreviousFocusableElement; |
| 2503 |
2493 return flags; | 2504 return flags; |
2494 } | 2505 } |
2495 | 2506 |
| 2507 Element* WebViewImpl::nextFocusableElementInForm(Element* element, WebFocusType
focusType) |
| 2508 { |
| 2509 if (!element->isFormControlElement() && !element->isContentEditable()) |
| 2510 return nullptr; |
| 2511 |
| 2512 HTMLFormElement* formOwner = nullptr; |
| 2513 if (element->isContentEditable()) |
| 2514 formOwner = Traversal<HTMLFormElement>::firstAncestor(*element); |
| 2515 else |
| 2516 formOwner = toHTMLFormControlElement(element)->formOwner(); |
| 2517 |
| 2518 if (!formOwner) |
| 2519 return nullptr; |
| 2520 |
| 2521 Element* nextElement = element; |
| 2522 while ((nextElement = page()->focusController().findFocusableElement(focusTy
pe, *nextElement))) { |
| 2523 if (nextElement->isContentEditable() && nextElement->isDescendantOf(form
Owner)) |
| 2524 return nextElement; |
| 2525 if (!nextElement->isFormControlElement()) |
| 2526 continue; |
| 2527 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextEleme
nt); |
| 2528 if (formElement->formOwner() != formOwner) |
| 2529 continue; |
| 2530 LayoutObject* layout = nextElement->layoutObject(); |
| 2531 if (layout && layout->isTextControl()) { |
| 2532 // TODO(ajith.v) Extend it for Select element, Radio button and Chec
k boxes |
| 2533 return nextElement; |
| 2534 } |
| 2535 } |
| 2536 return nullptr; |
| 2537 } |
| 2538 |
| 2539 bool WebViewImpl::isListeningToKeyboardEvents(Element* element) |
| 2540 { |
| 2541 if (!element->isFormControlElement() && !element->isContentEditable()) |
| 2542 return false; |
| 2543 Node* node = element; |
| 2544 do { |
| 2545 if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventLi
steners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::key
up)) |
| 2546 return true; |
| 2547 } while ((node = node->parentNode())); |
| 2548 return false; |
| 2549 } |
| 2550 |
| 2551 void WebViewImpl::advanceFocusInForm(WebFocusType focusType) |
| 2552 { |
| 2553 Element* element = focusedElement(); |
| 2554 if (!element) |
| 2555 return; |
| 2556 |
| 2557 RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element
, focusType); |
| 2558 if (!nextElement) |
| 2559 return; |
| 2560 |
| 2561 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); |
| 2562 nextElement->focus(false, focusType); |
| 2563 } |
| 2564 |
2496 WebString WebViewImpl::inputModeOfFocusedElement() | 2565 WebString WebViewImpl::inputModeOfFocusedElement() |
2497 { | 2566 { |
2498 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2567 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
2499 return WebString(); | 2568 return WebString(); |
2500 | 2569 |
2501 Element* element = focusedElement(); | 2570 Element* element = focusedElement(); |
2502 if (!element) | 2571 if (!element) |
2503 return WebString(); | 2572 return WebString(); |
2504 | 2573 |
2505 if (isHTMLInputElement(*element)) { | 2574 if (isHTMLInputElement(*element)) { |
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4385 { | 4454 { |
4386 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4455 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4387 } | 4456 } |
4388 | 4457 |
4389 void WebViewImpl::forceNextDrawingBufferCreationToFail() | 4458 void WebViewImpl::forceNextDrawingBufferCreationToFail() |
4390 { | 4459 { |
4391 DrawingBuffer::forceNextDrawingBufferCreationToFail(); | 4460 DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
4392 } | 4461 } |
4393 | 4462 |
4394 } // namespace blink | 4463 } // namespace blink |
OLD | NEW |