Diff
Modified: trunk/Source/WebCore/ChangeLog (98163 => 98164)
--- trunk/Source/WebCore/ChangeLog 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/ChangeLog 2011-10-21 22:56:39 UTC (rev 98164)
@@ -1,3 +1,38 @@
+2011-10-21 Adam Barth <aba...@webkit.org>
+
+ Introduce Event::hasInterface to make uses of interfaceName more readable
+ https://bugs.webkit.org/show_bug.cgi?id=70652
+
+ Reviewed by Eric Seidel.
+
+ Eric felt that this approach would be more readable because it requires
+ less syntax at each callsite.
+
+ * bindings/js/JSErrorHandler.cpp:
+ (WebCore::JSErrorHandler::handleEvent):
+ * bindings/objc/DOMEvents.mm:
+ (kitClass):
+ * bindings/v8/V8WindowErrorHandler.cpp:
+ (WebCore::V8WindowErrorHandler::callListenerFunction):
+ * bindings/v8/V8WorkerContextErrorHandler.cpp:
+ (WebCore::V8WorkerContextErrorHandler::callListenerFunction):
+ * dom/Event.cpp:
+ (WebCore::Event::hasInterface):
+ * dom/Event.h:
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::determineDispatchBehavior):
+ * dom/Node.cpp:
+ (WebCore::Node::defaultEventHandler):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::defaultEventHandler):
+ * html/HTMLTextAreaElement.cpp:
+ (WebCore::HTMLTextAreaElement::defaultEventHandler):
+ * html/TextFieldInputType.cpp:
+ (WebCore::TextFieldInputType::forwardEvent):
+ (WebCore::TextFieldInputType::shouldSubmitImplicitly):
+ * inspector/InspectorDOMStorageResource.cpp:
+ (WebCore::InspectorDOMStorageResource::handleEvent):
+
2011-10-21 Adam Klein <ad...@chromium.org>
[MutationObservers] Implement basic subtree observation
Modified: trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp (98163 => 98164)
--- trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -53,7 +53,7 @@
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
- if (event->interfaceName() != eventNames().interfaceForErrorEvent)
+ if (!event->hasInterface(eventNames().interfaceForErrorEvent))
return JSEventListener::handleEvent(scriptExecutionContext, event);
ASSERT(scriptExecutionContext);
Modified: trunk/Source/WebCore/bindings/objc/DOMEvents.mm (98163 => 98164)
--- trunk/Source/WebCore/bindings/objc/DOMEvents.mm 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/bindings/objc/DOMEvents.mm 2011-10-21 22:56:39 UTC (rev 98164)
@@ -44,34 +44,34 @@
#import "DOMSVGZoomEvent.h"
#endif
+using WebCore::eventNames;
+
Class kitClass(WebCore::Event* impl)
{
- AtomicString desiredInterface = impl->interfaceName();
-
if (impl->isUIEvent()) {
if (impl->isKeyboardEvent())
return [DOMKeyboardEvent class];
if (impl->isMouseEvent())
return [DOMMouseEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForTextEvent)
+ if (impl->hasInterface(eventNames().interfaceForTextEvent))
return [DOMTextEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForWheelEvent)
+ if (impl->hasInterface(eventNames().interfaceForWheelEvent))
return [DOMWheelEvent class];
#if ENABLE(SVG_DOM_OBJC_BINDINGS)
- if (desiredInterface == WebCore::eventNames().interfaceForSVGZoomEvent)
+ if (impl->hasInterface(eventNames().interfaceForSVGZoomEvent))
return [DOMSVGZoomEvent class];
#endif
return [DOMUIEvent class];
}
- if (desiredInterface == WebCore::eventNames().interfaceForMutationEvent)
+ if (impl->hasInterface(eventNames().interfaceForMutationEvent))
return [DOMMutationEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForOverflowEvent)
+ if (impl->hasInterface(eventNames().interfaceForOverflowEvent))
return [DOMOverflowEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForMessageEvent)
+ if (impl->hasInterface(eventNames().interfaceForMessageEvent))
return [DOMMessageEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForProgressEvent || desiredInterface == WebCore::eventNames().interfaceForXMLHttpRequestProgressEvent)
+ if (impl->hasInterface(eventNames().interfaceForProgressEvent) || impl->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent))
return [DOMProgressEvent class];
- if (desiredInterface == WebCore::eventNames().interfaceForBeforeLoadEvent)
+ if (impl->hasInterface(eventNames().interfaceForBeforeLoadEvent))
return [DOMBeforeLoadEvent class];
return [DOMEvent class];
}
Modified: trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp (98163 => 98164)
--- trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -45,7 +45,7 @@
v8::Local<v8::Value> V8WindowErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
- if (event->interfaceName() != eventNames().interfaceForErrorEvent)
+ if (!event->hasInterface(eventNames().interfaceForErrorEvent))
return V8EventListener::callListenerFunction(context, jsEvent, event);
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp (98163 => 98164)
--- trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -47,7 +47,7 @@
v8::Local<v8::Value> V8WorkerContextErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
- ASSERT(event->interfaceName() == eventNames().interfaceForErrorEvent);
+ ASSERT(event->hasInterface(eventNames().interfaceForErrorEvent));
v8::Local<v8::Object> listener = getListenerObject(context);
v8::Local<v8::Value> returnValue;
if (!listener.IsEmpty() && listener->IsFunction()) {
Modified: trunk/Source/WebCore/dom/Event.cpp (98163 => 98164)
--- trunk/Source/WebCore/dom/Event.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/dom/Event.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -102,6 +102,11 @@
return eventNames().interfaceForEvent;
}
+bool Event::hasInterface(const AtomicString& name) const
+{
+ return interfaceName() == name;
+}
+
bool Event::isUIEvent() const
{
return false;
Modified: trunk/Source/WebCore/dom/Event.h (98163 => 98164)
--- trunk/Source/WebCore/dom/Event.h 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/dom/Event.h 2011-10-21 22:56:39 UTC (rev 98164)
@@ -113,6 +113,7 @@
Clipboard* clipboardData() const { return isClipboardEvent() ? clipboard() : 0; }
virtual const AtomicString& interfaceName() const;
+ bool hasInterface(const AtomicString&) const;
// These events are general classes of events.
virtual bool isUIEvent() const;
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (98163 => 98164)
--- trunk/Source/WebCore/dom/EventDispatcher.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -396,7 +396,7 @@
// Per XBL 2.0 spec, mutation events should never cross shadow DOM boundary:
// http://dev.w3.org/2006/xbl2/#event-flow-and-targeting-across-shadow-s
- if (event->interfaceName() == eventNames().interfaceForMutationEvent)
+ if (event->hasInterface(eventNames().interfaceForMutationEvent))
return StayInsideShadowDOM;
// WebKit never allowed selectstart event to cross the the shadow DOM boundary.
Modified: trunk/Source/WebCore/dom/Node.cpp (98163 => 98164)
--- trunk/Source/WebCore/dom/Node.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/dom/Node.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -2889,7 +2889,7 @@
page->contextMenuController()->handleContextMenuEvent(event);
#endif
} else if (eventType == eventNames().textInputEvent) {
- if (event->interfaceName() == eventNames().interfaceForTextEvent)
+ if (event->hasInterface(eventNames().interfaceForTextEvent))
if (Frame* frame = document()->frame())
frame->eventHandler()->defaultTextInputEventHandler(static_cast<TextEvent*>(event));
#if ENABLE(PAN_SCROLLING)
@@ -2909,7 +2909,7 @@
}
}
#endif
- } else if (eventType == eventNames().mousewheelEvent && event->interfaceName() == eventNames().interfaceForWheelEvent) {
+ } else if (eventType == eventNames().mousewheelEvent && event->hasInterface(eventNames().interfaceForWheelEvent)) {
WheelEvent* wheelEvent = static_cast<WheelEvent*>(event);
// If we don't have a renderer, send the wheel event to the first node we find with a renderer.
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (98163 => 98164)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -1269,7 +1269,7 @@
if (evt->isBeforeTextInsertedEvent())
m_inputType->handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(evt));
- if (evt->interfaceName() == eventNames().interfaceForWheelEvent) {
+ if (evt->hasInterface(eventNames().interfaceForWheelEvent)) {
m_inputType->handleWheelEvent(static_cast<WheelEvent*>(evt));
if (evt->defaultHandled())
return;
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (98163 => 98164)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -211,7 +211,7 @@
void HTMLTextAreaElement::defaultEventHandler(Event* event)
{
- if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->interfaceName() == eventNames().interfaceForWheelEvent || event->type() == eventNames().blurEvent))
+ if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(eventNames().interfaceForWheelEvent) || event->type() == eventNames().blurEvent))
forwardEvent(event);
else if (renderer() && event->isBeforeTextInsertedEvent())
handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event));
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (98163 => 98164)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -142,7 +142,7 @@
void TextFieldInputType::forwardEvent(Event* event)
{
- if (element()->renderer() && (event->isMouseEvent() || event->isDragEvent() || event->interfaceName() == eventNames().interfaceForWheelEvent || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {
+ if (element()->renderer() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(eventNames().interfaceForWheelEvent) || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {
RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(element()->renderer());
if (event->type() == eventNames().blurEvent) {
if (RenderBox* innerTextRenderer = innerTextElement()->renderBox()) {
@@ -160,7 +160,7 @@
bool TextFieldInputType::shouldSubmitImplicitly(Event* event)
{
- return (event->type() == eventNames().textInputEvent && event->interfaceName() == eventNames().interfaceForTextEvent && static_cast<TextEvent*>(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
+ return (event->type() == eventNames().textInputEvent && event->hasInterface(eventNames().interfaceForTextEvent) && static_cast<TextEvent*>(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
}
RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle*) const
Modified: trunk/Source/WebCore/inspector/InspectorDOMStorageResource.cpp (98163 => 98164)
--- trunk/Source/WebCore/inspector/InspectorDOMStorageResource.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebCore/inspector/InspectorDOMStorageResource.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -102,7 +102,7 @@
void InspectorDOMStorageResource::handleEvent(ScriptExecutionContext*, Event* event)
{
ASSERT(m_frontend);
- if (event->type() != eventNames().storageEvent || event->interfaceName() != eventNames().interfaceForStorageEvent)
+ if (event->type() != eventNames().storageEvent || event->hasInterface(eventNames().interfaceForStorageEvent))
return;
StorageEvent* storageEvent = static_cast<StorageEvent*>(event);
Modified: trunk/Source/WebKit/chromium/ChangeLog (98163 => 98164)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-10-21 22:56:39 UTC (rev 98164)
@@ -1,5 +1,31 @@
2011-10-21 Adam Barth <aba...@webkit.org>
+ Introduce Event::hasInterface to make uses of interfaceName more readable
+ https://bugs.webkit.org/show_bug.cgi?id=70652
+
+ Reviewed by Eric Seidel.
+
+ Update call sites to the new interface.
+
+ * src/WebDOMEvent.cpp:
+ (WebKit::WebDOMEvent::isMutationEvent):
+ (WebKit::WebDOMEvent::isTextEvent):
+ (WebKit::WebDOMEvent::isCompositionEvent):
+ (WebKit::WebDOMEvent::isMessageEvent):
+ (WebKit::WebDOMEvent::isWheelEvent):
+ (WebKit::WebDOMEvent::isOverflowEvent):
+ (WebKit::WebDOMEvent::isPageTransitionEvent):
+ (WebKit::WebDOMEvent::isPopStateEvent):
+ (WebKit::WebDOMEvent::isProgressEvent):
+ (WebKit::WebDOMEvent::isXMLHttpRequestProgressEvent):
+ (WebKit::WebDOMEvent::isWebKitAnimationEvent):
+ (WebKit::WebDOMEvent::isWebKitTransitionEvent):
+ (WebKit::WebDOMEvent::isBeforeLoadEvent):
+ * src/WebPluginContainerImpl.cpp:
+ (WebKit::WebPluginContainerImpl::handleEvent):
+
+2011-10-21 Adam Barth <aba...@webkit.org>
+
Event.h has too many virtual isMumbleEvent() functions
https://bugs.webkit.org/show_bug.cgi?id=70636
Modified: trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp (98163 => 98164)
--- trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebKit/chromium/src/WebDOMEvent.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -36,6 +36,8 @@
#include "Node.h"
#include <wtf/PassRefPtr.h>
+using WebCore::eventNames;
+
namespace WebKit {
class WebDOMEventPrivate : public WebCore::Event {
@@ -124,19 +126,19 @@
bool WebDOMEvent::isMutationEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForMutationEvent;
+ return m_private->hasInterface(WebCore::eventNames().interfaceForMutationEvent);
}
bool WebDOMEvent::isTextEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForTextEvent;
+ return m_private->hasInterface(eventNames().interfaceForTextEvent);
}
bool WebDOMEvent::isCompositionEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForCompositionEvent;
+ return m_private->hasInterface(eventNames().interfaceForCompositionEvent);
}
bool WebDOMEvent::isDragEvent() const
@@ -154,13 +156,13 @@
bool WebDOMEvent::isMessageEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForMessageEvent;
+ return m_private->hasInterface(eventNames().interfaceForMessageEvent);
}
bool WebDOMEvent::isWheelEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForWheelEvent;
+ return m_private->hasInterface(eventNames().interfaceForWheelEvent);
}
bool WebDOMEvent::isBeforeTextInsertedEvent() const
@@ -172,49 +174,49 @@
bool WebDOMEvent::isOverflowEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForOverflowEvent;
+ return m_private->hasInterface(eventNames().interfaceForOverflowEvent);
}
bool WebDOMEvent::isPageTransitionEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForPageTransitionEvent;
+ return m_private->hasInterface(eventNames().interfaceForPageTransitionEvent);
}
bool WebDOMEvent::isPopStateEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForPopStateEvent;
+ return m_private->hasInterface(eventNames().interfaceForPopStateEvent);
}
bool WebDOMEvent::isProgressEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForProgressEvent;
+ return m_private->hasInterface(eventNames().interfaceForProgressEvent);
}
bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForXMLHttpRequestProgressEvent;
+ return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent);
}
bool WebDOMEvent::isWebKitAnimationEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForWebKitAnimationEvent;
+ return m_private->hasInterface(eventNames().interfaceForWebKitAnimationEvent);
}
bool WebDOMEvent::isWebKitTransitionEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForWebKitTransitionEvent;
+ return m_private->hasInterface(eventNames().interfaceForWebKitTransitionEvent);
}
bool WebDOMEvent::isBeforeLoadEvent() const
{
ASSERT(m_private);
- return m_private->interfaceName() == WebCore::eventNames().interfaceForBeforeLoadEvent;
+ return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (98163 => 98164)
--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp 2011-10-21 22:52:29 UTC (rev 98163)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp 2011-10-21 22:56:39 UTC (rev 98164)
@@ -186,7 +186,7 @@
// where mozilla behaves differently than the spec.
if (event->isMouseEvent())
handleMouseEvent(static_cast<MouseEvent*>(event));
- else if (event->interfaceName() == eventNames().interfaceForWheelEvent)
+ else if (event->hasInterface(eventNames().interfaceForWheelEvent))
handleWheelEvent(static_cast<WheelEvent*>(event));
else if (event->isKeyboardEvent())
handleKeyboardEvent(static_cast<KeyboardEvent*>(event));