Commit 55132112 authored by darin@apple.com's avatar darin@apple.com

WebCore: Custom properties on DOM objects are lost after GC (as demonstrated by the gc-9.html test)

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

Patch by Darin Adler <darin@apple.com> on 2009-08-12
Reviewed by Geoff Garen.

* GNUmakefile.am: Added the two new source files.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* WebCoreSources.bkl: Ditto.

* bindings/js/JSCSSRuleListCustom.cpp: Added.
(WebCore::JSCSSRuleList::markChildren): Call markDOMObjectWrapper
on rules in the list.

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::markChildren): Added. Call
markDOMObjectWrapper on the CSSValue objects that are owned by the
declaration as values of the properties.

* bindings/js/JSDOMBinding.cpp:
(WebCore::isObservableThroughDOM): Added code to handle some
cases where nodes are observable because they own objects that
in turn have custom properties.

* bindings/js/JSDOMBinding.h: Fix a typo in the header.

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::markChildren): Added call to markDOMObjectWrapper
for implementation and styleSheets.

* bindings/js/JSElementCustom.cpp:
(WebCore::JSElement::markChildren): Added. Calls markDOMObjectWrapper
for attributes and style.

* bindings/js/JSHTMLCanvasElementCustom.cpp: Added.
(WebCore::JSHTMLCanvasElement::markChildren): Call markDOMObjectWrapper
on the rendering context.

* bindings/js/JSStyleSheetCustom.cpp:
(WebCore::JSStyleSheet::markChildren): Call markDOMObjectWrapper on
items in the stylesheet.

* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::markChildren): Added. Calls
markDOMObjectWrapper on stylesheets in the list.

* css/CSSRuleList.idl: Added CustomMarkFunction.
* css/CSSStyleDeclaration.idl: Ditto.
* css/StyleSheetList.idl: Ditto.
* dom/Element.idl: Ditto.
* html/HTMLCanvasElement.idl: Ditto.

* dom/Element.h: Made everything private that could be.
Added access to the attributeMap that does returns
the existing map without doing any of the lazy-updating work. This
is needed to get at the existing attributes during garbage collection
without having side effects.

* html/HTMLCanvasElement.h: Cleaned up the header a bit, making
members private. Added renderingContext2D function for use in
JSHTMLCanvasElement::markChildren.

LayoutTests: Custom properties on DOM objects are lost after GC (as demonstrated by the gc-9.html test)
https://bugs.webkit.org/show_bug.cgi?id=28194

Patch by Darin Adler <darin@apple.com> on 2009-08-12
Reviewed by Geoff Garen.

