| 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 Element* nextElement = element; |
| 2551 for (nextElement = page()->focusController().findFocusableElement(focusType,
*nextElement); nextElement; nextElement = page()->focusController().findFocusab
leElement(focusType, *nextElement)) { |
| 2552 if (nextElement->isContentEditable() && nextElement->isDescendantOf(form
Owner)) |
| 2553 return nextElement; |
| 2554 if (!nextElement->isFormControlElement()) |
| 2555 continue; |
| 2556 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextEleme
nt); |
| 2557 if (formElement->formOwner() != formOwner) |
| 2558 continue; |
| 2559 // Skip disabled or readonly editable elements. |
| 2560 if (formElement->isDisabledOrReadOnly()) |
| 2561 continue; |
| 2562 LayoutObject* layout = nextElement->layoutObject(); |
| 2563 if (layout && layout->isTextControl()) { |
| 2564 // TODO(ajith.v) Extend it for Select element, Radio button and Chec
k boxes |
| 2565 return nextElement; |
| 2566 } |
| 2567 } |
| 2568 return nullptr; |
| 2569 } |
| 2570 |
| 2571 bool WebViewImpl::isListeningToKeyboardEvents(Element* element) |
| 2572 { |
| 2573 if (!element->isFormControlElement() && !element->isContentEditable()) |
| 2574 return false; |
| 2575 for (Node* node = element; node; node = node->parentNode()) { |
| 2576 if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventLi
steners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::key
up)) |
| 2577 return true; |
| 2578 } |
| 2579 return false; |
| 2580 } |
| 2581 |
| 2582 void WebViewImpl::advanceFocusInForm(WebFocusType focusType) |
| 2583 { |
| 2584 Element* element = focusedElement(); |
| 2585 if (!element) |
| 2586 return; |
| 2587 |
| 2588 RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element
, focusType); |
| 2589 if (!nextElement) |
| 2590 return; |
| 2591 |
| 2592 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); |
| 2593 nextElement->focus(false, focusType); |
| 2594 } |
| 2595 |
| 2525 WebString WebViewImpl::inputModeOfFocusedElement() | 2596 WebString WebViewImpl::inputModeOfFocusedElement() |
| 2526 { | 2597 { |
| 2527 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2598 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 2528 return WebString(); | 2599 return WebString(); |
| 2529 | 2600 |
| 2530 Element* element = focusedElement(); | 2601 Element* element = focusedElement(); |
| 2531 if (!element) | 2602 if (!element) |
| 2532 return WebString(); | 2603 return WebString(); |
| 2533 | 2604 |
| 2534 if (isHTMLInputElement(*element)) { | 2605 if (isHTMLInputElement(*element)) { |
| (...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4420 if (m_pageColorOverlay) | 4491 if (m_pageColorOverlay) |
| 4421 m_pageColorOverlay->update(); | 4492 m_pageColorOverlay->update(); |
| 4422 if (m_inspectorOverlay) { | 4493 if (m_inspectorOverlay) { |
| 4423 PageOverlay* inspectorPageOverlay = m_inspectorOverlay->pageOverlay(); | 4494 PageOverlay* inspectorPageOverlay = m_inspectorOverlay->pageOverlay(); |
| 4424 if (inspectorPageOverlay) | 4495 if (inspectorPageOverlay) |
| 4425 inspectorPageOverlay->update(); | 4496 inspectorPageOverlay->update(); |
| 4426 } | 4497 } |
| 4427 } | 4498 } |
| 4428 | 4499 |
| 4429 } // namespace blink | 4500 } // namespace blink |
| OLD | NEW |