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/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/canvas/WebGLRenderingContext.h" | 69 #include "core/html/canvas/WebGLRenderingContext.h" |
| 68 #include "core/html/forms/PopupMenuClient.h" | 70 #include "core/html/forms/PopupMenuClient.h" |
| 69 #include "core/input/EventHandler.h" | 71 #include "core/input/EventHandler.h" |
| 70 #include "core/layout/LayoutPart.h" | 72 #include "core/layout/LayoutPart.h" |
| 71 #include "core/layout/LayoutView.h" | 73 #include "core/layout/LayoutView.h" |
| 72 #include "core/layout/TextAutosizer.h" | 74 #include "core/layout/TextAutosizer.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 115 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
| 114 #include "platform/graphics/Image.h" | 116 #include "platform/graphics/Image.h" |
| 115 #include "platform/graphics/ImageBuffer.h" | 117 #include "platform/graphics/ImageBuffer.h" |
| 116 #include "platform/graphics/gpu/DrawingBuffer.h" | 118 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 117 #include "platform/scroll/ScrollbarTheme.h" | 119 #include "platform/scroll/ScrollbarTheme.h" |
| 118 #include "platform/weborigin/SchemeRegistry.h" | 120 #include "platform/weborigin/SchemeRegistry.h" |
| 119 #include "public/platform/Platform.h" | 121 #include "public/platform/Platform.h" |
| 120 #include "public/platform/WebCompositeAndReadbackAsyncCallback.h" | 122 #include "public/platform/WebCompositeAndReadbackAsyncCallback.h" |
| 121 #include "public/platform/WebDragData.h" | 123 #include "public/platform/WebDragData.h" |
| 122 #include "public/platform/WebFloatPoint.h" | 124 #include "public/platform/WebFloatPoint.h" |
| 125 #include "public/platform/WebFocusType.h" | |
|
kochi
2015/07/03 04:10:34
It's strange you already used "WebFocusType" in We
AKV
2015/07/26 15:56:34
Done.
| |
| 123 #include "public/platform/WebGestureCurve.h" | 126 #include "public/platform/WebGestureCurve.h" |
| 124 #include "public/platform/WebImage.h" | 127 #include "public/platform/WebImage.h" |
| 125 #include "public/platform/WebLayerTreeView.h" | 128 #include "public/platform/WebLayerTreeView.h" |
| 126 #include "public/platform/WebURLRequest.h" | 129 #include "public/platform/WebURLRequest.h" |
| 127 #include "public/platform/WebVector.h" | 130 #include "public/platform/WebVector.h" |
| 128 #include "public/web/WebAXObject.h" | 131 #include "public/web/WebAXObject.h" |
| 129 #include "public/web/WebActiveWheelFlingParameters.h" | 132 #include "public/web/WebActiveWheelFlingParameters.h" |
| 130 #include "public/web/WebAutofillClient.h" | 133 #include "public/web/WebAutofillClient.h" |
| 131 #include "public/web/WebBeginFrameArgs.h" | 134 #include "public/web/WebBeginFrameArgs.h" |
| 132 #include "public/web/WebElement.h" | 135 #include "public/web/WebElement.h" |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2498 flags |= WebTextInputFlagAutocapitalizeCharacters; | 2501 flags |= WebTextInputFlagAutocapitalizeCharacters; |
| 2499 else if (autocapitalize == words) | 2502 else if (autocapitalize == words) |
| 2500 flags |= WebTextInputFlagAutocapitalizeWords; | 2503 flags |= WebTextInputFlagAutocapitalizeWords; |
| 2501 else if (autocapitalize == sentences) | 2504 else if (autocapitalize == sentences) |
| 2502 flags |= WebTextInputFlagAutocapitalizeSentences; | 2505 flags |= WebTextInputFlagAutocapitalizeSentences; |
| 2503 else | 2506 else |
| 2504 ASSERT_NOT_REACHED(); | 2507 ASSERT_NOT_REACHED(); |
| 2505 } | 2508 } |
| 2506 } | 2509 } |
| 2507 | 2510 |
| 2511 if (isListeningToKeyboardEvents(element)) | |
| 2512 flags |= WebTextInputFlagListeningToKeyboardEvents; | |
| 2513 | |
| 2514 if (nextFocusableElementInForm(element, WebFocusTypeForward)) | |
| 2515 flags |= WebTextInputFlagHaveNextFocusableElement; | |
| 2516 | |
| 2517 if (nextFocusableElementInForm(element, WebFocusTypeBackward)) | |
| 2518 flags |= WebTextInputFlagHavePreviousFocusableElement; | |
| 2519 | |
| 2508 return flags; | 2520 return flags; |
| 2509 } | 2521 } |
| 2510 | 2522 |
| 2523 Element* WebViewImpl::nextFocusableElementInForm(Element* element, WebFocusType focusType) | |
| 2524 { | |
| 2525 if (!element->isFormControlElement() && !element->isContentEditable()) | |
| 2526 return nullptr; | |
| 2527 | |
| 2528 HTMLFormElement* formOwner = nullptr; | |
| 2529 if (element->isContentEditable()) | |
| 2530 formOwner = Traversal<HTMLFormElement>::firstAncestor(*element); | |
| 2531 else | |
| 2532 formOwner = toHTMLFormControlElement(element)->formOwner(); | |
| 2533 | |
| 2534 if (!formOwner) | |
| 2535 return nullptr; | |
| 2536 | |
| 2537 Node* nextNode = element; | |
|
kochi
2015/07/03 04:10:34
Now FocusController::findFocusableElement() return
AKV
2015/07/26 15:56:34
Done.
| |
| 2538 while ((nextNode = page()->focusController().findFocusableElement(focusType, *nextNode))) { | |
| 2539 if (nextNode->isContentEditable() && nextNode->isDescendantOf(formOwner) ) | |
| 2540 return toElement(nextNode); | |
|
kochi
2015/07/03 04:10:34
If the pointer type is changed to Element*, you do
AKV
2015/07/26 15:56:34
Done.
| |
| 2541 if (!toElement(nextNode)->isFormControlElement()) | |
|
kochi
2015/07/03 04:10:34
Ditto.
AKV
2015/07/26 15:56:34
Done.
| |
| 2542 continue; | |
| 2543 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextNode) ; | |
| 2544 if (formElement->formOwner() != formOwner) | |
| 2545 continue; | |
| 2546 LayoutObject* layout = nextNode->layoutObject(); | |
| 2547 if (layout && layout->isTextControl()) { | |
| 2548 // TODO(ajith.v) Extend it for Select element, Radio button and Chec k boxes | |
| 2549 return toElement(nextNode); | |
|
kochi
2015/07/03 04:10:34
Ditto.
AKV
2015/07/26 15:56:34
Done.
| |
| 2550 } | |
| 2551 } | |
| 2552 return nullptr; | |
| 2553 } | |
| 2554 | |
| 2555 bool WebViewImpl::isListeningToKeyboardEvents(Element* element) | |
| 2556 { | |
| 2557 if (!element->isFormControlElement() && !element->isContentEditable()) | |
| 2558 return false; | |
| 2559 Node* node = element; | |
| 2560 do { | |
| 2561 if (node->hasEventListeners(EventTypeNames::keydown) || node->hasEventLi steners(EventTypeNames::keypress) || node->hasEventListeners(EventTypeNames::key up)) | |
| 2562 return true; | |
| 2563 } while ((node = node->parentNode())); | |
| 2564 return false; | |
| 2565 } | |
| 2566 | |
| 2567 void WebViewImpl::advanceFocusInForm(WebFocusType focusType) | |
| 2568 { | |
| 2569 Element* element = focusedElement(); | |
| 2570 if (!element) | |
| 2571 return; | |
| 2572 | |
| 2573 RefPtrWillBeRawPtr<Element> nextElement = nextFocusableElementInForm(element , focusType); | |
| 2574 if (!nextElement) | |
| 2575 return; | |
| 2576 | |
| 2577 nextElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); | |
| 2578 nextElement->focus(false, focusType); | |
| 2579 } | |
| 2580 | |
| 2511 WebString WebViewImpl::inputModeOfFocusedElement() | 2581 WebString WebViewImpl::inputModeOfFocusedElement() |
| 2512 { | 2582 { |
| 2513 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2583 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 2514 return WebString(); | 2584 return WebString(); |
| 2515 | 2585 |
| 2516 Element* element = focusedElement(); | 2586 Element* element = focusedElement(); |
| 2517 if (!element) | 2587 if (!element) |
| 2518 return WebString(); | 2588 return WebString(); |
| 2519 | 2589 |
| 2520 if (isHTMLInputElement(*element)) { | 2590 if (isHTMLInputElement(*element)) { |
| (...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4397 { | 4467 { |
| 4398 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4468 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
| 4399 } | 4469 } |
| 4400 | 4470 |
| 4401 void WebViewImpl::forceNextDrawingBufferCreationToFail() | 4471 void WebViewImpl::forceNextDrawingBufferCreationToFail() |
| 4402 { | 4472 { |
| 4403 DrawingBuffer::forceNextDrawingBufferCreationToFail(); | 4473 DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
| 4404 } | 4474 } |
| 4405 | 4475 |
| 4406 } // namespace blink | 4476 } // namespace blink |
| OLD | NEW |