[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
antonm at chromium.org
antonm at chromium.org
Wed Dec 22 12:04:06 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 07d9c24f63795abef59390d99e66d80b09ec1356
Author: antonm at chromium.org <antonm at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 13 12:29:14 2010 +0000
2010-08-13 Anton Muhin <antonm at chromium.org>
Reviewed by Nate Chapin.
Reapplying http://trac.webkit.org/changeset/65284 after fixed include.
[v8] Create callbacks for named access of elements from document object on fly.
https://bugs.webkit.org/show_bug.cgi?id=43725
That should speed up access to methods on document as there is no need to
consult with interceptor before invoking the method.
This reapplies http://trac.webkit.org/changeset/60670 reverted with
http://trac.webkit.org/changeset/63845. The main difference is in treatment
of removed named elements: we don't remove an accessor any more, but leave it.
Therefore any accessor should be able to treat the case when there is no
expando property.
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::namedItemAdded):
(WebCore::ScriptController::namedItemRemoved):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::checkDocumentWrapper):
(WebCore::V8DOMWindowShell::updateDocumentWrapperCache):
(WebCore::getter):
(WebCore::V8DOMWindowShell::namedItemAdded):
(WebCore::V8DOMWindowShell::namedItemRemoved):
* bindings/v8/V8DOMWindowShell.h:
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::instantiateV8Object):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::WrapInShadowObject):
(WebCore::V8HTMLDocument::GetNamedProperty):
(WebCore::V8HTMLDocument::allAccessorSetter):
(WebCore::toV8):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::removeItemFromMap):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7e8e14c..3236c03 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2010-08-13 Anton Muhin <antonm at chromium.org>
+
+ Reviewed by Nate Chapin.
+
+ Reapplying http://trac.webkit.org/changeset/65284 after fixed include.
+
+ [v8] Create callbacks for named access of elements from document object on fly.
+ https://bugs.webkit.org/show_bug.cgi?id=43725
+
+ That should speed up access to methods on document as there is no need to
+ consult with interceptor before invoking the method.
+
+ This reapplies http://trac.webkit.org/changeset/60670 reverted with
+ http://trac.webkit.org/changeset/63845. The main difference is in treatment
+ of removed named elements: we don't remove an accessor any more, but leave it.
+ Therefore any accessor should be able to treat the case when there is no
+ expando property.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/v8/ScriptController.cpp:
+ (WebCore::ScriptController::namedItemAdded):
+ (WebCore::ScriptController::namedItemRemoved):
+ * bindings/v8/V8DOMWindowShell.cpp:
+ (WebCore::checkDocumentWrapper):
+ (WebCore::V8DOMWindowShell::updateDocumentWrapperCache):
+ (WebCore::getter):
+ (WebCore::V8DOMWindowShell::namedItemAdded):
+ (WebCore::V8DOMWindowShell::namedItemRemoved):
+ * bindings/v8/V8DOMWindowShell.h:
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::V8DOMWrapper::instantiateV8Object):
+ * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+ (WebCore::V8HTMLDocument::WrapInShadowObject):
+ (WebCore::V8HTMLDocument::GetNamedProperty):
+ (WebCore::V8HTMLDocument::allAccessorSetter):
+ (WebCore::toV8):
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::removeItemFromMap):
+
2010-08-13 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Yury Semikhatsky.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index aec4d64..ebbcf8b 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -275,6 +275,13 @@ END
END
}
+ if ($implClassName eq "HTMLDocument") {
+ push(@headerContent, <<END);
+ static v8::Local<v8::Object> WrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl);
+ static v8::Handle<v8::Value> GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key);
+END
+ }
+
my @enabledAtRuntime;
foreach my $function (@{$dataNode->functions}) {
my $name = $function->signature->name;
@@ -362,9 +369,6 @@ sub GetInternalFields
if (IsSubType($dataNode, "Document")) {
push(@customInternalFields, "implementationIndex");
- if ($name eq "HTMLDocument") {
- push(@customInternalFields, ("markerIndex", "shadowIndex"));
- }
} elsif ($name eq "DOMWindow") {
push(@customInternalFields, "enteredIsolatedWorldIndex");
}
@@ -401,7 +405,6 @@ END
my %indexerSpecialCases = (
"Storage" => 1,
"HTMLAppletElement" => 1,
- "HTMLDocument" => 1,
"HTMLEmbedElement" => 1,
"HTMLObjectElement" => 1
);
@@ -428,6 +431,10 @@ sub GenerateHeaderNamedAndIndexedPropertyAccessors
if ($interfaceName eq "HTMLSelectElement" || $interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedElement" || $interfaceName eq "HTMLObjectElement") {
$hasCustomNamedGetter = 1;
}
+ if ($interfaceName eq "HTMLDocument") {
+ $hasCustomNamedGetter = 0;
+ $hasCustomIndexedGetter = 0;
+ }
my $isIndexerSpecialCase = exists $indexerSpecialCases{$interfaceName};
if ($hasCustomIndexedGetter || $isIndexerSpecialCase) {
@@ -456,7 +463,7 @@ END
static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&);
END
}
- if ($hasCustomDeleters || $interfaceName eq "HTMLDocument") {
+ if ($hasCustomDeleters) {
push(@headerContent, <<END);
static v8::Handle<v8::Boolean> namedPropertyDeleter(v8::Local<v8::String>, const v8::AccessorInfo&);
END
@@ -1503,6 +1510,10 @@ sub GenerateImplementationNamedPropertyGetter
$hasCustomGetter = 1;
}
+ if ($interfaceName eq "HTMLDocument") {
+ $hasCustomGetter = 0;
+ }
+
my $hasGetter = $dataNode->extendedAttributes->{"HasNameGetter"} || $hasCustomGetter || $namedPropertyGetter;
if (!$hasGetter) {
return;
@@ -1518,8 +1529,7 @@ END
}
my $hasSetter = $dataNode->extendedAttributes->{"DelegatingPutFunction"};
- # FIXME: Try to remove hard-coded HTMLDocument reference by aligning handling of document.all with JSC bindings.
- my $hasDeleter = $dataNode->extendedAttributes->{"CustomDeleteProperty"} || $interfaceName eq "HTMLDocument";
+ my $hasDeleter = $dataNode->extendedAttributes->{"CustomDeleteProperty"};
my $hasEnumerator = $dataNode->extendedAttributes->{"CustomGetPropertyNames"};
my $setOn = "Instance";
@@ -2004,6 +2014,11 @@ END
instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::External::Wrap(&V8DOMWindow::info), false);
END
}
+ if ($interfaceName eq "HTMLDocument") {
+ push(@implContent, <<END);
+ desc->SetHiddenPrototype(true);
+END
+ }
if ($interfaceName eq "Location") {
push(@implContent, <<END);
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index febfdda..5b3b747 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -478,10 +478,12 @@ void ScriptController::updateDocument()
void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
{
+ m_proxy->windowShell()->namedItemAdded(doc, name);
}
void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
{
+ m_proxy->windowShell()->namedItemRemoved(doc, name);
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index a13b562..d747c75 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -50,6 +50,7 @@
#include "V8DOMWindow.h"
#include "V8Document.h"
#include "V8GCForContextDispose.h"
+#include "V8HTMLDocument.h"
#include "V8HiddenPropertyName.h"
#include "V8History.h"
#include "V8Location.h"
@@ -406,6 +407,12 @@ void V8DOMWindowShell::clearDocumentWrapper()
}
}
+static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
+{
+ ASSERT(V8Document::toNative(wrapper) == document);
+ ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::Object>::Cast(wrapper->GetPrototype())) == document));
+}
+
void V8DOMWindowShell::updateDocumentWrapperCache()
{
v8::HandleScope handleScope;
@@ -424,6 +431,10 @@ void V8DOMWindowShell::updateDocumentWrapperCache()
}
v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document());
+ ASSERT(documentWrapper == m_document || m_document.IsEmpty());
+ if (m_document.IsEmpty())
+ updateDocumentWrapper(v8::Handle<v8::Object>::Cast(documentWrapper));
+ checkDocumentWrapper(m_document, m_frame->document());
// If instantiation of the document wrapper fails, clear the cache
// and let the DOMWindow accessor handle access to the document.
@@ -501,6 +512,37 @@ void V8DOMWindowShell::updateDocument()
updateSecurityOrigin();
}
+v8::Handle<v8::Value> getter(v8::Local<v8::String> property, const v8::AccessorInfo& info)
+{
+ // FIXME(antonm): consider passing AtomicStringImpl directly.
+ AtomicString name = v8StringToAtomicWebCoreString(property);
+ HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
+ ASSERT(htmlDocument);
+ v8::Handle<v8::Value> result = V8HTMLDocument::GetNamedProperty(htmlDocument, name);
+ if (!result.IsEmpty())
+ return result;
+ v8::Handle<v8::Value> prototype = info.Holder()->GetPrototype();
+ if (prototype->IsObject())
+ return prototype.As<v8::Object>()->Get(property);
+ return v8::Undefined();
+}
+
+void V8DOMWindowShell::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
+{
+ initContextIfNeeded();
+
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(m_context);
+
+ ASSERT(!m_document.IsEmpty());
+ checkDocumentWrapper(m_document, doc);
+ m_document->SetAccessor(v8String(name), getter);
+}
+
+void V8DOMWindowShell::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
+{
+}
+
void V8DOMWindowShell::updateSecurityOrigin()
{
v8::HandleScope scope;
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.h b/WebCore/bindings/v8/V8DOMWindowShell.h
index 2ccb410..7958bf1 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.h
+++ b/WebCore/bindings/v8/V8DOMWindowShell.h
@@ -37,11 +37,13 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/AtomicString.h>
namespace WebCore {
class DOMWindow;
class Frame;
+class HTMLDocument;
// V8WindowShell represents all the per-global object state for a Frame that
// persist between navigations.
@@ -54,6 +56,9 @@ public:
// Update document object of the frame.
void updateDocument();
+ void namedItemAdded(HTMLDocument*, const AtomicString&);
+ void namedItemRemoved(HTMLDocument*, const AtomicString&);
+
// Update the security origin of a document
// (e.g., after setting docoument.domain).
void updateSecurityOrigin();
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index d6f05f4..8a72a3a 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -284,6 +284,8 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, WrapperT
if (!instance.IsEmpty()) {
// Avoid setting the DOM wrapper for failed allocations.
setDOMWrapper(instance, type, impl);
+ if (type == &V8HTMLDocument::info)
+ instance = V8HTMLDocument::WrapInShadowObject(instance, static_cast<Node*>(impl));
}
return instance;
}
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 86f2eb5..24ac47c 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -49,48 +49,38 @@
namespace WebCore {
-v8::Handle<v8::Boolean> V8HTMLDocument::namedPropertyDeleter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+v8::Local<v8::Object> V8HTMLDocument::WrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl)
{
- // Only handle document.all. Insert the marker object into the
- // shadow internal field to signal that document.all is no longer
- // shadowed.
- AtomicString key = v8StringToAtomicWebCoreString(name);
- DEFINE_STATIC_LOCAL(const AtomicString, all, ("all"));
- if (key != all)
- return deletionNotHandledByInterceptor();
-
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex);
- info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, marker);
- return v8::True();
-}
-
-v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- INC_STATS("DOM.HTMLDocument.NamedPropertyGetter");
- AtomicString key = v8StringToAtomicWebCoreString(name);
-
- // Special case for document.all. If the value in the shadow
- // internal field is not the marker object, then document.all has
- // been temporarily shadowed and we return the value.
- DEFINE_STATIC_LOCAL(const AtomicString, all, ("all"));
- if (key == all) {
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex);
- v8::Local<v8::Value> value = info.Holder()->GetInternalField(V8HTMLDocument::shadowIndex);
- if (marker != value)
- return value;
+ DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, shadowTemplate, ());
+ if (shadowTemplate.IsEmpty()) {
+ shadowTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
+ if (shadowTemplate.IsEmpty())
+ return v8::Local<v8::Object>();
+ shadowTemplate->SetClassName(v8::String::New("HTMLDocument"));
+ shadowTemplate->Inherit(V8HTMLDocument::GetTemplate());
+ shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount);
}
- HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
+ v8::Local<v8::Function> shadowConstructor = shadowTemplate->GetFunction();
+ if (shadowConstructor.IsEmpty())
+ return v8::Local<v8::Object>();
- // Fast case for named elements that are not there.
+ v8::Local<v8::Object> shadow = shadowConstructor->NewInstance();
+ if (shadow.IsEmpty())
+ return v8::Local<v8::Object>();
+ V8DOMWrapper::setDOMWrapper(shadow, &V8HTMLDocument::info, impl);
+ shadow->SetPrototype(wrapper);
+ return shadow;
+}
+
+v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key)
+{
if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl()))
return v8::Handle<v8::Value>();
RefPtr<HTMLCollection> items = htmlDocument->documentNamedItems(key);
if (!items->length())
- return notHandledByInterceptor();
+ return v8::Handle<v8::Value>();
if (items->length() == 1) {
Node* node = items->firstItem();
@@ -104,13 +94,6 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String>
return toV8(items.release());
}
-v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info)
-{
- INC_STATS("DOM.HTMLDocument.IndexedPropertyGetter");
- v8::Local<v8::Integer> indexV8 = v8::Integer::NewFromUnsigned(index);
- return namedPropertyGetter(indexV8->ToString(), info);
-}
-
// HTMLDocument ----------------------------------------------------------------
// Concatenates "args" to a string. If args is empty, returns empty string.
@@ -193,10 +176,8 @@ v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> na
void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
- INC_STATS("DOM.HTMLDocument.all._set");
- v8::Handle<v8::Object> holder = info.Holder();
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value);
+ // Just emulate a normal JS behaviour---install a property on this.
+ info.This()->ForceSet(name, value);
}
v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
@@ -210,12 +191,6 @@ v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
proxy->windowShell()->updateDocumentWrapper(wrapper);
}
- // Create marker object and insert it in two internal fields.
- // This is used to implement temporary shadowing of document.all.
- ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Object> marker = v8::Object::New();
- wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker);
- wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker);
return wrapper;
}
diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp
index 559c1e0..5798783 100644
--- a/WebCore/html/HTMLDocument.cpp
+++ b/WebCore/html/HTMLDocument.cpp
@@ -323,9 +323,9 @@ void HTMLDocument::removeItemFromMap(HashCountedSet<AtomicStringImpl*>& map, con
{
if (name.isEmpty())
return;
+ map.remove(name.impl());
if (Frame* f = frame())
f->script()->namedItemRemoved(this, name);
- map.remove(name.impl());
}
void HTMLDocument::addNamedItem(const AtomicString& name)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list