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