- Revision
- 151267
- Author
- [email protected]
- Date
- 2013-06-06 06:39:27 -0700 (Thu, 06 Jun 2013)
Log Message
[GTK] Parameters 'inResult' and 'resolver' from function 'webkit_dom_document_evaluate' should be allowed to be NULL
https://bugs.webkit.org/show_bug.cgi?id=117129
Patch by Diego Pino Garcia <[email protected]> on 2013-06-06
Reviewed by Xan Lopez.
Source/WebCore:
At this moment there was a temporary fix that allowed parameter
'inResult' to be NULL (see: webk.it/42115). However, there was no fix
for parameter 'resolver'.
This patch refactors the code of the previous fix, moving the code for
determine whether a parameter can be NULL or not to GetGReturnMacro.
The solution is quite general and will alow to add other parameters in
the future if needed.
* bindings/scripts/CodeGeneratorGObject.pm:
(GetGReturnMacro): Pass functionName, as in some cases the code
generated depends on the paramName and the functionName
(ParamCanBeNull): Checks if a parameter is allowed to be NULL
(GenerateFunction):
Source/WebKit/gtk:
Add test for function 'webkit_dom_document_evaluate'.
* tests/testdomdocument.c:
(test_dom_document_evaluate): Checks function dom_document_evaluate,
executes an XPath _expression_ on a HTML document.
(main):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151266 => 151267)
--- trunk/Source/WebCore/ChangeLog 2013-06-06 12:57:46 UTC (rev 151266)
+++ trunk/Source/WebCore/ChangeLog 2013-06-06 13:39:27 UTC (rev 151267)
@@ -1,3 +1,25 @@
+2013-06-06 Diego Pino Garcia <[email protected]>
+
+ [GTK] Parameters 'inResult' and 'resolver' from function 'webkit_dom_document_evaluate' should be allowed to be NULL
+ https://bugs.webkit.org/show_bug.cgi?id=117129
+
+ Reviewed by Xan Lopez.
+
+ At this moment there was a temporary fix that allowed parameter
+ 'inResult' to be NULL (see: webk.it/42115). However, there was no fix
+ for parameter 'resolver'.
+
+ This patch refactors the code of the previous fix, moving the code for
+ determine whether a parameter can be NULL or not to GetGReturnMacro.
+ The solution is quite general and will alow to add other parameters in
+ the future if needed.
+
+ * bindings/scripts/CodeGeneratorGObject.pm:
+ (GetGReturnMacro): Pass functionName, as in some cases the code
+ generated depends on the paramName and the functionName
+ (ParamCanBeNull): Checks if a parameter is allowed to be NULL
+ (GenerateFunction):
+
2013-06-06 Zalan Bujtas <[email protected]>
SVG objects are misplaced when SVG root has CSS transform.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (151266 => 151267)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2013-06-06 12:57:46 UTC (rev 151266)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2013-06-06 13:39:27 UTC (rev 151267)
@@ -45,6 +45,11 @@
"NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, "DOMTokenList" => 1,
"HTMLCollection" => 1);
+# List of function parameters that are allowed to be NULL
+my $canBeNullParams = {
+ 'webkit_dom_document_evaluate' => ['inResult', 'resolver']
+};
+
# Default constructor
sub new {
my $object = shift;
@@ -845,7 +850,7 @@
}
sub GetGReturnMacro {
- my ($paramName, $paramIDLType, $returnType) = @_;
+ my ($paramName, $paramIDLType, $returnType, $functionName) = @_;
my $condition;
if ($paramIDLType eq "GError") {
@@ -853,6 +858,9 @@
} elsif (IsGDOMClassType($paramIDLType)) {
my $paramTypeCaps = uc(FixUpDecamelizedName(decamelize($paramIDLType)));
$condition = "WEBKIT_DOM_IS_${paramTypeCaps}($paramName)";
+ if (ParamCanBeNull($functionName, $paramName)) {
+ $condition = "!$paramName || $condition";
+ }
} else {
$condition = "$paramName";
}
@@ -868,6 +876,15 @@
return $macro;
}
+sub ParamCanBeNull {
+ my($functionName, $paramName) = @_;
+
+ if (defined($functionName)) {
+ return scalar(grep(/$paramName/, @{$canBeNullParams->{$functionName}}));
+ }
+ return 0;
+}
+
sub GenerateFunction {
my ($object, $interfaceName, $function, $prefix, $parentNode) = @_;
@@ -973,12 +990,8 @@
my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType);
my $paramIsGDOMType = IsGDOMClassType($paramIDLType);
if (!$paramTypeIsPrimitive) {
- # FIXME: Temporary hack for generating a proper implementation
- # of the webkit_dom_document_evaluate function (Bug-ID: 42115)
- if (!(($functionName eq "webkit_dom_document_evaluate") && ($paramIDLType eq "XPathResult"))) {
- $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType);
- push(@cBody, $gReturnMacro);
- }
+ $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType, $functionName);
+ push(@cBody, $gReturnMacro);
}
}
Modified: trunk/Source/WebKit/gtk/ChangeLog (151266 => 151267)
--- trunk/Source/WebKit/gtk/ChangeLog 2013-06-06 12:57:46 UTC (rev 151266)
+++ trunk/Source/WebKit/gtk/ChangeLog 2013-06-06 13:39:27 UTC (rev 151267)
@@ -1,3 +1,17 @@
+2013-06-06 Diego Pino Garcia <[email protected]>
+
+ [GTK] Parameters 'inResult' and 'resolver' from function 'webkit_dom_document_evaluate' should be allowed to be NULL
+ https://bugs.webkit.org/show_bug.cgi?id=117129
+
+ Reviewed by Xan Lopez.
+
+ Add test for function 'webkit_dom_document_evaluate'.
+
+ * tests/testdomdocument.c:
+ (test_dom_document_evaluate): Checks function dom_document_evaluate,
+ executes an XPath _expression_ on a HTML document.
+ (main):
+
2013-06-05 Alberto Garcia <[email protected]>
[GTK] AcceleratedCompositingContext: fix layerFlushTimerFiredCallback condition
Modified: trunk/Source/WebKit/gtk/tests/testdomdocument.c (151266 => 151267)
--- trunk/Source/WebKit/gtk/tests/testdomdocument.c 2013-06-06 12:57:46 UTC (rev 151266)
+++ trunk/Source/WebKit/gtk/tests/testdomdocument.c 2013-06-06 13:39:27 UTC (rev 151267)
@@ -32,6 +32,7 @@
#define HTML_DOCUMENT_LINKS "<html><head><title>Title</title></head><body><a href="" href="" href=""
#define HTML_DOCUMENT_IFRAME "<html><head><title>IFrame</title></head><body><iframe id='iframe'></iframe><div id='test'></div></body></html>"
#define HTML_DOCUMENT_TABLE "<html><body><table id=\"table\"></table></body></html>"
+#define HTML_DOCUMENT_EVALUATE "<html><head><title></title></head><body><div>First div</div><div>Second div</div></body></html>"
typedef struct {
GtkWidget* webView;
@@ -208,6 +209,36 @@
g_assert_cmpint(webkit_dom_html_collection_get_length(rows), ==, 1);
}
+static void test_dom_document_evaluate(DomDocumentFixture* fixture, gconstpointer data)
+{
+ g_assert(fixture);
+ WebKitWebView* view = (WebKitWebView*)fixture->webView;
+ g_assert(view);
+ WebKitDOMDocument* document = webkit_web_view_get_dom_document(view);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+ WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_tag_name(document, "html");
+ g_assert(list);
+ gulong length = webkit_dom_node_list_get_length(list);
+ g_assert_cmpint(length, ==, 1);
+ WebKitDOMNode* html = webkit_dom_node_list_item(list, 0);
+ g_assert(WEBKIT_DOM_IS_NODE(html));
+
+ WebKitDOMXPathResult* result = webkit_dom_document_evaluate(document, "//div", html, NULL, 0, NULL, NULL);
+ g_assert(WEBKIT_DOM_IS_XPATH_RESULT(result));
+
+ int i = 0;
+ WebKitDOMNode* node;
+ while ( (node = webkit_dom_xpath_result_iterate_next(result, NULL)) != NULL) {
+ g_assert(node);
+ WebKitDOMElement* element = (WebKitDOMElement*)node;
+ g_assert_cmpstr(webkit_dom_element_get_tag_name(element), ==, "DIV");
+ i++;
+ }
+ g_assert_cmpint(i, ==, 2);
+
+ g_object_unref(list);
+}
+
static void weak_notify(gpointer data, GObject* zombie)
{
guint* count = (guint*)data;
@@ -380,6 +411,12 @@
test_dom_document_insert_row,
dom_document_fixture_teardown);
+ g_test_add("/webkit/domdocument/test_document_evaluate",
+ DomDocumentFixture, HTML_DOCUMENT_EVALUATE,
+ dom_document_fixture_setup,
+ test_dom_document_evaluate,
+ dom_document_fixture_teardown);
+
g_test_add("/webkit/domdocument/test_garbage_collection",
DomDocumentFixture, HTML_DOCUMENT_LINKS,
dom_document_fixture_setup,