Title: [231506] branches/safari-605-branch
Revision
231506
Author
[email protected]
Date
2018-05-08 12:42:20 -0700 (Tue, 08 May 2018)

Log Message

Cherry-pick r231291. rdar://problem/40050729

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231291 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-605-branch/LayoutTests/ChangeLog (231505 => 231506)


--- branches/safari-605-branch/LayoutTests/ChangeLog	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/LayoutTests/ChangeLog	2018-05-08 19:42:20 UTC (rev 231506)
@@ -1,3 +1,50 @@
+2018-05-08  Jason Marcell  <[email protected]>
+
+        Cherry-pick r231291. rdar://problem/40050729
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-04-30  Jason Marcell  <[email protected]>
 
         Apply patch. rdar://problem/39741039

Added: branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2-expected.txt (0 => 231506)


--- branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2-expected.txt	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2-expected.txt	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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: branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2.html (0 => 231506)


--- branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2.html	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/fast/forms/access-key-mutation-2.html	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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: branches/safari-605-branch/Source/WebCore/ChangeLog (231505 => 231506)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-05-08 19:42:20 UTC (rev 231506)
@@ -1,5 +1,66 @@
 2018-05-08  Jason Marcell  <[email protected]>
 
+        Cherry-pick r231291. rdar://problem/40050729
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-08  Jason Marcell  <[email protected]>
+
         Cherry-pick r231187. rdar://problem/39987469
 
     Improve the performance of FontCascadeDescription's effectiveFamilies

Modified: branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.cpp (231505 => 231506)


--- branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.cpp	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.cpp	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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();
 }
 
@@ -614,7 +616,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
@@ -671,6 +674,7 @@
 void HTMLInputElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     ASSERT(m_inputType);
+    Ref<InputType> protectedInputType(*m_inputType);
 
     if (name == nameAttr) {
         removeFromRadioButtonGroup();
@@ -878,6 +882,7 @@
 
 bool HTMLInputElement::appendFormData(DOMFormData& formData, bool multipart)
 {
+    Ref<InputType> protectedInputType(*m_inputType);
     return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(formData, multipart);
 }
 

Modified: branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.h (231505 => 231506)


--- branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.h	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/Source/WebCore/html/HTMLInputElement.h	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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: branches/safari-605-branch/Source/WebCore/html/InputType.cpp (231505 => 231506)


--- branches/safari-605-branch/Source/WebCore/html/InputType.cpp	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/Source/WebCore/html/InputType.cpp	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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: branches/safari-605-branch/Source/WebCore/html/InputType.h (231505 => 231506)


--- branches/safari-605-branch/Source/WebCore/html/InputType.h	2018-05-08 19:42:17 UTC (rev 231505)
+++ branches/safari-605-branch/Source/WebCore/html/InputType.h	2018-05-08 19:42:20 UTC (rev 231506)
@@ -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