Modified: trunk/Source/WebCore/ChangeLog (115495 => 115496)
--- trunk/Source/WebCore/ChangeLog 2012-04-27 21:38:39 UTC (rev 115495)
+++ trunk/Source/WebCore/ChangeLog 2012-04-27 21:46:11 UTC (rev 115496)
@@ -1,3 +1,37 @@
+;2012-04-27 Geoffrey Garen <[email protected]>
+
+ Removed the sole use of Weak<Unknown>
+ https://bugs.webkit.org/show_bug.cgi?id=85099
+
+ Reviewed by Sam Weinig.
+
+ The semantics and implementation of Weak<Unknown> are unclear because:
+ - Should you call a finalizer for a non-GC thingy? If so, when?
+
+ * Possible answer: No.
+
+ - If WeakImpls for GC thingies live with the GC thingies in the
+ heap, where do WeakImpls for non-GC thingies live?
+
+ * Possible answer: Directly in the Weak<T>.
+
+ Since no clients actually want these behaviors, it's hard to tell if
+ they're the right behaviors, and it's not worth the implementation
+ complexity. If we come up with a client that wants these behaviors, we
+ can always revisit this.
+
+ * bindings/js/JSNodeFilterCondition.cpp:
+ (WebCore::JSNodeFilterCondition::JSNodeFilterCondition): Just leave our
+ filter NULL if it's not an object -- that's a better way to indicate
+ "not a valid filter object".
+
+ (WebCore::JSNodeFilterCondition::acceptNode): Fixed up some naming to
+ clarify that the object we're working with is not necessarily a function.
+
+ * bindings/js/JSNodeFilterCondition.h:
+ (JSNodeFilterCondition): Use Weak<JSObject>, since that more closely
+ matches what we're trying to do.
+
2012-04-26 Kentaro Hara <[email protected]>
[V8] Pass Isolate to getDOMXXXMap()
Modified: trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp (115495 => 115496)
--- trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp 2012-04-27 21:38:39 UTC (rev 115495)
+++ trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp 2012-04-27 21:46:11 UTC (rev 115496)
@@ -34,32 +34,30 @@
ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition);
JSNodeFilterCondition::JSNodeFilterCondition(JSGlobalData& globalData, NodeFilter* owner, JSValue filter)
- : m_filter(globalData, filter, &m_weakOwner, owner)
{
+ if (!filter.isObject())
+ return;
+ m_filter = PassWeak<JSObject>(globalData, jsCast<JSObject*>(filter), &m_weakOwner, owner);
}
short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) const
{
JSLock lock(SilenceAssertionsOnly);
- if (!m_filter || !m_filter->isObject())
+ if (!m_filter)
return NodeFilter::FILTER_ACCEPT;
- // The exec argument here should only be null if this was called from a
- // non-_javascript_ language, and this is a _javascript_ filter, and the document
- // in question is not associated with the frame. In that case, we're going to
- // behave incorrectly, and just reject nodes instead of calling the filter function.
- // To fix that we'd need to come up with a way to find a suitable _javascript_
- // execution context for the filter function to run in.
+ // Exec is null if we've been called from a non-_javascript_ language and the document
+ // is no longer able to run _javascript_ (e.g., it's disconnected from its frame).
if (!exec)
return NodeFilter::FILTER_REJECT;
- JSValue function = m_filter.get();
+ JSValue filter = m_filter.get();
CallData callData;
- CallType callType = getCallData(function, callData);
+ CallType callType = getCallData(filter, callData);
if (callType == CallTypeNone) {
- function = m_filter.get().get(exec, Identifier(exec, "acceptNode"));
- callType = getCallData(function, callData);
+ filter = filter.get(exec, Identifier(exec, "acceptNode"));
+ callType = getCallData(filter, callData);
if (callType == CallTypeNone) {
throwError(exec, createTypeError(exec, "NodeFilter object does not have an acceptNode function"));
return NodeFilter::FILTER_REJECT;
@@ -73,7 +71,7 @@
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
- JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, m_filter.get(), args);
+ JSValue result = JSMainThreadExecState::call(exec, filter, callType, callData, m_filter.get(), args);
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
Modified: trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.h (115495 => 115496)
--- trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.h 2012-04-27 21:38:39 UTC (rev 115495)
+++ trunk/Source/WebCore/bindings/js/JSNodeFilterCondition.h 2012-04-27 21:46:11 UTC (rev 115496)
@@ -46,7 +46,7 @@
virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
};
WeakOwner m_weakOwner;
- mutable JSC::Weak<JSC::Unknown> m_filter;
+ mutable JSC::Weak<JSC::JSObject> m_filter;
};
} // namespace WebCore