Commit d2805949 authored by Peter Van der Beken's avatar Peter Van der Beken
Browse files

Fix for bug 508780 (Stop using tearoff from quickstubs for...

Fix for bug 508780 (Stop using tearoff from quickstubs for nsDOMCSSDeclaration/nsComputedDOMStyle), part 1. r=jst.

--HG--
extra : rebase_source : c08832cbf78e54b82a7bc3dd22e7bc8710ed8b29
parent 5eaa8403
Loading
Loading
Loading
Loading
+24 −26
Original line number Diff line number Diff line
@@ -231,24 +231,8 @@ members = [

    # dom/public/idl/css
    'nsIDOMElementCSSInlineStyle.style',
    'nsIDOMCSS2Properties.background',
    'nsIDOMCSS2Properties.height',
    'nsIDOMCSS2Properties.textAlign',
    'nsIDOMCSS2Properties.right',
    'nsIDOMCSS2Properties.bottom',
    'nsIDOMCSS2Properties.fontSize',
    'nsIDOMCSS2Properties.backgroundColor',
    'nsIDOMCSS2Properties.letterSpacing',
    'nsIDOMCSS2Properties.verticalAlign',
    'nsIDOMCSS2Properties.color',
    'nsIDOMCSS2Properties.top',
    'nsIDOMCSS2Properties.width',
    'nsIDOMCSS2Properties.display',
    'nsIDOMCSS2Properties.zIndex',
    'nsIDOMCSS2Properties.position',
    'nsIDOMCSS2Properties.left',
    'nsIDOMCSS2Properties.visibility',
    'nsIDOMNSCSS2Properties.opacity',
    'nsIDOMCSS2Properties.*',
    'nsIDOMNSCSS2Properties.*',
    'nsIDOMRect.top',
    'nsIDOMRect.right',
    'nsIDOMRect.left',
@@ -524,7 +508,8 @@ customIncludes = [
    'nsINode.h',
    'nsIContent.h',
    'nsIDocument.h',
    'nsINodeList.h'
    'nsINodeList.h',
    'nsCSSPropertiesQS.h'
    ]

nsIDOMNode_GetChildNodes_customMethodCallCode = """
@@ -545,6 +530,16 @@ nsIDOMHTMLDocument_Write_customMethodCallCode = """
    rv = self->%s(arg0);
"""

CSS2Properties_ = {
    'thisType': 'nsICSSDeclaration',
    'additionalArguments': 'const nsCSSProperty prop',
    'additionalArgumentValues': 'QS_CSS_PROP_%s',
    'getter_code': '    nsString result;\n' + 
                   '    rv = self->GetPropertyValue(prop, result);',
    'setter_code': '    rv = self->SetPropertyValue(prop, arg0);',
    'canFail': True
}

customMethodCalls = {
    'nsIDOMNode_GetNextSibling': {
        'thisType': 'nsINode',
@@ -586,5 +581,8 @@ customMethodCalls = {
    'nsIDOMHTMLDocument_Writeln': {
        'code': nsIDOMHTMLDocument_Write_customMethodCallCode % 'Writeln',
        'canFail': True
        },
    'nsIDOMCSS2Properties_': CSS2Properties_,
    'nsIDOMNSCSS2Properties_': CSS2Properties_
    }
    }
+27 −0
Original line number Diff line number Diff line
#ifndef nsCSSPropertiesQS_h__
#define nsCSSPropertiesQS_h__

#include "nsICSSDeclaration.h"

#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_,     \
                 kwtable_, stylestruct_, stylestructoffset_, animtype_)        \
static const nsCSSProperty QS_CSS_PROP_##method_ = eCSSProperty_##id_;

#define CSS_PROP_LIST_EXCLUDE_INTERNAL
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
  CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
#include "nsCSSPropList.h"

// Aliases
CSS_PROP(X, opacity, MozOpacity, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline, MozOutline, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_color, MozOutlineColor, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_style, MozOutlineStyle, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_width, MozOutlineWidth, 0, X, X, X, X, X, X, X)
CSS_PROP(X, outline_offset, MozOutlineOffset, 0, X, X, X, X, X, X, X)

#undef CSS_PROP_SHORTHAND
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL
#undef CSS_PROP

#endif /* nsCSSPropertiesQS_h__ */
+64 −9
Original line number Diff line number Diff line
@@ -650,17 +650,68 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
    assert isAttr or isMethod
    isGetter = isAttr and not isSetter

    customMethodCall = customMethodCalls.get(stubName, None)

    # Function prolog.
    f.write("static JSBool\n")
    signature = "static JSBool\n"
    if isAttr:
        # JSPropertyOp signature.
        f.write(stubName + "(JSContext *cx, JSObject *obj, jsval id, "
                "jsval *vp)\n")
        signature += "%s(JSContext *cx, JSObject *obj, jsval id,%s jsval *vp)\n"
    else:
        # JSFastNative.
        f.write(stubName + "(JSContext *cx, uintN argc, jsval *vp)\n")
        signature += "%s(JSContext *cx, uintN argc,%s jsval *vp)\n"

    customMethodCall = customMethodCalls.get(stubName, None)
    if customMethodCall is None:
        customMethodCall = customMethodCalls.get(member.iface.name + '_', None)
        if customMethodCall is not None:
            templateName = member.iface.name
            if isGetter:
                templateName += '_Get'
            elif isSetter:
                templateName += '_Set'

            # Generate the code for the stub, calling the template function
            # that's shared between the stubs. The stubs can't have additional
            # arguments, only the template function can.
            callTemplate = signature % (stubName, '')
            callTemplate += "{\n"

            nativeName = (member.binaryname is not None and member.binaryname
                          or header.firstCap(member.name))
            argumentValues = (customMethodCall['additionalArgumentValues']
                              % nativeName)
            if isAttr:
                callTemplate += ("    return %s(cx, obj, id, %s, vp);\n"
                                 % (templateName, argumentValues))
            else:
                callTemplate += ("    return %s(cx, argc, %s, vp);\n"
                                 % (templateName, argumentValues))
            callTemplate += "}\n\n"

            # Fall through and create the template function stub called from the
            # real stubs, but only generate the stub once. Otherwise, just write
            # out the call to the template function and return.
            templateGenerated = templateName + '_generated'
            if templateGenerated in customMethodCall:
                f.write(callTemplate)
                return
            customMethodCall[templateGenerated] = True

            if isMethod:
                code = customMethodCall['code']
            else:
                code = customMethodCall['getter_code' if isGetter else 'setter_code']
            stubName = templateName
    else:
        callTemplate = ""
        code = customMethodCall['code']

    # Function prolog.

    # Only template functions can have additional arguments.
    if customMethodCall is None or not 'additionalArguments' in customMethodCall:
        additionalArguments = ''
    else:
        additionalArguments = " %s," % customMethodCall['additionalArguments']
    f.write(signature % (stubName, additionalArguments))
    f.write("{\n")
    f.write("    XPC_QS_ASSERT_CONTEXT_OK(cx);\n")

@@ -750,9 +801,9 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
        rvdeclared = True

    if customMethodCall is not None:
        f.write("%s\n" % customMethodCall['code'])
        f.write("%s\n" % code)

    if customMethodCall is None or isGetter:
    if customMethodCall is None or (isGetter and callTemplate is ""):
        if customMethodCall is not None:
            f.write("#ifdef DEBUG\n")
            f.write("    nsresult debug_rv;\n")
@@ -824,6 +875,10 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
    # Epilog.
    f.write("}\n\n")

    # Now write out the call to the template function.
    if customMethodCall is not None:
        f.write(callTemplate)

traceTypeMap = {
    'void':
        ["jsval ", "JSVAL", "JSVAL_VOID"],