Changeset 151267 in webkit


Ignore:
Timestamp:
Jun 6, 2013 6:39:27 AM (11 years ago)
Author:
commit-queue@webkit.org
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 <Diego Pino Garcia> 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):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r151265 r151267  
     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 Xan Lopez.
     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-06  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r149679 r151267  
    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 {
     
    846851
    847852sub GetGReturnMacro {
    848     my ($paramName, $paramIDLType, $returnType) = @_;
     853    my ($paramName, $paramIDLType, $returnType, $functionName) = @_;
    849854
    850855    my $condition;
     
    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";
     
    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) = @_;
     
    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    }
  • trunk/Source/WebKit/gtk/ChangeLog

    r151245 r151267  
     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 Xan Lopez.
     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
  • trunk/Source/WebKit/gtk/tests/testdomdocument.c

    r149952 r151267  
    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 {
     
    207208    g_assert(WEBKIT_DOM_IS_HTML_COLLECTION(rows));
    208209    g_assert_cmpint(webkit_dom_html_collection_get_length(rows), ==, 1);
     210}
     211
     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);
    209240}
    210241
     
    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,
Note: See TracChangeset for help on using the changeset viewer.