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 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() && !element->isContentEditable()) | |
| 2538 return nullptr; | |
| 2539 | |
| 2540 HTMLFormElement* formOwner = nullptr; | |
| 2541 if (element->isContentEditable()) { | |
| 2542 // Check whether it's child of a form element | |
| 2543 Element* parent = element; | |
|
tkent
2015/04/20 01:40:20
formOwner = Traversal<HTMLFormElement>::firstAnces
AKV
2015/04/20 19:46:49
Done. Thanks., this is very simple :)
| |
| 2544 while ((parent = parent->parentElement())) { | |
| 2545 if (!isHTMLFormElement(parent)) | |
| 2546 continue; | |
| 2547 formOwner = reinterpret_cast<HTMLFormElement*>(toHTMLElement(parent) ); | |
|
tkent
2015/04/20 01:40:20
Do not use reinterpret_cast<>.
AKV
2015/04/20 19:46:49
Done.
| |
| 2548 break; | |
| 2549 } | |
| 2550 } else { | |
| 2551 HTMLFormControlElement* formControlElement = toHTMLFormControlElement(el ement); | |
|
tkent
2015/04/20 01:40:21
formOwner = toHTMLFormControlElement(element)->for
AKV
2015/04/20 19:46:49
Done.
| |
| 2552 formOwner = formControlElement->formOwner(); | |
| 2553 } | |
| 2554 | |
| 2555 if (!formOwner) | |
| 2556 return nullptr; | |
| 2557 | |
| 2558 Node* nextNode = element; | |
| 2559 while ((nextNode = page()->focusController().findFocusableNode(focusType, *n extNode))) { | |
| 2560 if (nextNode->isContentEditable() && nextNode->isDescendantOf(reinterpre t_cast<Node*>(formOwner))) | |
|
tkent
2015/04/20 01:40:21
Do not use reinterpret_cast<>.
AKV
2015/04/20 19:46:49
Done.
| |
| 2561 return toElement(nextNode); | |
| 2562 if (!toElement(nextNode)->isFormControlElement()) | |
| 2563 continue; | |
| 2564 HTMLFormControlElement* formElement = toHTMLFormControlElement(nextNode) ; | |
| 2565 if (formElement->formOwner() != formOwner) | |
| 2566 continue; | |
| 2567 LayoutObject* layout = nextNode->layoutObject(); | |
| 2568 if (layout && layout->isTextControl()) { | |
| 2569 // TODO(AKV) Extend it for Select element, Radio button and Check bo xes | |
|
tkent
2015/04/20 01:40:21
Please use the username part of your @chromium.org
AKV
2015/04/20 19:46:49
Done.
| |
| 2570 return toElement(nextNode); | |
| 2571 } | |
| 2572 } | |
| 2573 return nullptr; | |
| 2574 } | |
| 2575 | |
| 2576 bool WebViewImpl::isListeningToKeyboardEvents(const Element& element) | |
| 2577 { | |
| 2578 if (!element.isFormControlElement()) | |
|
tkent
2015/04/20 01:40:21
This returns a wrong result for contenteditable e
AKV
2015/04/20 19:46:49
Thanks. I corrected :)
| |
| 2579 return false; | |
| 2580 | |
| 2581 return (element.hasEventListeners(EventTypeNames::keydown) || element.hasEve ntListeners(EventTypeNames::keypress) || element.hasEventListeners(EventTypeName s::keyup)); | |
|
tkent
2015/04/20 01:40:20
I found this didn't work for the following case.
AKV
2015/04/20 19:46:49
Thanks. I just corrected using document listener a
| |
| 2582 } | |
| 2583 | |
| 2584 void WebViewImpl::advanceFocusToNextFormControl(WebFocusType focusType) | |
|
tkent
2015/04/20 01:40:21
You clarified you'd like to handle contenteditable
AKV
2015/04/20 19:46:49
Done. Thanks
| |
| 2585 { | |
| 2586 Element* element = focusedElement(); | |
| 2587 if (!element) | |
| 2588 return; | |
| 2589 | |
| 2590 Element* nextElement = nextFocusableElement(element, focusType); | |
|
tkent
2015/04/20 01:40:21
You can make |nextElement| RefPtrWillBeRawPtr<Elem
AKV
2015/04/20 19:46:49
Done.
| |
| 2591 if (!nextElement) | |
| 2592 return; | |
| 2593 | |
| 2594 RefPtrWillBeRawPtr<Element> nextFocusElement = nextElement; | |
| 2595 nextFocusElement->scrollIntoViewIfNeeded(true /*centerIfNeeded*/); | |
| 2596 nextFocusElement->focus(false, focusType); | |
| 2597 } | |
| 2598 | |
| 2525 WebString WebViewImpl::inputModeOfFocusedElement() | 2599 WebString WebViewImpl::inputModeOfFocusedElement() |
| 2526 { | 2600 { |
| 2527 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) | 2601 if (!RuntimeEnabledFeatures::inputModeAttributeEnabled()) |
| 2528 return WebString(); | 2602 return WebString(); |
| 2529 | 2603 |
| 2530 Element* element = focusedElement(); | 2604 Element* element = focusedElement(); |
| 2531 if (!element) | 2605 if (!element) |
| 2532 return WebString(); | 2606 return WebString(); |
| 2533 | 2607 |
| 2534 if (isHTMLInputElement(*element)) { | 2608 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 | 4586 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4513 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4587 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4514 } | 4588 } |
| 4515 | 4589 |
| 4516 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4590 void WebViewImpl::forceNextWebGLContextCreationToFail() |
| 4517 { | 4591 { |
| 4518 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4592 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
| 4519 } | 4593 } |
| 4520 | 4594 |
| 4521 } // namespace blink | 4595 } // namespace blink |
| OLD | NEW |