[webkit-dev] why js script" var a = new XMLHttpRequest; ", it's ok; but "var a = new StyleSheet; ", it'll throw an exception?

Suk Zhong sukmaillist at gmail.com
Sun Jun 7 01:26:52 PDT 2009


Hi dave,Nevo,ZHOU Xiao-bo:
   Thanks your reponses.
   Our problems are removed.
   //1.why it has this return?
   class JSCell has the following getConstructData function
   ConstructType JSCell::getConstructData(ConstructData&)
   {
       return ConstructTypeNone;
   }
   and JSCell is inherited by class
JSObject,JSDOMObject,JSXMLHttpRequestConstructor and
JSStyleSheetConstructor,
   and JSXMLHttpRequestConstructor overrides it's function getConstructData,
but JSStyleSheetConstructor doesn't.

   //2.which codes make the two object have different immediate value?
   //3.some people can explain the whole role of class JSImmediate?
   at first we maybe be confused by JSValuePtr::getConstructData function,in
our current understand,JSValuePtr stores immediate value only for
int/double/null etc

   //4.our trac maybe be not correct,who can explain why newing StyleSheet
has exception and newing XMLHttpRequest is OK?
   if we want to newing StyleSheet is OK,we may directly override
JSStyleSheetConstructor's getConstructData function like
JSXMLHttpRequestConstructor,or through adding CanBeConstructed interface to
StyleSheet in StyleSheet.idl like DOMParser.idl,the generate-bindings.pl
script may help us to generate the normal implemention of getConstructData
function.

Thanks all
Best Regards
Suk

2009/6/6 Suk Zhong <sukmaillist at gmail.com>

> Hi dave:
>         Thanks your response.running the following script "var a = new
> CSSStyleSheet;" will also throw an exception like  "var a = new
> StyleSheet;".
>
> Best Regards
> Suk
>
> 2009/6/5 David Hyatt <hyatt at apple.com>
>
> Just a guess, but I believe StyleSheet is abstract, and if you want to
>> craft a stylesheet, you'd probably use CSSStyleSheet instead.
>>
>> dave
>>
>>
>> On Jun 5, 2009, at 3:28 AM, Suk Zhong wrote:
>>
>>  Hi All:
>>>   We're trying to extend WebKit dom js binding.We have some questions.
>>>
>>>   in DOMWindow.idl having the following code:
>>>   attribute StyleSheetConstructor StyleSheet;
>>>   attribute [JSCCustomGetter] XMLHttpRequestConstructor XMLHttpRequest;
>>>
>>>   and we find class JSXMLHttpRequestConstructor has function
>>> getConstructData, while JSStyleSheetConstructor doesn't have function
>>> getConstructData.
>>>
>>>   if test the following js script:"var a = new XMLHttpRequest;", it's
>>> ok;but "var a = new StyleSheet;", it'll throw an exception.
>>>
>>>   and we trac this problem to Interpreter::privateExecute() and
>>> JSValuePtr::getConstructData function
>>>
>>>   inline ConstructType JSValuePtr::getConstructData(ConstructData&
>>> constructData)
>>>   {
>>>        return JSImmediate::isImmediate(asValue()) ? ConstructTypeNone :
>>> asCell()->getConstructData(constructData);
>>>   }
>>>   and we know this function returns ConstructTypeNone for
>>> JSStyleSheetConstructor object,  ConstructTypeHost for
>>> JSXMLHttpRequestConstructor object;
>>>
>>>   JSStyleSheetConstructor object and JSXMLHttpRequestConstructor object
>>> are returned by the same template function getDOMConstructor.
>>>
>>>   our questions are:
>>>
>>>   1.why it has this return?
>>>   2.which codes make the two object have different immediate value?
>>>   3.some people can explain the whole role of class JSImmediate?
>>>   4.our trac maybe be not correct,who can explain why newing StyleSheet
>>> has exception and newing XMLHttpRequest is OK?
>>>
>>> Thanks and Best Regards
>>>
>>> Suk
>>> _______________________________________________
>>> webkit-dev mailing list
>>> webkit-dev at lists.webkit.org
>>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090607/1d7ac401/attachment.html>


More information about the webkit-dev mailing list