Changeset 117745 in webkit
- Timestamp:
- May 21, 2012, 1:27:42 AM (14 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 2 added
- 5 edited
-
ChangeLog (modified) (1 diff)
-
WebKit.gyp (modified) (2 diffs)
-
public/WebTextInputInfo.h (added)
-
public/WebWidget.h (modified) (2 diffs)
-
src/WebTextInputInfo.cpp (added)
-
src/WebViewImpl.cpp (modified) (4 diffs)
-
src/WebViewImpl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r117741 r117745 1 2012-05-21 Adam Barth <abarth@webkit.org> 2 3 [Chromium] Implement WebViewImpl::textInputInfo() for Android 4 https://bugs.webkit.org/show_bug.cgi?id=86440 5 6 Reviewed by Darin Fisher. 7 8 This patch adds WebView::textInputInfo(), which describes the text 9 input that currently has focus. Android is planning to use this to 10 determine what sort of keyboard or text entry UI to show. This API 11 subsumes the textInputType() API, which will be removed once the 12 clients have been updated. 13 14 * WebKit.gyp: 15 * public/WebTextInputInfo.h: Added. 16 (WebKit): 17 (WebTextInputInfo): 18 (WebKit::WebTextInputInfo::WebTextInputInfo): 19 (WebKit::operator==): 20 (WebKit::operator!=): 21 * public/WebTextInputType.h: 22 * public/WebWidget.h: 23 (WebWidget): 24 (WebKit::WebWidget::textInputInfo): 25 (WebKit::WebWidget::textInputType): 26 * src/WebViewImpl.cpp: 27 (WebKit::WebViewImpl::textInputInfo): 28 (WebKit): 29 (WebKit::WebViewImpl::textInputType): 30 * src/WebViewImpl.h: 31 (WebViewImpl): 32 1 33 2012-05-21 Sheriff Bot <webkit.review.bot@gmail.com> 2 34 -
trunk/Source/WebKit/chromium/WebKit.gyp
r117538 r117745 273 273 'public/WebTextDirection.h', 274 274 'public/WebTextFieldDecoratorClient.h', 275 'public/WebTextInputInfo.h', 275 276 'public/WebTextInputType.h', 276 277 'public/WebTextRun.h', … … 659 660 'src/WebStorageQuotaCallbacksImpl.h', 660 661 'src/WebSurroundingText.cpp', 662 'src/WebTextInputInfo.cpp', 661 663 'src/WebTextRun.cpp', 662 664 'src/WebURLLoadTiming.cpp', -
trunk/Source/WebKit/chromium/public/WebWidget.h
r117402 r117745 33 33 34 34 #include "WebCompositionUnderline.h" 35 #include "WebTextInputType.h"36 35 #include "WebTextDirection.h" 36 #include "WebTextInputInfo.h" 37 37 #include "platform/WebCanvas.h" 38 38 #include "platform/WebCommon.h" … … 171 171 virtual bool compositionRange(size_t* location, size_t* length) { return false; } 172 172 173 // Returns information about the current text input of this WebWidget. 174 virtual WebTextInputInfo textInputInfo() { return WebTextInputInfo(); } 175 173 176 // Returns the current text input type of this WebWidget. 174 virtual WebTextInputType textInputType() { return WebKit::WebTextInputTypeNone; } 177 // FIXME: Remove this method. It's redundant with textInputInfo(). 178 virtual WebTextInputType textInputType() { return WebTextInputTypeNone; } 175 179 176 180 // Returns the start and end bounds of the current selection. -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r117560 r117745 114 114 #include "SpeechRecognitionClientProxy.h" 115 115 #include "StyleResolver.h" 116 #include "Text.h" 116 117 #include "TextFieldDecoratorImpl.h" 117 118 #include "TextIterator.h" … … 141 142 #include "WebRuntimeFeatures.h" 142 143 #include "WebSettingsImpl.h" 144 #include "WebTextInputInfo.h" 143 145 #include "WebViewClient.h" 144 146 #include "WheelEvent.h" … … 1881 1883 } 1882 1884 1885 WebTextInputInfo WebViewImpl::textInputInfo() 1886 { 1887 WebTextInputInfo info; 1888 1889 Frame* focused = focusedWebCoreFrame(); 1890 if (!focused) 1891 return info; 1892 1893 Editor* editor = focused->editor(); 1894 if (!editor || !editor->canEdit()) 1895 return info; 1896 1897 FrameSelection* selection = focused->selection(); 1898 if (!selection) 1899 return info; 1900 1901 Node* node = focusedWebCoreNode(); 1902 if (!node) 1903 return info; 1904 1905 info.type = textInputType(); 1906 if (info.type == WebTextInputTypeNone) 1907 return info; 1908 1909 if (node->hasTagName(HTMLNames::textareaTag)) 1910 info.value = static_cast<HTMLTextAreaElement*>(node)->value(); 1911 else if (node->hasTagName(HTMLNames::inputTag)) 1912 info.value = static_cast<HTMLInputElement*>(node)->value(); 1913 else if (node->shouldUseInputMethod()) 1914 info.value = node->nodeValue(); 1915 else 1916 return info; 1917 1918 if (info.value.isEmpty()) 1919 return info; 1920 1921 if (node->hasTagName(HTMLNames::textareaTag) || node->hasTagName(HTMLNames::inputTag)) { 1922 HTMLTextFormControlElement* formElement = static_cast<HTMLTextFormControlElement*>(node); 1923 info.selectionStart = formElement->selectionStart(); 1924 info.selectionEnd = formElement->selectionEnd(); 1925 if (editor->hasComposition()) { 1926 info.compositionStart = formElement->indexForVisiblePosition(Position(editor->compositionNode(), editor->compositionStart())); 1927 info.compositionEnd = formElement->indexForVisiblePosition(Position(editor->compositionNode(), editor->compositionEnd())); 1928 } 1929 } else { 1930 info.selectionStart = selection->start().computeOffsetInContainerNode(); 1931 info.selectionEnd = selection->end().computeOffsetInContainerNode(); 1932 if (editor->hasComposition()) { 1933 info.compositionStart = static_cast<int>(editor->compositionStart()); 1934 info.compositionEnd = static_cast<int>(editor->compositionEnd()); 1935 } 1936 } 1937 1938 return info; 1939 } 1940 1883 1941 WebTextInputType WebViewImpl::textInputType() 1884 1942 { … … 1887 1945 return WebTextInputTypeNone; 1888 1946 1889 if (node->nodeType() == Node::ELEMENT_NODE) { 1890 Element* element = static_cast<Element*>(node); 1891 if (element->hasLocalName(HTMLNames::inputTag)) { 1892 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 1893 1894 if (input->readOnly() || input->disabled()) 1895 return WebTextInputTypeNone; 1896 1897 if (input->isPasswordField()) 1898 return WebTextInputTypePassword; 1899 if (input->isSearchField()) 1900 return WebTextInputTypeSearch; 1901 if (input->isEmailField()) 1902 return WebTextInputTypeEmail; 1903 if (input->isNumberField()) 1904 return WebTextInputTypeNumber; 1905 if (input->isTelephoneField()) 1906 return WebTextInputTypeTelephone; 1907 if (input->isURLField()) 1908 return WebTextInputTypeURL; 1909 if (input->isDateField()) 1910 return WebTextInputTypeDate; 1911 if (input->isDateTimeField()) 1912 return WebTextInputTypeDateTime; 1913 if (input->isDateTimeLocalField()) 1914 return WebTextInputTypeDateTimeLocal; 1915 if (input->isMonthField()) 1916 return WebTextInputTypeMonth; 1917 if (input->isTimeField()) 1918 return WebTextInputTypeTime; 1919 if (input->isWeekField()) 1920 return WebTextInputTypeWeek; 1921 if (input->isTextField()) 1922 return WebTextInputTypeText; 1923 1947 if (node->hasTagName(HTMLNames::inputTag)) { 1948 HTMLInputElement* input = static_cast<HTMLInputElement*>(node); 1949 1950 if (input->readOnly() || input->disabled()) 1924 1951 return WebTextInputTypeNone; 1925 } 1926 1927 if (element->hasLocalName(HTMLNames::textareaTag)) { 1928 HTMLTextAreaElement* textarea = static_cast<HTMLTextAreaElement*>(element); 1929 1930 if (textarea->readOnly() || textarea->disabled()) 1931 return WebTextInputTypeNone; 1952 1953 if (input->isPasswordField()) 1954 return WebTextInputTypePassword; 1955 if (input->isSearchField()) 1956 return WebTextInputTypeSearch; 1957 if (input->isEmailField()) 1958 return WebTextInputTypeEmail; 1959 if (input->isNumberField()) 1960 return WebTextInputTypeNumber; 1961 if (input->isTelephoneField()) 1962 return WebTextInputTypeTelephone; 1963 if (input->isURLField()) 1964 return WebTextInputTypeURL; 1965 if (input->isDateField()) 1966 return WebTextInputTypeDate; 1967 if (input->isDateTimeField()) 1968 return WebTextInputTypeDateTime; 1969 if (input->isDateTimeLocalField()) 1970 return WebTextInputTypeDateTimeLocal; 1971 if (input->isMonthField()) 1972 return WebTextInputTypeMonth; 1973 if (input->isTimeField()) 1974 return WebTextInputTypeTime; 1975 if (input->isWeekField()) 1976 return WebTextInputTypeWeek; 1977 if (input->isTextField()) 1932 1978 return WebTextInputTypeText; 1933 } 1934 } 1935 1936 // For other situations. 1979 1980 return WebTextInputTypeNone; 1981 } 1982 1983 if (node->hasTagName(HTMLNames::textareaTag)) { 1984 HTMLTextAreaElement* textarea = static_cast<HTMLTextAreaElement*>(node); 1985 1986 if (textarea->readOnly() || textarea->disabled()) 1987 return WebTextInputTypeNone; 1988 1989 return WebTextInputTypeText; 1990 } 1991 1937 1992 if (node->shouldUseInputMethod()) 1938 1993 return WebTextInputTypeText; -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r117560 r117745 146 146 virtual bool confirmComposition(const WebString& text); 147 147 virtual bool compositionRange(size_t* location, size_t* length); 148 virtual WebTextInputInfo textInputInfo(); 148 149 virtual WebTextInputType textInputType(); 149 150 virtual bool selectionBounds(WebRect& start, WebRect& end) const;
Note:
See TracChangeset
for help on using the changeset viewer.