Changeset 199878 in webkit
- Timestamp:
- Apr 22, 2016 8:59:10 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199877 r199878 1 2016-04-22 Chris Dumez <cdumez@apple.com> 2 3 Drop [UsePointersEvenForNonNullableObjectArguments] from MutationObserver 4 https://bugs.webkit.org/show_bug.cgi?id=156890 5 6 Reviewed by Darin Adler. 7 8 Rebaseline now that MutationObserver.observe() throws a TypeError instead 9 of a NOT_FOUND_ERR when passed a null Node. 10 11 * fast/dom/MutationObserver/observe-exceptions-expected.txt: 12 1 13 2016-04-22 Dave Hyatt <hyatt@apple.com> 2 14 -
trunk/LayoutTests/fast/dom/MutationObserver/observe-exceptions-expected.txt
r189271 r199878 8 8 PASS observer.observe(undefined) threw exception TypeError: Not enough arguments. 9 9 PASS observer.observe(document.body) threw exception TypeError: Not enough arguments. 10 PASS observer.observe(document.body, null) threw exception Error: SyntaxError: DOM Exception 12.11 PASS observer.observe(document.body, undefined) threw exception Error: SyntaxError: DOM Exception 12.12 PASS observer.observe(null, {attributes: true}) threw exception Error: NotFoundError: DOM Exception 8.13 PASS observer.observe(undefined, {attributes: true}) threw exception Error: NotFoundError: DOM Exception 8.14 PASS observer.observe(document.body, {subtree: true}) threw exception Error: SyntaxError: DOM Exception 12.10 PASS observer.observe(document.body, null) threw exception TypeError: Type error. 11 PASS observer.observe(document.body, undefined) threw exception TypeError: Type error. 12 PASS observer.observe(null, {attributes: true}) threw exception TypeError: Type error. 13 PASS observer.observe(undefined, {attributes: true}) threw exception TypeError: Type error. 14 PASS observer.observe(document.body, {subtree: true}) threw exception TypeError: Type error. 15 15 PASS observer.observe(document.body, {childList: true, attributeOldValue: true}) did not throw exception. 16 16 PASS observer.observe(document.body, {attributes: true, characterDataOldValue: true}) did not throw exception. 17 17 PASS observer.observe(document.body, {characterData: true, attributeFilter: ["id"]}) did not throw exception. 18 PASS observer.observe(document.body, {attributes: false, attributeOldValue: true}) threw exception Error: SyntaxError: DOM Exception 12.19 PASS observer.observe(document.body, {attributes: false, attributeFilter: ["id"]}) threw exception Error: SyntaxError: DOM Exception 12.20 PASS observer.observe(document.body, {characterData: false, characterDataOldValue: true}) threw exception Error: SyntaxError: DOM Exception 12.18 PASS observer.observe(document.body, {attributes: false, attributeOldValue: true}) threw exception TypeError: Type error. 19 PASS observer.observe(document.body, {attributes: false, attributeFilter: ["id"]}) threw exception TypeError: Type error. 20 PASS observer.observe(document.body, {characterData: false, characterDataOldValue: true}) threw exception TypeError: Type error. 21 21 PASS successfullyParsed is true 22 22 -
trunk/Source/WebCore/ChangeLog
r199877 r199878 1 2016-04-22 Chris Dumez <cdumez@apple.com> 2 3 Drop [UsePointersEvenForNonNullableObjectArguments] from MutationObserver 4 https://bugs.webkit.org/show_bug.cgi?id=156890 5 6 Reviewed by Darin Adler. 7 8 Drop [UsePointersEvenForNonNullableObjectArguments] from MutationObserver 9 and clean up / modernize the code a bit. There is not significant Web- 10 exposed behavior change except that MutationObserver.observe() now throws 11 a different kind of exception (a TypeError as per Web IDL) when passed in 12 a null Node. 13 14 No new tests, rebaselined existing test. 15 16 * bindings/js/JSMutationCallback.cpp: 17 (WebCore::JSMutationCallback::call): 18 * bindings/js/JSMutationCallback.h: 19 * bindings/js/JSMutationObserverCustom.cpp: 20 (WebCore::constructJSMutationObserver): 21 * css/PropertySetCSSStyleDeclaration.cpp: 22 * dom/ChildListMutationScope.cpp: 23 (WebCore::ChildListMutationAccumulator::enqueueMutationRecord): 24 * dom/MutationCallback.h: 25 * dom/MutationObserver.cpp: 26 (WebCore::MutationObserver::create): 27 (WebCore::MutationObserver::MutationObserver): 28 (WebCore::MutationObserver::observe): 29 (WebCore::MutationObserver::takeRecords): 30 (WebCore::MutationObserver::enqueueMutationRecord): 31 (WebCore::MutationObserver::deliver): 32 (WebCore::MutationObserver::disconnect): Deleted. 33 * dom/MutationObserver.h: 34 * dom/MutationObserver.idl: 35 * dom/MutationObserverInterestGroup.cpp: 36 (WebCore::MutationObserverInterestGroup::enqueueMutationRecord): 37 * dom/MutationObserverInterestGroup.h: 38 * dom/MutationRecord.cpp: 39 (WebCore::MutationRecord::createChildList): 40 * dom/MutationRecord.h: 41 1 42 2016-04-22 Dave Hyatt <hyatt@apple.com> 2 43 -
trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp
r197614 r199878 52 52 } 53 53 54 void JSMutationCallback::call(const Vector<Ref Ptr<MutationRecord>>& mutations, MutationObserver* observer)54 void JSMutationCallback::call(const Vector<Ref<MutationRecord>>& mutations, MutationObserver* observer) 55 55 { 56 56 if (!canInvokeCallback()) -
trunk/Source/WebCore/bindings/js/JSMutationCallback.h
r197563 r199878 47 47 virtual ~JSMutationCallback(); 48 48 49 void call(const Vector<Ref Ptr<MutationRecord>>&, MutationObserver*) override;49 void call(const Vector<Ref<MutationRecord>>&, MutationObserver*) override; 50 50 51 51 ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); } -
trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp
r197614 r199878 55 55 56 56 DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee()); 57 RefPtr<JSMutationCallback>callback = JSMutationCallback::create(object, jsConstructor->globalObject());58 JSObject* jsObserver = asObject(toJS(exec, jsConstructor->globalObject(), MutationObserver::create( callback.release())));57 auto callback = JSMutationCallback::create(object, jsConstructor->globalObject()); 58 JSObject* jsObserver = asObject(toJS(exec, jsConstructor->globalObject(), MutationObserver::create(WTFMove(callback)))); 59 59 PrivateName propertyName; 60 60 jsObserver->putDirect(jsConstructor->globalObject()->vm(), propertyName, object); -
trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
r198284 r199878 78 78 79 79 if (m_mutation && s_shouldDeliver) 80 m_mutationRecipients->enqueueMutationRecord(m_mutation );80 m_mutationRecipients->enqueueMutationRecord(m_mutation.releaseNonNull()); 81 81 82 82 s_shouldDeliver = false; -
trunk/Source/WebCore/dom/ChildListMutationScope.cpp
r194819 r199878 128 128 ASSERT(!isEmpty()); 129 129 130 RefPtr<NodeList> addedNodes = StaticNodeList::adopt(m_addedNodes); 131 RefPtr<NodeList> removedNodes = StaticNodeList::adopt(m_removedNodes); 132 RefPtr<MutationRecord> record = MutationRecord::createChildList(m_target, addedNodes.release(), removedNodes.release(), m_previousSibling.release(), m_nextSibling.release()); 133 m_observers->enqueueMutationRecord(record.release()); 130 auto record = MutationRecord::createChildList(m_target, StaticNodeList::adopt(m_addedNodes), StaticNodeList::adopt(m_removedNodes), WTFMove(m_previousSibling), WTFMove(m_nextSibling)); 131 m_observers->enqueueMutationRecord(WTFMove(record)); 134 132 m_lastAdded = nullptr; 135 133 ASSERT(isEmpty()); -
trunk/Source/WebCore/dom/MutationCallback.h
r157653 r199878 45 45 virtual ~MutationCallback() { } 46 46 47 virtual void call(const Vector<Ref Ptr<MutationRecord>>&, MutationObserver*) = 0;47 virtual void call(const Vector<Ref<MutationRecord>>&, MutationObserver*) = 0; 48 48 virtual ScriptExecutionContext* scriptExecutionContext() const = 0; 49 49 }; -
trunk/Source/WebCore/dom/MutationObserver.cpp
r199735 r199878 47 47 static unsigned s_observerPriority = 0; 48 48 49 Ref<MutationObserver> MutationObserver::create( PassRefPtr<MutationCallback>callback)50 { 51 ASSERT(isMainThread()); 52 return adoptRef(*new MutationObserver( callback));53 } 54 55 MutationObserver::MutationObserver( PassRefPtr<MutationCallback>callback)56 : m_callback( callback)49 Ref<MutationObserver> MutationObserver::create(Ref<MutationCallback>&& callback) 50 { 51 ASSERT(isMainThread()); 52 return adoptRef(*new MutationObserver(WTFMove(callback))); 53 } 54 55 MutationObserver::MutationObserver(Ref<MutationCallback>&& callback) 56 : m_callback(WTFMove(callback)) 57 57 , m_priority(s_observerPriority++) 58 58 { … … 72 72 } 73 73 74 void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary, ExceptionCode& ec) 75 { 76 if (!node) { 77 ec = NOT_FOUND_ERR; 78 return; 79 } 80 74 void MutationObserver::observe(Node& node, const Dictionary& optionsDictionary, ExceptionCode& ec) 75 { 81 76 static const struct { 82 77 const char* name; … … 108 103 109 104 if (!validateOptions(options)) { 110 ec = SYNTAX_ERR;111 return; 112 } 113 114 node ->registerMutationObserver(this, options, attributeFilter);115 } 116 117 Vector<Ref Ptr<MutationRecord>> MutationObserver::takeRecords()118 { 119 Vector<Ref Ptr<MutationRecord>> records;105 ec = TypeError; 106 return; 107 } 108 109 node.registerMutationObserver(this, options, attributeFilter); 110 } 111 112 Vector<Ref<MutationRecord>> MutationObserver::takeRecords() 113 { 114 Vector<Ref<MutationRecord>> records; 120 115 records.swap(m_records); 121 116 return records; … … 190 185 } 191 186 192 void MutationObserver::enqueueMutationRecord( PassRefPtr<MutationRecord>mutation)193 { 194 ASSERT(isMainThread()); 195 m_records.append( mutation);187 void MutationObserver::enqueueMutationRecord(Ref<MutationRecord>&& mutation) 188 { 189 ASSERT(isMainThread()); 190 m_records.append(WTFMove(mutation)); 196 191 activeMutationObservers().add(this); 197 192 … … 237 232 return; 238 233 239 Vector<Ref Ptr<MutationRecord>> records;234 Vector<Ref<MutationRecord>> records; 240 235 records.swap(m_records); 241 236 -
trunk/Source/WebCore/dom/MutationObserver.h
r193286 r199878 74 74 }; 75 75 76 static Ref<MutationObserver> create( PassRefPtr<MutationCallback>);76 static Ref<MutationObserver> create(Ref<MutationCallback>&&); 77 77 78 78 ~MutationObserver(); 79 79 80 void observe(Node *, const Dictionary&, ExceptionCode&);81 Vector<Ref Ptr<MutationRecord>> takeRecords();80 void observe(Node&, const Dictionary&, ExceptionCode&); 81 Vector<Ref<MutationRecord>> takeRecords(); 82 82 void disconnect(); 83 83 void observationStarted(MutationObserverRegistration*); 84 84 void observationEnded(MutationObserverRegistration*); 85 void enqueueMutationRecord( PassRefPtr<MutationRecord>);85 void enqueueMutationRecord(Ref<MutationRecord>&&); 86 86 void setHasTransientRegistration(); 87 87 bool canDeliver(); … … 92 92 struct ObserverLessThan; 93 93 94 explicit MutationObserver( PassRefPtr<MutationCallback>);94 explicit MutationObserver(Ref<MutationCallback>&&); 95 95 void deliver(); 96 96 … … 98 98 static bool validateOptions(MutationObserverOptions); 99 99 100 Ref Ptr<MutationCallback> m_callback;101 Vector<Ref Ptr<MutationRecord>> m_records;100 Ref<MutationCallback> m_callback; 101 Vector<Ref<MutationRecord>> m_records; 102 102 HashSet<MutationObserverRegistration*> m_registrations; 103 103 unsigned m_priority; -
trunk/Source/WebCore/dom/MutationObserver.idl
r198833 r199878 32 32 CustomConstructor(MutationCallback callback), 33 33 CustomIsReachable, 34 UsePointersEvenForNonNullableObjectArguments,35 34 ImplementationLacksVTable, 36 35 ] interface MutationObserver { -
trunk/Source/WebCore/dom/MutationObserverInterestGroup.cpp
r195243 r199878 65 65 } 66 66 67 void MutationObserverInterestGroup::enqueueMutationRecord( PassRefPtr<MutationRecord> prpMutation)67 void MutationObserverInterestGroup::enqueueMutationRecord(Ref<MutationRecord>&& mutation) 68 68 { 69 RefPtr<MutationRecord> mutation = prpMutation;70 69 RefPtr<MutationRecord> mutationWithNullOldValue; 71 70 for (auto& observerOptionsPair : m_observers) { 72 71 MutationObserver* observer = observerOptionsPair.key; 73 72 if (hasOldValue(observerOptionsPair.value)) { 74 observer->enqueueMutationRecord(mutation );73 observer->enqueueMutationRecord(mutation.copyRef()); 75 74 continue; 76 75 } 77 76 if (!mutationWithNullOldValue) { 78 77 if (mutation->oldValue().isNull()) 79 mutationWithNullOldValue = mutation ;78 mutationWithNullOldValue = mutation.ptr(); 80 79 else 81 mutationWithNullOldValue = MutationRecord::createWithNullOldValue( *mutation).ptr();80 mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).ptr(); 82 81 } 83 observer->enqueueMutationRecord( mutationWithNullOldValue);82 observer->enqueueMutationRecord(*mutationWithNullOldValue); 84 83 } 85 84 } -
trunk/Source/WebCore/dom/MutationObserverInterestGroup.h
r199735 r199878 71 71 72 72 bool isOldValueRequested(); 73 void enqueueMutationRecord( PassRefPtr<MutationRecord>);73 void enqueueMutationRecord(Ref<MutationRecord>&&); 74 74 75 75 private: -
trunk/Source/WebCore/dom/MutationRecord.cpp
r197563 r199878 43 43 class ChildListRecord : public MutationRecord { 44 44 public: 45 ChildListRecord(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node>nextSibling)45 ChildListRecord(ContainerNode& target, Ref<NodeList>&& added, Ref<NodeList>&& removed, RefPtr<Node>&& previousSibling, RefPtr<Node>&& nextSibling) 46 46 : m_target(target) 47 , m_addedNodes( added)48 , m_removedNodes( removed)49 , m_previousSibling( previousSibling)50 , m_nextSibling( nextSibling)47 , m_addedNodes(WTFMove(added)) 48 , m_removedNodes(WTFMove(removed)) 49 , m_previousSibling(WTFMove(previousSibling)) 50 , m_nextSibling(WTFMove(nextSibling)) 51 51 { 52 52 } … … 165 165 } // namespace 166 166 167 Ref<MutationRecord> MutationRecord::createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node>nextSibling)167 Ref<MutationRecord> MutationRecord::createChildList(ContainerNode& target, Ref<NodeList>&& added, Ref<NodeList>&& removed, RefPtr<Node>&& previousSibling, RefPtr<Node>&& nextSibling) 168 168 { 169 return adoptRef(static_cast<MutationRecord&>(*new ChildListRecord(target, added, removed, previousSibling, nextSibling)));169 return adoptRef(static_cast<MutationRecord&>(*new ChildListRecord(target, WTFMove(added), WTFMove(removed), WTFMove(previousSibling), WTFMove(nextSibling)))); 170 170 } 171 171 -
trunk/Source/WebCore/dom/MutationRecord.h
r195243 r199878 48 48 class MutationRecord : public RefCounted<MutationRecord> { 49 49 public: 50 static Ref<MutationRecord> createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node>nextSibling);50 static Ref<MutationRecord> createChildList(ContainerNode& target, Ref<NodeList>&& added, Ref<NodeList>&& removed, RefPtr<Node>&& previousSibling, RefPtr<Node>&& nextSibling); 51 51 static Ref<MutationRecord> createAttributes(Element& target, const QualifiedName&, const AtomicString& oldValue); 52 52 static Ref<MutationRecord> createCharacterData(CharacterData& target, const String& oldValue);
Note: See TracChangeset
for help on using the changeset viewer.