Diff
Modified: trunk/Source/WTF/ChangeLog (177292 => 177293)
--- trunk/Source/WTF/ChangeLog 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WTF/ChangeLog 2014-12-15 19:17:04 UTC (rev 177293)
@@ -1,3 +1,15 @@
+2014-12-15 Andreas Kling <[email protected]>
+
+ Purge PassRefPtr from FocusEvent code.
+ <https://webkit.org/b/139647>
+
+ Reviewed by Anders Carlsson.
+
+ Add a RefPtr::copyRef() to use when passing a RefPtr to a RefPtr&& without
+ transferring the ownership.
+
+ * wtf/RefPtr.h:
+
2014-12-15 Oliver Hunt <[email protected]>
Make sure range based iteration of Vector<> still receives bounds checking
Modified: trunk/Source/WTF/wtf/RefPtr.h (177292 => 177293)
--- trunk/Source/WTF/wtf/RefPtr.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WTF/wtf/RefPtr.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -88,6 +88,8 @@
static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
+ RefPtr copyRef() WARN_UNUSED_RETURN { return RefPtr(m_ptr); }
+
private:
T* m_ptr;
};
Modified: trunk/Source/WebCore/ChangeLog (177292 => 177293)
--- trunk/Source/WebCore/ChangeLog 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/ChangeLog 2014-12-15 19:17:04 UTC (rev 177293)
@@ -1,3 +1,37 @@
+2014-12-15 Andreas Kling <[email protected]>
+
+ Purge PassRefPtr from FocusEvent code.
+ <https://webkit.org/b/139647>
+
+ Reviewed by Anders Carlsson.
+
+ Convert FocusEvent-related code from using PassRefPtr to using RefPtr&& instead.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setFocusedElement):
+ * dom/Element.cpp:
+ (WebCore::Element::dispatchFocusInEvent):
+ (WebCore::Element::dispatchFocusOutEvent):
+ (WebCore::Element::dispatchFocusEvent):
+ (WebCore::Element::dispatchBlurEvent):
+ * dom/Element.h:
+ * dom/FocusEvent.cpp:
+ (WebCore::FocusEvent::FocusEvent):
+ * dom/FocusEvent.h:
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::dispatchBlurEvent):
+ * html/HTMLFormControlElement.h:
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::dispatchFocusEvent):
+ (WebCore::HTMLSelectElement::dispatchBlurEvent):
+ * html/HTMLSelectElement.h:
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::HTMLTextFormControlElement::dispatchFocusEvent):
+ (WebCore::HTMLTextFormControlElement::dispatchBlurEvent):
+ * html/HTMLTextFormControlElement.h:
+ * page/FocusController.cpp:
+ (WebCore::dispatchEventsOnWindowAndFocusedElement):
+
2014-12-15 Myles C. Maxfield <[email protected]>
[iOS] Codepoints not associated with languages are drawn as boxes
Modified: trunk/Source/WebCore/dom/Document.cpp (177292 => 177293)
--- trunk/Source/WebCore/dom/Document.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -3452,7 +3452,7 @@
}
// Dispatch the blur event and let the node do any other blur related activities (important for text fields)
- oldFocusedElement->dispatchBlurEvent(newFocusedElement);
+ oldFocusedElement->dispatchBlurEvent(newFocusedElement.copyRef());
if (m_focusedElement) {
// handler shifted focus
@@ -3460,10 +3460,10 @@
newFocusedElement = nullptr;
}
- oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement); // DOM level 3 name for the bubbling blur event.
+ oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement.copyRef()); // DOM level 3 name for the bubbling blur event.
// FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
// on it, probably when <rdar://problem/8503958> is resolved.
- oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement); // DOM level 2 name for compatibility.
+ oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement.copyRef()); // DOM level 2 name for compatibility.
if (m_focusedElement) {
// handler shifted focus
@@ -3492,7 +3492,7 @@
m_focusedElement = newFocusedElement;
// Dispatch the focus event and let the node do any other focus related activities (important for text fields)
- m_focusedElement->dispatchFocusEvent(oldFocusedElement, direction);
+ m_focusedElement->dispatchFocusEvent(oldFocusedElement.copyRef(), direction);
if (m_focusedElement != newFocusedElement) {
// handler shifted focus
@@ -3500,7 +3500,7 @@
goto SetFocusedNodeDone;
}
- m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement); // DOM level 3 bubbling focus event.
+ m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement.copyRef()); // DOM level 3 bubbling focus event.
if (m_focusedElement != newFocusedElement) {
// handler shifted focus
@@ -3510,7 +3510,7 @@
// FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends
// on it, probably when <rdar://problem/8503958> is m.
- m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement); // DOM level 2 for compatibility.
+ m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement.copyRef()); // DOM level 2 for compatibility.
if (m_focusedElement != newFocusedElement) {
// handler shifted focus
Modified: trunk/Source/WebCore/dom/Element.cpp (177292 => 177293)
--- trunk/Source/WebCore/dom/Element.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -1992,36 +1992,34 @@
}
}
-void Element::dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Element> oldFocusedElement)
+void Element::dispatchFocusInEvent(const AtomicString& eventType, RefPtr<Element>&& oldFocusedElement)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
- dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, oldFocusedElement));
+ dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, WTF::move(oldFocusedElement)));
}
-void Element::dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Element> newFocusedElement)
+void Element::dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
- dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, newFocusedElement));
+ dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, WTF::move(newFocusedElement)));
}
-void Element::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection)
+void Element::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection)
{
if (document().page())
document().page()->chrome().client().elementDidFocus(this);
- RefPtr<FocusEvent> event = FocusEvent::create(eventNames().focusEvent, false, false, document().defaultView(), 0, oldFocusedElement);
- EventDispatcher::dispatchEvent(this, event.release());
+ EventDispatcher::dispatchEvent(this, FocusEvent::create(eventNames().focusEvent, false, false, document().defaultView(), 0, WTF::move(oldFocusedElement)));
}
-void Element::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
+void Element::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
{
if (document().page())
document().page()->chrome().client().elementDidBlur(this);
- RefPtr<FocusEvent> event = FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, newFocusedElement);
- EventDispatcher::dispatchEvent(this, event.release());
+ EventDispatcher::dispatchEvent(this, FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, WTF::move(newFocusedElement)));
}
void Element::mergeWithNextTextNode(Text& node, ExceptionCode& ec)
Modified: trunk/Source/WebCore/dom/Element.h (177292 => 177293)
--- trunk/Source/WebCore/dom/Element.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/dom/Element.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -532,10 +532,10 @@
bool dispatchWheelEvent(const PlatformWheelEvent&);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
- void dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Element> oldFocusedElement);
- void dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Element> newFocusedElement);
- virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection);
- virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement);
+ void dispatchFocusInEvent(const AtomicString& eventType, RefPtr<Element>&& oldFocusedElement);
+ void dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement);
+ virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection);
+ virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement);
virtual bool willRecalcStyle(Style::Change);
virtual void didRecalcStyle(Style::Change);
Modified: trunk/Source/WebCore/dom/FocusEvent.cpp (177292 => 177293)
--- trunk/Source/WebCore/dom/FocusEvent.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/dom/FocusEvent.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -49,9 +49,9 @@
{
}
-FocusEvent::FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail, PassRefPtr<EventTarget> relatedTarget)
- : UIEvent(type, canBubble, cancelable, view, detail)
- , m_relatedTarget(relatedTarget)
+FocusEvent::FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<AbstractView>&& view, int detail, RefPtr<EventTarget>&& relatedTarget)
+ : UIEvent(type, canBubble, cancelable, WTF::move(view), detail)
+ , m_relatedTarget(WTF::move(relatedTarget))
{
}
Modified: trunk/Source/WebCore/dom/FocusEvent.h (177292 => 177293)
--- trunk/Source/WebCore/dom/FocusEvent.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/dom/FocusEvent.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -46,9 +46,9 @@
return adoptRef(*new FocusEvent);
}
- static Ref<FocusEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail, PassRefPtr<EventTarget> relatedTarget)
+ static Ref<FocusEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<AbstractView>&& view, int detail, RefPtr<EventTarget>&& relatedTarget)
{
- return adoptRef(*new FocusEvent(type, canBubble, cancelable, view, detail, relatedTarget));
+ return adoptRef(*new FocusEvent(type, canBubble, cancelable, WTF::move(view), detail, WTF::move(relatedTarget)));
}
static Ref<FocusEvent> create(const AtomicString& type, const FocusEventInit& initializer)
@@ -57,13 +57,13 @@
}
virtual EventTarget* relatedTarget() const override { return m_relatedTarget.get(); }
- void setRelatedTarget(PassRefPtr<EventTarget> relatedTarget) { m_relatedTarget = relatedTarget; }
+ void setRelatedTarget(RefPtr<EventTarget>&& relatedTarget) { m_relatedTarget = WTF::move(relatedTarget); }
virtual EventInterface eventInterface() const override;
private:
FocusEvent();
- FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, int, PassRefPtr<EventTarget>);
+ FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<AbstractView>&&, int, RefPtr<EventTarget>&&);
FocusEvent(const AtomicString& type, const FocusEventInit&);
virtual bool isFocusEvent() const override;
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -500,9 +500,9 @@
return m_validationMessage && m_validationMessage->shadowTreeContains(node);
}
-void HTMLFormControlElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
+void HTMLFormControlElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
{
- HTMLElement::dispatchBlurEvent(newFocusedElement);
+ HTMLElement::dispatchBlurEvent(WTF::move(newFocusedElement));
hideVisibleValidationMessage();
}
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -138,7 +138,7 @@
virtual void didRecalcStyle(Style::Change) override;
- virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) override;
+ virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) override;
// This must be called any time the result of willValidate() has changed.
void setNeedsWillValidateCheck();
Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLSelectElement.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -945,23 +945,23 @@
return optionIndex;
}
-void HTMLSelectElement::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection direction)
+void HTMLSelectElement::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection direction)
{
// Save the selection so it can be compared to the new selection when
// dispatching change events during blur event dispatch.
if (usesMenuList())
saveLastSelection();
- HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, direction);
+ HTMLFormControlElementWithState::dispatchFocusEvent(WTF::move(oldFocusedElement), direction);
}
-void HTMLSelectElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
+void HTMLSelectElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
{
// We only need to fire change events here for menu lists, because we fire
// change events for list boxes whenever the selection change is actually made.
// This matches other browsers' behavior.
if (usesMenuList())
dispatchChangeEventForMenuList();
- HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement);
+ HTMLFormControlElementWithState::dispatchBlurEvent(WTF::move(newFocusedElement));
}
void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeElement)
Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLSelectElement.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -122,8 +122,8 @@
virtual bool isKeyboardFocusable(KeyboardEvent*) const override;
virtual bool isMouseFocusable() const override;
- virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection) override final;
- virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) override final;
+ virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) override final;
+ virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) override final;
virtual bool canStartSelection() const override { return false; }
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -87,20 +87,20 @@
return InsertionDone;
}
-void HTMLTextFormControlElement::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection direction)
+void HTMLTextFormControlElement::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection direction)
{
if (supportsPlaceholder())
updatePlaceholderVisibility();
handleFocusEvent(oldFocusedElement.get(), direction);
- HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, direction);
+ HTMLFormControlElementWithState::dispatchFocusEvent(WTF::move(oldFocusedElement), direction);
}
-void HTMLTextFormControlElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
+void HTMLTextFormControlElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
{
if (supportsPlaceholder())
updatePlaceholderVisibility();
handleBlurEvent();
- HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement);
+ HTMLFormControlElementWithState::dispatchBlurEvent(WTF::move(newFocusedElement));
}
void HTMLTextFormControlElement::didEditInnerTextValue()
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (177292 => 177293)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2014-12-15 19:17:04 UTC (rev 177293)
@@ -126,8 +126,8 @@
int computeSelectionEnd() const;
TextFieldSelectionDirection computeSelectionDirection() const;
- virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection) override final;
- virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) override final;
+ virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) override final;
+ virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) override final;
virtual bool childShouldCreateRenderer(const Node&) const override;
unsigned indexForPosition(const Position&) const;
Modified: trunk/Source/WebCore/page/FocusController.cpp (177292 => 177293)
--- trunk/Source/WebCore/page/FocusController.cpp 2014-12-15 19:05:14 UTC (rev 177292)
+++ trunk/Source/WebCore/page/FocusController.cpp 2014-12-15 19:17:04 UTC (rev 177293)
@@ -127,10 +127,10 @@
}
if (!focused && document->focusedElement())
- document->focusedElement()->dispatchBlurEvent(0);
+ document->focusedElement()->dispatchBlurEvent(nullptr);
document->dispatchWindowEvent(Event::create(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false));
if (focused && document->focusedElement())
- document->focusedElement()->dispatchFocusEvent(0, FocusDirectionNone);
+ document->focusedElement()->dispatchFocusEvent(nullptr, FocusDirectionNone);
}
static inline bool hasCustomFocusLogic(Element& element)