* fast/dom/gc-9-expected.txt: Regenerated.
* fast/dom/gc-9.html: Updated to expect correct behavior instead of failures.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47165 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1e524bbc
2009-08-12 Darin Adler <darin@apple.com>
Reviewed by Geoff Garen.
Custom properties on DOM objects are lost after GC (as demonstrated by the gc-9.html test)
https://bugs.webkit.org/show_bug.cgi?id=28194
* fast/dom/gc-9-expected.txt: Regenerated.
* fast/dom/gc-9.html: Updated to expect correct behavior instead of failures.
2009-08-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Eric Seidel.
......
......@@ -41,9 +41,12 @@ PASS: new XPathEvaluator().evaluate('/', document, null, 0, null).myCustomProper
PASS: document.createNSResolver(document).myCustomProperty should be undefined and is.
PASS: document.createExpression('/', document.createNSResolver(document)).myCustomProperty should be undefined and is.
DOM OBJECTS AFTER GARBAGE COLLECTION:
PASS: document.implementation.myCustomProperty should be 1 and is.
PASS: document.myCustomProperty should be 1 and is.
PASS: document.body.myCustomProperty should be 1 and is.
PASS: document.body.attributes.myCustomProperty should be 1 and is.
PASS: document.getElementsByTagName('body').myCustomProperty should be undefined and is.
PASS: document.getElementsByTagName('canvas')[0].getContext('2d').myCustomProperty should be 1 and is.
PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0).myCustomProperty should be undefined and is.
PASS: document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat').myCustomProperty should be undefined and is.
PASS: document.getElementsByTagName('select')[0].options.myCustomProperty should be undefined and is.
......@@ -63,7 +66,12 @@ PASS: document.getElementsByTagName('table')[0].tBodies.myCustomProperty should
PASS: document.getElementsByTagName('table')[0].tBodies[0].rows.myCustomProperty should be undefined and is.
PASS: document.body.children.myCustomProperty should be undefined and is.
PASS: document.getElementsByTagName('map')[0].areas.myCustomProperty should be undefined and is.
PASS: document.body.style.myCustomProperty should be 1 and is.
PASS: document.body.style.getPropertyCSSValue('color').myCustomProperty should be 1 and is.
PASS: document.styleSheets.myCustomProperty should be 1 and is.
PASS: document.styleSheets[0].myCustomProperty should be 1 and is.
PASS: document.styleSheets[0].cssRules.myCustomProperty should be undefined and is.
PASS: document.styleSheets[0].cssRules[0].myCustomProperty should be 1 and is.
PASS: new XPathEvaluator().myCustomProperty should be undefined and is.
PASS: new XPathEvaluator().evaluate('/', document, null, 0, null).myCustomProperty should be undefined and is.
PASS: document.createNSResolver(document).myCustomProperty should be undefined and is.
......
......@@ -103,15 +103,15 @@ function test()
// If "allow custom" is specified, then custom properties are allowed and survive garbage collection.
// If "allow custom skip" is specified, this means this property is not guaranteed to survive garbage
// collection, so we don't test it at all, since there is a chance it might due to conservative GC algorithm.
// All "allow custom skip" represent bugs that need to be fixed.
// Any uses of "allow custom skip" represent bugs that need to be fixed.
var objectsToTest = [
[ "document.implementation", "allow custom skip" ], // DOMImplementation
[ "document.implementation", "allow custom" ], // DOMImplementation
[ "document", "allow custom" ],
[ "document.body", "allow custom" ],
[ "document.body.attributes", "allow custom skip" ], // NamedNodeMap
[ "document.body.attributes", "allow custom" ], // NamedNodeMap
[ "document.getElementsByTagName('body')" ], // NodeList
[ "document.getElementsByTagName('canvas')[0].getContext('2d')", "allow custom skip" ], // CanvasRenderingContext2D
[ "document.getElementsByTagName('canvas')[0].getContext('2d')", "allow custom" ], // CanvasRenderingContext2D
[ "document.getElementsByTagName('canvas')[0].getContext('2d').createLinearGradient(0, 0, 0, 0)" ], // CanvasGradient
[ "document.getElementsByTagName('canvas')[0].getContext('2d').createPattern(new Image(), 'no-repeat')" ], // CanvasPattern
[ "document.getElementsByTagName('select')[0].options" ],
......@@ -134,12 +134,12 @@ var objectsToTest = [
[ "document.body.children" ],
[ "document.getElementsByTagName('map')[0].areas" ],
[ "document.body.style", "allow custom skip" ],
[ "document.body.style.getPropertyCSSValue('color')", "allow custom skip" ],
[ "document.styleSheets", "allow custom skip" ],
[ "document.styleSheets[0]", "allow custom skip" ],
[ "document.body.style", "allow custom" ],
[ "document.body.style.getPropertyCSSValue('color')", "allow custom" ],
[ "document.styleSheets", "allow custom" ],
[ "document.styleSheets[0]", "allow custom" ],
[ "document.styleSheets[0].cssRules" ],
[ "document.styleSheets[0].cssRules[0]", "allow custom skip" ],
[ "document.styleSheets[0].cssRules[0]", "allow custom" ],
[ "new XPathEvaluator()" ], // XPathEvaluator
[ "new XPathEvaluator().evaluate('/', document, null, 0, null)" ], // XPathResult
......
2009-08-12 Darin Adler <darin@apple.com>
Reviewed by Geoff Garen.
Custom properties on DOM objects are lost after GC (as demonstrated by the gc-9.html test)
https://bugs.webkit.org/show_bug.cgi?id=28194
* GNUmakefile.am: Added the two new source files.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* WebCoreSources.bkl: Ditto.
* bindings/js/JSCSSRuleListCustom.cpp: Added.
(WebCore::JSCSSRuleList::markChildren): Call markDOMObjectWrapper
on rules in the list.
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::markChildren): Added. Call
markDOMObjectWrapper on the CSSValue objects that are owned by the
declaration as values of the properties.
* bindings/js/JSDOMBinding.cpp:
(WebCore::isObservableThroughDOM): Added code to handle some
cases where nodes are observable because they own objects that
in turn have custom properties.
* bindings/js/JSDOMBinding.h: Fix a typo in the header.
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::markChildren): Added call to markDOMObjectWrapper
for implementation and styleSheets.
* bindings/js/JSElementCustom.cpp:
(WebCore::JSElement::markChildren): Added. Calls markDOMObjectWrapper
for attributes and style.
* bindings/js/JSHTMLCanvasElementCustom.cpp: Added.
(WebCore::JSHTMLCanvasElement::markChildren): Call markDOMObjectWrapper
on the rendering context.
* bindings/js/JSStyleSheetCustom.cpp:
(WebCore::JSStyleSheet::markChildren): Call markDOMObjectWrapper on
items in the stylesheet.
* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::markChildren): Added. Calls
markDOMObjectWrapper on stylesheets in the list.
* css/CSSRuleList.idl: Added CustomMarkFunction.
* css/CSSStyleDeclaration.idl: Ditto.
* css/StyleSheetList.idl: Ditto.
* dom/Element.idl: Ditto.
* html/HTMLCanvasElement.idl: Ditto.
* dom/Element.h: Made everything private that could be.
Added access to the attributeMap that does returns
the existing map without doing any of the lazy-updating work. This
is needed to get at the existing attributes during garbage collection
without having side effects.
* html/HTMLCanvasElement.h: Cleaned up the header a bit, making
members private. Added renderingContext2D function for use in
JSHTMLCanvasElement::markChildren.
2009-08-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Eric Seidel.
......@@ -314,6 +314,7 @@ webcore_sources += \
WebCore/bindings/js/JSDataGridDataSource.cpp \
WebCore/bindings/js/JSDataGridDataSource.h \
WebCore/bindings/js/JSCSSRuleCustom.cpp \
WebCore/bindings/js/JSCSSRuleListCustom.cpp \
WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp \
WebCore/bindings/js/JSCSSStyleDeclarationCustom.h \
WebCore/bindings/js/JSCSSValueCustom.cpp \
......@@ -352,6 +353,7 @@ webcore_sources += \
WebCore/bindings/js/JSHTMLAllCollection.h \
WebCore/bindings/js/JSHTMLAppletElementCustom.cpp \
WebCore/bindings/js/JSHTMLAppletElementCustom.h \
WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp \
WebCore/bindings/js/JSHTMLCollectionCustom.cpp \
WebCore/bindings/js/JSHTMLDataGridElementCustom.cpp \
WebCore/bindings/js/JSHTMLDocumentCustom.cpp \
......
......@@ -414,6 +414,7 @@
'bindings/js/JSConsoleCustom.cpp',
'bindings/js/JSCoordinatesCustom.cpp',
'bindings/js/JSCSSRuleCustom.cpp',
'bindings/js/JSCSSRuleListCustom.cpp',
'bindings/js/JSCSSStyleDeclarationCustom.cpp',
'bindings/js/JSCSSStyleDeclarationCustom.h',
'bindings/js/JSCSSValueCustom.cpp',
......@@ -464,6 +465,7 @@
'bindings/js/JSHTMLAllCollection.h',
'bindings/js/JSHTMLAppletElementCustom.cpp',
'bindings/js/JSHTMLAppletElementCustom.h',
'bindings/js/JSHTMLCanvasElementCustom.cpp',
'bindings/js/JSHTMLCollectionCustom.cpp',
'bindings/js/JSHTMLDataGridElementCustom.cpp',
'bindings/js/JSHTMLDocumentCustom.cpp',
......
......@@ -629,6 +629,7 @@ SOURCES += \
bindings/js/JSClipboardCustom.cpp \
bindings/js/JSConsoleCustom.cpp \
bindings/js/JSCSSRuleCustom.cpp \
bindings/js/JSCSSRuleListCustom.cpp \
bindings/js/JSCSSStyleDeclarationCustom.cpp \
bindings/js/JSCSSValueCustom.cpp \
bindings/js/JSCoordinatesCustom.cpp \
......@@ -651,6 +652,7 @@ SOURCES += \
bindings/js/JSHTMLAllCollection.cpp \
bindings/js/JSHistoryCustom.cpp \
bindings/js/JSHTMLAppletElementCustom.cpp \
bindings/js/JSHTMLCanvasElementCustom.cpp \
bindings/js/JSHTMLCollectionCustom.cpp \
bindings/js/JSHTMLDataGridElementCustom.cpp \
bindings/js/JSHTMLDocumentCustom.cpp \
......
......@@ -28618,6 +28618,10 @@
RelativePath="..\bindings\js\JSCSSRuleCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSCSSRuleListCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSCSSStyleDeclarationCustom.cpp"
>
......@@ -28802,6 +28806,10 @@
RelativePath="..\bindings\js\JSHTMLAppletElementCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSHTMLCanvasElementCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSHTMLCollectionCustom.cpp"
>
......
......@@ -644,7 +644,6 @@
33503CC71017A1B1003B47E1 /* Notification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503CC61017A1B1003B47E1 /* Notification.cpp */; };
3390CA550FFC157B00921962 /* NotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3390CA510FFC157B00921962 /* NotificationCenter.cpp */; };
3390CA560FFC157B00921962 /* NotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3390CA520FFC157B00921962 /* NotificationCenter.h */; };
3390CA570FFC157B00921962 /* NotificationCenter.idl in Resources */ = {isa = PBXBuildFile; fileRef = 3390CA530FFC157B00921962 /* NotificationCenter.idl */; };
3390CA580FFC157B00921962 /* NotificationContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 3390CA540FFC157B00921962 /* NotificationContents.h */; };
371F4F400D25B9AF00ECE0D5 /* FontData.h in Headers */ = {isa = PBXBuildFile; fileRef = 371F4F3E0D25B9AF00ECE0D5 /* FontData.h */; settings = {ATTRIBUTES = (Private, ); }; };
371F4F410D25B9AF00ECE0D5 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371F4F3F0D25B9AF00ECE0D5 /* FontData.cpp */; };
......@@ -2099,6 +2098,8 @@
938E65F709F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */; };
938E666009F09B81008A48EC /* JSHTMLCanvasElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 938E665F09F09B81008A48EC /* JSHTMLCanvasElement.cpp */; };
938E666209F09B87008A48EC /* JSHTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 938E666109F09B87008A48EC /* JSHTMLCanvasElement.h */; };
9392262D1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392262C1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp */; };
9392262F10321084006E7D5D /* JSCSSRuleListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */; };
9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F1410AD185F400691BD4 /* RenderCounter.h */; };
9392F1440AD185FE00691BD4 /* RenderCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392F1430AD185FE00691BD4 /* RenderCounter.cpp */; };
9392F14C0AD1861B00691BD4 /* CounterNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F14B0AD1861B00691BD4 /* CounterNode.h */; };
......@@ -7121,6 +7122,8 @@
938E662509F09956008A48EC /* HTMLCanvasElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLCanvasElement.idl; sourceTree = "<group>"; };
938E665F09F09B81008A48EC /* JSHTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCanvasElement.cpp; sourceTree = "<group>"; };
938E666109F09B87008A48EC /* JSHTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLCanvasElement.h; sourceTree = "<group>"; };
9392262C1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCanvasElementCustom.cpp; sourceTree = "<group>"; };
9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSRuleListCustom.cpp; sourceTree = "<group>"; };
9392F1410AD185F400691BD4 /* RenderCounter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderCounter.h; sourceTree = "<group>"; };
9392F1430AD185FE00691BD4 /* RenderCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCounter.cpp; sourceTree = "<group>"; };
9392F14B0AD1861B00691BD4 /* CounterNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CounterNode.h; sourceTree = "<group>"; };
......@@ -13794,6 +13797,7 @@
C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */,
FE700DD00F92D81A008E2BFE /* JSCoordinatesCustom.cpp */,
BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */,
BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
FE80D7A20E9C1ED2000D6F75 /* JSCustomPositionCallback.cpp */,
......@@ -13827,6 +13831,7 @@
FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */,
BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
9392262C1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp */,
BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
BCBCAE530FF1A29E000762AE /* JSHTMLDataGridElementCustom.cpp */,
BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */,
......@@ -19303,6 +19308,8 @@
49484FC7102CF23C00187DD3 /* CanvasPixelArray.cpp in Sources */,
49484FCA102CF23C00187DD3 /* CanvasRenderingContext2D.cpp in Sources */,
49484FCD102CF23C00187DD3 /* CanvasStyle.cpp in Sources */,
9392262D1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp in Sources */,
9392262F10321084006E7D5D /* JSCSSRuleListCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -60,6 +60,7 @@ This file contains the list of files needed to build WebCore.
bindings/js/JSClipboardCustom.cpp
bindings/js/JSConsoleCustom.cpp
bindings/js/JSCSSRuleCustom.cpp
bindings/js/JSCSSRuleListCustom.cpp
bindings/js/JSCSSStyleDeclarationCustom.cpp
bindings/js/JSCSSValueCustom.cpp
bindings/js/JSCoordinatesCustom.cpp
......@@ -90,6 +91,7 @@ This file contains the list of files needed to build WebCore.
bindings/js/JSHTMLAllCollection.cpp
bindings/js/JSHistoryCustom.cpp
bindings/js/JSHTMLAppletElementCustom.cpp
bindings/js/JSHTMLCanvasElementCustom.cpp
bindings/js/JSHTMLCollectionCustom.cpp
bindings/js/JSHTMLDataGridElementCustom.cpp
bindings/js/JSHTMLDocumentCustom.cpp
......
/*
* Copyright (C) 2009 Apple Inc. All right reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSCSSRuleList.h"
#include "CSSRuleList.h"
using namespace JSC;
namespace WebCore {
void JSCSSRuleList::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
CSSRuleList* list = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
unsigned length = list->length();
for (unsigned i = 0; i < length; ++i)
markDOMObjectWrapper(markStack, globalData, list->item(i));
}
}
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,8 +27,8 @@
#include "JSCSSStyleDeclarationCustom.h"
#include "AtomicString.h"
#include "CSSMutableStyleDeclaration.h"
#include "CSSPrimitiveValue.h"
#include "CSSStyleDeclaration.h"
#include "CSSValue.h"
#include "PlatformString.h"
#include <runtime/StringObjectThatMasqueradesAsUndefined.h>
......@@ -40,6 +40,21 @@ using namespace WTF;
namespace WebCore {
void JSCSSStyleDeclaration::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
CSSStyleDeclaration* declaration = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
if (declaration->isMutableStyleDeclaration()) {
CSSMutableStyleDeclaration* mutableDeclaration = static_cast<CSSMutableStyleDeclaration*>(declaration);
CSSMutableStyleDeclaration::const_iterator end = mutableDeclaration->end();
for (CSSMutableStyleDeclaration::const_iterator it = mutableDeclaration->begin(); it != end; ++it)
markDOMObjectWrapper(markStack, globalData, it->value());
}
}
// Check for a CSS prefix.
// Passed prefix is all lowercase.
// First character of the prefix within the property name may be upper or lowercase.
......
......@@ -28,6 +28,7 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "HTMLAudioElement.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
#include "HTMLScriptElement.h"
#include "HTMLNames.h"
......@@ -264,18 +265,48 @@ static inline bool isObservableThroughDOM(JSNode* jsNode)
Node* node = jsNode->impl();
if (node->inDocument()) {
// 1. If a node is in the document, and its wrapper has custom properties,
// If a node is in the document, and its wrapper has custom properties,
// the wrapper is observable because future access to the node through the
// DOM must reflect those properties.
if (jsNode->hasCustomProperties())
return true;
// 2. If a node is in the document, and has event listeners, its wrapper is
// If a node is in the document, and has event listeners, its wrapper is
// observable because its wrapper is responsible for marking those event listeners.
if (node->eventListeners().size())
return true; // Technically, we may overzealously mark a wrapper for a node that has only non-JS event listeners. Oh well.
// If a node owns another object with a wrapper with custom properties,
// the wrapper must be treated as observable, because future access to
// those objects through the DOM must reflect those properties.
// FIXME: It would be better if this logic could be in the node next to
// the custom markChildren functions rather than here.
if (node->isElementNode()) {
if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) {
if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), attributes)) {
if (wrapper->hasCustomProperties())
return true;
}
}
if (node->isStyledElement()) {
if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) {
if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), style)) {
if (wrapper->hasCustomProperties())
return true;
}
}
}
if (static_cast<Element*>(node)->hasTagName(canvasTag)) {
if (CanvasRenderingContext2D* context = static_cast<HTMLCanvasElement*>(node)->renderingContext2D()) {
if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), context)) {
if (wrapper->hasCustomProperties())
return true;
}
}
}
}
} else {
// 3. If a wrapper is the last reference to an image or script element
// If a wrapper is the last reference to an image or script element
// that is loading but not in the document, the wrapper is observable
// because it is the only thing keeping the image element alive, and if
// the image element is destroyed, its load event will not fire.
......@@ -348,6 +379,9 @@ void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocum
void markDOMObjectWrapper(MarkStack& markStack, JSGlobalData& globalData, void* object)
{
// FIXME: This could be changed to only mark wrappers that are "observable"
// as markDOMNodesForDocument does, allowing us to collect more wrappers,
// but doing this correctly would be challenging.
if (!object)
return;
DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, object);
......
......@@ -61,7 +61,7 @@ namespace WebCore {
#endif
};
// FIXME: This class should colapse into DOMObject once all DOMObjects are
// FIXME: This class should collapse into DOMObject once all DOMObjects are
// updated to store a globalObject pointer.
class DOMObjectWithGlobalPointer : public DOMObject {
public:
......
......@@ -42,8 +42,14 @@ namespace WebCore {
void JSDocument::markChildren(MarkStack& markStack)
{
JSNode::markChildren(markStack);
markDOMNodesForDocument(markStack, impl());
markActiveObjectsForContext(markStack, *Heap::heap(this)->globalData(), impl());
Document* document = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
markDOMNodesForDocument(markStack, document);
markActiveObjectsForContext(markStack, globalData, document);
markDOMObjectWrapper(markStack, globalData, document->implementation());
markDOMObjectWrapper(markStack, globalData, document->styleSheets());
}
JSValue JSDocument::location(ExecState* exec) const
......
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -51,6 +51,18 @@ namespace WebCore {
using namespace HTMLNames;
void JSElement::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
Element* element = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
markDOMObjectWrapper(markStack, globalData, element->attributeMap());
if (element->isStyledElement())
markDOMObjectWrapper(markStack, globalData, static_cast<StyledElement*>(element)->inlineStyleDecl());
}
static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* element, const String& name, const String& value)
{
if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIsJavaScript(deprecatedParseURL(value))) {
......@@ -59,7 +71,7 @@ static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* elem
return false;
}
return true;
}
}
JSValue JSElement::setAttribute(ExecState* exec, const ArgList& args)
{
......
/*
* Copyright (C) 2009 Apple Inc. All right reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSHTMLCanvasElement.h"
#include "HTMLCanvasElement.h"
using namespace JSC;
namespace WebCore {
void JSHTMLCanvasElement::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl());
JSGlobalData& globalData = *Heap::heap(this)->globalData();
markDOMObjectWrapper(markStack, globalData, canvas->renderingContext2D());
}
}
......@@ -56,12 +56,19 @@ void JSStyleSheet::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
StyleSheet* sheet = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
unsigned length = sheet->length();
for (unsigned i = 0; i < length; ++i)
markDOMObjectWrapper(markStack, globalData, sheet->item(i));
// This prevents us from having a style sheet with a dangling ownerNode pointer.
// A better solution would be to handle this on the DOM side -- if the style sheet
// is kept around, then we want the node to stay around too. One possibility would
// be to make ref/deref on the style sheet ref/deref the node instead, but there's
// a lot of disentangling of the CSS DOM objects that would need to happen first.
if (Node* ownerNode = impl()->ownerNode()) {
if (Node* ownerNode = sheet->ownerNode()) {
if (JSNode* ownerNodeWrapper = getCachedDOMNodeWrapper(ownerNode->document(), ownerNode))
markStack.append(ownerNodeWrapper);
}
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -35,6 +35,18 @@ using namespace JSC;
namespace WebCore {
void JSStyleSheetList::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
StyleSheetList* list = impl();
JSGlobalData& globalData = *Heap::heap(this)->globalData();
unsigned length = list->length();
for (unsigned i = 0; i < length; ++i)
markDOMObjectWrapper(markStack, globalData, list->item(i));
}
bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, const Identifier& propertyName)
{
return styleSheetList->getNamedItem(propertyName);
......
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,6 +27,7 @@ module css {
// Introduced in DOM Level 2:
interface [
CustomMarkFunction,
GenerateConstructor,
HasIndexGetter,
InterfaceUUID=64c346a0-1e34-49d3-9472-57ec8e0fdccb,
......
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
......@@ -22,6 +22,7 @@ module css {
// Introduced in DOM Level 2:
interface [
CustomMarkFunction,
GenerateConstructor,
DelegatingPutFunction,
HasNameGetter,
......
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
......@@ -22,6 +22,7 @@ module stylesheets {
// Introduced in DOM Level 2:
interface [
CustomMarkFunction,
GenerateConstructor,
HasIndexGetter,
HasNameGetter,
......
......@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -42,7 +42,7 @@ class IntSize;
class Element : public ContainerNode {
public:
Element(const QualifiedName&, Document*);
~Element();
virtual ~Element();
const AtomicString& getIDAttribute() const;
bool hasAttribute(const QualifiedName&) const;
......@@ -64,7 +64,6 @@ public:
void scrollIntoView(bool alignToTop = true);
void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
void scrollByUnits(int units, ScrollGranularity);
void scrollByLines(int lines);
void scrollByPages(int pages);
......@@ -108,17 +107,11 @@ public:
const AtomicString& localName() const { return m_tagName.localName(); }
const AtomicString& prefix() const { return m_tagName.prefix(); }
virtual void setPrefix(const AtomicString&, ExceptionCode&);
const AtomicString& namespaceURI() const { return m_tagName.namespaceURI(); }
virtual KURL baseURI() const;
// DOM methods overridden from parent classes
virtual NodeType nodeTyp