Gitweb links:
...log
http://git.netsurf-browser.org/libdom.git/shortlog/200e0137b1d6397af6097d9359749e09622ba83a
...commit
http://git.netsurf-browser.org/libdom.git/commit/200e0137b1d6397af6097d9359749e09622ba83a
...tree
http://git.netsurf-browser.org/libdom.git/tree/200e0137b1d6397af6097d9359749e09622ba83a
The branch, master has been updated
via 200e0137b1d6397af6097d9359749e09622ba83a (commit)
from 9bb1399bac063e4daac119fc636147cbab066c9d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=200e0137b1d6397af6097d9359749e09622ba83a
commit 200e0137b1d6397af6097d9359749e09622ba83a
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
DOMTSHandler: Unref nodes in for-each blocks
In order to satisfy (hopefully) the last of the sanitize checks,
ensure that we unref nodes during `for-each` iterations.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm
index 81ac9b1..7c68cd4 100644
--- a/test/DOMTSHandler.pm
+++ b/test/DOMTSHandler.pm
@@ -180,6 +180,7 @@ sub new {
# The list for UNREF
unref => [],
string_unref => [],
+ block_unrefs => ["!!!"],
# The indent of current statement
indent => "",
# The variables for List/Collection
@@ -1251,7 +1252,9 @@ sub generate_control_statement {
}
case "for-each" {
- # Detect what is the collection type, if it is
"string", we
+ # Push a block onto the cleanups
+ push(@{$self->{"block_unrefs"}}, "b");
+ # Detect what is the collection type, if it is
"string", we
# should also do some conversion work
my $coll = $ats->{"collection"};
# The default member type is dom_node
@@ -1308,6 +1311,7 @@ sub generate_control_statement {
print "foreach_initialise_domnodelist($coll,
\&iterator$iterator_index);\n";
print "while(get_next_domnodelist($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
if ($self->{"var"}->{$coll} eq "NamedNodeMap") {
@@ -1316,6 +1320,7 @@ sub generate_control_statement {
print
"foreach_initialise_domnamednodemap($coll, \&iterator$iterator_index);\n";
print "while(get_next_domnamednodemap($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
if ($self->{"var"}->{$coll} eq "HTMLCollection") {
@@ -1324,6 +1329,7 @@ sub generate_control_statement {
print
"foreach_initialise_domhtmlcollection($coll, \&iterator$iterator_index);\n";
print "while(get_next_domhtmlcollection($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
}
}
@@ -1342,12 +1348,20 @@ sub complete_control_statement {
case [qw(if while for-each)] {
# Firstly, we should cleanup the dom_string in this
block
$self->cleanup_block_domstring();
-
+ $self->pop_block_unrefs() if ($name eq 'for-each');
print "}\n";
}
}
}
+sub pop_block_unrefs {
+ my ($self) = @_;
+ while ((my $var = pop(@{$self->{'block_unrefs'}})) ne 'b') {
+ die "OMG!" if ($var eq '!!!');
+ print("if ($var != NULL) {\n dom_node_unref($var);\n $var =
NULL;\n}\n");
+ }
+}
+
###############################################################################
#
-----------------------------------------------------------------------
Summary of changes:
test/DOMTSHandler.pm | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm
index 81ac9b1..7c68cd4 100644
--- a/test/DOMTSHandler.pm
+++ b/test/DOMTSHandler.pm
@@ -180,6 +180,7 @@ sub new {
# The list for UNREF
unref => [],
string_unref => [],
+ block_unrefs => ["!!!"],
# The indent of current statement
indent => "",
# The variables for List/Collection
@@ -1251,7 +1252,9 @@ sub generate_control_statement {
}
case "for-each" {
- # Detect what is the collection type, if it is
"string", we
+ # Push a block onto the cleanups
+ push(@{$self->{"block_unrefs"}}, "b");
+ # Detect what is the collection type, if it is
"string", we
# should also do some conversion work
my $coll = $ats->{"collection"};
# The default member type is dom_node
@@ -1308,6 +1311,7 @@ sub generate_control_statement {
print "foreach_initialise_domnodelist($coll,
\&iterator$iterator_index);\n";
print "while(get_next_domnodelist($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
if ($self->{"var"}->{$coll} eq "NamedNodeMap") {
@@ -1316,6 +1320,7 @@ sub generate_control_statement {
print
"foreach_initialise_domnamednodemap($coll, \&iterator$iterator_index);\n";
print "while(get_next_domnamednodemap($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
if ($self->{"var"}->{$coll} eq "HTMLCollection") {
@@ -1324,6 +1329,7 @@ sub generate_control_statement {
print
"foreach_initialise_domhtmlcollection($coll, \&iterator$iterator_index);\n";
print "while(get_next_domhtmlcollection($coll,
\&iterator$iterator_index, \&$member)) {\n";
$self->addto_cleanup($member);
+ push(@{$self->{'block_unrefs'}}, $member);
}
}
}
@@ -1342,12 +1348,20 @@ sub complete_control_statement {
case [qw(if while for-each)] {
# Firstly, we should cleanup the dom_string in this
block
$self->cleanup_block_domstring();
-
+ $self->pop_block_unrefs() if ($name eq 'for-each');
print "}\n";
}
}
}
+sub pop_block_unrefs {
+ my ($self) = @_;
+ while ((my $var = pop(@{$self->{'block_unrefs'}})) ne 'b') {
+ die "OMG!" if ($var eq '!!!');
+ print("if ($var != NULL) {\n dom_node_unref($var);\n $var =
NULL;\n}\n");
+ }
+}
+
###############################################################################
#
--
Document Object Model library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org