Title: [234744] trunk/Source/WebCore
- Revision
- 234744
- Author
- [email protected]
- Date
- 2018-08-09 16:56:42 -0700 (Thu, 09 Aug 2018)
Log Message
InputType should not interact with an HTMLInputElement is no longer associated with
https://bugs.webkit.org/show_bug.cgi?id=188410
Reviewed by Ryosuke Niwa.
Clear InputType::m_element when the InputType is no longer associated with the HTMLInputElement
because the element changed type. We were already dealing with the InputType no longer being
associated with an element because the element died by using a WeakPtr. However, it is conceptually
better (more correct) to also clear this pointer if the element is still alive but associated with
another InputType.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
* html/InputType.h:
(WebCore::InputType::detachFromElement):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (234743 => 234744)
--- trunk/Source/WebCore/ChangeLog 2018-08-09 23:49:11 UTC (rev 234743)
+++ trunk/Source/WebCore/ChangeLog 2018-08-09 23:56:42 UTC (rev 234744)
@@ -1,3 +1,21 @@
+2018-08-09 Chris Dumez <[email protected]>
+
+ InputType should not interact with an HTMLInputElement is no longer associated with
+ https://bugs.webkit.org/show_bug.cgi?id=188410
+
+ Reviewed by Ryosuke Niwa.
+
+ Clear InputType::m_element when the InputType is no longer associated with the HTMLInputElement
+ because the element changed type. We were already dealing with the InputType no longer being
+ associated with an element because the element died by using a WeakPtr. However, it is conceptually
+ better (more correct) to also clear this pointer if the element is still alive but associated with
+ another InputType.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::updateType):
+ * html/InputType.h:
+ (WebCore::InputType::detachFromElement):
+
2018-08-09 Jer Noble <[email protected]>
Video playback is using more power
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (234743 => 234744)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2018-08-09 23:49:11 UTC (rev 234743)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2018-08-09 23:56:42 UTC (rev 234744)
@@ -521,6 +521,7 @@
}
m_inputType->destroyShadowSubtree();
+ m_inputType->detachFromElement();
m_inputType = WTFMove(newType);
m_inputType->createShadowSubtree();
Modified: trunk/Source/WebCore/html/InputType.h (234743 => 234744)
--- trunk/Source/WebCore/html/InputType.h 2018-08-09 23:49:11 UTC (rev 234743)
+++ trunk/Source/WebCore/html/InputType.h 2018-08-09 23:56:42 UTC (rev 234744)
@@ -77,6 +77,8 @@
static Ref<InputType> createText(HTMLInputElement&);
virtual ~InputType();
+ void detachFromElement() { m_element = nullptr; }
+
static bool themeSupportsDataListUI(InputType*);
virtual const AtomicString& formControlType() const = 0;
@@ -314,7 +316,7 @@
// Helper for stepUp()/stepDown(). Adds step value * count to the current value.
ExceptionOr<void> applyStep(int count, AnyStepHandling, TextFieldEventBehavior);
- // Raw pointer because the HTMLInputElement object owns this InputType object.
+ // m_element is null if this InputType is no longer associated with an element (either the element died or changed input type).
WeakPtr<HTMLInputElement> m_element;
};
Modified: trunk/Source/WebCore/html/RangeInputType.cpp (234743 => 234744)
--- trunk/Source/WebCore/html/RangeInputType.cpp 2018-08-09 23:49:11 UTC (rev 234743)
+++ trunk/Source/WebCore/html/RangeInputType.cpp 2018-08-09 23:56:42 UTC (rev 234744)
@@ -321,8 +321,8 @@
{
InputType::accessKeyAction(sendMouseEvents);
- ASSERT(element());
- element()->dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
+ if (auto* element = this->element())
+ element->dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
}
void RangeInputType::attributeChanged(const QualifiedName& name)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes