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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #include "platform/graphics/Color.h" | 109 #include "platform/graphics/Color.h" |
110 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 110 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
111 #include "platform/graphics/Image.h" | 111 #include "platform/graphics/Image.h" |
112 #include "platform/graphics/ImageBuffer.h" | 112 #include "platform/graphics/ImageBuffer.h" |
113 #include "platform/scroll/ScrollbarTheme.h" | 113 #include "platform/scroll/ScrollbarTheme.h" |
114 #include "platform/weborigin/SchemeRegistry.h" | 114 #include "platform/weborigin/SchemeRegistry.h" |
115 #include "public/platform/Platform.h" | 115 #include "public/platform/Platform.h" |
116 #include "public/platform/WebCompositeAndReadbackAsyncCallback.h" | 116 #include "public/platform/WebCompositeAndReadbackAsyncCallback.h" |
117 #include "public/platform/WebDragData.h" | 117 #include "public/platform/WebDragData.h" |
118 #include "public/platform/WebFloatPoint.h" | 118 #include "public/platform/WebFloatPoint.h" |
| 119 #include "public/platform/WebFocusType.h" |
119 #include "public/platform/WebGestureCurve.h" | 120 #include "public/platform/WebGestureCurve.h" |
120 #include "public/platform/WebImage.h" | 121 #include "public/platform/WebImage.h" |
121 #include "public/platform/WebLayerTreeView.h" | 122 #include "public/platform/WebLayerTreeView.h" |
122 #include "public/platform/WebURLRequest.h" | 123 #include "public/platform/WebURLRequest.h" |
123 #include "public/platform/WebVector.h" | 124 #include "public/platform/WebVector.h" |
124 #include "public/web/WebAXObject.h" | 125 #include "public/web/WebAXObject.h" |
125 #include "public/web/WebActiveWheelFlingParameters.h" | 126 #include "public/web/WebActiveWheelFlingParameters.h" |
126 #include "public/web/WebAutofillClient.h" | 127 #include "public/web/WebAutofillClient.h" |
127 #include "public/web/WebBeginFrameArgs.h" | 128 #include "public/web/WebBeginFrameArgs.h" |
128 #include "public/web/WebFrameClient.h" | 129 #include "public/web/WebFrameClient.h" |
(...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2512 flags |= WebTextInputFlagAutocapitalizeCharacters; | 2513 flags |= WebTextInputFlagAutocapitalizeCharacters; |
2513 else if (autocapitalize == words) | 2514 else if (autocapitalize == words) |
2514 flags |= WebTextInputFlagAutocapitalizeWords; | 2515 flags |= WebTextInputFlagAutocapitalizeWords; |
2515 else if (autocapitalize == sentences) | 2516 else if (autocapitalize == sentences) |
2516 flags |= WebTextInputFlagAutocapitalizeSentences; | 2517 flags |= WebTextInputFlagAutocapitalizeSentences; |
2517 else | 2518 else |
2518 ASSERT_NOT_REACHED(); | 2519 ASSERT_NOT_REACHED(); |
2519 } | 2520 } |
2520 } | 2521 } |
2521 | 2522 |
| 2523 if (isListeningToKeyboardEvents(*element)) |
| 2524 flags |= WebTextInputFlagListeningToKeyboardEvents; |
| 2525 |
| 2526 if (nextFocusableElement(element, WebFocusTypeForward)) |
| 2527 flags |= WebTextInputFlagHaveNextFocusableElement; |
| 2528 |
| 2529 if (nextFocusableElement(element, WebFocusTypeBackward)) |
| 2530 flags |= WebTextInputFlagHavePreviousFocusableElement; |
| 2531 |
2522 return flags; | 2532 return flags; |
2523 } | 2533 } |
2524 | 2534 |
| 2535 Element* WebViewImpl::nextFocusableElement(Element* element, WebFocusType focusT
ype) |
| 2536 { |
| 2537 if (!element->isFormControlElement()) |
| 2538 return nullptr; |
| 2539 |
| 2540 HTMLFormControlElement* formControlElement = toHTMLFormControlElement(elemen
t); |
| 2541 HTMLFormElement* formOwner = formControlElement->formOwner(); |
| 2542 if (!formOwner) |
| 2543 return nullptr; |
| 2544 |
| 2545 Node* nextNode = element; |
| 2546 while ((nextNode = page()->focusController().findFocusableNode(focusType, *n
extNode))) { |
| 2547 if (!toElement(nextNode)->isFormControlElement()) |
| 2548 continue; |
| 2549 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextNode)
; |
| 2550 if (formElement->formOwner() != formOwner) |
| 2551 continue; |
| 2552 LayoutObject* layout = nextNode->layoutObject(); |
| 2553 if (nextNode->isContentEditable() || (layout && layout->isTextControl())
) { |
| 2554 // TODO(AKV) Extend it for Select element, Radio button and Check bo
xes |
| 2555 return toElement(nextNode); |
| 2556 } |
| 2557 } |
| 2558 return nullptr; |
| 2559 } |
| 2560 |
| 2561 bool WebViewImpl::isListeningToKeyboardEvents(const Element& element) |
| 2562 { |
| 2563 if (!element.isFormControlElement()) |
| 2564 return false; |
| 2565 |
| 2566 return (element.hasEventListeners(EventTypeNames::keydown) || element.hasEve
ntListeners(EventTypeNames::keypress) || element.hasEventListeners(EventTypeName
s::keyup)); |
| 2567 } |
| 2568 |
| 2569 void WebViewImpl::advanceFocusToNextInputField(WebFocusType focusType) |
| 2570 { |
| 2571 Element* element = focusedElement(); |
| 2572 if (!element) |
| 2573 return; |
| 2574 |
| 2575 Element* nextElement = nextFocusableElement(element, focusType); |
| 2576 if (!nextElement) |
| 2577 return; |
| 2578 |
| 2579 RefPtrWillBeRawPtr<Element> nextFocusElement = nextElement; |
| 2580 nextFocusElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); |
| 2581 nextFocusElement->focus(false, focusType); |
| 2582 } |
| 2583 |
2525 WebString WebViewImpl::inputModeOfFocusedElement() | 2584 WebString WebViewImpl::inputModeOfFocusedElement() |
2526 { | 2585 { |
2527 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2586 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
2528 return WebString(); | 2587 return WebString(); |
2529 | 2588 |
2530 Element* element = focusedElement(); | 2589 Element* element = focusedElement(); |
2531 if (!element) | 2590 if (!element) |
2532 return WebString(); | 2591 return WebString(); |
2533 | 2592 |
2534 if (isHTMLInputElement(*element)) { | 2593 if (isHTMLInputElement(*element)) { |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4571 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4513 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4572 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4514 } | 4573 } |
4515 | 4574 |
4516 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4575 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4517 { | 4576 { |
4518 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4577 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4519 } | 4578 } |
4520 | 4579 |
4521 } // namespace blink | 4580 } // namespace blink |
OLD | NEW |