Changeset 58108 in webkit


Ignore:
Timestamp:
Apr 22, 2010 12:39:50 PM (14 years ago)
Author:
xan@webkit.org
Message:

WebCore:

2010-04-22 Xan Lopez <xlopez@igalia.com>

Reviewed by Gustavo Noronha.

[GTK] GObject DOM bindings
https://bugs.webkit.org/show_bug.cgi?id=33590

Extend the bindings to cover most of Document.idl

  • GNUmakefile.am:
  • bindings/gobject/WebKitDOMBinding.cpp: (WebKit::createWrapper): (WebKit::kit):
  • bindings/gobject/WebKitDOMBinding.h:
  • bindings/gobject/WebKitHTMLElementWrapperFactory.cpp: Added. (WebKit::createAnchorWrapper): (WebKit::createAppletWrapper): (WebKit::createAreaWrapper): (WebKit::createBaseWrapper): (WebKit::createBaseFontWrapper): (WebKit::createBlockquoteWrapper): (WebKit::createBodyWrapper): (WebKit::createBRWrapper): (WebKit::createButtonWrapper): (WebKit::createCanvasWrapper): (WebKit::createTableCaptionWrapper): (WebKit::createTableColWrapper): (WebKit::createModWrapper): (WebKit::createDirectoryWrapper): (WebKit::createDivWrapper): (WebKit::createDListWrapper): (WebKit::createEmbedWrapper): (WebKit::createFieldSetWrapper): (WebKit::createFontWrapper): (WebKit::createFormWrapper): (WebKit::createFrameWrapper): (WebKit::createFrameSetWrapper): (WebKit::createHeadingWrapper): (WebKit::createHeadWrapper): (WebKit::createHRWrapper): (WebKit::createHtmlWrapper): (WebKit::createIFrameWrapper): (WebKit::createImageWrapper): (WebKit::createInputWrapper): (WebKit::createIsIndexWrapper): (WebKit::createLabelWrapper): (WebKit::createLegendWrapper): (WebKit::createLIWrapper): (WebKit::createLinkWrapper): (WebKit::createMapWrapper): (WebKit::createMarqueeWrapper): (WebKit::createMenuWrapper): (WebKit::createMetaWrapper): (WebKit::createObjectWrapper): (WebKit::createOListWrapper): (WebKit::createOptGroupWrapper): (WebKit::createOptionWrapper): (WebKit::createParagraphWrapper): (WebKit::createParamWrapper): (WebKit::createPreWrapper): (WebKit::createQuoteWrapper): (WebKit::createScriptWrapper): (WebKit::createSelectWrapper): (WebKit::createStyleWrapper): (WebKit::createTableWrapper): (WebKit::createTableSectionWrapper): (WebKit::createTableCellWrapper): (WebKit::createTextAreaWrapper): (WebKit::createTitleWrapper): (WebKit::createTableRowWrapper): (WebKit::createUListWrapper): (WebKit::createHTMLElementWrapper):
  • bindings/gobject/WebKitHTMLElementWrapperFactory.h: Added.
  • bindings/scripts/CodeGeneratorGObject.pm:
  • dom/Node.idl:

WebKit/gtk:

2010-04-22 Xan Lopez <xlopez@igalia.com>

Reviewed by Gustavo Noronha.

[GTK] GObject DOM bindings
https://bugs.webkit.org/show_bug.cgi?id=33590

