Title: [234409] releases/WebKitGTK/webkit-2.20
Revision
234409
Author
[email protected]
Date
2018-07-31 00:23:28 -0700 (Tue, 31 Jul 2018)

Log Message

Merge r231291 - Use RetainPtr for form input type
https://bugs.webkit.org/show_bug.cgi?id=185210
<rdar://problem/39734040>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Refactor our HTMLInputElement class to store its InputType member as a RefPtr.

Test: fast/forms/access-key-mutation-2.html.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement):
(WebCore::HTMLInputElement::didAddUserAgentShadowRoot):
(WebCore::HTMLInputElement::accessKeyAction):
(WebCore::HTMLInputElement::parseAttribute):
(WebCore::HTMLInputElement::appendFormData):
* html/HTMLInputElement.h:
* html/InputType.cpp:
(WebCore::createInputType):
(WebCore::InputType::create):
(WebCore::InputType::createText):
* html/InputType.h:

LayoutTests:

* fast/forms/access-key-mutation-2-expected.txt: Added.
* fast/forms/access-key-mutation-2.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog	2018-07-31 07:23:28 UTC (rev 234409)
@@ -1,3 +1,14 @@
+2018-05-02  Brent Fulgham  <[email protected]>
+
+        Use RetainPtr for form input type
+        https://bugs.webkit.org/show_bug.cgi?id=185210
+        <rdar://problem/39734040>
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/forms/access-key-mutation-2-expected.txt: Added.
+        * fast/forms/access-key-mutation-2.html: Added.
+
 2018-05-01  Brent Fulgham  <[email protected]>
 
         Prevent assertion when changing forms

Added: releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2-expected.txt (0 => 234409)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2-expected.txt	2018-07-31 07:23:28 UTC (rev 234409)
@@ -0,0 +1,10 @@
+Access key should work when input type attribute is mutated. To test this manually, press the <alt>+k keys (on Mac OS X, press <Ctrl>+<Opt> instead of <alt>).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS if not crashed.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2.html (0 => 234409)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/fast/forms/access-key-mutation-2.html	2018-07-31 07:23:28 UTC (rev 234409)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+description('Access key should work when input type attribute is mutated. To test this manually, press the &lt;alt&gt;+k keys (on Mac OS X, press &lt;Ctrl&gt;+&lt;Opt&gt; instead of &lt;alt&gt;).');
+
+jsTestIsAsync = true;
+
+function pressKey(key)
+{
+    if (navigator.userAgent.search(/\bMac OS X\b/) !== -1)
+        modifiers = ["ctrlKey", "altKey"];
+    else
+        modifiers = ["altKey"];
+
+    if (window.eventSender)
+        eventSender.keyDown(key, modifiers);
+}
+
+function eventhandler()
+{
+    input.type = "button"
+}
+
+function start()
+{
+    pressKey('k');
+    testPassed('if not crashed.');
+    finishJSTest();
+}
+</script>
+</head>
+<body>
+<input id="input" type="range" accesskey="k" _onfocus_="eventhandler()">
+<iframe _onload_="start()"></iframe>
+</body>
+</html>
+

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog	2018-07-31 07:23:28 UTC (rev 234409)
@@ -1,3 +1,28 @@
+2018-05-02  Brent Fulgham  <[email protected]>
+
+        Use RetainPtr for form input type
+        https://bugs.webkit.org/show_bug.cgi?id=185210
+        <rdar://problem/39734040>
+
+        Reviewed by Ryosuke Niwa.
+
+        Refactor our HTMLInputElement class to store its InputType member as a RefPtr.
+
+        Test: fast/forms/access-key-mutation-2.html.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement):
+        (WebCore::HTMLInputElement::didAddUserAgentShadowRoot):
+        (WebCore::HTMLInputElement::accessKeyAction):
+        (WebCore::HTMLInputElement::parseAttribute):
+        (WebCore::HTMLInputElement::appendFormData):
+        * html/HTMLInputElement.h:
+        * html/InputType.cpp:
+        (WebCore::createInputType):
+        (WebCore::InputType::create):
+        (WebCore::InputType::createText):
+        * html/InputType.h:
+
 2018-05-01  Brent Fulgham  <[email protected]>
 
         Prevent Debug ASSERT when changing forms

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.cpp (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.cpp	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.cpp	2018-07-31 07:23:28 UTC (rev 234409)
@@ -97,7 +97,6 @@
 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser)
     : HTMLTextFormControlElement(tagName, document, form)
     , m_size(defaultSize)
-    , m_maxResults(-1)
     , m_isChecked(false)
     , m_reflectsCheckedAttribute(true)
     , m_isIndeterminate(false)
@@ -120,10 +119,12 @@
     , m_hasTouchEventHandler(false)
 #endif
     , m_isSpellcheckDisabledExceptTextReplacement(false)
