Source/WebCore/ChangeLog

 12013-06-06 Diego Pino Garcia <dpino@igalia.com>
 2
 3 [GTK] Parameters 'inResult' and 'resolver' from function 'webkit_dom_document_evaluate' should be allowed to be NULL
 4 https://bugs.webkit.org/show_bug.cgi?id=117129
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 At this moment there was a temporary fix that allowed parameter
 9 'inResult' to be NULL (see: webk.it/42115). However, there was no fix
 10 for parameter 'resolver'.
 11
 12 This patch refactors the code of the previous fix, moving the code for
 13 determine whether a parameter can be NULL or not to GetGReturnMacro.
 14 The solution is quite general and will alow to add other parameters in
 15 the future if needed.
 16
 17 * bindings/scripts/CodeGeneratorGObject.pm:
 18 (GetGReturnMacro): Pass functionName, as in some cases the code
 19 generated depends on the paramName and the functionName
 20 (ParamCanBeNull): Checks if a parameter is allowed to be NULL
 21 (GenerateFunction):
 22
1232013-06-05 Ryosuke Niwa <rniwa@webkit.org>
224
325 Revert the second half of r151257. WebGLRenderingContext::create can return null.

Source/WebKit/gtk/ChangeLog

 12013-06-06 Diego Pino Garcia <dpino@igalia.com>
 2
 3 [GTK] Parameters 'inResult' and 'resolver' from function 'webkit_dom_document_evaluate' should be allowed to be NULL
 4 https://bugs.webkit.org/show_bug.cgi?id=117129
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add test for function 'webkit_dom_document_evaluate'.
 9
 10 * tests/testdomdocument.c:
 11 (test_dom_document_evaluate): Checks function dom_document_evaluate,
 12 executes an XPath expression on a HTML document.
 13 (main):
 14
1152013-06-05 Alberto Garcia <agarcia@igalia.com>
216
317 [GTK] AcceleratedCompositingContext: fix layerFlushTimerFiredCallback condition

Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

@@my %baseTypeHash = ("Object" => 1, "Node" => 1, "NodeList" => 1, "NamedNodeMap"
4545 "NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, "DOMTokenList" => 1,
4646 "HTMLCollection" => 1);
4747
 48# List of function parameters that are allowed to be NULL
 49my $canBeNullParams = {
 50 'webkit_dom_document_evaluate' => ['inResult', 'resolver']
 51};
 52
4853# Default constructor
4954sub new {
5055 my $object = shift;

@@EOF
845850}
846851
847852sub GetGReturnMacro {
848  my ($paramName, $paramIDLType, $returnType) = @_;
 853 my ($paramName, $paramIDLType, $returnType, $functionName) = @_;
849854
850855 my $condition;
851856 if ($paramIDLType eq "GError") {

@@sub GetGReturnMacro {
853858 } elsif (IsGDOMClassType($paramIDLType)) {
854859 my $paramTypeCaps = uc(FixUpDecamelizedName(decamelize($paramIDLType)));
855860 $condition = "WEBKIT_DOM_IS_${paramTypeCaps}($paramName)";
 861 if (ParamCanBeNull($functionName, $paramName)) {
 862 $condition = "!$paramName || $condition";
 863 }
856864 } else {
857865 $condition = "$paramName";
858866 }

@@sub GetGReturnMacro {
868876 return $macro;
869877}
870878
 879sub ParamCanBeNull {
 880 my($functionName, $paramName) = @_;
 881
 882 if (defined($functionName)) {
 883 return scalar(grep(/$paramName/, @{$canBeNullParams->{$functionName}}));
 884 }
 885 return 0;
 886}
 887
871888sub GenerateFunction {
872889 my ($object, $interfaceName, $function, $prefix, $parentNode) = @_;
873890

@@sub GenerateFunction {
973990 my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType);
974991 my $paramIsGDOMType = IsGDOMClassType($paramIDLType);
975992 if (!$paramTypeIsPrimitive) {
976  # FIXME: Temporary hack for generating a proper implementation
977  # of the webkit_dom_document_evaluate function (Bug-ID: 42115)
978  if (!(($functionName eq "webkit_dom_document_evaluate") && ($paramIDLType eq "XPathResult"))) {
979  $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType);
980  push(@cBody, $gReturnMacro);
981  }
 993 $gReturnMacro = GetGReturnMacro($paramName, $paramIDLType, $returnType, $functionName);
 994 push(@cBody, $gReturnMacro);
982995 }
983996 }
984997

Source/WebKit/gtk/tests/testdomdocument.c

3232#define HTML_DOCUMENT_LINKS "<html><head><title>Title</title></head><body><a href=\"about:blank\">blank</a><a href=\"http://www.google.com\">google</a><a href=\"http://www.webkit.org\">webkit</a></body></html>"
3333#define HTML_DOCUMENT_IFRAME "<html><head><title>IFrame</title></head><body><iframe id='iframe'></iframe><div id='test'></div></body></html>"
3434#define HTML_DOCUMENT_TABLE "<html><body><table id=\"table\"></table></body></html>"
 35#define HTML_DOCUMENT_EVALUATE "<html><head><title></title></head><body><div>First div</div><div>Second div</div></body></html>"
3536
3637typedef struct {
3738 GtkWidget* webView;

@@static void test_dom_document_insert_row(DomDocumentFixture* fixture, gconstpoin
208209 g_assert_cmpint(webkit_dom_html_collection_get_length(rows), ==, 1);
209210}
210211
 212static void test_dom_document_evaluate(DomDocumentFixture* fixture, gconstpointer data)
 213{
 214 g_assert(fixture);
 215 WebKitWebView* view = (WebKitWebView*)fixture->webView;
 216 g_assert(view);
 217 WebKitDOMDocument* document = webkit_web_view_get_dom_document(view);
 218 g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 219 WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_tag_name(document, "html");
 220 g_assert(list);
 221 gulong length = webkit_dom_node_list_get_length(list);
 222 g_assert_cmpint(length, ==, 1);
 223 WebKitDOMNode* html = webkit_dom_node_list_item(list, 0);
 224 g_assert(WEBKIT_DOM_IS_NODE(html));
 225
 226 WebKitDOMXPathResult* result = webkit_dom_document_evaluate(document, "//div", html, NULL, 0, NULL, NULL);
 227 g_assert(WEBKIT_DOM_IS_XPATH_RESULT(result));
 228
 229 int i = 0;
 230 WebKitDOMNode* node;
 231 while ( (node = webkit_dom_xpath_result_iterate_next(result, NULL)) != NULL) {
 232 g_assert(node);
 233 WebKitDOMElement* element = (WebKitDOMElement*)node;
 234 g_assert_cmpstr(webkit_dom_element_get_tag_name(element), ==, "DIV");
 235 i++;
 236 }
 237 g_assert_cmpint(i, ==, 2);
 238
 239 g_object_unref(list);
 240}
 241
211242static void weak_notify(gpointer data, GObject* zombie)
212243{
213244 guint* count = (guint*)data;

@@int main(int argc, char** argv)
380411 test_dom_document_insert_row,
381412 dom_document_fixture_teardown);
382413
 414 g_test_add("/webkit/domdocument/test_document_evaluate",
 415 DomDocumentFixture, HTML_DOCUMENT_EVALUATE,
 416 dom_document_fixture_setup,
 417 test_dom_document_evaluate,
 418 dom_document_fixture_teardown);
 419
383420 g_test_add("/webkit/domdocument/test_garbage_collection",
384421 DomDocumentFixture, HTML_DOCUMENT_LINKS,
385422 dom_document_fixture_setup,