Changeset 126113 in webkit
- Timestamp:
- Aug 20, 2012 6:14:51 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126110 r126113 1 2012-08-20 Adam Klein <adamk@chromium.org> 2 3 Allow MutationEvents to be enabled/disabled per context 4 https://bugs.webkit.org/show_bug.cgi?id=94016 5 6 Reviewed by Ojan Vafai. 7 8 Chromium wants to be able to turn MutationEvents off for some 9 Documents (e.g., for Apps V2). This patch makes the firing (and the 10 constructor on DOMWindow) of MutationEvents a per-context feature, with 11 the default being enabled. 12 13 No functional change (since the feature defaults to enabled). 14 It's not clear to me that there's a way to test this in DRT without 15 adding a special hook for this one feature. It will be tested in 16 Chromium once it's implemented in Chromium. 17 18 * dom/ContextFeatures.cpp: 19 (WebCore::ContextFeatures::mutationEventsEnabled): Add new method, 20 with the default being enabled. 21 * dom/ContextFeatures.h: 22 * dom/Document.cpp: 23 (WebCore::Document::addMutationEventListenerTypeIfEnabled): Add new 24 method that checks the ContextFeature flag before adding the passed-in 25 listener type. 26 (WebCore::Document::addListenerTypeIfNeeded): Call the new method 27 instead of addListenerType for MutationEvent types. 28 * dom/Document.h: 29 (WebCore::Document::addListenerType): Make private to avoid anyone 30 outside Document from enabling MutationEvent listeners. All callers 31 must go through addListenerTypeIfNeeded. 32 1 33 2012-08-20 Levi Weintraub <leviw@chromium.org> 2 34 -
trunk/Source/WebCore/dom/ContextFeatures.cpp
r123535 r126113 112 112 } 113 113 114 bool ContextFeatures::mutationEventsEnabled(Document* document) 115 { 116 ASSERT(document); 117 if (!document) 118 return true; 119 return document->contextFeatures()->isEnabled(document, MutationEvents, true); 120 } 121 114 122 void provideContextFeaturesTo(Page* page, ContextFeaturesClient* client) 115 123 { -
trunk/Source/WebCore/dom/ContextFeatures.h
r123535 r126113 45 45 PagePopup, 46 46 HTMLNotifications, 47 MutationEvents, 47 48 FeatureTypeSize // Should be the last entry. 48 49 }; … … 57 58 static bool pagePopupEnabled(Document*); 58 59 static bool htmlNotificationsEnabled(Document*); 60 static bool mutationEventsEnabled(Document*); 59 61 60 62 bool isEnabled(Document*, FeatureType, bool) const; -
trunk/Source/WebCore/dom/Document.cpp
r126080 r126113 4122 4122 } 4123 4123 4124 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 4125 { 4126 if (ContextFeatures::mutationEventsEnabled(this)) 4127 addListenerType(listenerType); 4128 } 4129 4124 4130 void Document::addListenerTypeIfNeeded(const AtomicString& eventType) 4125 4131 { 4126 4132 if (eventType == eventNames().DOMSubtreeModifiedEvent) 4127 add ListenerType(DOMSUBTREEMODIFIED_LISTENER);4133 addMutationEventListenerTypeIfEnabled(DOMSUBTREEMODIFIED_LISTENER); 4128 4134 else if (eventType == eventNames().DOMNodeInsertedEvent) 4129 add ListenerType(DOMNODEINSERTED_LISTENER);4135 addMutationEventListenerTypeIfEnabled(DOMNODEINSERTED_LISTENER); 4130 4136 else if (eventType == eventNames().DOMNodeRemovedEvent) 4131 add ListenerType(DOMNODEREMOVED_LISTENER);4137 addMutationEventListenerTypeIfEnabled(DOMNODEREMOVED_LISTENER); 4132 4138 else if (eventType == eventNames().DOMNodeRemovedFromDocumentEvent) 4133 add ListenerType(DOMNODEREMOVEDFROMDOCUMENT_LISTENER);4139 addMutationEventListenerTypeIfEnabled(DOMNODEREMOVEDFROMDOCUMENT_LISTENER); 4134 4140 else if (eventType == eventNames().DOMNodeInsertedIntoDocumentEvent) 4135 add ListenerType(DOMNODEINSERTEDINTODOCUMENT_LISTENER);4141 addMutationEventListenerTypeIfEnabled(DOMNODEINSERTEDINTODOCUMENT_LISTENER); 4136 4142 else if (eventType == eventNames().DOMAttrModifiedEvent) 4137 add ListenerType(DOMATTRMODIFIED_LISTENER);4143 addMutationEventListenerTypeIfEnabled(DOMATTRMODIFIED_LISTENER); 4138 4144 else if (eventType == eventNames().DOMCharacterDataModifiedEvent) 4139 add ListenerType(DOMCHARACTERDATAMODIFIED_LISTENER);4145 addMutationEventListenerTypeIfEnabled(DOMCHARACTERDATAMODIFIED_LISTENER); 4140 4146 else if (eventType == eventNames().overflowchangedEvent) 4141 4147 addListenerType(OVERFLOWCHANGED_LISTENER); -
trunk/Source/WebCore/dom/Document.h
r126080 r126113 808 808 809 809 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); } 810 void addListenerType(ListenerType listenerType) { m_listenerTypes = m_listenerTypes | listenerType; }811 810 void addListenerTypeIfNeeded(const AtomicString& eventType); 812 811 … … 1268 1267 void setVisualUpdatesAllowed(bool); 1269 1268 void visualUpdatesSuppressionTimerFired(Timer<Document>*); 1269 1270 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; } 1271 void addMutationEventListenerTypeIfEnabled(ListenerType); 1270 1272 1271 1273 int m_guardRefCount; -
trunk/Source/WebKit/chromium/ChangeLog
r126111 r126113 1 2012-08-20 Adam Klein <adamk@chromium.org> 2 3 Allow MutationEvents to be enabled/disabled per context 4 https://bugs.webkit.org/show_bug.cgi?id=94016 5 6 Reviewed by Ojan Vafai. 7 8 Add Chromium/WebKit API for enabling/disabling MutationEvents via 9 WebPermissionClient. 10 11 * public/WebPermissionClient.h: 12 (WebPermissionClient): 13 (WebKit::WebPermissionClient::allowMutationEvents): 14 * src/ContextFeaturesClientImpl.cpp: 15 (WebKit::ContextFeaturesClientImpl::askIfIsEnabled): 16 1 17 2012-08-20 Sheriff Bot <webkit.review.bot@gmail.com> 2 18 -
trunk/Source/WebKit/chromium/public/WebPermissionClient.h
r123535 r126113 97 97 virtual bool allowHTMLNotifications(const WebDocument&) { return true; } 98 98 99 // Controls whether to enable MutationEvents for this document. 100 // The common use case of this method is actually to selectively disable MutationEvents, 101 // but it's been named for consistency with the rest of the interface. 102 virtual bool allowMutationEvents(const WebDocument&, bool defaultValue) { return defaultValue; } 103 99 104 // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled. 100 105 virtual void didNotAllowPlugins(WebFrame*) { } -
trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp
r123535 r126113 146 146 case ContextFeatures::HTMLNotifications: 147 147 return m_client->allowHTMLNotifications(WebDocument(document)); 148 case ContextFeatures::MutationEvents: 149 return m_client->allowMutationEvents(WebDocument(document), defaultValue); 148 150 default: 149 151 return defaultValue;
Note: See TracChangeset
for help on using the changeset viewer.