summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 20:51:16 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 20:51:16 +0000
commit933a23d23270bba7b6a3a26c2424b299386b548e (patch)
tree3c42d8b6d0cd5053cdb9390a2d02b4df6ec73243
parentf16576d5803e57d36bf625cc3f23c9530f683dcd (diff)
downloadchromium_src-933a23d23270bba7b6a3a26c2424b299386b548e.zip
chromium_src-933a23d23270bba7b6a3a26c2424b299386b548e.tar.gz
chromium_src-933a23d23270bba7b6a3a26c2424b299386b548e.tar.bz2
Chrome side change to use V8EventListenerList from upstream. This involves removing V8EventListenerList from v8_proxy and change the project files to compile V8EventListenerList.
Review URL: http://codereview.chromium.org/60102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13107 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/build/V8Bindings/V8Bindings.vcproj8
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp85
-rw-r--r--webkit/port/bindings/v8/v8_proxy.h30
-rw-r--r--webkit/webkit.gyp2
4 files changed, 11 insertions, 114 deletions
diff --git a/webkit/build/V8Bindings/V8Bindings.vcproj b/webkit/build/V8Bindings/V8Bindings.vcproj
index d10fdc0..dff4f33 100644
--- a/webkit/build/V8Bindings/V8Bindings.vcproj
+++ b/webkit/build/V8Bindings/V8Bindings.vcproj
@@ -3005,6 +3005,14 @@
>
</File>
<File
+ RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\V8EventListenerList.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\V8EventListenerList.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\V8LazyEventListener.cpp"
>
</File>
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index 54d24a9..5740c1e 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -50,91 +50,6 @@
namespace WebCore {
-V8EventListenerList::V8EventListenerList(const char* name)
-{
- ASSERT(strlen(name) <= kMaxKeyNameLength);
- v8::HandleScope handleScope;
-
- // Write the name into a temporary buffer, leaving 1 space at the beginning
- // for a prefix we'll vary between the inline and non-inline keys.
- char keyBuffer[kMaxKeyNameLength + 2] = { 0 };
- strncpy(keyBuffer + 1, name, kMaxKeyNameLength);
- keyBuffer[0] = '1';
- m_inlineKey = v8::Persistent<v8::String>::New(v8::String::New(keyBuffer));
- keyBuffer[0] = '2';
- m_nonInlineKey = v8::Persistent<v8::String>::New(v8::String::New(keyBuffer));
-}
-
-V8EventListenerList::~V8EventListenerList()
-{
- m_inlineKey.Dispose();
- m_nonInlineKey.Dispose();
-}
-
-V8EventListenerList::iterator V8EventListenerList::begin()
-{
- return m_list.begin();
-}
-
-V8EventListenerList::iterator V8EventListenerList::end()
-{
- return m_list.end();
-}
-
-v8::Handle<v8::String> V8EventListenerList::getKey(bool isInline)
-{
- if (isInline)
- return m_inlineKey;
- else
- return m_nonInlineKey;
-}
-
-// See comment in .h file for this function, and update accordingly if
-// implementation details change here.
-void V8EventListenerList::add(V8EventListener* listener)
-{
- m_list.append(listener);
-
- v8::HandleScope handleScope;
- v8::Local<v8::Object> object = listener->getListenerObject();
- v8::Local<v8::Value> value = v8::External::Wrap(listener);
- object->SetHiddenValue(getKey(listener->isInline()), value);
-}
-
-void V8EventListenerList::remove(V8EventListener* listener)
-{
- v8::HandleScope handleScope;
- for (size_t i = 0; i < m_list.size(); i++) {
- V8EventListener* element = m_list.at(i);
- if (element->isInline() == listener->isInline() && element == listener) {
- v8::Local<v8::Object> object = listener->getListenerObject();
- object->DeleteHiddenValue(getKey(listener->isInline()));
- m_list.remove(i);
- break;
- }
- }
-}
-
-void V8EventListenerList::clear()
-{
- v8::HandleScope handleScope;
- for (size_t i = 0; i < m_list.size(); i++) {
- V8EventListener* element = m_list.at(i);
- v8::Local<v8::Object> object = element->getListenerObject();
- object->DeleteHiddenValue(getKey(element->isInline()));
- }
- m_list.clear();
-}
-
-V8EventListener* V8EventListenerList::find(v8::Local<v8::Object> object, bool isInline)
-{
- v8::Local<v8::Value> value = object->GetHiddenValue(getKey(isInline));
- if (value.IsEmpty())
- return 0;
- return reinterpret_cast<V8EventListener*>(v8::External::Unwrap(value));
-}
-
-
// Static utility context.
v8::Persistent<v8::Context> V8Proxy::m_utilityContext;
diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h
index d1a7a9f..3c4e833 100644
--- a/webkit/port/bindings/v8/v8_proxy.h
+++ b/webkit/port/bindings/v8/v8_proxy.h
@@ -16,6 +16,7 @@
#include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode
#include "SecurityOrigin.h" // for WebCore::SecurityOrigin
#include "V8DOMMap.h"
+#include "V8EventListenerList.h"
#include <wtf/Assertions.h>
#include <wtf/PassRefPtr.h> // so generated bindings don't have to
#include <wtf/Vector.h>
@@ -77,35 +78,6 @@ class SVGElementInstance;
class V8EventListener;
class V8ObjectEventListener;
-// This is a container for V8EventListener objects that also does some
-// caching to speed up finding entries by v8::Object.
-class V8EventListenerList {
- public:
- static const size_t kMaxKeyNameLength = 254;
- // The name should be distinct from any other V8EventListenerList
- // within the same process, and <= kMaxKeyNameLength characters.
- explicit V8EventListenerList(const char* name);
- ~V8EventListenerList();
-
- typedef Vector<V8EventListener*>::iterator iterator;
- V8EventListenerList::iterator begin();
- iterator end();
-
- // In addition to adding the listener to this list, this also caches the
- // V8EventListener as a hidden property on its wrapped v8 listener object,
- // so we can quickly look it up later.
- void add(V8EventListener*);
- void remove(V8EventListener*);
- V8EventListener* find(v8::Local<v8::Object>, bool isInline);
- void clear();
-
- private:
- v8::Handle<v8::String> getKey(bool isInline);
- v8::Persistent<v8::String> m_inlineKey;
- v8::Persistent<v8::String> m_nonInlineKey;
- Vector<V8EventListener*> m_list;
-};
-
// TODO(fqian): use standard logging facilities in WebCore.
void log_info(Frame* frame, const String& msg, const String& url);
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index d65dff2..9ec0fff 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1040,6 +1040,8 @@
'../third_party/WebKit/WebCore/bindings/v8/V8Collection.h',
'../third_party/WebKit/WebCore/bindings/v8/V8DOMMap.cpp',
'../third_party/WebKit/WebCore/bindings/v8/V8DOMMap.h',
+ '../third_party/WebKit/WebCore/bindings/v8/V8EventListenerList.cpp',
+ '../third_party/WebKit/WebCore/bindings/v8/V8EventListenerList.h',
'../third_party/WebKit/WebCore/bindings/v8/V8LazyEventListener.cpp',
'../third_party/WebKit/WebCore/bindings/v8/V8LazyEventListener.h',
'../third_party/WebKit/WebCore/bindings/v8/V8NodeFilterCondition.cpp',