Commit acd07906 authored by arv@chromium.org's avatar arv@chromium.org

[V8] Allow bindings for attributes on DOM nodes to also set a named hidden reference

https://bugs.webkit.org/show_bug.cgi?id=78052

Reviewed by Nate Chapin.

Source/WebCore:

Before this patch the code generator did not add the named hidden reference when the data node
was a DOM Node. This lead to us having to create custom toV8 bindings in a few places.

Covered by existing tests

* Target.pri:
* UseV8.cmake:
* WebCore.gypi:
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
(HasCustomToV8Implementation):
* bindings/v8/custom/V8DOMStringMapCustom.cpp:
* bindings/v8/custom/V8DOMTokenListCustom.cpp: Removed.
* bindings/v8/custom/V8NamedNodeMapCustom.cpp:

LayoutTests:

* platform/chromium/test_expectations.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107035 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3336d004
2012-02-07 Erik Arvidsson <arv@chromium.org>
[V8] Allow bindings for attributes on DOM nodes to also set a named hidden reference
https://bugs.webkit.org/show_bug.cgi?id=78052
Reviewed by Nate Chapin.
* platform/chromium/test_expectations.txt:
2012-02-07 Julien Chaffraix <jchaffraix@webkit.org>
Unreviewed gardening.
......@@ -585,7 +585,6 @@ BUGWK66377 : fast/dom/StyleSheet/gc-inline-style-cssvalues.html = TEXT
BUGWK66377 : fast/dom/StyleSheet/gc-parent-rule.html = TEXT
BUGWK66377 : fast/dom/StyleSheet/gc-parent-stylesheet.html = TEXT
BUGWK66377 : fast/dom/StyleSheet/gc-rule-children-wrappers.html = TEXT
BUGWK66377 : fast/dom/StyleSheet/gc-styleheet-wrapper.xhtml = TEXT
// -----------------------------------------------------------------
// PENDING TESTS (forked to pending/, need to be sent upstream)
......
2012-02-07 Erik Arvidsson <arv@chromium.org>
[V8] Allow bindings for attributes on DOM nodes to also set a named hidden reference
https://bugs.webkit.org/show_bug.cgi?id=78052
Reviewed by Nate Chapin.
Before this patch the code generator did not add the named hidden reference when the data node
was a DOM Node. This lead to us having to create custom toV8 bindings in a few places.
Covered by existing tests
* Target.pri:
* UseV8.cmake:
* WebCore.gypi:
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
(HasCustomToV8Implementation):
* bindings/v8/custom/V8DOMStringMapCustom.cpp:
* bindings/v8/custom/V8DOMTokenListCustom.cpp: Removed.
* bindings/v8/custom/V8NamedNodeMapCustom.cpp:
2012-02-07 Kentaro Hara <haraken@chromium.org>
[GTK] Ignore [Custom] attributes in CodeGeneratorGObject.pm
......@@ -158,8 +158,7 @@ v8 {
bindings/v8/custom/V8InjectedScriptHostCustom.cpp \
bindings/v8/custom/V8InjectedScriptManager.cpp \
bindings/v8/custom/V8InspectorFrontendHostCustom.cpp \
bindings/v8/custom/V8DOMStringMapCustom.cpp \
bindings/v8/custom/V8DOMTokenListCustom.cpp
bindings/v8/custom/V8DOMStringMapCustom.cpp
SOURCES += \
bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp \
......
......@@ -81,7 +81,6 @@ LIST(APPEND WebCore_SOURCES
bindings/v8/custom/V8CustomXPathNSResolver.cpp
bindings/v8/custom/V8DOMFormDataCustom.cpp
bindings/v8/custom/V8DOMStringMapCustom.cpp
bindings/v8/custom/V8DOMTokenListCustom.cpp
bindings/v8/custom/V8DOMWindowCustom.cpp
bindings/v8/custom/V8DataViewCustom.cpp
bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp
......
......@@ -1816,7 +1816,6 @@
'bindings/v8/custom/V8CustomXPathNSResolver.h',
'bindings/v8/custom/V8DOMFormDataCustom.cpp',
'bindings/v8/custom/V8DOMStringMapCustom.cpp',
'bindings/v8/custom/V8DOMTokenListCustom.cpp',
'bindings/v8/custom/V8DOMWindowCustom.cpp',
'bindings/v8/custom/V8DataViewCustom.cpp',
'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp',
......
......@@ -3,7 +3,7 @@
# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
# Copyright (C) 2006 Apple Computer, Inc.
# Copyright (C) 2007, 2008, 2009 Google Inc.
# Copyright (C) 2007-2012 Google Inc.
# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
# Copyright (C) Research In Motion Limited 2010. All rights reserved.
# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
......@@ -922,7 +922,7 @@ END
# Special case for readonly or Replaceable attributes (with a few exceptions). This attempts to ensure that JS wrappers don't get
# garbage-collected prematurely when their lifetime is strongly tied to their owner. We accomplish this by inserting a reference to
# the newly created wrapper into an internal field of the holder object.
if (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"})
if ($attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"})
&& $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow"
&& $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))) {
AddIncludesForType($returnType);
......@@ -3119,14 +3119,11 @@ sub HasCustomToV8Implementation {
# We generate a custom converter (but JSC doesn't) for the following:
return 1 if $interfaceName eq "CSSStyleSheet";
return 1 if $interfaceName eq "CanvasPixelArray";
return 1 if $interfaceName eq "DOMStringMap";
return 1 if $interfaceName eq "DOMWindow";
return 1 if $interfaceName eq "DOMTokenList";
return 1 if $interfaceName eq "Element";
return 1 if $interfaceName eq "HTMLDocument";
return 1 if $interfaceName eq "HTMLElement";
return 1 if $interfaceName eq "Location";
return 1 if $interfaceName eq "NamedNodeMap";
return 1 if $interfaceName eq "SVGDocument";
return 1 if $interfaceName eq "SVGElement";
return 1 if $interfaceName eq "ScriptProfile";
......@@ -3142,8 +3139,6 @@ sub HasCustomToV8Implementation {
return 0 if $interfaceName eq "MediaList";
return 0 if $interfaceName eq "StyleSheetList";
return 0 if $interfaceName eq "DOMImplementation";
return 0 if $interfaceName eq "DOMStringMap";
return 0 if $interfaceName eq "DOMTokenList";
return 0 if $interfaceName eq "TextTrack";
# For everything else, do what JSC does.
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -84,19 +84,4 @@ v8::Handle<v8::Value> V8DOMStringMap::namedPropertySetter(v8::Local<v8::String>
return value;
}
v8::Handle<v8::Value> toV8(DOMStringMap* impl)
{
if (!impl)
return v8::Null();
v8::Handle<v8::Object> wrapper = V8DOMStringMap::wrap(impl);
// Add a hidden reference from the element to the DOMStringMap.
Element* element = impl->element();
if (!wrapper.IsEmpty() && element) {
v8::Handle<v8::Value> elementValue = toV8(element);
if (!elementValue.IsEmpty() && elementValue->IsObject())
V8DOMWrapper::setNamedHiddenReference(elementValue.As<v8::Object>(), "domStringMap", wrapper);
}
return wrapper;
}
} // namespace WebCore
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "V8DOMTokenList.h"
#include "DOMTokenList.h"
#include "V8Binding.h"
#include "V8DOMWrapper.h"
#include "V8Element.h"
namespace WebCore {
v8::Handle<v8::Value> toV8(DOMTokenList* impl)
{
if (!impl)
return v8::Null();
v8::Handle<v8::Object> wrapper = V8DOMTokenList::wrap(impl);
// Add a hidden reference from the element to the DOMTokenList.
Element* element = impl->element();
if (!wrapper.IsEmpty() && element) {
v8::Handle<v8::Value> elementValue = toV8(element);
if (!elementValue.IsEmpty() && elementValue->IsObject())
V8DOMWrapper::setNamedHiddenReference(elementValue.As<v8::Object>(), "domTokenList", wrapper);
}
return wrapper;
}
} // namespace WebCore
/*
* Copyright (C) 2007-2009 Google Inc. All rights reserved.
* Copyright (C) 2007-2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -71,16 +71,4 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String>
return toV8(result.release());
}
v8::Handle<v8::Value> toV8(NamedNodeMap* impl)
{
if (!impl)
return v8::Null();
v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl);
// Add a hidden reference from named node map to its owner node.
Element* element = impl->element();
if (!wrapper.IsEmpty() && element)
V8DOMWrapper::setNamedHiddenReference(wrapper, "ownerNode", toV8(element));
return wrapper;
}
} // namespace WebCore
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment