Changeset 243684 in webkit
- Timestamp:
- Mar 31, 2019, 1:01:44 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/change-inputmode-crash-expected.txt (added)
-
LayoutTests/fast/forms/change-inputmode-crash.html (added)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243681 r243684 1 2019-03-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Crash when changing inputmode for certain types of focusable elements 4 https://bugs.webkit.org/show_bug.cgi?id=196431 5 <rdar://problem/49454962> 6 7 Reviewed by Tim Horton. 8 9 Add a layout test that exercises the edge case; see WebKit ChangeLogs for more details. 10 11 * fast/forms/change-inputmode-crash-expected.txt: Added. 12 * fast/forms/change-inputmode-crash.html: Added. 13 1 14 2019-03-29 Dean Jackson <dino@apple.com> 2 15 -
trunk/Source/WebKit/ChangeLog
r243683 r243684 1 2019-03-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Crash when changing inputmode for certain types of focusable elements 4 https://bugs.webkit.org/show_bug.cgi?id=196431 5 <rdar://problem/49454962> 6 7 Reviewed by Tim Horton. 8 9 The crash is happening because WebPage::focusedElementDidChangeInputMode assumes that the document's focused 10 element must be the same as m_focusedElement in WebPage. However, this is not the case, since m_focusedElement 11 is only set for certain types of elements that require user input (e.g. text fields, editable content, select 12 menus, etc.). The function then attempts to dereference m_focusedElement, which may be null if the document's 13 focused element doesn't fall into one of the aforementioned categories. 14 15 To fix this, bail if the element that is changing inputmode is not equal to the WebPage's current focused 16 element. See below for more details. 17 18 Test: fast/forms/change-inputmode-crash.html 19 20 * WebProcess/WebPage/WebPage.cpp: 21 (WebKit::isTextFormControlOrEditableContent): 22 23 Clean up some existing logic by introducing a helper method for determining whether an element should 24 propagate inputmode attribute changes to the UI process. Also, check the element type using type traits instead 25 of checking against the tag name. 26 27 (WebKit::WebPage::elementDidFocus): 28 (WebKit::WebPage::focusedElementDidChangeInputMode): 29 1 30 2019-03-31 Sam Weinig <weinig@apple.com> 2 31 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r243630 r243684 174 174 #include <WebCore/HTMLPlugInElement.h> 175 175 #include <WebCore/HTMLPlugInImageElement.h> 176 #include <WebCore/HTMLSelectElement.h> 176 177 #include <WebCore/HTMLTextAreaElement.h> 178 #include <WebCore/HTMLTextFormControlElement.h> 177 179 #include <WebCore/HTMLUListElement.h> 178 180 #include <WebCore/HistoryController.h> … … 5346 5348 } 5347 5349 5350 static bool isTextFormControlOrEditableContent(const WebCore::Element& element) 5351 { 5352 return is<HTMLTextFormControlElement>(element) || element.hasEditableStyle(); 5353 } 5354 5348 5355 void WebPage::elementDidFocus(WebCore::Element& element) 5349 5356 { … … 5354 5361 } 5355 5362 5356 if ( element.hasTagName(WebCore::HTMLNames::selectTag) || element.hasTagName(WebCore::HTMLNames::inputTag) || element.hasTagName(WebCore::HTMLNames::textareaTag) || element.hasEditableStyle()) {5363 if (is<HTMLSelectElement>(element) || isTextFormControlOrEditableContent(element)) { 5357 5364 m_focusedElement = &element; 5358 5365 … … 5400 5407 void WebPage::focusedElementDidChangeInputMode(WebCore::Element& element, WebCore::InputMode mode) 5401 5408 { 5409 if (m_focusedElement != &element) 5410 return; 5411 5402 5412 #if PLATFORM(IOS_FAMILY) 5403 ASSERT(m_focusedElement == &element);5404 5413 ASSERT(is<HTMLElement>(element)); 5405 5414 ASSERT(downcast<HTMLElement>(element).canonicalInputMode() == mode); 5406 5415 5407 if (!is <HTMLTextAreaElement>(*m_focusedElement) && !is<HTMLInputElement>(*m_focusedElement) && !m_focusedElement->hasEditableStyle())5416 if (!isTextFormControlOrEditableContent(element)) 5408 5417 return; 5409 5418 5410 5419 send(Messages::WebPageProxy::FocusedElementDidChangeInputMode(mode)); 5411 5420 #else 5412 UNUSED_PARAM(element);5413 5421 UNUSED_PARAM(mode); 5414 5422 #endif
Note:
See TracChangeset
for help on using the changeset viewer.