From 6ca5cff06c9f21c1a185ff04ed4e022c4b00fba9 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 23 Feb 2011 14:56:10 +0000 Subject: [PATCH] Add asserts to verify correct DOM object usage. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@192 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/dom_document_impl.cc | 8 ++++++++ libcef/dom_event_impl.cc | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/libcef/dom_document_impl.cc b/libcef/dom_document_impl.cc index c6f84cf1c..f3cf10808 100644 --- a/libcef/dom_document_impl.cc +++ b/libcef/dom_document_impl.cc @@ -255,6 +255,14 @@ void CefDOMDocumentImpl::Detach() if (!VerifyContext()) return; + // If you hit this assert it means that you are keeping references to node + // objects beyond the valid scope. + DCHECK(node_map_.empty()); + + // If you hit this assert it means that you are keeping references to this + // document object beyond the valid scope. + DCHECK(GetRefCt() == 1); + if (!node_map_.empty()) { NodeMap::const_iterator it = node_map_.begin(); for (; it != node_map_.end(); ++it) diff --git a/libcef/dom_event_impl.cc b/libcef/dom_event_impl.cc index f7db2fb8c..7dc7ffef6 100644 --- a/libcef/dom_event_impl.cc +++ b/libcef/dom_event_impl.cc @@ -147,6 +147,10 @@ CefRefPtr CefDOMEventImpl::GetCurrentTarget() void CefDOMEventImpl::Detach() { + // If you hit this assert it means that you are keeping references to this + // event object beyond the valid scope. + DCHECK(GetRefCt() == 1); + document_ = NULL; event_.assign(WebDOMEvent()); }