Diff
Modified: trunk/Source/WebCore/ChangeLog (97713 => 97714)
--- trunk/Source/WebCore/ChangeLog 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/ChangeLog 2011-10-18 04:31:00 UTC (rev 97714)
@@ -1,3 +1,36 @@
+2011-10-17 Adam Klein <[email protected]>
+
+ Parse MutationObserverOptions directly into a bitfield
+ https://bugs.webkit.org/show_bug.cgi?id=70287
+
+ Reviewed by Ryosuke Niwa.
+
+ Replaces the MutationObserverOptions class with a typedef,
+ used to pass a bitfield composed of enums defined in
+ WebKitMutationObserver.h.
+
+ No new tests because no behavior should change.
+
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSDictionary.h: Removed now-unused method.
+ * bindings/js/JSWebKitMutationObserverCustom.cpp:
+ (WebCore::JSWebKitMutationObserver::observe):
+ * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
+ (WebCore::V8WebKitMutationObserver::observeCallback):
+ * dom/MutationObserverOptions.h: Removed.
+ * dom/Node.cpp:
+ (WebCore::Node::registerMutationObserver):
+ * dom/Node.h:
+ * dom/NodeRareData.h:
+ (WebCore::MutationObserverEntry::MutationObserverEntry):
+ (WebCore::MutationObserverEntry::matches):
+ * dom/WebKitMutationObserver.cpp:
+ (WebCore::WebKitMutationObserver::observe):
+ * dom/WebKitMutationObserver.h:
+
2011-10-17 Luke Macpherson <[email protected]>
Add compile-time asserts for RenderStyle::(Non)InheritedFlags size.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (97713 => 97714)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-10-18 04:31:00 UTC (rev 97714)
@@ -1237,7 +1237,6 @@
Source/WebCore/dom/MutationCallback.h \
Source/WebCore/dom/MutationEvent.cpp \
Source/WebCore/dom/MutationEvent.h \
- Source/WebCore/dom/MutationObserverOptions.h \
Source/WebCore/dom/MutationRecord.cpp \
Source/WebCore/dom/MutationRecord.h \
Source/WebCore/dom/NamedNodeMap.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (97713 => 97714)
--- trunk/Source/WebCore/WebCore.gypi 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/WebCore.gypi 2011-10-18 04:31:00 UTC (rev 97714)
@@ -5227,7 +5227,6 @@
'dom/MutationCallback.h',
'dom/MutationEvent.cpp',
'dom/MutationEvent.h',
- 'dom/MutationObserverOptions.h',
'dom/MutationRecord.cpp',
'dom/MutationRecord.h',
'dom/NameNodeList.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (97713 => 97714)
--- trunk/Source/WebCore/WebCore.pro 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/WebCore.pro 2011-10-18 04:31:00 UTC (rev 97714)
@@ -1555,7 +1555,6 @@
dom/MouseRelatedEvent.h \
dom/MutationCallback.h \
dom/MutationEvent.h \
- dom/MutationObserverOptions.h \
dom/MutationRecord.h \
dom/NamedNodeMap.h \
dom/NameNodeList.h \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (97713 => 97714)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-18 04:31:00 UTC (rev 97714)
@@ -5469,7 +5469,6 @@
C6F0900A14327B6100685849 /* MutationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0900114327B6100685849 /* MutationCallback.h */; };
C6F0900E14327B6100685849 /* WebKitMutationObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0900514327B6100685849 /* WebKitMutationObserver.cpp */; };
C6F0900F14327B6100685849 /* WebKitMutationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0900614327B6100685849 /* WebKitMutationObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
- C6F0901114327B6100685849 /* MutationObserverOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0900814327B6100685849 /* MutationObserverOptions.h */; };
C6F0902814327D4F00685849 /* JSMutationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0902014327D4F00685849 /* JSMutationCallback.cpp */; };
C6F0902914327D4F00685849 /* JSMutationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F0902114327D4F00685849 /* JSMutationCallback.h */; };
C6F0902C14327D4F00685849 /* JSWebKitMutationObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6F0902414327D4F00685849 /* JSWebKitMutationObserver.cpp */; };
@@ -12771,7 +12770,6 @@
C6F0900514327B6100685849 /* WebKitMutationObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitMutationObserver.cpp; sourceTree = "<group>"; };
C6F0900614327B6100685849 /* WebKitMutationObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitMutationObserver.h; sourceTree = "<group>"; };
C6F0900714327B6100685849 /* WebKitMutationObserver.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitMutationObserver.idl; sourceTree = "<group>"; };
- C6F0900814327B6100685849 /* MutationObserverOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutationObserverOptions.h; sourceTree = "<group>"; };
C6F0902014327D4F00685849 /* JSMutationCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationCallback.cpp; sourceTree = "<group>"; };
C6F0902114327D4F00685849 /* JSMutationCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMutationCallback.h; sourceTree = "<group>"; };
C6F0902414327D4F00685849 /* JSWebKitMutationObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitMutationObserver.cpp; sourceTree = "<group>"; };
@@ -21128,7 +21126,6 @@
85031B330A44EFC700F992E0 /* MutationEvent.cpp */,
85031B340A44EFC700F992E0 /* MutationEvent.h */,
93EEC1F309C2877700C515D1 /* MutationEvent.idl */,
- C6F0900814327B6100685849 /* MutationObserverOptions.h */,
C6F08FB91430FE8F00685849 /* MutationRecord.cpp */,
C6F08FBA1430FE8F00685849 /* MutationRecord.h */,
C6F08FBB1430FE8F00685849 /* MutationRecord.idl */,
@@ -23634,7 +23631,6 @@
B1AD4E6313A12A0B00846B27 /* MutableTextTrack.h in Headers */,
C6F0900A14327B6100685849 /* MutationCallback.h in Headers */,
85031B4A0A44EFC700F992E0 /* MutationEvent.h in Headers */,
- C6F0901114327B6100685849 /* MutationObserverOptions.h in Headers */,
C6F08FBD1430FE8F00685849 /* MutationRecord.h in Headers */,
A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */,
A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
Modified: trunk/Source/WebCore/bindings/js/JSDictionary.h (97713 => 97714)
--- trunk/Source/WebCore/bindings/js/JSDictionary.h 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.h 2011-10-18 04:31:00 UTC (rev 97714)
@@ -52,9 +52,6 @@
template <typename T, typename Result>
bool tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&));
- template <typename T>
- bool tryGetProperty(const char* propertyName, T& context, void (T::*setter)(bool));
-
private:
enum GetPropertyResult {
ExceptionThrown,
@@ -106,30 +103,6 @@
return true;
}
-template <typename T>
-bool JSDictionary::tryGetProperty(const char* propertyName, T& context, void (T::*setter)(bool))
-{
- JSC::JSValue value;
- switch (tryGetProperty(propertyName, value)) {
- case ExceptionThrown:
- return false;
- case PropertyFound: {
- bool result;
- convertValue(m_exec, value, result);
-
- if (m_exec->hadException())
- return false;
-
- (context.*setter)(result);
- break;
- }
- case NoPropertyFound:
- break;
- }
-
- return true;
-}
-
template <typename Result>
bool JSDictionary::tryGetProperty(const char* propertyName, Result& finalResult)
{
Modified: trunk/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp (97713 => 97714)
--- trunk/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp 2011-10-18 04:31:00 UTC (rev 97714)
@@ -38,7 +38,6 @@
#include "JSDictionary.h"
#include "JSMutationCallback.h"
#include "JSNode.h"
-#include "MutationObserverOptions.h"
#include "Node.h"
#include "WebKitMutationObserver.h"
#include <runtime/Error.h>
@@ -78,17 +77,23 @@
}
JSDictionary dictionary(exec, optionsObject);
+ MutationObserverOptions options = 0;
+ bool option;
+ if (dictionary.tryGetProperty("childList", option) && option)
+ options |= WebKitMutationObserver::ChildList;
+ if (dictionary.tryGetProperty("attributes", option) && option)
+ options |= WebKitMutationObserver::Attributes;
+ if (dictionary.tryGetProperty("subtree", option) && option)
+ options |= WebKitMutationObserver::Subtree;
+ if (dictionary.tryGetProperty("attributeOldValue", option) && option)
+ options |= WebKitMutationObserver::AttributeOldValue;
+ if (dictionary.tryGetProperty("characterDataOldValue", option) && option)
+ options |= WebKitMutationObserver::CharacterDataOldValue;
- RefPtr<MutationObserverOptions> options = MutationObserverOptions::create();
- if (!dictionary.tryGetProperty("childList", *options, &MutationObserverOptions::setChildList)
- || !dictionary.tryGetProperty("attributes", *options, &MutationObserverOptions::setAttributes)
- || !dictionary.tryGetProperty("characterData", *options, &MutationObserverOptions::setCharacterData)
- || !dictionary.tryGetProperty("subtree", *options, &MutationObserverOptions::setSubtree)
- || !dictionary.tryGetProperty("attributeOldValue", *options, &MutationObserverOptions::setAttributeOldValue)
- || !dictionary.tryGetProperty("characterDataOldValue", *options, &MutationObserverOptions::setCharacterDataOldValue))
+ if (exec->hadException())
return jsUndefined();
- impl()->observe(target, options.get());
+ impl()->observe(target, options);
return jsUndefined();
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp (97713 => 97714)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp 2011-10-18 04:31:00 UTC (rev 97714)
@@ -35,7 +35,6 @@
#include "V8WebKitMutationObserver.h"
#include "ExceptionCode.h"
-#include "MutationObserverOptions.h"
#include "OptionsObject.h"
#include "V8Binding.h"
#include "V8BindingMacros.h"
@@ -86,23 +85,22 @@
return throwError(TYPE_MISMATCH_ERR);
OptionsObject optionsObject(args[1]);
- RefPtr<MutationObserverOptions> options = MutationObserverOptions::create();
-
+ unsigned options = 0;
bool option;
- if (optionsObject.getKeyValue("childList", option))
- options->setChildList(option);
- if (optionsObject.getKeyValue("attributes", option))
- options->setAttributes(option);
- if (optionsObject.getKeyValue("characterData", option))
- options->setCharacterData(option);
- if (optionsObject.getKeyValue("subtree", option))
- options->setSubtree(option);
- if (optionsObject.getKeyValue("attributeOldValue", option))
- options->setAttributeOldValue(option);
- if (optionsObject.getKeyValue("characterDataOldValue", option))
- options->setCharacterDataOldValue(option);
+ if (optionsObject.getKeyValue("childList", option) && option)
+ options |= WebKitMutationObserver::ChildList;
+ if (optionsObject.getKeyValue("attributes", option) && option)
+ options |= WebKitMutationObserver::Attributes;
+ if (optionsObject.getKeyValue("characterData", option) && option)
+ options |= WebKitMutationObserver::CharacterData;
+ if (optionsObject.getKeyValue("subtree", option) && option)
+ options |= WebKitMutationObserver::Subtree;
+ if (optionsObject.getKeyValue("attributeOldValue", option) && option)
+ options |= WebKitMutationObserver::AttributeOldValue;
+ if (optionsObject.getKeyValue("characterDataOldValue", option) && option)
+ options |= WebKitMutationObserver::CharacterDataOldValue;
- imp->observe(target, options.get());
+ imp->observe(target, options);
return v8::Handle<v8::Value>();
}
Deleted: trunk/Source/WebCore/dom/MutationObserverOptions.h (97713 => 97714)
--- trunk/Source/WebCore/dom/MutationObserverOptions.h 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/MutationObserverOptions.h 2011-10-18 04:31:00 UTC (rev 97714)
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MutationObserverOptions_h
-#define MutationObserverOptions_h
-
-#if ENABLE(MUTATION_OBSERVERS)
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class MutationObserverOptions : public RefCounted<MutationObserverOptions> {
-public:
- static PassRefPtr<MutationObserverOptions> create()
- {
- return adoptRef(new MutationObserverOptions);
- }
-
- bool childList() const { return m_childList; }
- void setChildList(bool value) { m_childList = value; }
-
- bool attributes() const { return m_attributes; }
- void setAttributes(bool value) { m_attributes = value; }
-
- bool characterData() const { return m_characterData; }
- void setCharacterData(bool value) { m_characterData = value; }
-
- bool subtree() const { return m_subtree; }
- void setSubtree(bool value) { m_subtree = value; }
-
- bool attributeOldValue() const { return m_attributeOldValue; }
- void setAttributeOldValue(bool value) { m_attributeOldValue = value; }
-
- bool characterDataOldValue() const { return m_attributeOldValue; }
- void setCharacterDataOldValue(bool value) { m_characterDataOldValue = value; }
-
- // FIXME: Figure out how to model this based on the IDL.
- // DOMString[] attributeFilter;
-
-private:
- MutationObserverOptions()
- : m_childList(false)
- , m_attributes(false)
- , m_characterData(false)
- , m_subtree(false)
- , m_attributeOldValue(false)
- , m_characterDataOldValue(false)
- {
- }
-
- bool m_childList;
- bool m_attributes;
- bool m_characterData;
- bool m_subtree;
- bool m_attributeOldValue;
- bool m_characterDataOldValue;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MUTATION_OBSERVERS)
-
-#endif // MutationObserverOptions_h
Modified: trunk/Source/WebCore/dom/Node.cpp (97713 => 97714)
--- trunk/Source/WebCore/dom/Node.cpp 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/Node.cpp 2011-10-18 04:31:00 UTC (rev 97714)
@@ -2705,7 +2705,7 @@
}
}
-Node::MutationRegistrationResult Node::registerMutationObserver(PassRefPtr<WebKitMutationObserver> observer, unsigned char options)
+Node::MutationRegistrationResult Node::registerMutationObserver(PassRefPtr<WebKitMutationObserver> observer, MutationObserverOptions options)
{
Vector<MutationObserverEntry>* observerEntries = ensureMutationObserverEntries();
MutationObserverEntry entry(observer, options);
Modified: trunk/Source/WebCore/dom/Node.h (97713 => 97714)
--- trunk/Source/WebCore/dom/Node.h 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/Node.h 2011-10-18 04:31:00 UTC (rev 97714)
@@ -598,7 +598,7 @@
MutationObserverRegistered,
MutationRegistrationOptionsReset
};
- MutationRegistrationResult registerMutationObserver(PassRefPtr<WebKitMutationObserver>, unsigned char options);
+ MutationRegistrationResult registerMutationObserver(PassRefPtr<WebKitMutationObserver>, MutationObserverOptions);
void unregisterMutationObserver(PassRefPtr<WebKitMutationObserver>);
#endif // ENABLE(MUTATION_OBSERVERS)
Modified: trunk/Source/WebCore/dom/NodeRareData.h (97713 => 97714)
--- trunk/Source/WebCore/dom/NodeRareData.h 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/NodeRareData.h 2011-10-18 04:31:00 UTC (rev 97714)
@@ -90,7 +90,7 @@
#if ENABLE(MUTATION_OBSERVERS)
struct MutationObserverEntry {
- MutationObserverEntry(PassRefPtr<WebKitMutationObserver> observer, unsigned char options)
+ MutationObserverEntry(PassRefPtr<WebKitMutationObserver> observer, MutationObserverOptions options)
: observer(observer)
, options(options)
{
@@ -101,13 +101,13 @@
return observer == other.observer;
}
- bool matches(unsigned char options) const
+ bool matches(MutationObserverOptions options) const
{
return this->options & options;
}
RefPtr<WebKitMutationObserver> observer;
- unsigned char options;
+ MutationObserverOptions options;
};
#endif // ENABLE(MUTATION_OBSERVERS)
Modified: trunk/Source/WebCore/dom/WebKitMutationObserver.cpp (97713 => 97714)
--- trunk/Source/WebCore/dom/WebKitMutationObserver.cpp 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/WebKitMutationObserver.cpp 2011-10-18 04:31:00 UTC (rev 97714)
@@ -34,7 +34,6 @@
#include "WebKitMutationObserver.h"
-#include "MutationObserverOptions.h"
#include "MutationCallback.h"
#include "MutationRecord.h"
#include "Node.h"
@@ -56,20 +55,11 @@
{
}
-void WebKitMutationObserver::observe(Node* node, MutationObserverOptions* options)
+void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options)
{
- unsigned char optionFlags = 0;
+ // FIXME: More options composition work needs to be done here, e.g., validation.
- // FIXME: Push composition of the optionFlags into the custom binding.
- if (options->childList())
- optionFlags |= ChildList;
- if (options->attributes())
- optionFlags |= Attributes;
- if (options->characterData())
- optionFlags |= CharacterData;
- // FIXME: More options composition work needs to be done here.
-
- if (node->registerMutationObserver(this, optionFlags) == Node::MutationObserverRegistered)
+ if (node->registerMutationObserver(this, options) == Node::MutationObserverRegistered)
m_observedNodes.append(node);
}
Modified: trunk/Source/WebCore/dom/WebKitMutationObserver.h (97713 => 97714)
--- trunk/Source/WebCore/dom/WebKitMutationObserver.h 2011-10-18 04:29:49 UTC (rev 97713)
+++ trunk/Source/WebCore/dom/WebKitMutationObserver.h 2011-10-18 04:31:00 UTC (rev 97714)
@@ -41,10 +41,11 @@
namespace WebCore {
class MutationCallback;
-class MutationObserverOptions;
class MutationRecord;
class Node;
+typedef unsigned char MutationObserverOptions;
+
class WebKitMutationObserver : public RefCounted<WebKitMutationObserver> {
public:
enum MutationType {
@@ -65,7 +66,7 @@
~WebKitMutationObserver();
- void observe(Node*, MutationObserverOptions*);
+ void observe(Node*, MutationObserverOptions);
void disconnect();
void observedNodeDestructed(Node*);
void enqueueMutationRecord(PassRefPtr<MutationRecord>);