Add webkit_web_view_get_document to retrieve the WebKitDOMDocument
from a WebKitWebView, and a very simple test for it.

  • tests/testwebview.c:
  • webkit/webkitwebview.cpp: (webkit_web_view_get_document):
  • webkit/webkitwebview.h:
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58107 r58108  
     12010-04-22  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        [GTK] GObject DOM bindings
     6        https://bugs.webkit.org/show_bug.cgi?id=33590
     7
     8        Extend the bindings to cover most of Document.idl
     9
     10        * GNUmakefile.am:
     11        * bindings/gobject/WebKitDOMBinding.cpp:
     12        (WebKit::createWrapper):
     13        (WebKit::kit):
     14        * bindings/gobject/WebKitDOMBinding.h:
     15        * bindings/gobject/WebKitHTMLElementWrapperFactory.cpp: Added.
     16        (WebKit::createAnchorWrapper):
     17        (WebKit::createAppletWrapper):
     18        (WebKit::createAreaWrapper):
     19        (WebKit::createBaseWrapper):
     20        (WebKit::createBaseFontWrapper):
     21        (WebKit::createBlockquoteWrapper):
     22        (WebKit::createBodyWrapper):
     23        (WebKit::createBRWrapper):
     24        (WebKit::createButtonWrapper):
     25        (WebKit::createCanvasWrapper):
     26        (WebKit::createTableCaptionWrapper):
     27        (WebKit::createTableColWrapper):
     28        (WebKit::createModWrapper):
     29        (WebKit::createDirectoryWrapper):
     30        (WebKit::createDivWrapper):
     31        (WebKit::createDListWrapper):
     32        (WebKit::createEmbedWrapper):
     33        (WebKit::createFieldSetWrapper):
     34        (WebKit::createFontWrapper):
     35        (WebKit::createFormWrapper):
     36        (WebKit::createFrameWrapper):
     37        (WebKit::createFrameSetWrapper):
     38        (WebKit::createHeadingWrapper):
     39        (WebKit::createHeadWrapper):
     40        (WebKit::createHRWrapper):
     41        (WebKit::createHtmlWrapper):
     42        (WebKit::createIFrameWrapper):
     43        (WebKit::createImageWrapper):
     44        (WebKit::createInputWrapper):
     45        (WebKit::createIsIndexWrapper):
     46        (WebKit::createLabelWrapper):
     47        (WebKit::createLegendWrapper):
     48        (WebKit::createLIWrapper):
     49        (WebKit::createLinkWrapper):
     50        (WebKit::createMapWrapper):
     51        (WebKit::createMarqueeWrapper):
     52        (WebKit::createMenuWrapper):
     53        (WebKit::createMetaWrapper):
     54        (WebKit::createObjectWrapper):
     55        (WebKit::createOListWrapper):
     56        (WebKit::createOptGroupWrapper):
     57        (WebKit::createOptionWrapper):
     58        (WebKit::createParagraphWrapper):
     59        (WebKit::createParamWrapper):
     60        (WebKit::createPreWrapper):
     61        (WebKit::createQuoteWrapper):
     62        (WebKit::createScriptWrapper):
     63        (WebKit::createSelectWrapper):
     64        (WebKit::createStyleWrapper):
     65        (WebKit::createTableWrapper):
     66        (WebKit::createTableSectionWrapper):
     67        (WebKit::createTableCellWrapper):
     68        (WebKit::createTextAreaWrapper):
     69        (WebKit::createTitleWrapper):
     70        (WebKit::createTableRowWrapper):
     71        (WebKit::createUListWrapper):
     72        (WebKit::createHTMLElementWrapper):
     73        * bindings/gobject/WebKitHTMLElementWrapperFactory.h: Added.
     74        * bindings/scripts/CodeGeneratorGObject.pm:
     75        * dom/Node.idl:
     76
    1772010-04-22  Eric Carlson  <eric.carlson@apple.com>
    278
  • trunk/WebCore/GNUmakefile.am

    r58093 r58108  
    319319        WebCore/bindings/gobject/WebKitDOMBinding.cpp \
    320320        WebCore/bindings/gobject/WebKitDOMBinding.h \
     321        WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp \
     322        WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h \
    321323        WebCore/bindings/gobject/WebKitDOMObject.cpp \
    322324        WebCore/bindings/gobject/WebKitDOMObject.h
     
    37953797        WebCore/css/CSSStyleSheet.idl \
    37963798        WebCore/css/CSSValue.idl \
     3799        WebCore/css/Media.idl \
    37973800        WebCore/css/MediaList.idl \
    37983801        WebCore/css/StyleSheet.idl \
     3802        WebCore/css/StyleSheetList.idl \
    37993803        WebCore/dom/Attr.idl \
     3804        WebCore/dom/CDATASection.idl \
     3805        WebCore/dom/CharacterData.idl \
     3806        WebCore/dom/Comment.idl \
     3807        WebCore/dom/Document.idl \
     3808        WebCore/dom/DocumentFragment.idl \
     3809        WebCore/dom/DocumentType.idl \
     3810        WebCore/dom/DOMImplementation.idl \
    38003811        WebCore/dom/Element.idl \
     3812        WebCore/dom/EntityReference.idl \
     3813        WebCore/dom/MessagePort.idl \
    38013814        WebCore/dom/NamedNodeMap.idl \
    38023815        WebCore/dom/Node.idl \
    3803         WebCore/dom/NodeList.idl
     3816        WebCore/dom/NodeFilter.idl \
     3817        WebCore/dom/NodeIterator.idl \
     3818        WebCore/dom/NodeList.idl \
     3819        WebCore/dom/ProcessingInstruction.idl \
     3820        WebCore/dom/Range.idl \
     3821        WebCore/dom/Text.idl \
     3822        WebCore/dom/TreeWalker.idl \
     3823        WebCore/html/Blob.idl \
     3824        WebCore/html/File.idl \
     3825        WebCore/html/FileList.idl \
     3826        WebCore/html/HTMLAnchorElement.idl \
     3827        WebCore/html/HTMLAppletElement.idl \
     3828        WebCore/html/HTMLAreaElement.idl \
     3829        WebCore/html/HTMLBaseElement.idl \
     3830        WebCore/html/HTMLBaseFontElement.idl \
     3831        WebCore/html/HTMLBlockquoteElement.idl \
     3832        WebCore/html/HTMLBodyElement.idl \
     3833        WebCore/html/HTMLBRElement.idl \
     3834        WebCore/html/HTMLButtonElement.idl \
     3835        WebCore/html/HTMLCanvasElement.idl \
     3836        WebCore/html/HTMLCollection.idl \
     3837        WebCore/html/HTMLDirectoryElement.idl \
     3838        WebCore/html/HTMLDivElement.idl \
     3839        WebCore/html/HTMLDListElement.idl \
     3840        WebCore/html/HTMLDocument.idl \
     3841        WebCore/html/HTMLElement.idl \
     3842        WebCore/html/HTMLEmbedElement.idl \
     3843        WebCore/html/HTMLFieldSetElement.idl \
     3844        WebCore/html/HTMLFontElement.idl \
     3845        WebCore/html/HTMLFormElement.idl \
     3846        WebCore/html/HTMLFrameElement.idl \
     3847        WebCore/html/HTMLFrameSetElement.idl \
     3848        WebCore/html/HTMLHeadElement.idl \
     3849        WebCore/html/HTMLHeadingElement.idl \
     3850        WebCore/html/HTMLHRElement.idl \
     3851        WebCore/html/HTMLHtmlElement.idl \
     3852        WebCore/html/HTMLIFrameElement.idl \
     3853        WebCore/html/HTMLImageElement.idl \
     3854        WebCore/html/HTMLInputElement.idl \
     3855        WebCore/html/HTMLIsIndexElement.idl \
     3856        WebCore/html/HTMLLabelElement.idl \
     3857        WebCore/html/HTMLLegendElement.idl \
     3858        WebCore/html/HTMLLIElement.idl \
     3859        WebCore/html/HTMLLinkElement.idl \
     3860        WebCore/html/HTMLMapElement.idl \
     3861        WebCore/html/HTMLMarqueeElement.idl \
     3862        WebCore/html/HTMLMenuElement.idl \
     3863        WebCore/html/HTMLMetaElement.idl \
     3864        WebCore/html/HTMLModElement.idl \
     3865        WebCore/html/HTMLObjectElement.idl \
     3866        WebCore/html/HTMLOListElement.idl \
     3867        WebCore/html/HTMLOptGroupElement.idl \
     3868        WebCore/html/HTMLOptionElement.idl \
     3869        WebCore/html/HTMLOptionsCollection.idl \
     3870        WebCore/html/HTMLParagraphElement.idl \
     3871        WebCore/html/HTMLParamElement.idl \
     3872        WebCore/html/HTMLPreElement.idl \
     3873        WebCore/html/HTMLQuoteElement.idl \
     3874        WebCore/html/HTMLScriptElement.idl \
     3875        WebCore/html/HTMLSelectElement.idl \
     3876        WebCore/html/HTMLStyleElement.idl \
     3877        WebCore/html/HTMLTableElement.idl \
     3878        WebCore/html/HTMLTableCaptionElement.idl \
     3879        WebCore/html/HTMLTableColElement.idl \
     3880        WebCore/html/HTMLTableSectionElement.idl \
     3881        WebCore/html/HTMLTableCellElement.idl \
     3882        WebCore/html/HTMLTextAreaElement.idl \
     3883        WebCore/html/HTMLTitleElement.idl \
     3884        WebCore/html/HTMLTableRowElement.idl \
     3885        WebCore/html/HTMLUListElement.idl \
     3886        WebCore/html/ValidityState.idl \
     3887        WebCore/loader/appcache/DOMApplicationCache.idl \
     3888        WebCore/page/BarInfo.idl \
     3889        WebCore/page/Console.idl \
     3890        WebCore/page/DOMWindow.idl \
     3891        WebCore/page/DOMSelection.idl \
     3892        WebCore/page/Geolocation.idl \
     3893        WebCore/page/History.idl \
     3894        WebCore/page/Location.idl \
     3895        WebCore/page/Navigator.idl \
     3896        WebCore/page/Screen.idl \
     3897        WebCore/page/WebKitPoint.idl \
     3898        WebCore/plugins/MimeType.idl \
     3899        WebCore/plugins/MimeTypeArray.idl \
     3900        WebCore/plugins/Plugin.idl \
     3901        WebCore/plugins/PluginArray.idl \
     3902        WebCore/storage/Database.idl \
     3903        WebCore/storage/Storage.idl \
     3904        WebCore/xml/XPathExpression.idl \
     3905        WebCore/xml/XPathNSResolver.idl \
     3906        WebCore/xml/XPathResult.idl
    38043907
    38053908# All classes autogenerated in the GObject DOM bindings
  • trunk/WebCore/bindings/gobject/WebKitDOMBinding.cpp

    r57987 r58108  
    2828#include "EventException.h"
    2929#include "HTMLNames.h"
     30#include "WebKitDOMElementPrivate.h"
    3031#include "WebKitDOMNode.h"
    3132#include "WebKitDOMNodePrivate.h"
     33#include "WebKitHTMLElementWrapperFactory.h"
    3234
    3335namespace WebKit {
     
    6769{
    6870    ASSERT(node);
     71    ASSERT(node->nodeType());
    6972
    7073    gpointer wrappedNode = 0;
    7174
    72     if (node->nodeType())
     75    switch (node->nodeType()) {
     76    case Node::ELEMENT_NODE:
     77        if (node->isHTMLElement())
     78            wrappedNode = createHTMLElementWrapper(static_cast<HTMLElement*>(node));
     79        else
     80            wrappedNode = wrapNode(node);
     81        break;
     82    default:
    7383        wrappedNode = wrapNode(node);
     84        break;
     85    }
    7486
    7587    return DOMObjectCache::put(node, wrappedNode);
     
    88100}
    89101
     102gpointer kit(Element* element)
     103{
     104    if (!element)
     105        return 0;
     106
     107    gpointer kitElement = DOMObjectCache::get(element);
     108    if (kitElement)
     109        return kitElement;
     110
     111    gpointer wrappedElement;
     112
     113    if (element->isHTMLElement())
     114        wrappedElement = createHTMLElementWrapper(static_cast<HTMLElement*>(element));
     115    else
     116        wrappedElement = wrapElement(element);
     117
     118    return DOMObjectCache::put(element, wrappedElement);
     119}
     120
    90121} // namespace WebKit
  • trunk/WebCore/bindings/gobject/WebKitDOMBinding.h

    r57985 r58108  
    2929namespace WebCore {
    3030class Node;
     31class Element;
    3132} // namespace WebCore
    3233
    3334namespace WebKit {
    3435gpointer kit(WebCore::Node* node);
     36gpointer kit(WebCore::Element* element);
    3537
    3638class DOMObjectCache {
  • trunk/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r57985 r58108  
    9696}
    9797
     98sub FixUpDecamelizedName {
     99    my $classname = shift;
     100
     101    # FIXME: try to merge this somehow with the fixes in ClassNameToGobjectType
     102    $classname =~ s/x_path/xpath/;
     103    $classname =~ s/web_kit/webkit/;
     104
     105    return $classname;
     106}
     107
    98108sub ClassNameToGObjectType {
    99109    my $className = shift;
     
    103113    # might be more like this in the future)
    104114    $CLASS_NAME =~ s/DOMCSS/DOM_CSS/;
     115    $CLASS_NAME =~ s/DOMHTML/DOM_HTML/;
     116    $CLASS_NAME =~ s/DOMDOM/DOM_DOM/;
     117    $CLASS_NAME =~ s/DOMCDATA/DOM_CDATA/;
     118    $CLASS_NAME =~ s/DOMX_PATH/DOM_XPATH/;
     119    $CLASS_NAME =~ s/DOM_WEB_KIT/DOM_WEBKIT/;
    105120    return $CLASS_NAME;
    106121}
     
    129144   
    130145    if ($attribute->signature->extendedAttributes->{"CustomGetter"} ||
    131         $attribute->signature->extendedAttributes->{"CustomSetter"}) {
     146        $attribute->signature->extendedAttributes->{"CustomSetter"} ||
     147        $attribute->signature->extendedAttributes->{"Replaceable"}) {
    132148        return 1;
    133149    }
     
    139155
    140156    if ($propType =~ /Constructor$/) {
     157        return 1;
     158    }
     159
     160    # This is for DOMWindow.idl location attribute
     161    if ($attribute->signature->name eq "location") {
     162        return 1;
     163    }
     164
     165    # This is for HTMLInput.idl valueAsDate
     166    if ($attribute->signature->name eq "valueAsDate") {
     167        return 1;
     168    }
     169
     170    # This is for DOMWindow.idl Crypto attribute
     171    if ($attribute->signature->type eq "Crypto") {
     172        return 1;
     173    }
     174
     175    return 0;
     176}
     177
     178sub SkipFunction {
     179    my $function = shift;
     180
     181    # FIXME: skip all custom methods; is this ok?
     182    if ($function->signature->extendedAttributes->{"Custom"}) {
     183        return 1;
     184    }
     185
     186    if ($function->signature->type eq "Event") {
     187        return 1;
     188    }
     189
     190    if ($function->signature->name eq "getSVGDocument") {
     191        return 1;
     192    }
     193
     194    if ($function->signature->name eq "getCSSCanvasContext") {
    141195        return 1;
    142196    }
     
    173227
    174228    my %types = ("DOMString", "gchar* ",
     229                 "CompareHow", "gushort",
    175230                 "float", "gfloat",
    176231                 "double", "gdouble",
     
    195250
    196251    return 0 if $type eq "DOMString";
     252    return 0 if $type eq "CompareHow";
    197253    return 0 if $type eq "float";
    198254    return 0 if $type eq "double";
     
    217273
    218274    my $clsCaps = substr(ClassNameToGObjectType($className), 12);
    219     my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName));
     275    my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName)));
    220276
    221277    # Properties
     
    298354
    299355        my $convertFunction = "";
     356        if ($gtype eq "string") {
     357            $convertFunction = "WebCore::String::fromUTF8";
     358        } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) {
     359            $convertFunction = "WebCore::String::number";
     360        }
     361
     362        my $setterContentHead;
     363        my $getterContentHead;
     364        my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
     365        my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
     366        if ($reflect || $reflectURL) {
     367            my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $camelPropName : ($reflect || $reflectURL);
     368            my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
     369            $implIncludes{"${namespace}.h"} = 1;
     370            my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
     371            $setterContentHead = "coreSelf->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${convertFunction}(g_value_get_$gtype(value))";
     372            $getterContentHead = "coreSelf->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr";
     373        } else {
     374            $setterContentHead = "coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))";
     375            $getterContentHead = "coreSelf->${getPropNameFunction}(";
     376        }
    300377
    301378        if ($writeable && ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" ||
     
    306383            push(@txtSetProps, "   case ${propEnum}:\n    {\n");
    307384            push(@txtSetProps, "        WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
    308 
    309             if ($gtype eq "string") {
    310                 $convertFunction = "WebCore::String::fromUTF8";
    311             } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) {
    312                 $convertFunction = "WebCore::String::number";
    313             }
    314 
    315             push(@txtSetProps, "        coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))");
     385            push(@txtSetProps, "        ${setterContentHead}");
    316386            push(@txtSetProps, ", ec") if @{$attribute->setterExceptions};
    317387            push(@txtSetProps, ");\n");
    318 
    319388            push(@txtSetProps, "        break;\n    }\n");
    320389        }
     
    331400        my $done = 0;
    332401        if ($gtype eq "string") {
    333             push(@txtGetProps, "        g_value_take_string(value, convertToUTF8String(coreSelf->${getPropNameFunction}(${exception})));\n");
     402            push(@txtGetProps, "        g_value_take_string(value, convertToUTF8String(${getterContentHead}${exception})));\n");
    334403            $done = 1;
    335404        } elsif ($gtype eq "object") {
    336 
    337405            $txtGetProp = << "EOF";
    338406        RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception});
     
    340408EOF
    341409            push(@txtGetProps, $txtGetProp);
    342 
    343410            $done = 1;
    344411        }
     
    484551    push(@hBodyPre, $implContent);
    485552
    486     my $clsCaps = uc(decamelize($interfaceName));
    487     my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName));
     553    my $decamelize = FixUpDecamelizedName(decamelize($interfaceName));
     554    my $clsCaps = uc($decamelize);
     555    my $lowerCaseIfaceName = "webkit_dom_" . ($decamelize);
    488556
    489557    $implContent = << "EOF";
    490 
    491558#define WEBKIT_TYPE_DOM_${clsCaps}            (${lowerCaseIfaceName}_get_type())
    492559#define WEBKIT_DOM_${clsCaps}(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_${clsCaps}, ${className}))
     
    534601    return "" if $type eq "boolean";
    535602    return "" if $type eq "void";
     603    return "" if $type eq "CompareHow";
    536604
    537605    return "$name.h";
     
    540608sub addIncludeInBody {
    541609    my $type = shift;
     610
     611    if ($type eq "DOMObject") {
     612        return;
     613    }
    542614
    543615    my $header = getIncludeHeader($type);
     
    556628    my ($object, $interfaceName, $function, $prefix) = @_;
    557629
     630    if (SkipFunction($function)) {
     631        return;
     632    }
     633
    558634    my $functionSigName = $function->signature->name;
    559635    my $functionSigType = $function->signature->type;
    560     my $functionName = "webkit_dom_" . decamelize($interfaceName) . "_" . $prefix . decamelize($functionSigName);
     636    my $decamelize = FixUpDecamelizedName(decamelize($interfaceName));
     637    my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName);
    561638    my $returnType = GetGlibTypeName($functionSigType);
    562639    my $returnValueIsGDOMType = IsGDOMClassType($functionSigType);
     
    572649    foreach my $param (@{$function->parameters}) {
    573650        my $paramIDLType = $param->type;
    574         if ($paramIDLType eq "Event") {
     651        if ($paramIDLType eq "Event" || $paramIDLType eq "EventListener") {
    575652            push(@hBody, "\n/* TODO: event function ${functionName} */\n\n");
    576653            push(@cBody, "\n/* TODO: event function ${functionName} */\n\n");
     
    589666            }
    590667        }
    591         if ($paramIsGDOMType || ($paramIDLType eq "DOMString")) {
     668        if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) {
    592669            $paramName = "_g_" . $paramName;
    593670        }
     
    599676    }
    600677
    601     if ($functionSigType eq "Event") {
    602         push(@hBody, "\n/* TODO: event function ${functionName} */\n\n");
    603         push(@cBody, "\n/* TODO: event function ${functionName} */\n\n");
    604         return;
    605     }
    606 
    607     if ($returnType ne "void" && $returnValueIsGDOMType) {
     678    if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") {
    608679        if ($functionSigType ne "EventTarget") {
    609680            $implIncludes{"webkit/WebKitDOM${functionSigType}Private.h"} = 1;
     
    668739        if ($paramIDLType eq "DOMString") {
    669740            push(@cBody, "    WebCore::String _g_${paramName} = WebCore::String::fromUTF8($paramName);\n");
    670         }
    671         if ($paramIsGDOMType) {
     741        } elsif ($paramIDLType eq "CompareHow") {
     742            push(@cBody, "    WebCore::Range::CompareHow _g_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n");
     743        } elsif ($paramIsGDOMType) {
    672744            push(@cBody, "    WebCore::${paramIDLType} * _g_${paramName} = WebKit::core($paramName);\n");
    673745            if ($returnType ne "void") {
     
    733805        return;
    734806    } elsif ($functionSigType eq "DOMString") {
    735         push(@cBody, "    ${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n" );
     807        my $getterContentHead;
     808        my $reflect = $function->signature->extendedAttributes->{"Reflect"};
     809        my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"};
     810        if ($reflect || $reflectURL) {
     811            my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL);
     812            my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
     813            $implIncludes{"${namespace}.h"} = 1;
     814            my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
     815            $getterContentHead = "${assign}convertToUTF8String(item->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr));\n";
     816        } else {
     817            $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n";
     818        }
     819
     820        push(@cBody, "    ${getterContentHead}");
    736821    } else {
    737         push(@cBody, "    ${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n" );
     822        my $setterContentHead;
     823        my $reflect = $function->signature->extendedAttributes->{"Reflect"};
     824        my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"};
     825        if ($reflect || $reflectURL) {
     826            my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL);
     827            $contentAttributeName =~ s/set//;
     828            $contentAttributeName = $codeGenerator->WK_lcfirst($contentAttributeName);
     829            my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
     830            $implIncludes{"${namespace}.h"} = 1;
     831            $setterContentHead = "${assign}${assignPre}item->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${callImplParams}${exceptions}${assignPost});\n";
     832        } else {
     833            $setterContentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n";
     834        }
     835
     836        push(@cBody, "    ${setterContentHead}");
    738837       
    739838        if(@{$function->raisesExceptions}) {
    740839            my $exceptionHandling = << "EOF";
    741     if(ec) {
     840    if (ec) {
    742841        WebCore::ExceptionCodeDescription ecdesc;
    743842        WebCore::getExceptionCodeDescription(ec, ecdesc);
     
    814913        $object->GenerateFunction($interfaceName, $function, "get_");
    815914       
    816         if ($attribute->type =~ /^readonly/ ||
    817             $attribute->signature->extendedAttributes->{"Replaceable"}  # can't handle this yet
    818             ) {
     915        if ($attribute->type =~ /^readonly/) {
    819916            next TOP;
    820917        }
     
    847944    my $implContent = "";
    848945
    849     my $clsCaps = uc(decamelize($interfaceName));
    850     my $lowerCaseIfaceName = "webkit_dom_" . decamelize($interfaceName);
     946    my $clsCaps = uc(FixUpDecamelizedName(decamelize($interfaceName)));
     947    my $lowerCaseIfaceName = "webkit_dom_" . FixUpDecamelizedName(decamelize($interfaceName));
    851948
    852949    $implContent = << "EOF";
     
    9631060}
    9641061
    965 sub UsesManualToJSImplementation {
     1062sub UsesManualKitImplementation {
    9661063    my $type = shift;
    9671064
    968     return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or
    969       $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or
    970       $type eq "Event" or $type eq "Element" or $type eq "Text";
     1065    return 1 if $type eq "Node" or $type eq "Element";
    9711066    return 0;
    9721067}
     
    9971092    $hdrIncludes{"webkit/${parentClassName}.h"} = 1;
    9981093
    999     if ($className ne "WebKitDOMNode") {
     1094    if (!UsesManualKitImplementation($interfaceName)) {
    10001095        my $converter = << "EOF";
    10011096namespace WebKit {
  • trunk/WebCore/dom/Node.idl

    r57985 r58108  
    6363        readonly attribute Node             nextSibling;
    6464        readonly attribute NamedNodeMap     attributes;
    65 #if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
    6665        readonly attribute Document         ownerDocument;
    67 #endif
    6866
    6967        [OldStyleObjC, Custom] Node insertBefore(in [Return] Node newChild,
  • trunk/WebKit/gtk/ChangeLog

    r58098 r58108  
     12010-04-22  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        [GTK] GObject DOM bindings
     6        https://bugs.webkit.org/show_bug.cgi?id=33590
     7
     8        Add webkit_web_view_get_document to retrieve the WebKitDOMDocument
     9        from a WebKitWebView, and a very simple test for it.
     10
     11        * tests/testwebview.c:
     12        * webkit/webkitwebview.cpp:
     13        (webkit_web_view_get_document):
     14        * webkit/webkitwebview.h:
     15
    1162010-04-22  Diego Escalante Urrelo  <descalante@igalia.com>
    217
  • trunk/WebKit/gtk/tests/testwebview.c

    r56217 r58108  
    337337}   
    338338
     339static void test_webkit_web_view_document()
     340{
     341    GtkWidget* window;
     342    GtkWidget* web_view;
     343    gchar* title;
     344    WebKitDOMDocument* document;
     345   
     346    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     347    web_view = webkit_web_view_new();
     348   
     349    gtk_container_add(GTK_CONTAINER(window), web_view);
     350    gtk_widget_show_all(window);
     351
     352    loop = g_main_loop_new(NULL, TRUE);
     353
     354    g_signal_connect(window, "map-event",
     355                     G_CALLBACK(map_event_cb), loop);
     356    g_main_loop_run(loop);
     357
     358    document = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(web_view));
     359    g_assert(document);
     360    webkit_dom_document_set_title(document, (gchar*)"First title");
     361    title = webkit_dom_document_get_title(document);
     362    g_assert(title);
     363    g_assert_cmpstr(title, ==, "First title");
     364    g_free(title);
     365    webkit_dom_document_set_title(document, (gchar*)"Title changed by DOM bindings");
     366    title = webkit_dom_document_get_title(document);
     367    g_assert(title);
     368    g_assert_cmpstr(title, ==, "Title changed by DOM bindings");
     369    g_free(title);
     370   
     371    gtk_widget_destroy(window);
     372}   
     373
    339374int main(int argc, char** argv)
    340375{
     
    365400    g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus);
    366401    g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features);
     402    g_test_add_func("/webkit/webview/document", test_webkit_web_view_document);
    367403
    368404    return g_test_run ();
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r58072 r58108  
    8282#include "ScriptValue.h"
    8383#include "Scrollbar.h"
     84#include "webkit/WebKitDOMDocumentPrivate.h"
    8485#include <wtf/text/CString.h>
    8586
     
    44324433    return cacheModel;
    44334434}
     4435
     4436/**
     4437 * webkit_web_view_get_dom_document:
     4438 * @webView: a #WebKitWebView
     4439 *
     4440 * Returns: the #WebKitDOMDocument currently loaded in the @webView
     4441 *
     4442 * Since: 1.3.0
     4443 **/
     4444WebKitDOMDocument*
     4445webkit_web_view_get_dom_document(WebKitWebView* webView)
     4446{
     4447    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
     4448
     4449    Frame* coreFrame = core(webView)->mainFrame();
     4450    if (!coreFrame)
     4451        return 0;
     4452
     4453    Document* doc = coreFrame->document();
     4454    if (!doc)
     4455        return 0;
     4456
     4457    return static_cast<WebKitDOMDocument*>(kit(doc));
     4458}
  • trunk/WebKit/gtk/webkit/webkitwebview.h

    r52418 r58108  
    2828
    2929#include <webkit/webkitdefines.h>
     30#include <webkit/webkitdom.h>
    3031#include <webkit/webkitwebbackforwardlist.h>
    3132#include <webkit/webkitwebframe.h>
     
    382383webkit_get_cache_model                          (void);
    383384
     385WEBKIT_API WebKitDOMDocument *
     386webkit_web_view_get_dom_document                (WebKitWebView        *webView);
     387
    384388G_END_DECLS
    385389
Note: See TracChangeset for help on using the changeset viewer.