+{
     // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and
     // its shadow subtree, just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
-    , m_inputType(createdByParser ? nullptr : InputType::createText(*this))
-{
+    if (!createdByParser)
+        m_inputType = InputType::createText(*this);
+
     ASSERT(hasTagName(inputTag));
     setHasCustomStyleResolveCallbacks();
 }
@@ -146,7 +147,8 @@
 
 void HTMLInputElement::didAddUserAgentShadowRoot(ShadowRoot&)
 {
-    m_inputType->createShadowSubtree();
+    Ref<InputType> protectedInputType(*m_inputType);
+    protectedInputType->createShadowSubtree();
     updateInnerTextElementEditability();
 }
 
@@ -612,7 +614,8 @@
 
 void HTMLInputElement::accessKeyAction(bool sendMouseEvents)
 {
-    m_inputType->accessKeyAction(sendMouseEvents);
+    Ref<InputType> protectedInputType(*m_inputType);
+    protectedInputType->accessKeyAction(sendMouseEvents);
 }
 
 bool HTMLInputElement::isPresentationAttribute(const QualifiedName& name) const
@@ -669,6 +672,7 @@
 void HTMLInputElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     ASSERT(m_inputType);
+    Ref<InputType> protectedInputType(*m_inputType);
 
     if (name == nameAttr) {
         removeFromRadioButtonGroup();
@@ -876,6 +880,7 @@
 
 bool HTMLInputElement::appendFormData(DOMFormData& formData, bool multipart)
 {
+    Ref<InputType> protectedInputType(*m_inputType);
     return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(formData, multipart);
 }
 

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.h (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.h	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/html/HTMLInputElement.h	2018-07-31 07:23:28 UTC (rev 234409)
@@ -446,7 +446,7 @@
     AtomicString m_name;
     String m_valueIfDirty;
     unsigned m_size;
-    short m_maxResults;
+    short m_maxResults { -1 };
     bool m_isChecked : 1;
     bool m_reflectsCheckedAttribute : 1;
     bool m_isIndeterminate : 1;
@@ -469,7 +469,7 @@
     bool m_hasTouchEventHandler : 1;
 #endif
     bool m_isSpellcheckDisabledExceptTextReplacement : 1;
-    std::unique_ptr<InputType> m_inputType;
+    RefPtr<InputType> m_inputType;
     // The ImageLoader must be owned by this element because the loader code assumes
     // that it lives as long as its owning element lives. If we move the loader into
     // the ImageInput object we may delete the loader while this element lives on.

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.cpp (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.cpp	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.cpp	2018-07-31 07:23:28 UTC (rev 234409)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov ([email protected])
  * Copyright (C) 2007 Samuel Weinig ([email protected])
  * Copyright (C) 2009, 2010, 2011, 2012 Google Inc. All rights reserved.
@@ -85,13 +85,13 @@
 
 typedef bool (RuntimeEnabledFeatures::*InputTypeConditionalFunction)() const;
 typedef const AtomicString& (*InputTypeNameFunction)();
-typedef std::unique_ptr<InputType> (*InputTypeFactoryFunction)(HTMLInputElement&);
+typedef Ref<InputType> (*InputTypeFactoryFunction)(HTMLInputElement&);
 typedef HashMap<AtomicString, InputTypeFactoryFunction, ASCIICaseInsensitiveHash> InputTypeFactoryMap;
 
 template<class T>
-static std::unique_ptr<InputType> createInputType(HTMLInputElement& element)
+static Ref<InputType> createInputType(HTMLInputElement& element)
 {
-    return std::make_unique<T>(element);
+    return adoptRef(*new T(element));
 }
 
 static InputTypeFactoryMap createInputTypeFactoryMap()
@@ -149,7 +149,7 @@
     return map;
 }
 
-std::unique_ptr<InputType> InputType::create(HTMLInputElement& element, const AtomicString& typeName)
+Ref<InputType> InputType::create(HTMLInputElement& element, const AtomicString& typeName)
 {
     if (!typeName.isEmpty()) {
         static const auto factoryMap = makeNeverDestroyed(createInputTypeFactoryMap());
@@ -156,12 +156,12 @@
         if (auto factory = factoryMap.get().get(typeName))
             return factory(element);
     }
-    return std::make_unique<TextInputType>(element);
+    return adoptRef(*new TextInputType(element));
 }
 
-std::unique_ptr<InputType> InputType::createText(HTMLInputElement& element)
+Ref<InputType> InputType::createText(HTMLInputElement& element)
 {
-    return std::make_unique<TextInputType>(element);
+    return adoptRef(*new TextInputType(element));
 }
 
 InputType::~InputType() = default;

Modified: releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.h (234408 => 234409)


--- releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.h	2018-07-31 07:01:09 UTC (rev 234408)
+++ releases/WebKitGTK/webkit-2.20/Source/WebCore/html/InputType.h	2018-07-31 07:23:28 UTC (rev 234409)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
 #include "StepRange.h"
 #include <wtf/FastMalloc.h>
 #include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 #if PLATFORM(IOS)
@@ -68,12 +69,12 @@
 // An InputType object represents the type-specific part of an HTMLInputElement.
 // Do not expose instances of InputType and classes derived from it to classes
 // other than HTMLInputElement.
-class InputType {
+class InputType : public RefCounted<InputType> {
     WTF_MAKE_FAST_ALLOCATED;
 
 public:
-    static std::unique_ptr<InputType> create(HTMLInputElement&, const AtomicString&);
-    static std::unique_ptr<InputType> createText(HTMLInputElement&);
+    static Ref<InputType> create(HTMLInputElement&, const AtomicString&);
+    static Ref<InputType> createText(HTMLInputElement&);
     virtual ~InputType();
 
     static bool themeSupportsDataListUI(InputType*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to