Search completed in 0.99 seconds.
ReferenceError: assignment to undeclared variable "x" - JavaScript
the javascript strict mode-only exception "assignment to undeclated variable" occurs when the value has been assigned to an un
declared variable. message referenceerror: assignment to un
declared variable "x" (firefox) referenceerror: "x" is not defined (chrome) referenceerror: variable undefined in strict mode (edge) error type referenceerror warning in strict mode only. what went wrong? a value has been assigned to an un
declared variable. in other words, there was an assignment without the var keyword. ...
...age referenceerror: assignment to un
declared variable "x" (firefox) referenceerror: "x" is not defined (chrome) referenceerror: variable undefined in strict mode (edge) error type referenceerror warning in strict mode only. what went wrong? ...
...rror: assignment to un
declared variable "x" (firefox) referenceerror: "x" is not defined (chrome) referenceerror: variable undefined in strict mode (edge) error type referenceerror warning in strict mode only. what went wrong? ...
...And 6 more matches
TypeError: variable "x" redeclares argument - JavaScript
the javascript strict mode-only exception "variable re
declares argument" occurs when the same variable name occurs as a function parameter and is then re
declared using a var assignment in a function body again. message typeerror: variable "x" re
declares argument (firefox) error type typeerror warning in strict mode only. what went wrong? the same variable name occurs as a function parameter and is then re
declared using a var assignment in a function body again. this might be a naming conflict and thus javascript warns about it. this error occurs as a warning in strict mode code only. in non-strict code, the redeclaration is silently ignored. examples invalid cases in this case, the variable "arg" re
declares the argument. 'use strict'; function f(arg) { var arg = 'foo'; } valid c...
Add to iPhoto
add-ons now that firefox is a 64-bit application. you can download an installable version of this extension on amo. once installed, when you right-click on an image, you'll see among the options in the contextual menu an option to "add image to iphoto". choose it, and iphoto will start up (if it's not already running) and import the image. declaring the apis the first thing we have to do is
declare the mac os x apis we'll be using. this extension uses a number of methods and data types, as well as constants, from three system frameworks. since a lot of this stuff is repetitive, we'll only look at selected parts of the code to get an idea how things work. you can download the extension and poke through the code inside it if you'd like to see all of it. for the sake of organization, i chose...
...mber of methods and data types, as well as constants, from three system frameworks. since a lot of this stuff is repetitive, we'll only look at selected parts of the code to get an idea how things work. you can download the extension and poke through the code inside it if you'd like to see all of it. for the sake of organization, i chose to implement each system framework (and, mind you, i only
declare the apis i actually use, not all of them) as a javascript object containing all the types and methods that framework's api. note: in a few cases, this code takes the easy way out by using ctypes.voidptr_t instead of a typed pointer. that's not really the ideal way to do things but saved some time for this simple example. some of this may change as i refine the example in the future; i'll update ...
...n a few cases, this code takes the easy way out by using ctypes.voidptr_t instead of a typed pointer. that's not really the ideal way to do things but saved some time for this simple example. some of this may change as i refine the example in the future; i'll update the article if and when that happens. some global types there are a few global data types used by all of our frameworks. these are
declared near the top of the code: const osstatus = ctypes.int32_t; const cfindex = ctypes.long; const optionbits = ctypes.uint32_t; osstatus used to represent the status code resulting from an operation. cfindex a core foundation long integer type used to represent indexes into lists. i debated including this in the corefoundation object, and probably would have if i were being more formal, but ...
...And 21 more matches
WebIDL bindings
oat value); double mymethod(const nullable<double>& arg); domstring strings are reflected in three different ways, depending on use: string arguments become const nsastring&. string return values become a mozilla::dom::domstring& out param appended to the argument list. this comes after all idl arguments, but before the errorresult&, if any, for the method. note that this allows callees to
declare their methods as taking an nsastring& or nsstring& if desired. strings in sequences, dictionaries, owning unions, and variadic arguments become nsstring. nullable strings are represented by the same types as non-nullable ones, but the string will return true for domstringisnull(). returning null as a string value can be done using setdomstringtonull on the out param if it's an nsastring or cal...
...d rethrow exceptions from setsomenumber, say. acallback.setsomenumber(2*number, rv, erethrowexceptions); if (rv.failed()) { // the exception is now stored on rv. this code must report // it usefully; otherwise it will assert. } } external interfaces external interfaces are represented in c++ as objects that xpconnect knows how to unwrap to. this can mean xpcom interfaces (whether
declared in xpidl or not) or it can mean some type that there's a castable native unwrapping function for. the c++ type to be used should be the nativetype listed for the external interface in the bindings.conf file. the exact representation depends on how the type is being used. arguments become nsifoo*. return values can be already_addrefed<nsifoo> or nsifoo* as desired. the pointer form is preferr...
... return values become a js::mutablehandle<jsobject*> out param appended to the argument list. this comes after all idl arguments, but before the errorresult&, if any, for the method. the return value is allowed to be in any compartment; bindings will wrap it into the context compartment as needed. typed arrays store a jsobject* and hence need to be rooted properly. on-stack typed arrays can be
declared as rootedtypedarray<typedarraytype> (e.g. rootedtypedarray<int16array>). typed arrays on the heap need to be traced. dictionary types a dictionary argument is represented by a const reference to a struct whose name is the dictionary name in the mozilla::dom namespace. the struct has one member for each of the dictionary's members with the same name except the first letter uppercased and pref...
...And 17 more matches
Using Objective-C from js-ctypes
thesizer alloc] it passes an alloc message to the nsspeechsynthesizer class, in objective-c syntax. it performs the following through this objective-c syntax: get the nsspeechsynthesizer class definition. register the alloc selector for the message. send a message to the class, with the selector. get a reference to a class class definitions are retrieved with the objc_getclass function,
declared in /usr/include/objc/runtime.h. the objc_getclass function receives the name of the class, looks up the definition, and returns it. class objc_getclass(const char *name); in /usr/include/objc/objc.h, class is defined as an opaque type by the following: typedef struct objc_class *class; in this example, we need the classnsspeechsynthesizer, which is retrieved with the following code: class...
...sel_registername receives the name of the selector, and returns the selector. sel sel_registername(const char *str); sel is defined as follows, in /usr/include/objc/objc.h. it's also an opaque type. typedef struct objc_selector *sel; in this example, we need to send alloc, its selector can be retrieved with the following code: sel alloc = sel_registername("...
...n /usr/include/objc/objc.h. it's also an opaque type. typedef struct objc_selector *sel; in this example, we need to send alloc, its selector can be retrieved with the following code: sel alloc = sel_registername("alloc"); sending a message once target class and selector are ready, you can send a message. this message can be sent using the objc_msgsend function, and its variants, which are
declared in /usr/include/objc/message.h. objc_msgsend function, receives the instance which receives the message, the selector, and variable argument list for the message, returning the returned value from the method. id objc_msgsend(id self, sel op, ...); id is defined as the following, in /usr/include/objc/objc.h, it's also an opaque type. class can be cast into id, so we can pass class returned by ...
...And 12 more matches
Standard OS Libraries
); /* note: if you go to getcursorpos page on msdn, it says first argument is of structure point, so lets create that structure, * the link here shows that that x and y are type long which is ctypes.long */ // https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805%28v=vs.85%29.aspx var point = new ctypes.structtype("tagpoint", [ { "x": ctypes.long }, { "y": ctypes.long } ]); /*
declare the signature of the function we are going to call */ var getcursorpos = lib.
declare('getcursorpos', ctypes.winapi_abi, ctypes.bool, point.ptr ); /* use it like this */ var point = point(); var ret = getcursorpos(point.address()); components.utils.reporterror(ret); components.utils.reporterror(point); lib.close(); resources for winapi githubgists :: noitidart / search · winap...
...esource://gre/modules/ctypes.jsm'); var gdk = ctypes.open('libgdk-x11-2.0.so.0'); // types var gint = ctypes.int; var gdkdevice = ctypes.structtype('gdkdevice'); var gdkmodifiertype = ctypes.int; var gdkwindow = ctypes.structtype('gdkwindow'); var void = ctypes.void_t; // https://developer.gnome.org/gdk3/stable/gdk3-windows.html#gdk-get-default-root-window var gdk_get_default_root_window = gdk.
declare('gdk_get_default_root_window', ctypes.default_abi, gdkwindow.ptr // return - the root window, which is top most parent of all windows ); // in gdk2 we have to use gdk_window_get_pointer, but in gdk3 it was deprecated and have to use gdk_window_get_device_position https://developer.gnome.org/gdk3/stable/gdk3-windows.html#gdk-window-get-pointer var gdk_window_get_pointer = gdk.
declare('gdk_...
... types var gint = ctypes.int; var gdkdevice = ctypes.structtype('gdkdevice'); var gdkdevicemanager = ctypes.structtype('gdkdevicemanager'); var gdkdisplay = ctypes.structtype('gdkdisplay'); var gdkmodifiertype = ctypes.int; var gdkwindow = ctypes.structtype('gdkwindow'); // https://developer.gnome.org/gdk3/stable/gdk3-windows.html#gdk-get-default-root-window var gdk_get_default_root_window = gdk.
declare('gdk_get_default_root_window', ctypes.default_abi, gdkwindow.ptr // return - the root window, which is top most parent of all windows ); // in gdk2 we have to use gdk_window_get_pointer, but in gdk3 it was deprecated and have to use gdk_window_get_device_position // https://developer.gnome.org/gdk3/stable/gdk3-windows.html#gdk-window-get-device-position var gdk_window_get_device_position ...
...And 12 more matches
Using js-ctypes
rary you wish to use. on windows, for example, you might load the system user32 library like this: var lib = ctypes.open("user32.dll"); on mac os x, you can load the core foundation library from the core foundation framework like this: var corefoundation = ctypes.open("/system/library/frameworks/corefoundation.framework/corefoundation"); the returned object is a library object that you use to
declare functions and data types for use with the loaded library. note: js-ctypes only works with c libraries; you can't use c++ methods directly. instead, you'll need to create a shim library that uses c functions that then call into the c++ library for you. examples can be found here: bugzilla :: bug 505907 - support c++ calling from jsctypes library search paths if you specify a full path, that pat...
... directory the directories listed in the path environment variable. note: this information comes from this article on msdn. after you're done when you're finished using a library, you should close it by calling the library object's close() method: lib.close(); if you fail to close the library, it will be automatically closed when it is garbage collected. using the library you may need to
declare new types. these can be simple types or more complex types such as structures. see declaring types for details. you will almost certainly need to
declare one or more functions, so that you can call them. once you've
declared the types and functions, you can write your code to make use of them. instantiating c data objects and referencing them is covered in the article working with data. memory ...
...ta. memory management moved to memory management page. examples these examples offer a quick look at how js-ctypes is used. see js-ctypes examples for more intricate examples. calling windows routines this example demonstrates how to use ctypes to call a win32 api. ...
...And 11 more matches
Following the Android Toasts Tutorial from a JNI Perspective
de: window.nativewindow.toast.show("hello, firefox!", "short"); converting java to jni.jsm the first step is to look at the java code and see all the different types, methods, constructors, and fields that are being used. in the toast code we have the following: types - context, charsequence, int, toast, and void methods - maketext, show fields - length_short no constructors are used.
declare the types we will start by declaring the types needed. in jni, there is the all-important property called sig. when something is
declared, we are stating the sig and the name. the sig's will be represented as javascript strings in jni.jsm, and the sig's of the types are as follows: java type signature boolean z byte b char c class/obj...
...his would be lblah/foo/bar;. if there is a sub class such as blah.foo.bar.subclass then a dollar sign is used in the slash notation, so this would be lblah/foo/bar$subclass;. when declaring methods, the signatures of the types go right next to each other without any spacing. the arguments are within the parenthesis, and the return type is immediately following. more on this later. so let us now
declare the types for our toast example. we see we have three classes and two basic types (int and void). the class signature is looked up on the android documentation. for instance, we go to android reference :: context and we see: we see that the signature in dot notation is android.content.context. so this will be written as landroid/content/context;. for convenience, let's make an object called si...
...gnature in dot notation is android.content.context. so this will be written as landroid/content/context;. for convenience, let's make an object called sig and populate it with our types. let sig = { context: 'landroid/content/context;', charsequence; 'ljava/lang/charsequence;', int: 'i', toast: 'landroid/widget/toast;', void: 'v', }; get java environment before we go on to
declare the other important features, we need to load our environment variable. we want to wrap this in a try-catch statement so if any errors occur we make sure to unload the classes and the java environment, this is good for performance. this is the template that will follow our object of signatures: var my_jenv = null; try { my_jenv = jni.getforthread(); // do the jni work here } finally {...
...And 9 more matches
Grammar and types - JavaScript
e a third type of comment syntax at the start of some javascript files, which looks something like this: #!/usr/bin/env node. this is called hashbang comment syntax, and is a special comment used to specify the path to a particular javascript engine that should execute the script. see hashbang comments for more details. declarations javascript has three kinds of variable declarations. var
declares a variable, optionally initializing it to a value. let
declares a block-scoped, local variable, optionally initializing it to a value. const
declares a block-scoped, read-only named constant. variables you use variables as symbolic names for values in your application. the names of variables, called identifiers, conform to certain rules. a javascript identifier must start with a letter, ...
...rs include the characters "a" through "z" (uppercase) as well as "a" through "z" (lowercase). you can use most of iso 8859-1 or unicode letters such as å and ü in identifiers. (for more details, see this blog post.) you can also use the unicode escape sequences as characters in identifiers. some examples of legal names are number_hits, temp99, $credit, and _name. declaring variables you can
declare a variable in two ways: with the keyword var. for example, var x = 42. this syntax can be used to
declare both local and global variables, depending on the execution context. with the keyword const or let. for example, let y = 13. this syntax can be used to
declare a block-scope local variable. (see variable scope below.) you can also simply assign a value to a variable for example, x = 42.
... with the keyword var. for example, var x = 42. this syntax can be used to
declare both local and global variables, depending on the execution context. with the keyword const or let. for example, let y = 13. this syntax can be used to
declare a block-scope local variable. (see variable scope below.) you can also simply assign a value to a variable for example, x = 42. this form creates an un
declared global variable. it also generates a strict javascript warning. un
declared global variables can often lead to unexpected behavior. thus, it is discouraged to use un
declared global variables. ...
...And 9 more matches
Introduction to XPCOM for the DOM
e dom, avoiding the details as much as possible. i will introduce nscomptr's, interfaces, reference counting, and the nsisupports interface. a tutorial about how to add a new interface is also provided, and eventually, a more detailed discussion of class inheritance in c++. interfaces object-oriented programming is based on the used of inheritance between classes. furthermore, a class can be de
declared to be "abstract" if it
declares some methods but does not implement them entirely. pushing this concept to its maximum, a class can be "purely virtual" if it
declares methods without implementing any of them. such a class is called an interface. the goal of interfaces is to have a single ... interface to a set of methods that manipulate an object (often represented by a class), without worrying ...
...le ... interface to a set of methods that manipulate an object (often represented by a class), without worrying about the details of the implementation. if you know a class implements an interface, just use the methods in the interface, and you don't have to care if the implementation of the interface (the concrete class) changes. xpcom pushes this concept to the extreme. pure virtual methods are
declared with the following syntax: virtual nsresult functionfoo() = 0; an interface is thus simply a c++ class where all the member functions are
declared as pure virtual functions. an interface can also be defined using xpidl. this is described in section 1.e, "how to add an interface". since an interface doesn't have any implementation, it has to be implemented by a non-abstract class -- a concret...
... since an interface doesn't have any implementation, it has to be implemented by a non-abstract class -- a concrete class. if the interface is called nsifoo and the class is called nsfoo, we say that "nsfoo implements nsifoo", or that "nsfoo inherits from nsifoo". the c++ code is the following: class nsfoo : public nsifoo for those unfamiliar with object-oriented c++, this means that nsfoo is
declared as "derived from" nsifoo, and that nsifoo is a "base class" of nsfoo. for this introduction you don't need to know more about object-oriented c++. however the section 1.f provides a more detailed discussion about it, and is necessary to understand most of the dom code. an instance of a class (called an object) can be allocated dynamically (on the heap, or free store), using the syntax nsfoo *f...
...And 8 more matches
Declaring types
at the core of all this is a set of predefined types provided by js-ctypes. these are all primitive types, upon which all other types are eventually based. primitive types primitive types are those types that represent a single value in memory, as opposed to arrays, structures, or functions. you can define values of these types without declaring new types. ...
...en pass a pointer to this value to a c function that requires a pointer to a 32-bit integer, like this: some_c_function(i.address()); declaring new primitive types there are times when you want to create new types that are simply new names for existing primitive types. for example, on windows, you may wish to be able to use the windows-standard dword type name for unsigned 32-bit integers. to
declare this type, you can simply do: const dword = ctypes.uint32_t; after doing this, dword is a ctype that can then be used to represent 32-bit unsigned integers. structures structures are
declared using the ctypes.structtype() constructor. this method accepts as input the name of the structure and an array of field descriptors, each describing one field in the structure. you can, optionally, leav...
... field descriptors each field descriptor is comprised of a field name and its data type, represented as a string and a ctype object, respectively. the format, then, looks like this: [ { field1: type1 }, { field2: type2 }, ... ...
...And 7 more matches
var - JavaScript
the var statement
declares a function-scoped or globally-scoped variable, optionally initializing it to a value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax var varname1 [= value1] [, varname2 [= value2] ... [, varnamen [= valuen]]]; varnamen variable name. it can be any legal identifier. valuen optional initial value of the variable. it can be any legal expression. default value is undefined. description var declarations, wherever they occur, are processed before any code is executed. this is called hoisting, and is discussed further below. ...
...arname2 [= value2] ... [, varnamen [= valuen]]]; varnamen variable name. it can be any legal identifier. valuen optional initial value of the variable. it can be any legal expression. default value is undefined. description var declarations, wherever they occur, are processed before any code is executed. this is called hoisting, and is discussed further below. the scope of a variable
declared with var is its current execution context and closures thereof, which is either the enclosing function and functions
declared within it, or, for variables
declared outside any function, global. duplicate variable declarations using var will not trigger an error, even in strict mode, and the variable will not lose its value, unless another assignment is performed. 'use strict'; function foo() { ...
...ble will not lose its value, unless another assignment is performed. ...
...And 7 more matches
Understanding WebAssembly text format - WebAssembly
ormat: 0000000: 0061 736d ; wasm_binary_magic 0000004: 0100 0000 ; wasm_binary_version adding functionality to your module ok, that’s not very interesting, let’s add some executable code to this module. all code in a webassembly module is grouped into functions, which have the following pseudo-code structure: ( func <signature> <locals> <body> ) the signature
declares what the function takes (parameters) and returns (return values). the locals are like vars in javascript, but with explicit types
declared. the body is just a linear list of low-level instructions. so this is similar to functions in other languages, even if it looks different because it is an s-expression. signatures and parameters the signature is a sequence of parameter type declarations...
...ssion. signatures and parameters the signature is a sequence of parameter type declarations followed by a list of return type declarations. it is worth noting here that: the absence of a (result) means the function doesn’t return anything. in the current iteration, there can be at most 1 return type, but later this will be relaxed to any number. ...
.... so for example, after executing the following function: (func (param $p i32) (result i32) local.get $p local.get $p i32.add) the stack contains exactly one i32 value — the result of the expression ($p + $p), which is handled by i32.add. the return value of a function is just the final value left on the stack. the webassembly validation rules ensure the stack matches exactly: if you
declare a (result f32), then the stack must contain exactly one f32 at the end. if there is no result type, the stack must be empty. our first function body as mentioned before, the function body is simply a list of instructions that are followed as the function is called. putting this together with what we have already learned, we can finally define a module containing our own simple function: (modu...
...And 7 more matches
Index - Archive of obsolete content
d shell see 'testing the android shell' below. running the performance tests requires the following steps: 660 tamarin build system documentation no summary! 661 tamarin releases this page tracks tamarin source code releases, past, present and future. 662 tamarin-central rev 703:2cee46be9ce0 tamarin-central rev 703:2cee46be9ce0 was
declared stable on 12/02/08. the announcement sent to tamarin-devel can be read here. 663 tamarin roadmap the tamarin roadmap is intended to provide visibility into planned features and release dates. the roadmap is a living document representing current best thinking and is subject to change. comments or questions are welcome and encouraged via the tamarin-devel mailing list. ...
... attached to, called the bound element, acquires the new behavior specified by the binding. 695 xbl 1.0 reference xbl no summary! 696 anonymous content a binding can specify an anonymous content template using the content element. this template describes a content tree that will be generated around the bound element during binding attachment. an element
declared in a bound document using a single tag can then be constructed out of multiple child elements, and this implementation is hidden from the bound document. 697 binding attachment and detachment xbl bindings can be attached to elements through css using the -moz-binding property. 698 binding implementations mozilla, reference, xbl bindings can define method...
...et of data from the datasource. the exact syntax is dependent on the type of datasource used in the template. for instance, for an sqlite datasource, an sql statement is used as the query. this will return a table of result records which are then used to generate output. for rdf and xml, the query contains a set of instructions for navigating through the rdf graph or xml document tree. a query is
declared with the query tag (new to ff3; ff2 only worked with rdf datasources and had no query tag), which you would place directly inside the <template>. the job of the query is to generate a set of output results. 1670 sqlite templates xul, xul_template_guide no summary! 1671 simple example xul, xul_template_guide no summary! 1672 simple query syntax...
...And 6 more matches
IPDL Tutorial
ipdl, short for "inter-process-communication protocol definition language", is a mozilla-specific language allowing c++ code to pass messages between processes or threads in an organized and secure way. all messages for multi-process plugins and tabs in firefox are
declared in the ipdl language. to experiment with adding a new ipdl protocol, see creating a new protocol. all ipdl messages are sent between parent and a child end points, called actors. an ipdl protocol
declares how actors communicate: it
declares the possible messages that may be sent between actors, as well as a state machine describing when messages are allowed to be sent. the parent actor is typically the more permanent side of the conversation: parent/child actors parent child ipc tabs ...
... the possible messages that may be sent between actors, as well as a state machine describing when messages are allowed to be sent. the parent actor is typically the more permanent side of the conversation: parent/child actors parent child ipc tabs chrome process content process ipc plugins content process plugin process each protocol is
declared in a separate file. the ipdl compiler generates several c++ headers from each ipdl protocol. this generated code manages the details of the underlying communication layer (sockets and pipes), constructing and sending messages, ensuring that all actors adhere to their specifications, and handling many error conditions. the following ipdl code defines a very basic interaction of browser and plugin...
...he underlying communication layer (sockets and pipes), constructing and sending messages, ensuring that all actors adhere to their specifications, and handling many error conditions. the following ipdl code defines a very basic interaction of browser and plugin actors: async protocol pplugin { child: async init(nscstring pluginpath); async shutdown(); parent: async ready(); }; this code
declares the pplugin protocol. two messages can be sent from the parent to the child, init() and shutdown(). one message can be sent from the child to the parent, ready(). ipdl protocols start with the letter p. the file in which the protocol is
declared must have a matching name, pplugin.ipdl. generated c++ code when pplugin.ipdl is compiled, the headers ppluginparent.h, and ppluginchild.h will be ge...
...And 6 more matches
XPIDL
jsval const jsval& jsval* anything jsid jsid jsid* not allowed promise mozilla::dom::promise* mozilla::dom::promise** promise typedefs in idl are basically as they are in c or c++: you define first the type that you want to refer to and then the name of the type. types can of course be one of the fundamental types, or any other type
declared via a typedef, interface, or a native type. native types are types which correspond to a given c++ type. most native types are not scriptable: if it is not present in the list above, then it is certainly not scriptable (some of the above, particularly jsid, are not scriptable). the contents of the parentheses of a native type declaration (although native declarations without parentheses are pa...
... in typelib. nsid this type gets const when an in type. special in typelib. ptr the type is really (native str)* ref the type is really (native str)& utf8string this is an nsacstring declaration whose text is utf-8. as far as i can tell, these properties also apply to typedefs. need to verify. webidl interfaces are also valid xpidl types. to
declare a webidl interface in xpidl, write webidl interfacename;. webidl types will be passed as mozilla::dom::interfacename* when used as in-parameters, as mozilla::dom::interfacename** when used as out or inout-parameters, and as refptr<mozilla::dom::interfacename> when used as an array element. other webidl types (e.g. dictionaries, enums, and unions), are not currently supported. constants const...
...lementing this interface. all children must also be marked with this property. function the javascript implementation of this interface may be a function that is invoked on property calls instead of an object with the given property scriptable this interface is usable by javascript classes. must inherit from a scriptable interface. ...
...And 6 more matches
Finding window handles - Archive of obsolete content
nterfacerequestor) .getinterface(ci.nsibasewindow); var hwndstring = basewindow.nativehandle; components.utils.import('resource://gre/modules/ctypes.jsm'); var user32 = ctypes.open('user32.dll'); /* http://msdn.microsoft.com/en-us/library/ms633539%28v=vs.85%29.aspx * bool winapi setforegroundwindow( * __in_ hwnd hwnd * ); */ var setforegroundwindow = user32.
declare('setforegroundwindow', ctypes.winapi_abi, ctypes.bool, // return bool ctypes.voidptr_t // hwnd ); var hwnd = ctypes.voidptr_t(ctypes.uint64(hwndstring)); var rez_setforegroundwindow = setforegroundwindow(hwnd); console.log('rez_setforegroundwindow:', rez_setforegroundwindow, rez_setforegroundwindow.tostring()); user32.close(); mac os x objective-c components.utils.import('resource:/...
...rfacerequestor) .getinterface(ci.nsibasewindow); var nswindowstring = basewindow.nativehandle; components.utils.import('resource://gre/modules/ctypes.jsm'); var objc = ctypes.open(ctypes.libraryname('objc')); // types let id = ctypes.voidptr_t; let sel = ctypes.voidptr_t; // constants let nil = ctypes.voidptr_t(0); //common functions let sel_registername = objc.
declare('sel_registername', ctypes.default_abi, sel, ctypes.char.ptr); let objc_msgsend = objc.
declare('objc_msgsend', ctypes.default_abi, id, id, sel, '...'); /* https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/nsapplication_class/index.html#//apple_ref/occ/instp/nsapplication/orderfront: * [nswindowptr orderfront:nil] */ var orderfront = sel_registername...
...(gdkwindowptrstring)); working with gdkwindow* gdkwindow* to xid var gdkwindow = ctypes.structtype('gdkwindow'); var gdkdrawable = ctypes.structtype('gdkdrawable'); var card32 = /^(alpha|hppa|ia64|ppc64|s390|x86_64)-/.test(services.appinfo.xpcomabi) ? ctypes.unsigned_int : ctypes.unsigned_long; var xid = card32; var gdk = ctypes.open('libgdk-x11-2.0.so.0'); var gdk_x11_drawable_get_xid = gdk.
declare('gdk_x11_drawable_get_xid', ctypes.default_abi, xid, gdkdrawable.ptr); var gdkwindowptrstring = basewindow.nativehandle; var gdkwinptr = gdkwindow.ptr(ctypes.uint64(gdkwindowptrstring)); var gdkdrawptr = ctypes.cast(gdkwinptr, gdkdrawable.ptr); var xidofwin = gdk_x11_drawable_get_xid(gdkdrawptr); gdkwindow* to gtkwindow* how to get the gtkwindow* from the gdkwindow*? mozilla developers have ...
...And 5 more matches
Storing the information you need — Variables - Learn web development
try typing in scoobydoo; note: don't confuse a variable that exists but has no defined value with a variable that doesn't exist at all — they are very different things. in the box analogy you saw above, not existing would mean there's no box (variable) for a value to go in. no value defined would mean that there is a box, but it has no value inside it. initializing a variable once you've
declared a variable, you can initialize it with a value. you do this by typing the variable name, followed by an equals sign (=), followed by the value you want to give it. for example: myname = 'chris'; myage = 37; try going back to the console now and typing in these lines. you should see the value you've assigned to the variable returned in the console to confirm it, in each case. again, you can ret...
...n (=), followed by the value you want to give it. for example: myname = 'chris'; myage = 37; try going back to the console now and typing in these lines. you should see the value you've assigned to the variable returned in the console to confirm it, in each case. again, you can return your variable values by simply typing their name into the console — try these again: myname; myage; you can
declare and initialize a variable at the same time, like this: let mydog = 'rover'; this is probably what you'll do most of the time, as it is quicker than doing the two actions on two separate lines. the difference between var and let at this point you may be thinking "why do we need two keywords for defining variables?? why have var and let?". the reasons are somewhat historical. back when javascr...
...iables that works somewhat differently to var, fixing its issues in the process. a couple of simple differences are explained below. we won't go into all the differences now, but you'll start to discover them as you learn more about javascript (if you really want to read about them now, feel free to check out our let reference page). for a start, if you write a multiline javascript program that
declares and initializes a variable, you can actually
declare a variable with var after you initialize it and it will still work. for example: myname = 'chris'; function logname() { console.log(myname); } logname(); var myname; note: this won't work when typing individual lines into a javascript console, just when running multiple lines of javascript in a web document. this works because of hoi...
...And 5 more matches
Index - Web APIs
h, bluetoothremotegattservice, experimental, property, reference, web bluetooth api, uuid the bluetoothgattservice.uuid read-only property returns a domstring representing the uuid of this service. 354 body api, body, experimental, fetch, fetch api, interface, reference, request the body mixin of the fetch api represents the body of the response/request, allowing you to
declare what its content type is and how it should be handled. 355 body.arraybuffer() api, arraybuffer, body, experimental, fetch, method, reference the arraybuffer() method of the body mixin takes a response stream and reads it to completion. it returns a promise that resolves with an arraybuffer. 356 body.blob() api, body, blob, experimental, fetch, method, reference...
... the document.onafterscriptexecute property references a function that fires when a static <script> element finishes executing its script. it does not fire if the element is added dynamically, such as with appendchild(). 940 document.onbeforescriptexecute api, dom, non-standard, property, reference, element.onbeforescriptexecute fired when the code in a <script> element
declared in an html document is about to start executing. does not fire if the element is added dynamically, eg with appendchild(). 941 document.onfullscreenchange api, document, event handler, fullscreen api, property, reference, fullscreen, onfullscreenchange the document interface's onfullscreenchange property is an event handler for the fullscreenchange event that is fired immedi...
...umenttypechildnode, property, read-only, reference the nondocumenttypechildnode.previouselementsibling read-only property returns the element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list. 2761 notation api, obsolete, reference, référence(2) represents a dtd notation (read-only). may
declare format of an unparsed entity or formally
declare the document's processing instruction targets. inherits methods and properties from node. its nodename is the notation name. has no parent. 2762 notification api, interface, notifications, reference the notification interface of the notifications api is used to configure and display desktop notifications to the user. 276...
...And 5 more matches
A re-introduction to JavaScript (JS tutorial) - JavaScript
.touppercase(); // "hello" other types javascript distinguishes between null, which is a value that indicates a deliberate non-value (and is only accessible through the null keyword), and undefined, which is a value of type undefined that indicates an uninitialized variable — that is, a value hasn't even been assigned yet. we'll talk about variables later, but in javascript it is possible to
declare a variable without assigning a value to it. if you do this, the variable's type is undefined. undefined is actually a constant. javascript has a boolean type, with possible values true and false (both of which are keywords.) any value can be converted to a boolean according to the following rules: false, 0, empty strings (""), nan, null, and undefined all become false. all other values becom...
...ow). for this reason, we sometimes speak simply of "true values" and "false values," meaning values that become true and false, respectively, when converted to booleans. alternatively, such values can be called "truthy" and "falsy", respectively. boolean operations such as && (logical and), || (logical or), and ! (logical not) are supported; see below. ...
...ues," meaning values that become true and false, respectively, when converted to booleans. alternatively, such values can be called "truthy" and "falsy", respectively. boolean operations such as && (logical and), || (logical or), and ! (logical not) are supported; see below. variables new variables in javascript are
declared using one of three keywords: let, const, or var. let allows you to
declare block-level variables. ...
...And 5 more matches
JavaScript Object Management - Archive of obsolete content
}; note: the naming standard that we normally follow is that the first part of the namespace corresponds to the development group (or company), and the second to the specific project. however, most extensions are small projects by individuals, so these examples follow a more practical approach of having just one namespace with the project name. notice how the 〈namespace〉 namespace is
declared using var. we need the namespace to be a global object that it can be used everywhere in the window chrome. you can include functions in any namespace, since namespaces are just regular js objects. that should come in handy when you have general utility functions or properties that you want to use across all objects within the namespace. for instance, there are frequently used xpcom services su...
...o. there are a few workarounds for this, and we use the ones we have found to be the most elegant and clear to read. the general guideline we follow is this: whenever you have to set a callback function parameter, wrap it in an anonymous function. that is, something like function() { /* your code, usually a single function call. */ }. if you have to use a reference to this inside the function,
declare a variable called that that equals this, and use that in the anonymous function. javascript has a host of features that make it extremely flexible, but it also has some disadvantages, as it is not as strict as other languages, such as java. a clear example of this is the fact that there are no private or public keywords that allow you to protect object members. as a alternative for this, a nam...
...o see the changes you need to make to the build system in order to include the files in the modules folder. they are minimal, and we add a very small makefile.in file in the modules directory, just to keep everything separated and organized. with the setup out of the way, let's get to it. ...
...And 4 more matches
Localization - Archive of obsolete content
coding text directly into an application, each piece of text is only a reference into the string table. xml provides entities which can be used for a similar purpose. you should already be familiar with entities if you have written html. the codes < and > are examples of entities which can be used to place less than and greater than signs into the text. xml has a syntax which allows you to
declare custom entities. you can use these so that the entity is replaced with its value, which can be a string of text. entities may be used whenever text occurs, including the values of attributes. the example below demonstrates the use of an entity in a button. <button label="&findlabel;"/> the text that will appear on the label will be the value that the entity &findlabel; has. a file is created w...
...ies may be used whenever text occurs, including the values of attributes. the example below demonstrates the use of an entity in a button. <button label="&findlabel;"/> the text that will appear on the label will be the value that the entity &findlabel; has. a file is created which contains the entity declarations for each supported language. in english, the &findlabel; entity will probably be
declared to have the text "find". dtd files entities are
declared in document type definition (dtd) files. files of this type are normally used to
declare the syntax and semantics of a particular xml file, but they also let you
declare entities. in the mozilla chrome system, you will find dtd files located in the locales subdirectory. you would normally have one dtd file (with an extension .dtd) per xu...
...ur language. (en-us.jar is the default for english.) you might have locale files in multiple languages, for example, us english (en-us) and french (fr). inside these archives, you will find the files that hold the localized text for each window. the structure of the archives is very similar to the directory structure used for skins. inside the archives, you would place the dtd files in which you
declare entities. typically, you will have one dtd file for each xul file, usually with the same filename except with a .dtd extension. so, for the find files dialog, we will need a file called findfile.dtd. for non-installed chrome files, you can just put the dtd file in the same directory as the xul file. note: you should encode dtd files as utf-8 for non-ascii characters. that is, you should save th...
...And 4 more matches
let - JavaScript
the let statement
declares a block-scoped local variable, optionally initializing it to a value. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax let var1 [= value1] [, var2 [= value2]] [, ..., varn [= valuen]; parameters var1, var2, …, varn the names of the variable or variables to
declare. each must be a legal javascript identifier. value1, value2, …, valuen optional for each variable
declared, you may optionally specify its initial value to any legal javascript expression. ...
...ll request. syntax let var1 [= value1] [, var2 [= value2]] [, ..., varn [= valuen]; parameters var1, var2, …, varn the names of the variable or variables to
declare. each must be a legal javascript identifier. value1, value2, …, valuen optional for each variable
declared, you may optionally specify its initial value to any legal javascript expression. description let allows you to
declare variables that are limited to the scope of a block statement, or expression on which it is used, unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope. the other difference between var and let is that the latter is initialized to a value only when a parser evaluates it (see below). just like const the let does not create properties ...
...d to the scope of a block statement, or expression on which it is used, unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope. the other difference between var and let is that the latter is initialized to a value only when a parser evaluates it (see below). just like const the let does not create properties of the window object when
declared globally (in the top-most scope). an explanation of why the name "let" was chosen can be found here. examples scoping rules variables
declared by let have their scope in the block for which they are defined, as well as in any contained sub-blocks. in this way, let works very much like var. the main difference is that the scope of a var variable is the entire enclosing function: function var...
...And 4 more matches
JNI.jsm
ly imported and is available from the privileged window scope as window.jni. there also exists a jenv variable in the window scope, so if you need to run jni from the global scope, use a different variable name then jenv. jni.jsm contains all the js-ctypes needed to communicate with the jni libraries. the js-ctypes is abstracted away while all the underlying data is all ctype data. ...
...i from the global scope, use a different variable name then jenv. jni.jsm contains all the js-ctypes needed to communicate with the jni libraries. the js-ctypes is abstracted away while all the underlying data is all ctype data. functions are
declared similar to js-ctypes but in a very different syntax. unlike c from js-ctypes, defining constants is not a manual magic number method in jni, it is
declared the same way we define functions, except in jni they are called fields. ...
...ype data. functions are
declared similar to js-ctypes but in a very different syntax. unlike c from js-ctypes, defining constants is not a manual magic number method in jni, it is
declared the same way we define functions, except in jni they are called fields. method overview cdata getforthread(); cdata loadclass(cdata ajenv, string aclassfullyqualifiedname, [optional] object a
declares); cdata newstring(cdata ajenv, string astr); string readstring(cdata ajenv, cdata ajavastring); void unloadclasses(); methods getforthread() blah blah cdata getforthread(); parameters this function does not take any arguments. ...
...And 3 more matches
Detailed XPCOM hashtable guide
n these situations, an array, a linked-list, or various tree data structures are more efficient. mozilla's hashtable implementations mozilla has several hashtable implementations, which have been tested and, tuned, and hide the inner complexities of hashtable implementations: pldhash - low-level c api; stores keys and data in one large memory structure; uses the heap efficiently; client must
declare an "entry class" and may not hold onto entry pointers. plhashtable - low-level c api; entry class pointers are constant; more efficient for large entry structures; often wastes memory making many small heap allocations. nsthashtable - low-level c++ wrapper around pldhash; generates callback functions and handles most casting automagically. client writes their own entry class which can include c...
...able - low-level c++ wrapper around pldhash; generates callback functions and handles most casting automagically. client writes their own entry class which can include complex key and data types. nsdatahashtable/nsinterfacehashtable/nsclasshashtable - high-level c++ wrappers around pldhash; simplifies the common usage pattern mapping a simple keytype to a simple datatype; client does not need to
declare or manage an entry class; nsdatahashtable datatype is a scalar such as pruint32; nsinterfacehashtable datatype is an interface; nsclasshashtable datatype is a class pointer owned by the hashtable. which hashtable should i use? key type: integer string/cstring nsid nsisupports* complex data type: none (hash set) nsthashtable<...> simple...
...entation is a fairly low-level implementation, written in c. it is extremely flexible, but requires some time to understand and use. a basic guide is included here, but you should read most of xpcom/glue/pldhash.h if you intend to use pldhash. the c++ wrappers for pldhash (see below) are often much easier and safer to use in c++ code, as many potential casting errors are easily avoided. you must
declare an entry struct type, deriving from pldhashentryhdr. this entry struct should contain whatever data you wish to store in the hashtable (any pointer or fixed-length data type). note: because of the double-hashing implementation, entries may move in memory when the hashtable is altered. if you need entry pointers to remain constant, you may want to consider using plhashtable instead. you must also...
...And 3 more matches
Localizations and character encodings - Developer guides
browsers process text as unicode internally. however, a way of representing characters in terms of bytes (character encoding) is used for transferring text over the network to the browser. the html specification recommends the use of the utf-8 encoding (which can represent all of unicode) and regardless of the encoding used requires web content to
declare what encoding was used. ...
...to
declare what encoding was used. the <meta> element's charset attribute is used to specify the page's character encoding. it must be used within a <head> block. to specify that a page is using, for example, the utf-8 character encoding (as per the recommendation), simply place the following line in the <head> block: <meta charset="utf-8"> details and browser internals when the encoding is
declared by web content like the html specification requires, firefox will use that encoding for turning the bytes into the internal representation. unfortunately, using utf-8 and declaring that utf-8 was used was not always the prevalent way of offering web content. ...
...: <meta charset="utf-8"> details and browser internals when the encoding is
declared by web content like the html specification requires, firefox will use that encoding for turning the bytes into the internal representation. unfortunately, using utf-8 and declaring that utf-8 was used was not always the prevalent way of offering web content. in the 1990s, it was common to leave the encoding un
declared and to use a region-specific encoding that wasn't able to represent all of unicode. firefox needs a fallback encoding that it uses for non-conforming legacy content that doesn't
declare its encoding. for most locales, the fallback encoding is windows-1252 (often called iso-8859-1), which was the encoding emitted by most windows applications in the 1990s and a superset of the encoding emitted by...
...And 3 more matches
Closures - JavaScript
outer function’s scope from an inner function. in javascript, closures are created every time a function is created, at function creation time. lexical scoping consider the following example code: function init() { var name = 'mozilla'; // name is a local variable created by init function displayname() { // displayname() is the inner function, a closure alert(name); // use variable
declared in the parent function } displayname(); } init(); init() creates a local variable called name and a function called displayname(). the displayname() function is an inner function that is defined inside init() and is available only within the body of the init() function. note that the displayname() function has no local variables of its own. however, since inner functions have access to the...
... local variable called name and a function called displayname(). the displayname() function is an inner function that is defined inside init() and is available only within the body of the init() function. note that the displayname() function has no local variables of its own. however, since inner functions have access to the variables of outer functions, displayname() can access the variable name
declared in the parent function, init(). run the code using this jsfiddle link and notice that the alert() statement within the displayname() function successfully displays the value of the name variable, which is
declared in its parent function. this is an example of lexical scoping, which describes how a parser resolves variable names when functions are nested. the word lexical refers to the fact that...
...his jsfiddle link and notice that the alert() statement within the displayname() function successfully displays the value of the name variable, which is
declared in its parent function. this is an example of lexical scoping, which describes how a parser resolves variable names when functions are nested. the word lexical refers to the fact that lexical scoping uses the location where a variable is
declared within the source code to determine where that variable is available. nested functions have access to variables
declared in their outer scope. closure consider the following code example: function makefunc() { var name = 'mozilla'; function displayname() { alert(name); } return displayname; } var myfunc = makefunc(); myfunc(); running this code has exactly the same effect as th...
...And 3 more matches
Chapter 3: Introduction to XUL—How to build a more intuitive UI - Archive of obsolete content
here are two separate elements—input for one line of text, and textarea for multiple lines. but both these functions are handled by textbox as shown in listing 16, which produces output as shown in figure 13. the textbox element uses the value attribute to set its default content; content entered by the user also can be captured using the value attribute. to set a maximum length in characters,
declare the maxlength attribute with a positive integer value. setting type="password" will turn the textbox into a special password-entry field, in which characters are hidden as they're typed. every character entered into a textbox generates an input event. if you use the oninput event handler, you can implement commands that reflect user input in real time. <vbox align="start"> <textbox/> <textb...
...rests of security, you can enforce access restrictions by declaring type="content" on a browser element. when you do this, any web page that gets opened will see itself as the topmost frame. if you are developing an application with an interface that can open web pages, i recommend that you always use this declaration to limit access to the parent frame. in certain circumstances, you may want to
declare type="content-primary". a browser element with this declaration is treated as a special browser among other xul documents, such that the window object displaying its web page can be accessed using the window.content property. in firefox itself, the content region of the active tab is
declared as a browser element with type="content-primary". keyboard shortcuts to implement keyboard shortcuts (p...
...that will intercept keyboard inputs. in xul, you can define keyboard shortcuts simply by using the key element, as shown in listing 19. <key id="key-save" key="s" modifiers="accel,shift" oncommand="save();"/> <key id="key-scroll-up" keycode="vk_page_up" oncommand="advancefocus(-1);"/> listing 19: defining keyboard shortcuts to make letters, numbers, symbols, or the space bar act as triggers,
declare that character as the key attribute’s value. you can use either uppercase and lowercase letters and they will be handled the same. for triggers on other special keys, use the keycode attribute with the appropriate keycode name value. in general you can use the keycode name for any key; the most commonly used ones are shown in table 3. key keycode name return vk_return ...
...And 2 more matches
Dehydra Object Reference - Archive of obsolete content
pt objects. the objects are designed to distill that type system to the minimum such that it can be easy to match on. often, the best way to become familiar with the dehydra objects is to print out the objects: dehydra example code an online tool for pretty-printing dehydra data understanding properties dehydra only sets properties that are applicable. for example, class types and typedefs are
declared and will have a .loc property. intrinsic types such as "int" are not
declared and will not have a .loc. dehydra only sets boolean flags when they are true. for example, a pointer type will have .ispointer == true, but a class type will not have an .ispointer property. common properties property type description .loc location object source location of a type or declaration. .attributes ...
...riables. these types are used to represent variables, functions, assignments, etc. the following properties are usually available: property type description .name string the function or variable name. .type type object the type of this function or variable. .isstatic boolean flag .isreturn boolean flag the variable is being returned. .isdecl boolean flag the variable is being
declared (local variables only). .assign array of variable objects this variable is the lhs of an assignment. the value is an array of values that were assigned. .isfcall boolean flag the variable is being used as a function call. .arguments array of variable objects arguments used to make a function call. .parameters array of variable objects a function definition's parameter names and types...
...oolean flag constructors generally have a .fieldof attribute (see variable objects). .isfunction boolean flag true for function variables. type objects dehydra provides detailed type objects. dehydra type objects use the dehydratype() prototype. common type properties property type description .name string if applicable, the name of of the type. for typedefs and classes, this is the
declared name. for built-in types this is the standard name such as "int". some types such as bitfields may not have names. .typedef type object if this is a typedef, the original type. .isconst boolean flag .isvolatile boolean flag .variantof type object "const int" and "int" are separate types in gcc; the const version is considered a variant of the normal version. the variantof pro...
...And 2 more matches
Elements - Archive of obsolete content
bindings this section is tested and adjusted for the current firefox implementation. please edit only if an actual behavior differs from the described one. please do not edit only on the basis of another xbl specification. <!element bindings ( binding* ) > hierarchy: root element may contain: <binding> the bindings element is the root element of any xbl document. it should usually
declare xbl as the default namespace (unless an xbl namespace prefix is used) and it may additionally
declare other namespace prefixes used in your binding. bindings contains zero or more binding elements as children. each binding child element defines a unique binding that can be attached to elements in other documents. an element can have only one binding attached (explicitly or inherited) at one mome...
...files) is utf-8. an explicit encoding declarations may be present to override the default, for example <?xml version="1.0" encoding="iso-8859-1"?> uri in namespace declarations is an opaque string used to uniquely identify the namespace. it doesn't have to (and often it doesn't) point to some actual schema or a namespace-related resource. namespaces in xml besides the default namespace, you can
declare any amount of additional namespaces to handle your content. the most useful namespaces could be html/xhtml, xul (xml user interface language), svg (scalable vector graphics) and xlink. this way a more-or-less universal namespace declaration in your bindings could be like: <bindings xmlns="http://www.mozilla.org/xbl" xmlns:html = "http://www.w3.org/1999/xhtml" xmlns:xul = "http://www.mozilla.
... document. note that content cannot be inherited, only behavior. display - this attribute specifies how the tag is displayed. by setting this attribute, you can have an element have the layout and display characteristics of an existing element. for example, use the value 'xul:button' to create an element that is displayed like a button. the part before the colon is a namespace prefix so you must
declare the xul namespace as well. not all tags have a unique display type. the following xul display types may be used: browser, button, checkbox, description, editor, grippy, iframe, image, label, menu, menuitem, menubar, progressmeter, radio, resizer, scrollbar, scrollbox, spacer, splitter, titlebar, treechildren and treecol. you may also use a number of html, mathml and svg tags. the 'display' attrib...
...And 2 more matches
Building accessible custom components in XUL - Archive of obsolete content
g controls were never as accessible as similar controls in desktop applications. assistive technologies could only see the generic html markup used to build the control; they had no way of knowing that a particular collection of div and span elements should be treated as a single cohesive control (such as a tab bar or a treeview). by implementing dhtml accessibility techniques, web developers can
declare that generic html elements are really acting as specific gui controls (such as a treeitem within a treeview). firefox 1.5 is the first browser to support dhtml accessibility; it maps the declarations within the html page to the underlying accessibility architecture so that assistive technologies can "read" a web page and know how to present these complex controls to the end user. this has all bee...
... assistive technologies that all of these unrelated elements are actually related. this is where dhtml accessibility comes in. further reading grid element reference description element reference label element reference grid tutorial label tutorial adding roles with dhtml accessibility download stage-2.zip install stage-2.xpi using the new dhtml accessibility techniques in firefox 1.5, we can
declare the role of each element in our spreadsheet. the grid element is really a spreadsheet. each label element is really a cell within the spreadsheet. each description element is really a row or column header within the spreadsheet. you can find a list of all the supported roles in firefox 1.5 on mozilla.org. role declarations are a little confusing at first glance, but they all follow the same pat...
...preadsheet. each label element is really a cell within the spreadsheet. each description element is really a row or column header within the spreadsheet. you can find a list of all the supported roles in firefox 1.5 on mozilla.org. role declarations are a little confusing at first glance, but they all follow the same pattern. the role attribute itself is in the xhtml 2 namespace. we will need to
declare the namespace (xmlns:x2="http://www.w3.org/tr/xhtml2") so we can add an xhtml2:role attribute to each xul element. the role attribute value is also in a namespace. we will need to
declare this namespace as well (xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/guiroletaxonomy#"), and then use this namespace prefix (wairole:) as part of the role attribute value. this will become clearer with some ...
...And 2 more matches
Index - Archive of obsolete content
et of data from the datasource. the exact syntax is dependent on the type of datasource used in the template. for instance, for an sqlite datasource, an sql statement is used as the query. this will return a table of result records which are then used to generate output. for rdf and xml, the query contains a set of instructions for navigating through the rdf graph or xml document tree. a query is
declared with the query tag (new to ff3; ff2 only worked with rdf datasources and had no query tag), which you would place directly inside the <template>. the job of the query is to generate a set of output results. 939 sqlite templates xul, xul_template_guide no summary! 940 simple example xul, xul_template_guide no summary! 941 simple query syntax ...
...pup element which should be used instead. see the documentation on the menupopup element for more information. 1151 popupset xul elements, xul reference a container for menupopup, panel and tooltip elements. this element is optional; the given elements need not appear in a popupset container. 1152 preference preferences system, xul elements, xul reference
declares a preference that may be adjusted in a prefpane. this element must be placed inside a preferences element. each preference element corresponds to a preference which is stored in the user's preferences file. you can connect a user interface element such as a checkbox to a preference element using the user interface element's preference attribute. 1153 preferences preferences system...
... larger than the number of column elements defined in the grid. 1167 rows xul elements, xul reference defines the rows of a grid. child row elements define the individual rows to appear in the grid. each child of a rows element should be a row element. 1168 rule xul elements, xul reference a rule is used in a template. the children of the rule are used to
declare the conditions in which the rule matches and the content that is generated. a rule may contain where, binding and/or action elements. a condition is defined used a where element. for each result that matches all of the conditions, content within the rule's action body is generated. the bindings element is optional and may specify additional variable bindings to be used. 1169 scale ...
...And 2 more matches
Anonymous Content - Archive of obsolete content
specify the outer element while the inner elements are described in the xbl. this is useful for creating a single widget that is made up of a set of other widgets, but can be referred to as only a single widget. mechanisms are provided for adding attributes to the inner elements that were specified on the outer element. ...
...all of the elements inside the content tag will be added inside the element that the binding is bound to. presumably this binding would be bound t...
...all of the elements inside the content tag will be added inside the element that the binding is bound to. ...
...And 2 more matches
Document Object Model - Archive of obsolete content
or each window. each frame will also have a separate window object. the window is often referred to using the window property, although this is optional. sometimes, this is done just to clarify the scope of the method you are referring to. for example, the following two lines which open a new window are functionally equivalent: window.open("test.xul","_new"); open("test.xul","_new"); when you
declare a function or a variable at the top level of a script, that is outside another function, you are actually declaring a property of the global object. in xul, each function you
declare will be set as a property of the window object. for example, the following code will display the text 'message' in an alert twice. function gettext(){ return "message"; } alert(gettext()); alert(window.gettext())...
...for example, if we combined the last two examples into a single file, we might want to call the gettext() function from within the other window (for example, the test.xul window). ...
... combined the last two examples into a single file, we might want to call the gettext() function from within the other window (for example, the test.xul window). to do this, we can do the following: alert(window.opener.gettext()); each window has an opener property which holds the window object that opened this one. in this example, we retrieve the opener window and call the gettext() function
declared in a script used there. note that we qualified the property with the 'window' identifier just to be clearer. the window's open() method also returns a reference to the new window so you can call functions of the new window from the opener. it is important to note, however, that the open() method returns before the window has fully loaded, so functions will not typically be available yet. the w...
...And 2 more matches
Grids - Archive of obsolete content
ating tabular grids. xul tabular layout xul has a set of elements for doing layout of elements in a grid-like manner using the grid element. it has some similarities to the html table tag. the grid does not display anything itself; it is used only to position elements in a tabular form with rows and columns. a grid contains elements that are aligned in rows just like tables. inside a grid, you
declare two things, the columns that are used and the rows that are used. just like html tables, you put content such as labels and buttons inside the rows. however, the grid allows either row or column based organization so you may put content in either rows or in columns. it is most common to use rows, as with a table. however, you can still use columns to specify the size and appearance of the columns...
...mn based organization so you may put content in either rows or in columns. it is most common to use rows, as with a table. however, you can still use columns to specify the size and appearance of the columns in a grid. alternatively, you can put content inside the columns, and use the rows to specify the appearance. we'll look at the case of organizing elements by row first. declaring a grid to
declare a set of rows, use the rows tag, which should be a child element of grid. inside that you should add row elements, which are used for each row. inside the row element, you should place the content that you want inside that row. similarly, the columns are
declared with the columns element, which should be placed as a child element of the grid. inside that go individual column elements, one for ea...
... with an example. example 1 : source view <grid flex="1"> <columns> <column flex="2"/> <column flex="1"/> </columns> <rows> <row> <button label="rabbit"/> <button label="elephant"/> </row> <row> <button label="koala"/> <button label="gorilla"/> </row> </rows> </grid> two rows and two columns have been added to a grid. each column is
declared with the column tag. each column has been given a flex attribute. each row contains two elements, both buttons. the first element in each row element is placed in the first column of the grid and the second element is each row is placed in the second column. note that you do not need an element to
declare a cell -- there is no equivalent of the html td element. instead, you put the contents of c...
...And 2 more matches
Using XPCOM Utilities to Make Things Easier
t recommended argument) a constructor for the given object static const nsmodulecomponentinfo components[] = { { "pretty class name", cid, contract_id, constructor }, // ... }; the important thing to note in the fictitious listing above is that it can support multiple components in a module. modules such as the networking libraries in gecko ("necko") have over 50 components
declared in a single nsmodulecomponentinfo array like this. the first entry of the nsmodulecomponentinfo above is the name of the component. though it isn't used that much internally at the present time, this name should be something that meaningfully describes the module. the second entry of the nsmodulecomponentinfo is the cid. the usual practice is to put the class id (cid) into a #define and use th...
...e nsmodulecomponentinfo array like this. the first entry of the nsmodulecomponentinfo above is the name of the component. though it isn't used that much internally at the present time, this name should be something that meaningfully describes the module. the second entry of the nsmodulecomponentinfo is the cid. the usual practice is to put the class id (cid) into a #define and use the define to
declare the cid in the components list. many cids take the following form: #define ns_ioservice_cid \ { /* 9ac9e770-18bc-11d3-9337-00104ba0fd40 */ \ 0x9ac9e770, \ 0x18bc, \ 0x11d3, \ {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \ }...
...\ 0x11d3, \ {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \ } the next entry is the contract id string, which is also usually defined in a #define in a header file. these three entries constitute the required parameters for the registerfactorylocation method we looked at in the prior chapter. when you use these implementation macros, you must
declare a constructor for the object, and this keeps you from having to write a factory object. factory macros the factory macro makes it easy to write factory implementations. given the class name concreteclass, the factory macro declaration is: ns_generic_factory_constructor(concreteclass) this results in a function called concreteclassconstructor that can be used in the nsmodulecomponentinfo stru...
...And 2 more matches
Library
the library object represents a native library loaded by the ctypes open() method. its methods let you
declare symbols exported by the library, and to manage the library. method overview close(); cdata
declare(name, [abi, ], returntype[, argtype1, ...]); methods close() closes the library. you need to call this once you're done using the library. close(); parameters none.
declare()
declares an api from the native library, allowing it to be used from javascript. this can be used both for exported data symbols and for functions. ...
...hod overview close(); cdata
declare(name, [abi, ], returntype[, argtype1, ...]); methods close() closes the library. you need to call this once you're done using the library. close(); parameters none.
declare()
declares an api from the native library, allowing it to be used from javascript. this can be used both for exported data symbols and for functions. cdata
declare( name[, abi, returntype argtype1, ...] ); parameters name the name of the symbol exported by the native library that is to be
declared as usable from javascript abi the abi used by the exported function; this will be ctypes.default_abi for most libraries, except for windows libraries, which will be ctypes.winapi_abi or ctypes.stdcall_abi. see abi constants. you don't need to pro...
... or ctypes.stdcall_abi. see abi constants. you don't need to provide this for exported data; it's only needed for function declarations. returntype the ctype type returned by the defined api, if it's a function. this parameter should not be provided if the api is an exported data symbol. argtype1...argtypen zero or more parameter ctype may be specified for the parameters of the function being
declared. these should not be provided if the api is an exported data symbol rather than a function. return value a functiontype cdata object representing the
declared api. exceptions thrown ctypes ctype functiontype abi typeerror the return type was specified as an array. alternative syntax another use for ctypes.
declare is to get non-function/non-methods from libraries. the syntax for...
...And 2 more matches
repeating-conic-gradient() - CSS: Cascading Style Sheets
90deg); repeating-radial-gradient(red 0 8%, yellow 8% 16%, blue 16% 24%); conic-gradient(red 120deg, yellow 120deg 240deg, blue 240deg); radial-gradient(red 33%, yellow 33% 66%, blue 66%); for a repeating gradient to repeat we define the first and last color stops. like in non-repeating gradients, the first and last color stops are assumed to be 0 and either 100% or 360deg if not explicitly
declared. when defaulting to these values, the repeating arc is 360 degrees, and therefore doesn't repeat. like the non-repeating conic gradient, the color-stops are placed around a gradient arc -- the circumference of a circle, rather than on the gradient line emerging from the center of the gradient. the colors transition as as if spun around the center of a circle, starting at the top if no from <ang...
... defaulting to these values, the repeating arc is 360 degrees, and therefore doesn't repeat. like the non-repeating conic gradient, the color-stops are placed around a gradient arc -- the circumference of a circle, rather than on the gradient line emerging from the center of the gradient. the colors transition as as if spun around the center of a circle, starting at the top if no from <angle> is
declared, and going clockwise for the the size of the angle that is the different between the largest and smallest color angle, then repeating. a repeating conic gradient is specified by indicating a rotation angle, the center of the gradient, and then specifying a list of color-stops. like non-repeating conic gradients, the color-stops of a repeating conic gradient are specified with an <angle>. units ...
...nsition between multiple colors. a color-stop's position can be explicitly defined by using an <angle>. if you don't specify the location of a color stop, it is placed halfway between the one that precedes it and the one that follows it. like the non-repeating gradient counterpart, if you don't specify an angle for the first or last color stop, the values are will be 0deg and 360deg. ...
...And 2 more matches
Functions - JavaScript
l are the function's arguments. arguments are passed to functions by value. if the function changes the value of an argument, this change is not reflected globally or in the calling function. ...
...he value of an argument, this change is not reflected globally or in the calling function. however, object references are values, too, and they are special: if the function changes the referred object's properties, that change is visible outside the function, as shown in the following example: /*
declare the function 'myfunc' */ function myfunc(theobject) { theobject.brand = "toyota"; } /* *
declare variable 'mycar'; * create and initialize a new object; * assign reference to it to 'mycar' */ var mycar = { brand: "honda", model: "accord", year: 1998 }; /* logs 'honda' */ console.log(mycar.brand); /* pass object reference to the function */ myfunc(mycar); /* * logs 'toyota' as the value of the 'brand' property * of the object, as changed to by the function. */ console.log(mycar...
... origin of the error. as we can see, both examples do not start with the function keyword. statements involving functions which do not start with function are function expressions. when functions are used only once, a common pattern is an iife (immediately invoked function expression). (function() { statements })(); iife are function expressions that are invoked as soon as the function is
declared. the generator function declaration (function* statement) there is a special syntax for generator function declarations (see function* statement for details): function* name([param[, param[, ... param]]]) { statements } name the function name. param the name of an argument to be passed to the function. statements the statements comprising the body of the function. the gene...
...And 2 more matches
const - JavaScript
constants are block-scoped, much like variables defined using the let keyword. the value of a constant can't be changed through reassignment, and it can't be re
declared. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax const name1 = value1 [, name2 = value2 [, ... [, namen = valuen]]]; namen the constant's name, which can be any legal identifier. valuen the constant's value. this can be any legal expression, including a function expression. description this declaration creates a constant whose scope can be either global or local to the block in which it is
declared. global constants do not become proper...
...(this makes sense, given that it can't be changed later.) the const declaration creates a read-only reference to a value. ...
...just that the variable identifier cannot be reassigned. for instance, in the case where the content is an object, this means the object's contents (e.g., its properties) can be altered. all the considerations about the "temporal dead zone" apply to both let and const. a constant cannot share its name with a function or a variable in the same scope. ...
...And 2 more matches
Introduction to XBL - Archive of obsolete content
?> <bindings xmlns="http://www.mozilla.org/xbl"> <binding id="binding1"> <!-- content, property, method and event descriptions go here --> </binding> <binding id="binding2"> <!-- content, property, method and event descriptions go here --> </binding> </bindings> the bindings element is the root element of an xbl file and contains one or more binding elements. each binding element
declares a single binding. the id attribute can be used to identify the binding, as in the example above. the template has two bindings, one called binding1 and the other called binding2. one might be attached to a scroll bar and the other to a menu. a binding can be attached to any xul element. if you use css classes, you can use as many different bindings as you need. note the namespace on the bindings...
...can be used to identify the binding, as in the example above. the template has two bindings, one called binding1 and the other called binding2. one might be attached to a scroll bar and the other to a menu. a binding can be attached to any xul element. if you use css classes, you can use as many different bindings as you need. note the namespace on the bindings element in the template above. this
declares that we are using xbl syntax. you assign a binding to an element by setting the css property -moz-binding to the url of the bindings file. for example: scrollbar { -moz-binding: url('chrome://findfile/content/findfile.xml#binding1'); } the url points to the binding with the id 'binding1' in the file 'chrome://findfile/content/findfile.xml'. the '#binding1' syntax is used to point to a speci...
...n the file 'chrome://findfile/content/findfile.xml'. the '#binding1' syntax is used to point to a specific binding, much like how you would point to an anchor in an html file. you will usually put all of your bindings in a single file. the result in this example, is that all scrollbar elements will have their behavior described by the binding 'binding1'. a binding has five types of things that it
declares: content: child elements that are added to the element that the binding is bound to. properties: properties added to the element. they can be accessed through a script. methods: methods added to the element. they can be called from a script. events: events, such as mouse clicks and keypresses that the element will respond to. the binding can add scripts to provide default handling. in a...
...xml#okcancel'); } xbl (example.xml): <?xml version="1.0"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <binding id="okcancel"> <content> <xul:button label="ok"/> <xul:button label="cancel"/> </content> </binding> </bindings> this example creates a window with a single box. the box has been
declared to have a class of okcancelbuttons. the style sheet associated with the file says that boxes with the class okcancelbuttons have a specialized binding, defined in the xbl file. you may use other elements besides the box, even your own custom tags. we'll look more at the details of the xbl part in the next section. however, to summarize, it causes two buttons to be added automatically inside the ...
TypeScript support in Svelte - Learn web development
note: the svelte template uses svelte-preprocess 4.0.0 to support typescript. from that version onward you have to use export/import type syntax to import types and interfaces. check this section of the troubleshooting guide for more information. now we'll use todotype from our todo.svelte component. first add the lang="ts" to our <script> tag. let's import the type and use it to
declare the todo property. replace the export let todo line with the following: import type { todotype } from '../types/todo.type' export let todo: todotype note: another reminder — when importing a .ts file you have to omit the extension. check the import section of the typescript manual for more information. now from todos.svelte, we will instantiate a todo component with a literal...
...of type todotype. nevertheless, if we think it makes our code easier to read, we could specify it like this: $: completedtodos = todos.filter((t: todotype) => t.completed).length most of the time typescript will be able to correctly infer the reactive variable type, but sometimes you might get an "implicitly has an 'any' type" error when working with reactive assignments. in those cases you can
declare the typed variable in a different statement, like this: let completetodos: number $: completedtodos = todos.filter((t: todotype) => t.completed).length you can't specify the type in the reactive assignment itself. the following statement $: completedtodos: number = todos.filter[...] is invalid. for more information read how do i type reactive assignments? / i get an "implicitly has type 'any' e...
...'undefined'. (ts) <todo {todo} this is because the todos prop in the todosstatus component has no default value, so typescript has inferred it to be of type undefined, which is not compatible with an array of todotype. the same thing is happening with our todo component. let's fix it. open the file todosstatus.svelte and add the lang='ts' attribute. then import the todotype and
declare the todos prop as an array of todotype. replace the first line of the <script> section with the following: import type { todotype } from '../types/todo.type' export let todos: todotype[] we will also specify the headingel, which we used to bind to the heading tag, as an htmlelement. update the let headingel line with the following: let headingel: htmlelement finally, you'll not...
...ript object with a couple limitations, for example undefined, functions, and symbols are not valid json values. so we'll create the type jsonvalue to specify these conditions. create the file json.type.ts in the types folder. give it the following content: export type jsonvalue = string | number | boolean | null | jsonvalue[] | { [key: string]: jsonvalue } the | operator lets us
declare variables that could store values of two or more types. a jsonvalue could be a string, a number, a boolean, and so on. in this case we are also making use of recursive types, to specify that a jsonvalue can have an array of jsonvalue, and also an object with properties of type jsonvalue. we will import our jsonvalue type and use it accordingly. update your localstore.ts file like this: /...
Advanced Svelte: Reactivity, lifecycle, accessibility - Learn web development
your app. objective: learn some advanced svelte techniques involving solving reactivity issues, keyboard accessibility problems to do with component lifecycle, and more. we'll focus on some accessibility issues involving focus management. to do so, we'll utilize some techniques for accessing dom nodes and executing methods like focus() and select(). we will also see how to
declare and clean-up event listeners on dom elements. we also need to learn a bit about component lifecycle, to understand when these dom nodes get mounted and and unmounted from the dom and how we can access them. we will also learn about the action directive, which will allow us to extend the functionality of html elements in a reusable and declarative way. finally, we will learn a bit more about com...
... don't forget to pass the prop into moreactions from inside todos.svelte, where the component is called: <moreactions {todos} on:checkall={e => checkalltodos(e.detail)} on:removecompleted={removecompletedtodos} /> working with the dom: focusing on the details now that we have completed all...
...reak the component encapsulation; setting focus on it should be its own responsibility. so we need the todosstatus component to expose a method that its parent can call to give focus to it. it's a very common scenario that a component needs to expose some behavior or information to the consumer; let's see how to achieve it with svelte. we've already seen that svelte uses export let var = ... to
declare props. but if instead of using let you export a const, class or function, it is read-only outside the component. function expressions are valid props, however. in the following example, the first three declarations are props, and the rest are exported values: <script> export let bar = 'optional default initial value' // prop export let baz = undefined // pr...
...: function removetodo(todo) { todos = todos.filter(t => t.id !== todo.id) todosstatus.focus() // give focus to status heading } go back to your app — now if you delete any todo, the status heading will be focussed — this is useful to highlight the change in numbers of todos, both to sighted users and screenreader users. note: you might be wondering why we need to
declare a new variable for component binding — why can't we just call todosstatus.focus()? you might have multiple todosstatus instances active, so you need a way to reference each particular instance. that's why you have to specify a variable to bind each specific instance to. the code so far git to see the state of the code as it should be at the end of this article, access your copy of our repo ...
XPCOM array guide
drefs(enumerator)); // now enumerate the elements ... typesafe arrays nscomarray<t> nscomarray<t> is a wrapper around nstarray<t>, so it has a similar api. it enforces both typesafety and xpcom reference counting by keeping an owning reference to each element in the array. usage it is most often used as a member of a c++ class to store a list of well-typed xpcom objects. it is also usually
declared as an inline member rather than a pointer. as a class member, nscomarray<t> is preferred over nsiarray when access to the array is confined to the class itself. for example, here is its use in a class: class nodecontainer { public: void addnode(nsinode* node); private: nscomarray<nsinode> mnodes; }; // typesafety of mnodes ensures that we only append an nsinode* void nodecontainer::addno...
... preferred over nsiarray when access to the array is confined to the class itself. for example, here is its use in a class: class nodecontainer { public: void addnode(nsinode* node); private: nscomarray<nsinode> mnodes; }; // typesafety of mnodes ensures that we only append an nsinode* void nodecontainer::addnode(nsinode* node) { mnodes.appendobject(node); } nscomarray<t> can also be
declared on the stack to collect a temporary list of objects and manipulate them. when the object goes out of scope, all its members are released. void processvisibleitems() { // temporary stack-based nscomarray nscomarray<nsifoo> fooitems; getcompletelist(fooitems); // now filter out non visible objects // doing this backwards pruint32 i = fooitems.count(); while (i > 0) { --i; p...
...remove three objects, starting at the third object in the array (that is, the object with index value 2): myarray.removeobjectsat(2, 3); nstarray<t> nstarray<t> is a typesafe array for holding various objects. it can be used to hold objects directly, not just pointers to objects. usage it is most often used as a member of a c++ class to store a list of well-typed objects. ...
...when the object goes out of scope, all its members have their destructors called. note that if the nstarray<t> holds pointers to objects, the objects will not be deleted (and hence not have their destructors called). you can work around this by using nstarray<uniqueptr<t>> instead. ...
Working with data
ypes.uintptr_t, for which the value property returns a ctypes.uint64. calling tostring() on that returns the pointer as a base 10 integer. using arrays of pointers if you need to work with c functions that accept arrays of pointers as inputs, you can construct an array of pointers like this: var ptrarraytype = ctypes.char.ptr.array(5); var myarray = ptrarraytype(); var somecfunction = library.
declare("somecfunction", ctypes.default_abi, ctypes.void_t, ctypes.char.ptr.array() /*same as ctypes.char.ptr.ptr*/); somecfunction(myarray); line 1
declares a new array type, capable of containing 5 arrays of pointers to c characters. this might be an array of strings, for example. the next line instantiates an object of that type, creating a new array. each pointer in the array is initialized to nul...
...ction", ctypes.default_abi, ctypes.void_t, ctypes.char.ptr.array() /*same as ctypes.char.ptr.ptr*/); somecfunction(myarray); line 1
declares a new array type, capable of containing 5 arrays of pointers to c characters. this might be an array of strings, for example. the next line instantiates an object of that type, creating a new array. each pointer in the array is initialized to null. line 4
declares the c function that accepts the array as an input, and the last line calls that function. ...
...array. each pointer in the array is initialized to null. line 4
declares the c function that accepts the array as an input, and the last line calls that function. ...
...pes.char.array(5); var myarray = myarraytype(); var somecfunction = library.
declare("somecfunction", ctypes.default_abi, ctypes.void_t, ctypes.char.array() /*same as ctypes.char.ptr*/); somecfunction(myarray); second example: var mystruct = ctypes.structtype('foo', [{bar: ctypes.bool}]); var mystructarraytype = mystruct.array(5); var myarray = mystructarraytype(); var somecfunction = library.
declare("somecfunction", ctypes.default_abi, ctypes.void_t, mystruct.ptr); somecfunction(myarray); this shows how to pass a buffer containing 5 elements of mystruct, the elements in myarray are not pointers. 64-bit integers while most numeric types in js-ctypes are represented by standard javascript number objects, 64-bit integers cannot all be represented accurately by this type. for that reason, 64...
cross-fade() - CSS: Cascading Style Sheets
the 50%/50% example seen above did not need to have the percentages listed, as when a percentage value is omitted, the included percentages are added together and subtracted from 100%. the result, if greater than 0, is then divided equally between all images with omitted percentages. in the last ex...
...d not need to have the percentages listed, as when a percentage value is omitted, the included percentages are added together and subtracted from 100%. the result, if greater than 0, is then divided equally between all images with omitted percentages. in the last example, the sum of both percentages is not 100%, and therefore both images include their respective opacities. if no percentages are
declared and three images are included, each image will be 33.33% opaque. the two following are lines (almost) identical: cross-fade( url(red.png), url(yellow.png), url(blue.png)); /* all three will be 33.3333% opaque */ cross-fade( url(red.png) 33.33%, url(yellow.png) 33.33%, url(blue.png) 33.33%); older, implemented syntax cross-fade( <image, <image>, <percentage> ) the specification for the cross-...
...the included percentage is subtracted from 100%, with the difference being the opacity of the second image. the green/red example (with the percentages totalling 150%) and the yellow/red/blue example (with three images) from the spec...
...the included percentage is subtracted from 100%, with the difference being the opacity of the second image. ...
Functions - JavaScript
const factorial = function fac(n) { return n < 2 ? 1 : n * fac(n - 1) } console.log(factorial(3)) function expressions are convenient when passing a function as an argument to another function. the following example shows a map function that should receive a function as first argument and an array as second argument. ...
... in javascript, a function can be defined based on a condition. ...
...eding statement calls the function with an argument of 5. the function executes its statements and returns the value 25. functions must be in scope when they are called, but the function declaration can be hoisted (appear below the call in the code), as in this example: console.log(square(5)); /* ... */ function square(n) { return n * n } the scope of a function is the function in which it is
declared (or the entire program, if it is
declared at the top level). note: this works only when defining the function using the above syntax (i.e. function funcname(){}). the code below will not work. this means that function hoisting only works with function declarations—not with function expressions. console.log(square) // square is hoisted with an initial value undefined. console.log(square(...
...n an array-like object. within a function, you can address the arguments passed to it as follows: arguments[i] where i is the ordinal number of the argument, starting at 0. so, the first argument passed to a function would be arguments[0]. the total number of arguments is indicated by arguments.length. using the arguments object, you can call a function with more arguments than it is formally
declared to accept. this is often useful if you don't know in advance how many arguments will be passed to the function. you can use arguments.length to determine the number of arguments actually passed to the function, and then access each argument using the arguments object. for example, consider a function that concatenates several strings. the only formal argument for the function is a string that s...
Classes - JavaScript
on prototypes but also have some syntax and semantics that are not shared with es5 classalike semantics. defining classes classes are in fact "special functions", and just as you can define function expressions and function declarations, the class syntax has two components: class expressions and class declarations. class declarations one way to define a class is using a class declaration. ...
...class expressions can be named or unnamed. the name given to a named class expression is local to the class's body. ...
...ke babel. public field declarations with the javascript field declaration syntax, the above example can be written as: class rectangle { height = 0; width; constructor(height, width) { this.height = height; this.width = width; } } by declaring fields up-front, class definitions become more self-documenting, and the fields are always present. as seen above, the fields can be
declared with or without a default value. see public class fields for more information. private field declarations using private fields, the definition can be refined as below. class rectangle { #height = 0; #width; constructor(height, width) { this.#height = height; this.#width = width; } } it's an error to reference private fields from outside of the class; they can only be read o...
...uctor(height, width) { this.#height = height; this.#width = width; } } it's an error to reference private fields from outside of the class; they can only be read or written within the class body. by defining things which are not visible outside of the class, you ensure that your classes' users can't depend on internals, which may change version to version. private fields can only be
declared up-front in a field declaration. private fields cannot be created later through assigning to them, the way that normal properties can. for more information, see private class fields. sub classing with extends the extends keyword is used in class declarations or class expressions to create a class as a child of another class. class animal { constructor(name) { this.name = name; } ...
typeof - JavaScript
typeof false === 'boolean'; typeof boolean(1) === 'boolean'; // boolean() will convert values based on if they're truthy or falsy typeof !!(1) === 'boolean'; // two calls of the ! ...
...avoid them. typeof...
...ata + ' wisen'); // 'string' regular expressions callable regular expressions were a non-standard addition in some browsers. typeof /s/ === 'function'; // chrome 1-12 non-conform to ecmascript 5.1 typeof /s/ === 'object'; // firefox 5+ conform to ecmascript 5.1 errors before ecmascript 2015, typeof was always guaranteed to return a string for any operand it was supplied with. even with un
declared identifiers, typeof will return 'undefined'. using typeof could never generate an error. but with the addition of block-scoped let and statements/const using typeof on let and const variables (or using typeof on a class) in a block before they are
declared will throw a referenceerror. block scoped variables are in a "temporal dead zone" from the start of the block until the initialization is pr...
...er generate an error. but with the addition of block-scoped let and statements/const using typeof on let and const variables (or using typeof on a class) in a block before they are
declared will throw a referenceerror. block scoped variables are in a "temporal dead zone" from the start of the block until the initialization is processed, during which, it will throw an error if accessed. typeof un
declaredvariable === 'undefined'; typeof newletvariable; // referenceerror typeof newconstvariable; // referenceerror typeof newclass; // referenceerror let newletvariable; const newconstvariable = 'hello'; class newclass{}; exceptions all current browsers expose a non-standard host object document.all with type undefined. typeof document.all === 'undefined'; although the specification allows custo...
block - JavaScript
ere javascript expects only one statement. combining statements into blocks is a common practice in javascript. the opposite behavior is possible using an empty statement, where you provide no statement, although one is required. blocks are commonly used in association with if...else and for statements. examples block scoping rules with var or function declaration in non-strict mode variables
declared with var or created by function declarations in non-strict mode do not have block scope. variables introduced within a block are scoped to the containing function or script, and the effects of setting them persist beyond the block itself. in other words, block statements do not introduce a scope. for example: var x = 1; { var x = 2; } console.log(x); // logs 2 this logs 2 because the var x ...
...troduce a scope. for example: var x = 1; { var x = 2; } console.log(x); // logs 2 this logs 2 because the var x statement within the block is in the same scope as the var x statement before the block. in non-strict code, function declarations inside blocks behave strangely. do not use them. ...
... in strict mode, starting with es2015, functions inside blocks are scoped to that block. prior to es2015, block-level functions were forbidden in strict mode. specifications specification ecmascript (ecma-262)the definition of 'block statement' in that specification. ...
...onst do have block scope: let x = 1; { let x = 2; } console.log(x); // logs 1 the x = 2 is limited in scope to the block in which it was defined. the same is true of const: const c = 1; { const c = 2; } console.log(c); // logs 1 and does not throw syntaxerror... note that the block-scoped const c = 2 does not throw a syntaxerror: identifier 'c' has already been
declared because it can be
declared uniquely within the block. in strict mode, starting with es2015, functions inside blocks are scoped to that block. prior to es2015, block-level functions were forbidden in strict mode. specifications specification ecmascript (ecma-262)the definition of 'block statement' in that specification. ...
Namespaces crash course - SVG: Scalable Vector Graphics
ace? easy. you just redefine the default namespace. here's a short example. <html xmlns="http://www.w3.org/1999/xhtml"> <body> <!-- some xhtml tags here --> <svg xmlns="http://www.w3.org/2000/svg" width="300px" height="200px"> <!-- some svg tags here --> </svg> <!-- some xhtml tags here --> </body> </html> in this example the xmlns parameter on the root <html> element
declares the default namespace to be xhtml. as a result, it and all its child elements are interpreted by the user agent as belonging to xhtml, except for the <svg> element. the <svg> element has its own xmlns parameter, and by redeclaring the default namespace, this tells the user agent that the <svg> element and its descendants (unless they also re
declare the default namespace) belong to svg. see, nam...
... scripting in namespaced xml namespaces affect not only markup, but also scripting. if you write scripts for namespaced xml such as svg, read on. the dom level 1 recommendation was created before the original namespaces in xml recommendation was released; the...
...w.w3.org/2000/svg"> <body> <h1>svg embedded inline in xhtml</h1> <svg:svg width="300px" height="200px"> <svg:circle cx="150" cy="100" r="50" fill="#ff0000"/> </svg:svg> </body> </html> note that because a namespace prefix is used for the <svg:svg> element and its child <svg:circle>, it wasn't necessary to re
declare the default namespace. in general though it is better to re
declare the default namespace rather than prefix lots of elements in this way. scripting in namespaced xml namespaces affect not only markup, but also scripting. if you write scripts for namespaced xml such as svg, read on. the dom level 1 recommendation was created before the original namespaces in xml recommendation was released; therefore, dom1 isn't namespace aware. this causes problems for namesp...
...if you don't, user agents such as firefox won't recognize your content and will simply show the xml markup or inform the user that there's an error in the xml. it's a good idea to use a template that includes all the commonly used namespace declarations when creating new svg files. if you don't already have one, make one up starting with the following cod...
The Essentials of an Extension - Archive of obsolete content
are mentioned: content xulschoolhello content/ skin xulschoolhello classic/1.0 skin/ locale xulschoolhello en-us locale/ the chrome.manifest file tells firefox where to look for chrome files. the text is spaced to look like a table, but that is not necessary. the parser ignores repeated spaces. the first word in a line tells firefox what it is that is being
declared (content, skin, locale, or others mentioned later on). the second is the package name, which we will explain shortly. skin and locale packages have a third value to specify what locale or what skin they are extending. there can be multiple skin and locale entries relating to different skins and locales. the most common case is having one skin entry for the global skin, classic/1.0, and multiple...
... of the elements in it. the line that we skipped in the chrome.manifest file states that this xul file is an overlay for the main browser window: overlay chrome://browser/content/browser.xul chrome://xulschoolhello/content/browseroverlay.xul with this line, firefox knows that it needs to take the contents of browseroverlay.xul and overlay it on the main browser window, browser.xul. you can
declare overlays for any window or dialog in firefox, but overlaying the main browser window is the most common case by far. now let's look at the contents of our xul file. we'll skip the first few lines because they relate to skin and locale, and we'll cover them later. <overlay id="xulschoolhello-browser-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> the root el...
...cumentation automatically from javadoc. sayhello : function(aevent) { let stringbundle = document.getelementbyid("xulschoolhello-string-bundle"); let message = stringbundle.getstring("xulschoolhello.greeting.label"); window.alert(message); } and, finally, this is our function declaration. three lines of code are all we need for it to work. the first line in the body of the function
declares a variable that will hold the stringbundle element defined in the overlay. the variable is
declared using let, which is similar to var but with more restricted scope. here you can read more about let declarations. just like in regular js, we can use the dom (document object model) in order to manipulate the xul document. first we get a reference of the stringbundle element in the document. this...
Drag and Drop JavaScript Wrapper - Archive of obsolete content
" ondragover="nsdraganddrop.dragover(event,textobserver)" ondragexit="nsdraganddrop.dragexit(event,textobserver)" ondragdrop="nsdraganddrop.drop(event,textobserver)" /> as mentioned earlier, there is nothing special that happens during a dragenter event, so you can just write that yourself. ...
...thing special that happens during a dragenter event, so you can just write that yourself. the functions are implemented by the nsdraganddrop object, which is
declared in the file nsdraganddrop.js, which was included in one of the script tags. they handle the event, handle the xpcom interfaces and pass a simpler data structure to functions of the observer object. the observer is an object that you
declare yourself. in the above examples, this observer is stored in the buttonobserver and textobserver variables. the observer is
declared in a script which you would include in the xul file using the script tag. the observer is an object which may have a number of properties, each set to a function which handles a particular aspect of drag and drop. five functions may be defined. you only have to defin...
...ds data to the transferdata object. var textobserver = { ondragstart: function (event, transferdata, action) { var htmltext = "<strong>cabbage</strong>"; var plaintext = "cabbage"; transferdata.data = new transferdata(); transferdata.data.adddataforflavour("text/html",htmltext); transferdata.data.adddataforflavour("text/unicode",plaintext); } } here, an observer has been
declared and stored in the variable textobserver. it has one property called ondragstart. (in javascript, properties can be
declared with the syntax name : value). this property is a function which sets the data that is being dragged. once called, it starts a drag for the string data "cabbage". of course, you would want to calculate this value from the element that was clicked on. conveniently, this elem...
Introduction to XUL - Archive of obsolete content
tandard xml version and doctype statements. since xml has no implicit display semantics, there must always be associated stylesheets. mozilla includes a standard stylesheet, "xul.css". you can load as many style sheets as you wish using repeated processing directives, although you should always make sure to load the xul.css file initially. and finally, any namespaces used in the document must be
declared. so a xul file will begin <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?> <!doctype window> <window xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> the html namespace is of course the standard one. the xul namespace is obviously a temporary one, but at least serves to explain the pr...
... element). in fact, xul largely uses extant widgets from html, with a few extensions and additions. each widget will define a unique xml syntax for describing itself; see the widget documentation referenced at the index for details. other infrastructure widgets may have javascript event handlers just as in html, and are tied together using javascript and broadcaster nodes. broadcaster nodes are
declared as <broadcaster> elements in the xul description, and are involved with the communication of changes of state between widgets. a widget or several widgets can arrange to have the value of one of their attributes be tied to a broadcaster node. this tie is defined within the xul: <xul:window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <broadcaster id="cangoback"/> <ti...
...l for css, since rules can be applied to individual elements in xul using the same # syntax that is possible for html elements. #main-window { display: block; width: 100%; height: 100%; } for example, the above style rule would apply to the main window and dictates that the window should consume the full width and height available to it in a content area. the next element in the example
declares the menubar. the menubar contains a single menu called "file". this menu contains a single menu item that has a simple javascript onclick handler attached to it. this handler fires when the menu is selected by the user, and it dumps the text "hello world!" to the debug console. (see menu bars and menus for details.) finally there is an html iframe. note that the frame is qualified with the pref...
Creating a Window - Archive of obsolete content
go here --> </window> this window will not do anything since it doesn't contain any ui elements. those will be added in the next section. in fact, there will not be shown any window at all. if you want to force the window to become visible you can add the width and height attribute to the window tag. here is a line by line breakdown of the code above: <?xml version="1.0"?> this line simply
declares that this is an xml file. you would normally add this line as is at the top of each xul file. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> this line is used to specify the style sheets to use for the file. this is the syntax that xml files use to import style sheets. in this case, we import the styles found in the global part of a skin package. we didn't specify a specific ...
...he default declarations for all of the xul elements. because xml does not have any knowledge of how elements should be displayed, the file indicates how. generally, you will put this line at the top of every xul file. you can also import other style sheets using a similar syntax. note that you would normally import the global style sheet from within your own style sheet file. <window this line
declares that you are describing a window. each user interface window is described in a separate file. this tag is much like the html tag which surrounds an entire html document, except that a user interface window is described instead of a document. several attributes can be placed in the window tag -- in this case there are four. in the example, each attribute is placed on a separate line but they do n...
...he items in the window. the value horizontal indicates that items should be placed horizontally across the window. you may also use the value vertical, which means that the items are placed in a column. this is the default value, so you may leave the attribute off entirely if you wish to have vertical orientation. xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> this line
declares the namespace for xul, which you should put on the window element to indicate that all of its children are xul. note that this url is never actually downloaded. mozilla will recognize this url internally. <!-- other elements go here --> replace this comment block with other elements (the buttons, menus and other user interface components) to appear in the window. we'll add some of these in th...
Hoisting - MDN Web Docs Glossary: Definitions of Web-related terms
top of your code, but this is not in fact what happens. instead, the variable and function declarations are put into memory during the compile phase, but stay exactly where you typed them in your code. learn more technical example one of the advantages of javascript putting function declarations into memory before it executes any code segment is that it allows you to use a function before you
declare it in your code. for example: function catname(name) { console.log("my cat's name is " + name); } catname("tiger"); /* the result of the code above is: "my cat's name is tiger" */ the above code snippet is how you would expect to write the code for it to work. now, let's see what happens when we call the function before we write it: catname("chloe"); function catname(name) { console.lo...
...e) { console.log("my cat's name is " + name); } /* the result of the code above is: "my cat's name is chloe" */ even though we call the function in our code first, before the function is written, the code still works. this is because of how context execution works in javascript. hoisting works well with other data types and variables. the variables can be initialized and used before they are
declared. only declarations are hoisted javascript only hoists declarations, not initializations. if a variable is
declared and initialized after using it, the value will be undefined. for example: console.log(num); // returns undefined, as only declaration was hoisted, no initialization has happened at this stage var num; // declaration num = 6; // initialization the example below only has initializ...
...s stage var num; // declaration num = 6; // initialization the example below only has initialization. no hoisting happens so trying to read the variable results in referenceerror exception. console.log(num); // throws referenceerror exception num = 6; // initialization below are more examples demonstrating hoisting. // example 1 // only y is hoisted x = 1; // initialize x, and if not already
declared,
declare it - but no hoisting as there is no var in the statement. console.log(x + " " + y); // '1 undefined' // this prints value of y as undefined as javascript only hoists declarations var y = 2; //
declare and initialize y // example 2 // no hoisting, but since initialization also causes declaration (if not already
declared), variables are available. a = 'cran'; // initialize a b = 'berry...
Index - MDN Web Docs Glossary: Definitions of Web-related terms
variable name already in use. 88 constructor codingscripting, glossary a constructor belongs to a particular class object that is instantiated. the constructor initializes this object and can provide access to its private information. the concept of a constructor can be applied to most object-oriented programming languages. essentially, a constructor in javascript is usually
declared at the instance of a class. 89 continuous media glossary, media continuous media is data where there is a timing relationship between source and destination. the most common examples of continuous media are audio and motion video. continuous media can be real-time (interactive), where there is a "tight" timing relationship between source and sink, or streaming (playback), wh...
...ing, glossary, needscontent a global object is an object that always exists in the global scope. 173 global scope codingscripting, glossary, needscontent in a programming environment, the global scope is the scope that contains, and is visible in, all other scopes. 174 global variable codingscripting, glossary a global variable is a variable that is
declared in the global scope in other words, a variable that is visible from all other scopes. 175 glyph glossary, svg, typography a glyph is a term used in typography for the visual representation of one or more characters. 176 gonk boot2gecko, firefox os, glossary, gonk, infrastructure, intro gonk is the lower-level operating system of firefox os and consists o...
...ial part of the specification that must be followed are often marked as normative. 527 privileged code privileged privileged code - javascript code of your extension. for example, code in content scripts. 528 undefined codingscripting, glossary, javascript, needscontent undefined is a primitive value automatically assigned to variables that have just been
declared, or to formal arguments for which there are no actual arguments. ...
Scope - MDN Web Docs Glossary: Definitions of Web-related terms
be layered in a hierarchy, so that child scopes have access to parent scopes, but not vice versa. a function serves as a closure in javascript, and thus creates a scope, so that (for example) a variable defined exclusively within the function cannot be accessed from outside the function or within other functions. ...
...within the function cannot be accessed from outside the function or within other functions. ...
...ction or within other functions. ...
CSS FAQ - Learn web development
ltiple rules that use id selectors. shorter stylesheets are more performant. class selectors have lower specificity than id selectors, so are easier to override if needed. note: see selectors for more information. how do i restore the default value of a property? initially css didn't provide a "default" keyword and the only way to restore the default value of a property is to explicitly re-
declare that property. for example: /* heading default color is black */ h1 { color: red; } h1 { color: black; } this has changed with css 2; the keyword initial is now a valid value for a css property. it resets it to its default value, which is defined in the css specification of the given property. /* heading default color is black */ h1 { color: red; } h1 { color: initial; } how do i derive one s...
... in multiple places. how do i assign multiple classes to an element? html elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them. <style type="text/css"> .news { background: black; color: white; } .today { font-weight: bold; } </style> <div class="news today"> ... content of today's news ... </div> if the same property is
declared in both rules, the conflict is resolved first through specificity, then according to the order of the css declarations. the order of classes in the class attribute is not relevant. why don't my style rules work properly? style rules that are syntactically correct may not apply in certain situations. you can use dom inspector's css style rules view to debug problems of this kind, but the most f...
...tocksymbol">ge</span> +1.0 ... </div> to avoid this kind of error, try to define rules only once for a certain selector, and group all rules belonging to that selector. use of a shorthand property using shorthand properties for defining style rules is good because it uses a very compact syntax. using shorthand with only some attributes is possible and correct, but it must be remembered that un
declared attributes are automatically reset to their default values. this means that a previous rule for a single attribute could be implicitly overridden. #stockticker { font-size: 12px; font-family: verdana; font-weight: bold; } .stocksymbol { font: 14px arial; color: red; } <div id="stockticker"> nys: <span class="stocksymbol">ge</span> +1.0 ... </div> in the previous example the problem occurr...
Solve common problems in your JavaScript code - Learn web development
ssname() getelementbyclassname() getelementbyid() getelementsbyid() semi-colon position you need to make sure you don't place any semi-colons incorrectly. for example: correct wrong elem.style.color = 'red'; elem.style.color = 'red;' functions there are a number of things that can go wrong with functions. ...
...not inside any functions), or return the value from the function. running code after a return statement remember also that when you return from a function, the javascript interpreter exits the function — no code after the return statement will run. ...
...is', age: 38 } basic definitions what is javascript? what is a variable? what are strings? what is an array? what is a loop? what is a function? what is an event? what is an object? what is json? what is a web api? what is the dom? basic use cases general how do you add javascript to your page? how do you add comments to javascript code? variables how do you
declare a variable? how do you initialize a variable with a value? how do you update a variable's value? (also see assignment operators) what data types can values have in javascript? what does 'loosely typed' mean? math what types of number do you have to deal with in web development? how do you do basic math in javascript? what is operator precedence, and how is it handled in javascript? ho...
Componentizing our Svelte app - Learn web development
future articles. let's get started. note: in the process of creating our first couple of components, we will also learn different techniques to communicate between components, and the pros and cons of each. extracting our filter component we'll begin by creating our filterbutton.svelte. first of all, create a new file — components/filterbutton.svelte. inside this file we will
declare a filter prop, and then copy the relevant markup over to it from todos.svelte. add the following content into the file: <script> export let filter = 'all' </script> <div class="filters btn-group stack-exception"> <button class="btn toggle-btn" class:btn__primary={filter === 'all'} aria-pressed={filter === 'all'} on:click={()=> filter = 'all'} > <span class="visually-hidden">show</span...
...the child component will execute the handler, passing the needed information as a parameter, and the handler will modify the parent's state. in our case, the filterbutton component will receive an onclick handler from its parent. whenever the user clicks on any filter button, the child will call the onclick handler, passing the selected filter as a parameter, back up to its parent. we will just
declare the onclick prop assigning a dummy handler to prevent errors, like this: export let onclick = (clicked) => {} and we'll
declare the following reactive statement — $: onclick(filter) — to call the onclick handler whenever the filter variable is updated. the <script> section of our filterbutton component should end up looking like this — update it now: <script> export let filter ...
...his: <script> export let filter = 'all' </script> try your app again, and you should still see your filters working correctly. creating our todo component now we will create a todo component to encapsulate each individual todo — including the checkbox and some editing logic so you can change an existing todo. our todo component will receive a single todo object as a prop. let's
declare the todo prop and move the code from the todos component. just for now, we'll replace the call to removetodo with an alert. we'll add that functionality back in later on. create a new component file — components/todo.svelte. put the following contents inside this file: <script> export let todo </script> <div class="stack-small"> <div class="c-cb"> <input type="checkbox" ...
Working with Svelte stores - Learn web development
apply this to our alert component. update the <script> and markup sections of alert.svelte as follows: <script> import { alert } from '../stores.js' </script> {#if $alert} <div on:click={() => $alert = ''}> <p>{ $alert }</p> </div> {/if} check your app again and you'll see that this works just like before. that's much better! behind the scenes svelte has generated the code to
declare the local variable $alert, subscribe to the alert store, update $alert whenever the store's content is modified, and unsubscribe when the component is unmounted. it will also generate the alert.set(...) statements whenever we assign a value to $alert. the end result of this nifty trick is that you can access global stores just as easily as using reactive local variables. this is a perfect examp...
...mically added and removed from the page. while visually evident to users who can see the page, they may not be so obvious to users of assistive technologies, like screen readers. to handle those situations, we can take advantage of aria live regions, which provide a way to programmatically expose dynamic content changes so that they can be detected and announced by assistive technologies. we can
declare a region that contains dynamic content that should be announced by assistive technologies with the aria-live property followed by the politeness setting, which is used to set the priority with which screen readers should handle updates to that regions. the possible settings are off, polite, or assertive. for common situations, you also have several predefined specialized role values that can be ...
...in the subscribe() method we add the handler to the subs array and return a function that, when executed, will remove the handler from the array. when we call set(), we update the value of the store, and call each handler — passing the new value as a parameter. anyway, usually you don't implement stores from scratch; instead you'd use the writable store...
Mozilla DOM Hacking Guide
, and thus call it. this is the schema used most of the time when using w3c dom objects and methods. it is however different for some dom level 0 objects and methods. i'll take two very different examples. the first one is the window.location object (the same holds true for document.location, actually). we can change the url of the current window by assigning window.location. in idl, location is
declared to be a readonly attribute. this is because, if we had a setlocation() method, it would take an nsidomlocation parameter, and not a url string. instead, in the helper class for the window object (nswindowsh, see the next section), we define the getproperty() member function. getproperty() is a function used by xpconnect when we are setting an unknown property on the object (window, in our case).
...tening. we saw in section 1.3 that nsdomclassinfo is the base class for all the helper classes. let's see what it's made of. let's begin with the public interface. constructor: it is called for each created helper class through the member initialization list. it simply initializes the mid data member with the aid argument. the nsixpcscriptable, nsisupports, and nsiclassinfo member functions,
declared with ns_decl_x macros. static nsiclassinfo* getclassinfoinstance(nsdomclassinfoid aid): this helper method returns a non-refcounted nsiclassinfo pointer to an instance of the helper class corresponding to the id passed in. the implementation is detailed in section 1.6. static nsiclassinfo* getclassinfoinstance(nsdomclassinfodata* adata);: this helper method returns a non-refcounted nsiclas...
...ass_if; static const nsiid *interface_list[] = { in this macro, |d| is a reference to the entry of the sclassinfodata array that corresponds to the class passed as an argument to the macro. the mprotochaininterface member pointer is initialized to the address of the iid of the interface passed as an argument to dom_classinfo_map_begin. a static array of pointers to objects of type nsiid is then
declared. it is initialized explicitly with the dom_classinfo_map_entry macro (see below). there are two other similar macros: #define dom_classinfo_map_begin_no_primary_interface(_class) _dom_classinfo_map_begin(_class, nsnull, pr_true) this macro is used if the dom class (for example xmlhttprequest) does not have any interface, yet you want the xmlhttprequest object to be available from javascript.
TLS Cipher Suite Discovery
ation to display to the user. libssl offers a public table of well defined cipher suite numbers. the cipher suites are listed in the table in order of preference, from the most preferred cipher suite to the least preferred. the size of this table varies from release to release, and so libssl makes the number of entries in that table publicly available too. the table and the number of entries are
declared in "ssl.h", as follows: /* constant table enumerating all implemented ssl 2 and 3 cipher suites. */ ssl_import const pruint16 ssl_implementedciphers[]; /* number of entries in the above table. */ ssl_import const pruint16 ssl_numimplementedciphers; of course, the raw integer numbers of the cipher suites are not likely to be known to most users, so libssl provides a function by which ...
... const pruint16 ssl_implementedciphers[]; /* number of entries in the above table. */ ssl_import const pruint16 ssl_numimplementedciphers; of course, the raw integer numbers of the cipher suites are not likely to be known to most users, so libssl provides a function by which the application can obtain a wealth of information about any supported cipher suite, by its number. this function is
declared in "ssl.h" as follows: ssl_import secstatus ssl_getciphersuiteinfo( pruint16 ciphersuite, sslciphersuiteinfo *info, pruintn len); the application provides the cipher suite number for which it wants information, the address of a block of memory allocated to receive that information, and the size in bytes of that block of memory. ssl_getciphersuiteinfo fills that c...
...e application provides the cipher suite number for which it wants information, the address of a block of memory allocated to receive that information, and the size in bytes of that block of memory. ssl_getciphersuiteinfo fills that caller-supplied memory with information from the sslciphersuiteinfo structure for that cipher suite. ...
JS::PersistentRooted
t* address() returns a pointer to ptr. const t* address() const persistentrooted<t>& operator=(const t& p) sets the value of ptr. persistentrooted<t>& operator=(const persistentrooted<t>& other) bool operator!=(const t& other) const compares ptr and other. bool operator==(const t& other) const description js::persistentrooted<t>
declares a variable of type t whose value is always rooted. this is typically used for global variables. js::persistentrooted<t> is a copyable, assignable global gc root type with arbitrary lifetime, an infallible constructor, and automatic unrooting on destruction. these roots can be used in heap-allocated data structures, so they are not associated with any particular jscontext or stack. they are reg...
... better types. it's up to the implementor of the type containing heap<t> or tenuredheap<t> members to make sure their referents get marked when the object itself is marked. js::persistentrooted<t> may be automatically coerced to a js::handle<t> and js::mutablehandle<t>. before spidermonkey 38, persistentrooted<t> itself cannot be a global variable, but from spidermonkey38, it can be
declared as a global variable, and initialized later with init() method (bug 1107639). there are typedefs available for the main types: namespace js { typedef persistentrooted<jsfunction*> persistentrootedfunction; typedef persistentrooted<jsid> persistentrootedid; typedef persistentrooted<jsobject*> persistentrootedobject; typedef persistentrooted<jsscript*> persistentrootedscript; typedef ...
...t; typedef persistentrooted<jsstring*> persistentrootedstring; typedef persistentrooted<js::symbol*> persistentrootedsymbol; // added in spidermonkey 38 typedef persistentrooted<value> persistentrootedvalue; } example following example allocates persistentrootedvalue, and provides two functions for setting and getting it from javascript. // to use maybe. #include <mozilla/maybe.h> //
declare global variable. // [spidermonkey 31] js::persistentrootedvalue itself cannot be a global variable. mozilla::maybe<js::persistentrootedvalue> persistentval; // you can also
declare it just as a pointer, instead of using maybe. // js::persistentrootedvalue* persistentval; // [spidermonkey 38] js::persistentrootedvalue itself can be a global variable. // js::persistentrootedvalue persistentval;...
mozIJSSubScriptLoader
methods loadsubscript() synchronously loads and executes the script from the specified url. as of gecko 8.0, scripts are loaded from the startup cache where possible. the loaded script is executed with the principal associated with the target object. any top-level functions or variables created by the loaded script via var are created as properties of the targetobj target object (but things
declared via let and const are not). additionally, properties of the targetobj target object can be referred to as variables in the loaded script. if the script returns a value, it will be returned by this method. note: this method must only be called from javascript! jsval loadsubscript( in string url, in object targetobj optional, in string charset optional, ); example let context = {}; s...
...o longer permitted. targetobj the object to use as the scope object for the script being executed. this is where var declarations in the script will be placed. it defaults to the global object of the caller. note that let and const declarations in the script will be placed on a syntactic scope that is not an object at all, and will not be available to the caller of loadsubscript. note: un
declared variables in the loaded script will be created as global variables in the caller (ie.: in the caller's global object). this object will be searched for variables that cannot be resolved in the subscript scope. charset an optional string to specify the character encoding of the file. if absent, the file is interpreted as ascii. loadsubscriptwithoptions() same as loadsubscript(), except t...
...bject options ); parameters url the url pointing to the script to load. it must be a local chrome:, resource: or file: url. options an object that may include any of these parameters: property type description target object the object to use as the scope object for the script being executed. it defaults to the global object of the caller. note: un
declared variables in the loaded script will be created as global variables in the caller (ie.: in the caller's global object). this object will be searched for variables that cannot be resolved in the subscript scope. charset string an optional string to specify the character encoding of the file. if absent, the file is interpreted as ascii. ignorecache boolean if...
nsIAccessibleText
ounding box. the valid range is 0..length. x x coordinate of the bounding box of the referenced character. y y coordinate of the bounding box of the referenced character. width width of the bounding box of the referenced character. height height of the bounding box of the referenced character. coordtype specifies if the coordinates are relative to the screen or to the parent window (see constants
declared in nsiaccessiblecoordinatetype.constants). getoffsetatpoint() get the text offset at the given point, or return -1 if no character exists at that point. long getoffsetatpoint( in long x, in long y, in unsigned long coordtype ); parameters x the position's x value for which to look up the index of the character that is rendered on to the display at that point. y the position's y value fo...
...etoffsetatpoint( in long x, in long y, in unsigned long coordtype ); parameters x the position's x value for which to look up the index of the character that is rendered on to the display at that point. y the position's y value for which to look up the index of the character that is rendered on to the display at that point. coordtype screen coordinates or window coordinates (see constants
declared in nsiaccessiblecoordinatetype). return value offset - index of the character under the given point or -1 if the point is invalid or there is no character under the point. getrangeextents() the virtual character after the last character of the represented text, that is the one at position length is a special case. it represents the current input position and will therefore typically be queried ...
...ounding box. the valid range is 0..length. x x coordinate of the bounding box of the referenced character. y y coordinate of the bounding box of the referenced character. width width of the bounding box of the referenced character. height height of the bounding box of the referenced character. coordtype specifies if the coordinates are relative to the screen or to the parent window (see constants
declared in nsiaccessiblecoordinatetype.constants. getselectionbounds() void getselectionbounds( in long selectionnum, out long startoffset, out long endoffset ); parameters selectionnum startoffset endoffset gettext() string methods may need to return multibyte-encoded strings, since some locales can not be encoded using 16-bit chars. so this method might return utf-16 strings, or it could ...
Working with Multiple Versions of Interfaces
atic_cast<hwnd>(wh); } return self; } there is good news and bad news. first the good news. plan b inside firefox 2 happily runs to completion. all the xpcom calls succeed, or at least think they succeed. the bad news is that the thing we get back is not a valid hwnd. the problem now is not just interface identifier mismatch, but class declaration mismatch. getwindowhandle is the tenth method
declared in the nsiaccessibledocument.h that firefox 2 was built with, but actually the eighth method in the sdk that i used to build my extension (and hence xpcom component). since these classes don't use vtables this means i'm probably, no i can be more positive, definitely calling the wrong method. if i were a betting man, i'd hedge a bet on getaccessibleinparentchain, that being the tenth method in...
... if i were a betting man, i'd hedge a bet on getaccessibleinparentchain, that being the tenth method in the interface declaration in the new sdk. in actual fact we were lucky we actually got as far as we did, since the very first interface we made use of has changed substantially. if there is any truth to the story i weave here, then this is because getaccessiblefor is still the very first method
declared in nsiaccessibleretrieval.h. so if you are lucky enough with your api's this technique may work without further ado. we are not so lucky. the realist's solution to make sure we call the right methods of the right interfaces we need to have two versions of both the nsiaccessibledocument and nsiaccessibleretrieval interfaces at our fingertips. i called my old ones: nsiaccessibleretrieval_old.h...
...n_nsiaccessibledocument_h__ #include "accessibility/nsiaccessibledocument.h" i even silenced my friend the compiler by enclosing both incantations within a compiler pragma: #pragma warning(push) #pragma warning(disable : 4005) ... #pragma warning(pop) so now i have to own up to the ugly hack. i did have to delve into my old versions and change: ns_define_static_iid_accessor(...) to ns_
declare_static_iid_accessor(...) this ugliness aside, my plan b routine now looks like: hwnd gethwndb(nsidomnode *node){ hwnd self = null; nsresult rv; nscomptr<nsicomponentmanager> compmgr; rv = ns_getcomponentmanager(getter_addrefs(compmgr)); if (ns_failed(rv)){ return self; } nscomptr<nsiaccessibleretrieval_old> refp; //n.b. _old rv = compmgr->createinstancebycontractid(accretcid, 0, ...
js-ctypes reference
components.utils.import("resource://gre/modules/ctypes.jsm"); you can use the ctypes object to load libraries, construct types, and perform miscellaneous tasks such as type casting. the ctypes object also provides numerous predefined types that correspond to primitives and common typedefs in c. working with libraries to load a library, use ctypes.open(). the library object is used mostly to
declare native functions provided by the library so that js-ctypes knows how to call them. see library.
declare() for instructions on how to
declare these functions. once you have finished working with a library, call library.close(). calling conventions see abi. types and data to use js-ctypes effectively, it is important to understand the different kinds of objects that the module provides. there a...
...rtant to understand the different kinds of objects that the module provides. there are three major categories: types these represent a type in c, and are thus represented by ctype objects. these objects have two main purposes. first, they provide a concrete representation of different data types, allowing the programmer to describe the arguments and return type of a native function (see library.
declare()). second, they serve as constructors to create concrete instances of the given type, i.e. cdata objects. out of the box, js-ctypes supports a number of predefined types. type constructors these are functions that define new types, and thus return a ctype object. these include ctypes.pointertype(type) and the .ptr property, which creates a new type describing a pointer to an existing type...
...1 [, argtype2 ...]), which creates a new type describing a c function. data these are instances of types, represented by cdata objects and instantiated by calling ctype objects as functions. these distinctions are crucial, and understanding them will alleviate much of the confusion surrounding js-ctypes. calling a type constructor will return a ctype. calling a ctype will return a cdata. you
declare the arguments and return value of a native function with ctype objects. you call a native function with cdata objects. other features error-handling js-ctypes supports both errno (on all platforms) and getlasterror (on windows platforms). callbacks you can pass regular javascript functions as callbacks to native functions. see the callbacks page for details. 64-bit integer handling because...
Synchronous and asynchronous requests - Web APIs
it, in turn, invokes the callback f...
...it, in turn, invokes the callback function specified in the invocation of the loadfile function (in this case, the function showmessage) which has been assigned to a property of the xhr object (line 11). ...
...ked when the xhr operation completes successfully. it, in turn, invokes the callback function specified in the invocation of the loadfile function (in this case, the function showmessage) which has been assigned to a property of the xhr object (line 11). the additional arguments (if any) supplied to the invocation of function loadfile are "applied" to the running of the callback function. line 5
declares a function invoked when the xhr operation fails to complete successfully. line 11 stores the success callback given as the second argument to loadfile in the xhr object's callback property. line 12 slices the arguments array given to the invocation of loadfile. starting with the third argument, all remaining arguments are collected, assigned to the arguments property of the variable xhr, passe...
linear-gradient() - CSS: Cascading Style Sheets
the 10% mark and solid blue from 90% to the end. between 10% and 90% the color transitions from red to blue, however the midpoint of the transition is at the 30% mark rather than 50% as would have happened without the 30% color hint. linear-gradient(red 10%, 30%, blue 90%); if two or more color stops are at the same location, the transition will be a hard line between the first and last colors
declared at that location. color stops should be listed in ascending order. subsequent color stops of lower value will override the value of the previous color stop creating a hard transition. the following changes from red to yellow at the 30% mark, and then transitions from yellow to blue over 35% of the gradient linear-gradient(red 40%, yellow 30%, blue 65%); multi-position color stop are allowed...
...n. color stops should be listed in ascending order. subsequent color stops of lower value will override the value of the previous color stop creating a hard transition. the following changes from red to yellow at the 30% mark, and then transitions from yellow to blue over 35% of the gradient linear-gradient(red 40%, yellow 30%, blue 65%); multi-position color stop are allowed. a color can be
declared as two adjacent color stops by including both positions in the css declaration. the following three gradients are equivalent: linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); linear-gradient(red, orange 10% 30%, yellow 50% 70%, green 90%); linear-gradient(red 0%, orange 10% 30%, yellow 50% 70%, green 90% 100%); by default, if there is no color wit...
... by including both positions in the css declaration. the following three gradients are equivalent: linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); linear-gradient(red, orange 10% 30%, yellow 50% 70%, green 90%); linear-gradient(red 0%, orange 10% 30%, yellow 50% 70%, green 90% 100%); by default, if there is no color with a 0% stop, the first color
declared will be at that point. similarly, the last color will continue to the 100% mark, or be at the 100% mark if no length has been
declared on that last stop. examples gradient at a 45-degree angle body { width: 100vw; height: 100vh; } body { background: linear-gradient(45deg, red, blue); } gradient that starts at 60% of the gradient line body { width: 100vw; height: 100vh; } ...
right - CSS: Cascading Style Sheets
s normal position. when position is set to sticky, the right property is used to compute the sticky-constraint rectangle. when position is set to static, the right property has no effect. when both left and right are defined, if not prevented from doing so by other properties, the element will stretch to satisfy both. if the element cannot stretch to satisfy both -- for example, if a width is
declared -- the position of the element is over-constrained. when this is the case, the left value has precedence when the container is left-to-right; the right value has precedence when the container is right-to-left. formal definition initial valueautoapplies topositioned elementsinheritednopercentagesrefer to the width of the containing blockcomputed valueif specified as a length, the corresponding ...
...if the element will not stretch or shrink to meet meet both. when the position of the element is overspecified, the precende is based on the container's direction: the left will take precendence if the container's direction is left-to-right. the right will take precedence if the container's direction is ri...
...take precendence if the container's direction is left-to-right. the right will take precedence if the container's direction is right-to-left. html <div id="parent">parent <div id="nowidth">no width</div> <div id="width">width: 100px</div> </div> css div { outline: 1px solid #cccccc; } #parent { width: 200px; height: 200px; background-color: #ffc7e4; position: relative; } /*
declare both a left and a right */ #width, #nowidth { background-color: #c2ffd7; position: absolute; left: 0; right: 0; } /*
declare a width */ #width { width: 100px; top: 60px; } result specifications specification status comment css positioned layout module level 3the definition of 'right' in that specification. working draft adds behavior for sticky...
HTML documentation index - HTML: Hypertext Markup Language
ribute is an enumerated attribute that is used to specify whether an element's translateable attribute values and its text node children should be translated when the page is localized, or whether to leave them unchanged. 34 x-ms-acceleratorkey attribute, html, html:microsoft extensions, non-standard, reference, x-ms-acceleratorkey the x-ms-acceleratorkey attribute accessibly
declares that an accelerator key has been assigned to an element: the element is activated via javascript when the key(s) are pressed on a keyboard. 35 x-ms-format-detection attribute, html, html:microsoft extensions, non-standard, reference, x-ms-format-detection the x-ms-format-detection attribute determines whether data formats within the element’s text, like phone numbers, are ...
...ute 49 html attribute: size attribute, html, input, reference, select the size attribute defines the width of the <input> and the height of the <select> element. for the input, if the type attribute is text or password then it's the number of characters. this must be an integer value 0 or higher. if no size is specified, or an invalid value is specified, the input has no size
declared, and the form control will be the default width based on the user agent. if css targets the element with properties impacting the width, css takes precedence. 50 html attribute: step attribute, attributes, constrain validation, step valid for the numeric input types, including the date, month, week, time, datetime-local, number and range types, the step attribute is a number...
...o microformats that provides a simpler way of annotating html structured syntax & vocabularies than previous approaches of using rdfa and microdata which require learning new attributes. 235 preloading content with rel="preload" guide, html, javascript, link, media, performance, web performance, as, preload, rel the preload value of the <link> element's rel attribute lets you
declare fetch requests in the html's <head>, specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in. 236 quirks mode and standards mode gecko, guide, html, needsupdate, web development, web standards, xhtml in the old days of the web, pages were typically written in two v...
class - JavaScript
rototype-based inheritance. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. you can also define a class using a class expression. but unlike a class expression, a class declaration doesn't allow an existing class to be
declared again and will throw a syntaxerror if attempted. syntax class name [extends othername] { // class body } description the class body of a class declaration is executed in strict mode. the constructor method is optional. class declarations are not hoisted (unlike function declarations). examples a simple class declaration in the following example, we first define a class named polygon,...
...re. note that super(), used in the constructor, can only be used in constructors, and must be called before the this keyword can be used. ...
...h) { this.name = 'polygon'; this.height = height; this.width = width; } } class square extends polygon { constructor(length) { super(length, length); this.name = 'square'; } } attempting to
declare a class twice re-declaring a class using the class declaration throws a syntaxerror. class foo {}; class foo {}; // uncaught syntaxerror: identifier 'foo' has already been
declared the same error is thrown when a class has been defined before using the class expression. let foo = class {}; class foo {}; // uncaught syntaxerror: identifier 'foo' has already been
declared specifications specification ecmascript (ecma-262)the definition of 'class definitions' in that specification. ...
function declaration - JavaScript
the properties, methods and behavior of function objects. see function for detailed information on functions. a function can also be created using an expression (see function expression). by default, functions return undefined. to return any other value, the function must have a return statement that specifies the value to return. conditionally created functions functions can be conditionally
declared, that is, a function statement can be nested within an if statement, however the results are inconsistent across implementations and therefore this pattern should not be used in production code. for conditional function creation, use function expressions instead. var hoisted = "foo" in this; console.log(`'foo' name ${hoisted ? "is" : "is not"} hoisted. typeof foo is ${typeof foo}`); if (false) ...
.... typeof foo is undefined // // in firefox: // 'foo' name is hoisted. typeof foo is undefined // // in edge: // 'foo' name is not hoisted. typeof foo is undefined // // in safari: // 'foo' name is hoisted. typeof foo is function function declaration hoisting function declarations in javascript are hoisted to the top of the enclosing function or global scope. ...
... are hoisted to the top of the enclosing function or global scope. you can use the function before you
declared it: hoisted(); // logs "foo" function hoisted() { console.log('foo'); } note that function expressions are not hoisted: nothoisted(); // typeerror: nothoisted is not a function var nothoisted = function() { console.log('bar'); }; examples using function the following code
declares a function that returns the total amount of sales, when given the number of units sold of products a, b, and c. function calc_sales(units_a, units_b, units_c) { return units_a * 79 + units_b * 129 + units_c * 699; } specifications specification ecmascript (ecma-262)the definition of 'function definitions' in that specification. ...
Statements and declarations - JavaScript
a specified condition is true. if the condition is false, another statement can be executed. switch evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case. throw throws a user-defined exception. try...catch marks a block of statements to try, and specifies a response, should an exception be thrown. ...
... statement can be executed. switch evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case. throw throws a user-defined exception. try...catch marks a block of statements to try, and specifies a response, should an exception be thrown. declarations var
declares a variable, optionally initializing it to a value. let
declares a block scope local variable, optionally initializing it to a value. const
declares a read-only named constant. functions and classes function
declares a function with the specified parameters. function* generator functions enable writing iterators more easily. async function
declares an async function with the specified parameters. return specifies the value to be returned by a fu...
... iterations do...while creates a loop that executes a specified statement until the test condition evaluates to false. the condition is evaluated after executing the statement, resulting in the specified statement executing at least once. ...
Chrome Authority - Archive of obsolete content
y an experimental feature of the sdk, and may change in future releases. using chrome authority the most powerful low-level modules are run with "chrome privileges", which gives them access to the infamous components object, which grants unfettered access to the host system. from this, the module can do pretty much anything the browser is capable of. to obtain these privileges, the module must
declare its intent with a statement like the following: var {cc, ci} = require("chrome"); the "chrome" built-in pseudo module is provided by the "toolkit/loader" module. the object returned by require("chrome"), when unpacked with the destructuring assignment feature available in the mozilla js environment, will provide the usual components.* aliases: cc an alias for components.classes. ci an alia...
...their statements must therefore be clear and easy to parse. a future manifest format may move the declaration portion out to a separate file, to allow for more fine-grained expression of authority. commands that build a manifest, like "jpm xpi" or "j...
Autocomplete - Archive of obsolete content
autocompletepopup="popup_autocomplete" /> finally, make sure that the value of the browser.formfill.enable pref is set to true. ...
...autocompletepopup="popup_autocomplete" /> finally, make sure that the value of the browser.formfill.enable pref is set to true. ...
MMgc - Archive of obsolete content
is true whether the object containing the pointer is gcobject or rcobject. class myobject : public mmgc::rcobject { ... }; class myothermanagedgcobject : public mmgc::gcobject { drcwb(myobject*) myobject; }; class myothermanagedrcobject : public mmgc::rcobject { drcwb(myobject*) myobject; }; the rcobject must zero itself out on deletion. for this reason, rcobject's always have finalizers.
declare a destructor that zeros out all of the fields of your rcobject. see zeroing rcobjects for more information. class myobject : public mmgc::rcobject { public: myobject() { x = 1; y = 2; z = 3; } ~myobject() { x = y = z = 0; } private: int x; int y; int z; }; gcroot if you have a pointer to a gcobject from an object in unmanaged memory, the unmanaged object must be a subclass of gcroot. gcro...
...the same way you always have. to allocate a managed (gc) object, you must use the parameterized form of operator new, and pass it a reference to the mmgc::gc object. class myobject : public mmgc::gcobject { ... }; ... myobject* myobject = new (gc) myobject(); dwb/drc/drcwb there are several smart pointer templates which must be used in your c++ code to work properly with mmgc. dwb dwb stands for
declared write barrier. it must be used on a pointer to a gcobject/gcfinalizedobject, when that pointer is a member variable of a class derived from gcobject/gcfinalizedobject/rcobject/rcfinalizedobject. class mymanagedclass : public mmgc::gcobject { // mymanagedclass is a gcobject, and // avmplus::hashtable is a gcobject, so use dwb dwb(avmplus::hashtable*) mytable; }; drc drc stands for deferred...
Mozilla Crypto FAQ - Archive of obsolete content
ns list to the commerce control list (ccl) of the ear. for more information see the document "principal statutory authority for the export administration regulations", which contains a copy of executive order 13026. haven't u.s. export controls on encryption software already been ruled unconstitutional? yes in a specific case, but the decision may yet be overruled. also, the case itself may be
declared moot in light of the new u.s. encryption export regulations. for several years professor daniel bernstein (currently at the university of illinois at chicago) has pursued a lawsuit against the u.s. government essentially claiming that u.s. export control regulations on encryption software and related conduct with regard to cryptography (e.g., "technical assistance") were unconstitutional. (bern...
...o appeal the decision, first to all eleven members of the 9th circuit court of appeals (referred to as the courten banc, or full court) and then possibly to the u.s. supreme court. until the appeals process is completed the u.s. government will continue to enforce current u.s. export regulations. in light of the new encryption export regulations it is also possible that the bernstein case may be
declared moot on the basis that professor bernstein is now free to do what he originally requested to do, i.e., publish his encryption source code online. for more information see the archives on the bernstein case maintained by the electronic frontier foundation, particularly the 9th circuit court of appeals ruling, the press release issued by the u.s. bureau of export administration immediately afterw...
Building Trees - Archive of obsolete content
here, the simple rdf query syntax is used, so the member variable is rdf:*. the remaining tags have a similar syntax to a tree, but have only a ...
...reechildren> <treeitem uri="rdf:*"> <treerow> <treecell label="rdf:http://purl.org/dc/elements/1.1/title"/> <treecell label="rdf:http://purl.org/dc/elements/1.1/date"/> </treerow> </treeitem> </treechildren> </template> </tree> note: the tree columns (treecols) are
declared outside the template as static content, since they only need to be
declared once. this template uses the simple rule syntax. the extended syntax could also be used. when using the tree builder, the uri attribute must be
declared on the treeitem element. here, the simple rdf query syntax is used, so the member variable is rdf:*. the remaining tags have a similar syntax to a tree, but have only a single row. this row is used as the template data by the tree builder. inste...
Rule Compilation - Archive of obsolete content
et of data from the datasource. the exact syntax is dependent on the type of datasource used in the template. for instance, for an sqlite datasource, an sql statement is used as the query. this will return a table of result records which are then used to generate output. for rdf and xml, the query contains a set of instructions for navigating through the rdf graph or xml document tree. a query is
declared with the query tag (new to ff3; ff2 only worked with rdf datasources and had no query tag), which you would place directly inside the <template>. the job of the query is to generate a set of output results. rules the template also contains a set of rules which define content to be generated based on various conditions. an attribute substitution syntax, explained later, is used to modify the attr...
...uld place directly inside the <template>. the job of the query is to generate a set of output results. rules the template also contains a set of rules which define content to be generated based on various conditions. an attribute substitution syntax, explained later, is used to modify the attributes of elements generated from the template, to correspond with the data for each result. each rule is
declared with a rule tag, and you may have more than one. for each result that is generated by the query, the conditions specified within the rules are scanned, and content is generated when a rule matches. only the first matching rule for each result from the query will apply. for example, the first rule might apply to results that represent books, while the second rule might apply only to results that ...
XML Assignments - Archive of obsolete content
gth(@name)"/> <assign var="?siblings" expr="count(../*) - 1"/> </query> <action> <hbox uri="?" align="center"> <button label="?name"/> <label value="?gender"/> <label value="?namelength"/> <label value="?siblings"/> </hbox> </action> </template> </vbox> two assign elements are placed as children of the query element. it allows us to
declare additional variables that may be used in the action body. the expr attribute specifies the xpath expression and the var attribute specifies the variable to assign to. note that while the query expression uses the root node (or reference node) as the xpath context, the expressions for the assign element are evaluated using each result node as the context. for each result, the ?namelength variable ...
... datasource aren't actually siblings). naturally, the number of siblings will be the same for all children, but you could imagine a more complex query expression that generated nodes where this wasn't actually the case. the two variable assignments may then be used in the action body to replace attributes in the generated content. if a variable is used in the action that doesn't correspond to one
declared in an assign element, the default behaviour is to take the corresponding attribute on the result node. here, the two attributes 'name' and 'gender' will be taken from the xml data, as in previous examples. « previousnext » ...
Adding HTML Elements - Archive of obsolete content
indow. you should avoid using html elements in xul files if you can. (there are some reasons, and the main one concerns the control of the layout described later). however, this section will describe how to use them anyway. remember that xml is case-sensitive though, so you'll have to enter the tags and attributes in lowercase. xhtml namespace in order to use html elements in a xul file, you must
declare that you are doing so using the xhtml namespace. this way, mozilla can distinguish the html tags from the xul ones. the attribute below should be added to the window tag of the xul file, or to the outermost html element. xmlns:html="http://www.w3.org/1999/xhtml" this is a declaration of html much like the one we used to
declare xul. this must be entered exactly as shown or it won't work correctl...
... the tags must be entered in lowercase. "quotes" must be placed around all attribute values. xml requires a trailing slash at the end of tags that have no content. this may be clearer from the examples below. using html elements you can use any html tag although some such as head and body are not really useful. some examples of using html elements are shown below.
Adding Methods to XBL-defined Elements - Archive of obsolete content
t, like the fields and properties do. the method element contains two type of child elements, parameter elements which describe the parameters to the method and body which contains the script for the method. the value of the name attribute becomes the name of the method. similarly, the name attributes on the parameter elements become the names of each parameter. each parameter element is used to
declare one parameter for the method. for example, if the method had three parameters, there would be three parameter elements. you do not need to have any though, in which case the method would take no parameters. the body element contains the script that is executed when the method is called. the names of the parameters are defined as variables in the script as if they had been passed as parameters. f...
... } </body> </method> </implementation> </binding> the oncommand handlers here first get a reference to their parent bound element. (in this example, it is the box with the labeledbutton class). then, the 'showtitle' method is called, which functions as it did before. custom properties and methods are added only to the outer xul element the xbl is bound to. none of the elements
declared inside the content tag have these properties or methods. this is why we have to get the parent first. the children of an element placed in the xul file can be retrieved in the normal way and don't move even if you use the children tag. for example: xul: <box id="outer" class="container"> <button label="one"/> <button label="two"/> <button label="three"/> <button label="four"/> </box> ...
Introduction to RDF - Archive of obsolete content
is an xml language which can be used to represent rdf data. it contains a fairly simple set of elements. the sample below shows a simple rdf template. <?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> ... </rdf:rdf> this has some similarities to the xul header. instead of the window element, the rdf element is used. you can see the namespace for rdf was
declared so that the rdf elements are recognized properly. inside, the rdf element, you will place the data. to see some example rdf/xml files, look at those provided with mozilla. they have the extension rdf. rdf database let's take the example of a bookmarks list generated from rdf. a bookmarks list contains a set of records, each with a set of data associated with it, such as a url, a bookmark title a...
...eq> </rdf:rdf> here, three records have been described, one for each animal. each rdf:description tag describes a single record. within each record, three fields are described, name, species and class. it isn't necessary for all records to have the same fields but it makes more sense to have them all the same. each of three fields have been given a namespace of animals, the url of which has been
declared on the rdf tag. the name was selected because it has meaning in this case, but we could have selected something else. the namespace feature is useful because the class field might conflict with that used for styles. the seq and li elements are used to specify that the records are in a list. this is much like how html lists are
declared. the seq element is used to indicate that the elements are o...
Property Files - Archive of obsolete content
e. however, a script does not get parsed for entities. in addition, you may wish to display a message which is generated from a script, if, for example, you do not know the exact text to be displayed. for this purpose, property files can be used. a property file contains a set of strings. you will find property files alongside the dtd files with a .properties extension. properties in the file are
declared with the syntax name=value. an example is shown below: notfoundalert=no files were found matching the criteria. deletealert=click ok to have all your files deleted. resultmessage=%2$s files found in the %1$s directory. here, the property file contains three properties. these would be read by a script and displayed to the user. a property file can also include comments. a line that begins with a...
...c="strings.properties"/> </stringbundleset> including this element will read the properties from the file 'strings.properties' in the same directory as the xul file. use a chrome url to read a file from the locale: <stringbundleset id="stringbundleset"> <stringbundle id="strings" src="chrome://myplugin/locale/strings.properties"/> </stringbundleset> like other non-displayed elements, you should
declare all your stringbundles inside a stringbundleset element so that they are all kept together. getting a string from the bundle this stringbundle element has a number of properties. the first is getstring which can be used in a script to read a string from the bundle. var strbundle = document.getelementbyid("strings"); var nofilesfound=strbundle.getstring("notfoundalert"); alert(nofilesfound); t...
Templates - Archive of obsolete content
otice that the buttons in the example get updated instantly. (you may have to focus the window for it to change.) container and datasources the template itself is placed inside a vertical box. the box has two special attributes that allow it to be used for templates, which are used to specify where the data comes from. the first attribute on the box is the datasources attribute. this is used to
declare what rdf datasource will be providing the data to create the elements. in this case, rdf:bookmarks is used. you can probably guess that this means to use the bookmarks datasource. this datasource is provided by mozilla. to use your own datasource, specify the url of an rdf file for the datasources attribute, as indicated in the example below: <box datasources="chrome://zoo/content/animals.rdf" ...
... that you can use will depend on the datasource you are using. if you are using your own rdf file as a datasource, the value will usually correspond to the value of an about attribute on an rdf bag, seq or alt element. inside the template by adding these two attributes to the box above, it allows the generation of elements using the template. however, the elements inside the template need to be
declared differently. you may notice in the example above that the button has a uri attribute and an unusual value for the label attribute. an attribute value inside the template that begins with 'rdf:' indicates that the value should be taken from the datasource. in the example earlier, this is the case for the label attribute. the remainder of the value refers to the name property in the datasource. i...
Trees - Archive of obsolete content
ses. tree styling will be discussed in detail in a later section. tree elements trees can be created with the tree element, which is described in the following sections. there are also two elements used to define the columns to be displayed in the tree. tree this is the outer element of a tree. treecols this element is a placeholder for a set of treecol elements. treecol this is used to
declare a column of the tree. by using this element, you can specify additional information about how the data in the columns are sorted and if the user can resize the columns. you should always place an id attribute on a column, as mozilla uses the ids to identify the columns when rearranging and hiding them. this is no longer required in mozilla 1.8 and later, but it is still a good idea to use ids on ...
...s contains the main body of the tree where the individual rows of data will be displayed. example tree with two columns example 1 : source view <tree flex="1"> <treecols> <treecol id="namecolumn" label="name" flex="1"/> <treecol id="addresscolumn" label="address" flex="2"/> </treecols> <treechildren/> </tree> first, the entire table is surrounded with a tree element. this
declares an element that is used as a table or tree. as with html tables, the data in a tree is always organized into rows. the columns are specified using the treecols tag. you may place as many columns as you wish in a tree. as with listboxes, a header row will appear with column labels. a drop-down menu will appear in the upper-right corner of the tree, which the user may use to show and hide individ...
Signature (functions) - MDN Web Docs Glossary: Definitions of Web-related terms
tions or methods. a signature can include: parameters and their types a return value and type exceptions that might be thrown or passed back information about the availability of the method in an object-oriented program (such as the keywords public, static, or prototype). in depth signatures in javascript javascript is a loosely typed or a dynamic language. that means you don't have to
declare the type of a variable ahead of time. the type will get determined automatically while the program is being processed. a signature in javascript can still give you some information about the method: myobject.prototype.myfunction(value) the method is installed on an object called myobject. the method is installed on the prototype of myobject (thus it is an instance method) as opposed to being...
...alled myobject. the method is installed on the prototype of myobject (thus it is an instance method) as opposed to being a static method. the name of the method is myfunction. the method accepts one parameter, which is called value and is not further defined. signatures in java in java, signatures are used to identify methods and classes at the level of the virtual machine code. you have to
declare types of variables in your code in order to be able to run the java code. java is strictly typed and will check any parameters at compilation time if they are correct. public static void main(string[] args) the public keyword is an access modifier and indicates that this method can be called by any object. the static keyword indicates that this method is a class method as opposed to being an...
HTML forms in legacy browsers - Learn web development
r example, the input of color type looks different in safari, chrome and firefox browser, but the color picker widget is the same in all browsers on a device as it opens up the operating system's native color picker. it's generally a good idea to not alter the default appearance of form control because altering one css property value may alter some input types but not others. for example, if you
declare input { font-size: 2rem; }, it will impact number, date, and text, but not color or range. if you alter a property, that may impact the appearance of the widget in unexpected ways. for example, [value] { background-color: #ccc; } may have been used to target every <input> with a value attribute, but changing the background-color or border radius on a <meter> will lead to likely unexpected results...
...mpact number, date, and text, but not color or range. if you alter a property, that may impact the appearance of the widget in unexpected ways. for example, [value] { background-color: #ccc; } may have been used to target every <input> with a value attribute, but changing the background-color or border radius on a <meter> will lead to likely unexpected results that differ across browsers. you can
declare appearance: none; to remove the browser styles, but that generally defeats the purpose: as you lose all styling, removing the default look and feel your visitors are used to. to summarize, when it comes to styling form control widgets, the side effects of styling them with css can be unpredictable. so don't. as you can see from the complexity of the property compatibility table for form widgets...
Client-side storage - Learn web development
x-start.js files into a new directory on your local machine. have a look at the files. you'll see that the html is pretty simple: a web site with a header and footer, as well as a main content area that contains a place to display notes, and a form for entering new notes into the database. the css provides some simple styling to make it clearer what is going on. the javascript file contains five
declared constants containing references to the <ul> element the notes will be displayed in, the title and body <input> elements, the <form> itself, and the <button>. rename your javascript file to index.js. you are now ready to start adding code to it. database initial set up now let's look at what we have to do in the first place, to actually set up a database. below the constant declarations...
...now let's look at what we have to do in the first place, to actually set up a database. below the constant declarations, add the following lines: // create an instance of a db object for us to store the open database in let db; here we are declaring a variable called db — this will later be used to store an object representing our database. we will use this in a few places, so we've
declared it globally here to make things easier. next, add the following to the bottom of your code: window.onload = function() { }; we will write all of our subsequent code inside this window.onload event handler function, called when the window's load event fires, to make sure we don't try to use indexeddb functionality before the app has completely finished loading (it could fail if we do...
Ember interactivity: Events, classes and state - Learn web development
hem. objective: to learn how to create component classes and use events to control interactivity, and keep track of app state using a service. adding interactivity now we've got a refactored componentized version of our todo app, lets walk through how we can add the interactivity we need to make the app functional. when beginning to think about interactivity, it's good to
declare what each component's goals and responsibilities are. in the below sections we’ll do this for each component, and then walk you through how the functionality can be implemented. creating todos for our card-header / todo input, we'll want to be able to submit our typed in todo task when we press the enter key and have it appear in the todos list. we want to be able to capture the text typed i...
...(text); if (key === 'enter' && hasvalue) { alert(text); target.value = '' } } } the @action decorator is the only ember-specific code here (aside from extending from the component superclass, and the ember-specific items we are importing using javascript module syntax) — the rest of the file is vanilla javascript, and would work in any application. the @action decorator
declares that the function is an "action", meaning it's a type of function that will be invoked from an event that occurred in the template. @action also binds the this of the function to the class instance. note: a decorator is basically a wrapper function, which wraps and calls other functions or properties, providing additional functionality along the way. for example, the @tracked decorator (see sl...
Getting started with Svelte - Learn web development
{ text-align: center; padding: 1em; max-width: 240px; margin: 0 auto; } h1 { color: #ff3e00; text-transform: uppercase; font-size: 4em; font-weight: 100; } @media (min-width: 640px) { main { max-width: none; } } </style> the <script> section the <script> block contains javascript that runs when a component instance is created. variables
declared (or imported) at the top level are 'visible' from the component's markup. top-level variables is the way svelte handles the component state, and they are reactive by default. we will explain in detail what this means later on. <script> export let name; </script> svelte uses the export keyword to mark a variable declaration as a property (or prop), which means it becomes accessible to consume...
...nd of our initial look at svelte, including how to install it locally, create a starter app, and how the basics work. in the next article we'll start building our first proper application — a todo list. before we do that, however, let's recap some of the things we’ve learned. in svelte: we define the script, style and markup of each component in a single .svelte file. component props are
declared with the export keyword. svelte components can be used just by importing the corresponding .svelte file. components styles are scoped, keeping them from clashing with each other. in the markup section you can include any javascript expression by putting it between curly braces. the top-level variables of a component constitute its state. reactivity is fired just by assigning a new value to ...
Dynamic behavior in Svelte: working with variables and props - Learn web development
ving todos, but there's an easier way to do it. we can tell svelte that we want our totaltodos and completedtodos variables to be reactive by prefixing them with $:. svelte will generate the code to automatically update them whenever data they depend on is changed. note: svelte uses the $: javascript label statement syntax to mark reactive statements. just like the export keyword being used to
declare props, this may look a little alien. this is another example in which svelte takes advantage of valid javascript syntax and gives it a new purpose — in this case to to mean "re-run this code whenever any of the referenced values change". once you get used to it, there's no going back. update your totaltodos and completedtodos variable definitions inside src/components/todos.svelte to look lik...
...id: 999, name: newtodoname, completed: false }] newtodoname = '' } giving each todo a unique id if you try to add new todos in your app now, you'll be able to add a new todo and have it appear in the ui! once. if you try it a second time, it won't work, and you'll get a console message saying "error: cannot have duplicate keys in a keyed each". we need unique ids for our todos! let's
declare a newtodoid variable calculated from the number of todos plus 1, and make it reactive. add the following snippet to the <script> section: let newtodoid $: { if (totaltodos === 0) { newtodoid = 1; } else { newtodoid = math.max(...todos.map(t => t.id)) + 1; } } note: as you can see, reactive statements are not limited to one-liners. the following would work too,...
Multiprocess on Windows
better pieces of documentation is a two-part series written by jeff prosise: understanding com apartments, part i understanding com apartments, part ii for the purposes of this document, "com" will refer to microsoft com (as opposed to xpcom). gecko and apartments most code that runs on gecko's main thread is not thread safe. since gecko's main thread uses com, and com requires threads to
declare their threading model, the main thread must initialize itself to live inside its own single threaded apartment (sta). this is true for both chrome and content processes. as you should already know from the prerequisite reading, single threaded apartments receive remote procedure calls (rpcs) from com, via the windows message queue. from a performance standpoint, this is less than ideal. the wind...
...ram. if your interface outputs an array of interfaces, the interceptor would only wrap the first element in the array, because it cannot distinguish between scalars and arrays. note: if your new interface does not contain either of these annotations, then you do not need to worry about this step. for those interfaces that do contain length_is or size_is annotations, we need to use another api
declared in mozilla/mscom/registration.h: registerarraydata(). registerarraydata() accepts an array of arraydata structs. you should statically define this array in your code, as const. for example: static const mozilla::mscom::arraydata kmyarraydata[] { { // first arraydata definition }, { // second arraydata definition } }; mozilla::mscom::registerarraydata(kmyarraydata); each arraydata struct ...
XPCOMUtils.jsm
ity routines for javascript components loaded by the javascript component loader. to use this, you first need to import the code module into your javascript scope: components.utils.import("resource://gre/modules/xpcomutils.jsm"); using xpcomutils exposing a javascript class as a component using these utility methods requires four key steps: import xpcomutils.jsm, as explained previously.
declare the class (or multiple classes) implementing the component(s). create an array of component constructors. define the nsgetfactory() or nsgetmodule() entry point. pseudocode this section provides some pseudocode that demonstrates how to put together a javascript class based on the steps listed above. constructor the constructor is a simple method that handles any required initialization tas...
...onent constructors. define the nsgetfactory() or nsgetmodule() entry point. pseudocode this section provides some pseudocode that demonstrates how to put together a javascript class based on the steps listed above. constructor the constructor is a simple method that handles any required initialization tasks. function mycomponent() { // initialize the component here } class declaration
declare the class prototype, using a form similar to this. mycomponent.prototype = { // properties required for xpcom registration: classdescription: "unique text description", classid: components.id("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"), contractid: "@example.com/xxx;1", // [optional] custom factory (an object implementing nsifactory). if not // provided, the default fac...
Interval Timing
ent type, printervaltime, for timing intervals of fewer than approximately 6 hours. this chapter describes printervaltime and the functions that allow you to use it for timing purposes: interval time type and constants interval functions interval time type and constants all timed functions in nspr require a parameter that depicts the amount of time allowed to elapse before the operation is
declared failed. the type of such arguments is printervaltime. such parameters are common in nspr functions such as those used for i/o operations and operations on condition variables. nspr 2.0 provides interval times that are efficient in terms of performance and storage requirements. conceptually, they are based on free-running counters that increment at a fixed rate without possibility of outside inf...
...t in terms of performance and storage requirements. conceptually, they are based on free-running counters that increment at a fixed rate without possibility of outside influence (as might be observed if one was using a time-of-day clock that gets reset due to some administrative action). the counters have no fixed epoch and have a finite period. to make use of these counters, the application must
declare a point in time, the epoch, and an amount of time elapsed since that epoch, the interval. in almost all cases the epoch is defined as the value of the interval timer at the time it was sampled. printervaltime interval functions interval timing functions are divided into three groups: getting the current interval and ticks per second converting standard clock units to platform-dependent ...
NSS 3.12.6 release notes
bug 527759: add multiple roots to nss (single patch) bu...
...late - nsstoken_findcertificatebyissuerandserialnumber] bug 526910: maxresponselength (initialized to pkix_default_max_response_length) is too small for downloading some crls. ...
NSS_3.12_release_notes.html
e_alert ssl_error_rx_unexpected_new_session_ticket ssl_error_rx_malformed_new_session_ticket new tls cipher suites (see sslproto.h): tls_rsa_with_camellia_128_cbc_sha tls_dhe_dss_with_camellia_128_cbc_sha tls_dhe_rsa_with_camellia_128_cbc_sha tls_rsa_with_camellia_256_cbc_sha tls_dhe_dss_with_camellia_256_cbc_sha tls_dhe_rsa_with_camellia_256_cbc_sha note: the following tls cipher suites are
declared but are not yet implemented: tls_dh_dss_with_camellia_128_cbc_sha tls_dh_rsa_with_camellia_128_cbc_sha tls_dh_anon_with_camellia_128_cbc_sha tls_dh_dss_with_camellia_256_cbc_sha tls_dh_rsa_with_camellia_256_cbc_sha tls_dh_anon_with_camellia_256_cbc_sha tls_ecdh_anon_with_null_sha tls_ecdh_anon_with_rc4_128_sha tls_ecdh_anon_with_3des_ede_cbc_sha tls_ecdh_anon_with_aes_128_cbc_sha tls_ecdh_anon_...
...n root certs slot description is empty bug 177184: nss_cmsdecoder_cancel might have a leak bug 232392: erroneous root ca tests in nss libraries bug 286642: util should be in a shared library bug 287052: function to get crl entry reason code has incorrect prototype and implementation bug 299308: need additional apis in the crl cache for libpkix bug 335039: nssckfwcryptooperation_updatecombo is not
declared bug 340917: crlutil should init nss read-only for some options bug 350948: freebl macro change can give 1% improvement in rsa performance on amd64 bug 352439: reference leaks in modutil bug 369144: certutil needs option to generate subjectkeyid extension bug 391771: pk11_config_name and pk11_config_strings leaked on shutdown bug 401194: crash in lg_findobjects on win64 bug 405652: in the tls cli...
NSS Developer Tutorial
to void *, so we can perform pointer arithmetic without casting. use char * only if the data is interpreted as text characters. for historical reasons, the buffer length is unsigned int, as opposed to size_t. unfortunately, this can be a source of integer overflow bugs on 64-bit systems. c features nss requires c99. however, not all features from c99 are equally available. variables can be
declared, at the point they are first used. the inline keyword can be used. variadic macro arguments are permitted, but their use should be limited to using __va_args__. the exact-width integer types in nspr should be used, in preference to those
declared in <stdint.h> (which will be used by nspr in the future). universal character names are not permitted, as are wide character types (char16_t and ch...
...are in the exports variable. private headers,which may be included by files in other directories, are in the private_exports variable. private headers, that are only included by files in the same directory, are not listed in either variable. only functions listed in the symbol export lists (nss.def, ssl.def, smime.def, etc.) are truly public functions. unfortunately, public headers may
declare private functions, for historical reasons. the symbol export lists are the authoritative source of public functions. behavioral changes bug/quirk compatible: occasionally we cannot fix a bug, because applications may depend on the buggy behavior. we would need to add a new function to provide the desired behavior. similarly, new options often need to be disabled by default. nss review/feature...
JSAPI User Guide
snative must call js_set_rval and return true. the value passed to js_set_rval is returned to the javascript caller. on failure, a jsnative calls an error-reporting function, in this case js_reporterror, and returns false. this causes a javascript exception to be thrown. the caller can catch the exception using a javascript try/catch statement. to make native functions callable from javascript,
declare a table of jsfunctionspecs describing the functions. then call js_definefunctions. static jsfunctionspec myjs_global_functions[] = { js_fs("rand", myjs_rand, 0, 0), js_fs("srand", myjs_srand, 0, 0), js_fs("system", myjs_system, 1, 0), js_fs_end }; ... if (!js_definefunctions(cx, global, myjs_global_functions)) return false; ... once the functions are ...
...you need to tie the object directly to the global object so that it persists as long as the global object itself persists. custom objects an application can create a custom object without bothering with a jsclass: implement the getters, setters, and methods for your custom object in c or c++. write a jspropertyop for each getter or setter. write a jsnative or jsfastnative for each method.
declare a jspropertyspec array containing information about your custom object's properties, including getters and setters.
declare a jsfunctionspec array containing information about your custom object's methods. call js_newobject, js_constructobject, or js_defineobject to create the object. call js_defineproperties to define the object's properties. call js_definefunctions to define the object's me...
JSPropertyDescriptor
a descriptor is used to
declare whether an attribute can be written to whether it can delete an object that can enumerate and specify content. properties a descriptor is an object that can have the following key values field name description getter the get syntax binds an object property to a function that will be called when that property is looked up. setter the set syntax binds an object property to a function to be called when there is an attempt to set that property. ...
...the get syntax binds an object property to a function that will be called when that property is looked up. setter the set syntax binds an object property to a function to be called when there is an attempt to set that property. value describes the value of the specified property, which can be any valid javascript value (function, object, string...) configurable
declare that the property can be modified and deleted enumerable
declare that the property can be enumerated, and the enumerable genus can be traversed by the for...in loop. writable
declare whether the specified attribute can be rewritten description a descriptor is a property that describes an object's properties. there are two main types of property descriptors that exi...
XForms Accessibility
ontrols. you can try the following link to test xforms accessibility: visual xforms elements in xhtml document at bugzilla.mozilla.org visual xforms elements in xul document at bugzilla.mozilla.org you can see xforms sample tests at mozilla xforms project there are set of tests at beaufour.dk w3c's xforms test at w3.org keyboard navigation issues navigation sequence though xforms spec
declares navindex attribute to define the navigation sequence (see 1.0 specs or 1.1 specs) but rich schwerdtfeger (distinguished engineer, swg accessibility architect/strategist chair, ibm accessibility architecture review board) gave some clarification about navindex. he wrote: navindex was in xforms - it was stripped out as it was believed the focus model was dependent on the content which used it. so...
...esn't have labelledby attribute. description it is formed from value of child xforms hint element if the element doesn't have describedby attribute. state it is formed as well from model item properties (mips) of instance node that xforms element is bound to as from valid/invalid or in-range/out-of-range states of instance node. instance node states are mapped to accessibility state constants
declared in nsiaccessiblestates interface like it shown below: relevant - state_unavailable readonly - state_readonly required - state_required invalid - state_invalid out of range - state_invalid attributes redefines datatype aria attribute. its value is xml schema builit-in datatype of instance node that xforms element is bound to. children mozilla xforms implementation allows form control ...
An Overview of XPCOM
for nsisupports looks like this: 00000000-0000-0000-c000-000000000046 the length of a cid can make it cumbersome to deal with in the code, so very often you see #defines for cids and other identifiers being used, as in this example: #define sample_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} you also see ns_define_cid used a lot. this simple macro
declares a constant with the value of the cid: static ns_define_cid(kwebshellcid, ns_web_shell_cid); a cid is sometimes also referred to as a class identifier. if the class to which a cid refers implements more than one interface, that cid guarantees that the class implements that whole set of interfaces when it's published or frozen. contract id a contract id is a human readable string used to acce...
...es which maintain the location of application- and system-specific locations, memory management to ensure everyone uses the same memory allocator, and an event notification system that allows passing of simple messages. the tutorial will show each of these component and services in use, and the xpcom api reference has a complete interface listing of these areas. xpcom types there are many xpcom
declared types and simple macros that we will use in the following samples. most of these types are simple mappings. the most common types are described in the following sections. method types the following are a set of types for ensuring correct calling convention and return type of xpcom methods. ns_imethod method declaration return type. xpcom method declarations should use this as thei...
Starting WebLock
leenumerator sites; }; the first line includes the file nsisupports.idl, which defines the nsisupports interface from which all xpcom interfaces must derive, and makes it possible for the iweblock interface to subclass that base interface. #include "nsisupports.idl" the next line of the xpidl is a forward declaration of the interface nsisimpleenumerator. again, this is similar to the forward
declare in c++ (except that c++ does not have the interface keyword seen here). interface nsisimpleenumerator; see the xpcom resources for more information about the xpidl syntax. scriptable interfaces the third line in iweblock is more complex. the first thing it says is that iweblock will bescriptable. [scriptable, uuid(ea54eee4-9548-4b63-b94d-c519ffc91d09)] the rest of the line provides a uuid...
...interface file. every header generated from an xpidl file has a similar macro that defines all the methods in that interface. this makes changes to the interface when designing a bit simpler, as you do not have to modify any class declarations. there are times, of course, when you cannot use these macros-as when two interfaces share the same method signatures. in these cases you have to manually
declare the methods in your class. but in practice, manually declaring class methods in xpcom is the exception and not the rule. the ns_decl_iweblock declaration macro expands into the following: ns_imethod lock(void); ns_imethod unlock(void); ns_imethod addsite(const char *url); ns_imethod removesite(const char *url); ns_imethod getsites(nsisimpleenumerator * *asites); ns_imethod setsites(n...
Mozilla internal string guide
value; getvalue(value); // if the result is less than 64 code units, // then this just saved us an allocation ... member variables in general, you should use the concrete classes nsstring and nscstring for member variables. class foo { ... // these store utf-8 and utf-16 values respectively nscstring mlocalname; nsstring mtitle; }; note that the strings are
declared directly in the class, not as pointers to strings. don't do this: class foo { public: foo() { mlocalname = new nscstring(); mtitle = new nsstring(); } ~foo() { delete mlocalname; delete mtitle; } private: // these store utf-8 and utf-16 values respectively nscstring* mlocalname; nsstring* mtitle; }; the above code may appear to save the cost of the st...
...t the criteria above. operations that undo the benefits of setcapacity() include but are not limited to: setlength() truncate() assign() assignliteral() adopt() copyasciitoutf16() lossycopyutf16toascii() appendutf16toutf8() appendutf8toutf16() copyutf16toutf8() copyutf8toutf16() if your string is an nsauto[c]string and you are calling setcapacity() with a constant n, please instead
declare the string as nsauto[c]stringn<n+1> without calling setcapacity() (while being mindful of not using such a large n as to overflow the run-time stack). there is no need to include room for the null terminator: it is the job of the string class. note: calling setcapacity() does not give you permission to use the pointer obtained from beginwriting() to write past the current length (as returned by...
mozIRegistry
sumably implement particular xpcom interfaces. so how do you go about creating an object that can provide the interface your component requires? one way is to create instances by using nsrepository. nsrepository is essentially a mapping from xpcom clsids to class factories, plus code to manage that mapping, including functions that create instances of a given clsid. the nsrepository functions are
declared in nsrepository.h. much more information about nsrepository can be found below. the second way you access other components is via the service manager. that thing isn't yet covered in this document. see the note above. in this section, i'll discuss a number of different components, their requirements for dynamically binding to other components, and how they might utilize the core xpcom components...
...ght be useful to refactor the nsrepository code so that it is structured the same way as the service manager. one could then make the nsrepository itself a service and permit full (?!) de-coupling of xpcom modules from the xpcom implementation. moziregistry this is the new interface that will surface essentially the same function as is currently provided by libreg (aka "netscape registry") as
declared in mozilla/modules/libreg/include/nsreg.h. clients will obtain this interface via the service manager (see mozilla/xpcom/public/nsiservicemanager.h). mozregistry this is the simplistic implementation of the moziregistry interface. it is built as a simple c wrapper for the functions in nsreg.h. it is intended to provide a (slightly) lighter-weight implementation that is entirely compatible with...
Working with windows in chrome code
ow.opener property or via a callback function passed to the window in a way described in the previous section. let's add code to the previous example to notify the opener when the user presses cancel on the progress dialog. using window.opener. the opener property returns its window's opener; that is, the window object that opened it. if we're sure the window that opened the progress dialog
declares the canceloperation function, we can use window.opener.canceloperation() to notify it, like this: <button label="cancel" oncommand="opener.canceloperation(); close();" /> using a callback function. alternatively, the opener window can pass a callback function to the progress dialog in the same way we passed the status string in the previous example: function oncancel() { alert("operatio...
...enwindow xpconnect will automatically wrap it as a generic nsisupports. the opened window can then just get at the underlying javascript object using wrappedjsobject. advanced data sharing the above code is useful when you need to pass data from one window to another or to a set of windows, but sometimes you just want to share a javascript variable in common between different windows. you could
declare a local variable in each window along with corresponding setter functions to keep the "instances" of the variable in sync across windows, but fortunately, there's a better way. to
declare a shared variable, we need to find a place that exists while the application is running and is easily accessible from the code in different chrome windows. there are actually a few such places. using javascrip...
Using COM from js-ctypes
e': ctypes.voidptr_t }, { 'setsyncspeaktimeout': ctypes.voidptr_t }, { 'getsyncspeaktimeout': ctypes.voidptr_t }, { 'speakcompleteevent': ctypes.voidptr_t }, { 'isuisupported': ctypes.voidptr_t }, { 'displayui': ctypes.voidptr_t } // end ispvoice ]); // functions // http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279%28v=vs.85%29.aspx let coinitializeex = lib.
declare('coinitializeex', winabi, hresult, // result lpvoid, // pvreserved dword // dwcoinit ); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms688715%28v=vs.85%29.aspx let couninitialize = lib.
declare('couninitialize', winabi, void // return ); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms686615%28v=vs.85%29.aspx let cocreateinstance = lib.d...
...9.aspx let cocreateinstance = lib.
declare('cocreateinstance', winabi, hresult, // return refclsid, // rclsid lpunknown, // punkouter dword, // dwclscontext refiid, // riid lpvoid // *ppv ); // helper functions function checkhresult(hr /*primative hresult*/, funcname /*jsstr*/) { // primative because thats what is returned by
declared functions that // return hresult hr = hr.tostring(); // makes it primative if (hr < 0) { console.error('hresult', hr, 'returned from function ', funcname /*, 'getstrofresult:', getstrofresult(hr)*/); throw new error('hresult ' + hr + ' returned from function ' + funcname); } } let clsidfromarr = iidfromarr = function(jsarr_pieces) { let ...
Declaring and Calling Functions
functions are
declared using the library object's
declare() method. once
declared, functions can be called using standard function syntax. prerequiste understanding see abi. example: no input parameters in this example, we
declare the libc clock() function, which returns the elapsed time since system startup, then fetch and output that value. const clock = lib.
declare("clock", ctypes.default_abi, ctypes.unsigned_long); console.log("clocks since startup: " + clock()); the clock() function requires no input parameters; it simply returns an unsigned long. example: multiple input parameters this example
declares the libc asctime() function, which converts a time structure into a string. ...
...ch and output that value. const clock = lib.
declare("clock", ctypes.default_abi, ctypes.unsigned_long); console.log("clocks since startup: " + clock()); the clock() function requires no input parameters; it simply returns an unsigned long. example: multiple input parameters this example
declares the libc asctime() function, which converts a time structure into a string. const asctime = lib.
declare("asctime", ctypes.default_abi, ctypes.char.ptr, struct_tm.ptr); for a more complete version of this example (including the implementation of the struct_tm type), see the structures example. returned values if the return type can fit into a javascript number without loss (that is, it's a number 32 bits or smaller, or is a double or float), then the function just return a javascript number. for ...
CType
these objects have assorted methods and properties that let you create objects of these types, find out information about them, and so forth. the specific properties and methods on each object vary depending on the data type represented. there are several kinds of types: primitive types these are typical unstructured data, such as the predefined types listed in predefined data types. big integer types the int64 and uint64 types provide access to 64-bit integer values, which javascript doesn't currently support. pointertype these represent pointers to data in memory. functiontype these represent callable c functions. structtype these represent c structures. ...
...ead only. size number the size of the type, in bytes. this is the same value as the c sizeof. read only. note: ctypes.void_t.size is undefined. methods available on all ctype objects array() returns a new ctype representing an array of elements of the type on which it was called. ctype array( [n] }; parameters n optional the number of elements in the
declared array type. if this parameter is left out, the array's size is indeterminate. return value a ctype representing the data type "array of this type". this is the same as calling ctypes.arraytype(the_type[, n]). tosource() returns a javascript expression that evaluates to a ctype describing the same c type as this object. string tosource(); parameters none. return value a javascript expr...
ctypes
ndows, available only for windows. cannot be set. constants abi constants these constants are used to specify the abi used to call a native function in the library. constant description default_abi corresponds to cdecl; standard libraries use this abi. you also use this for all system calls on mac os x and linux. stdcall_abi used for calling functions
declared with stdcall on windows. these functions' names are automatically mangled for you by js-ctypes. winapi_abi used for calling windows system functions. these are
declared as stdcall on windows, but do not have mangled names like those used by stdcall_abi above. predefined data types primitive types these types behave the same on all platforms. type description ...
...credit for this example is to nmaier (stackoverflow :: getting tb_button is crashing and not working) example of cast and functiontype on windows components.utils.import("resource://gre/modules/ctypes.jsm"); var kernel = ctypes.open("kernel32.dll"); var hmodule = ctypes.uint32_t; var hwnd = ctypes.uint32_t; var lpctstr = ctypes.jschar.ptr; var lpcstr = ctypes.char.ptr; var loadlibrary = kernel.
declare("loadlibraryw", ctypes.winapi_abi, hmodule, lpctstr); var getprocaddress = kernel.
declare("getprocaddress", ctypes.winapi_abi, ctypes.void_t.ptr, hmodule, lpcstr); var huser = loadlibrary("user32"); var funcptr = getprocaddress(huser, "messageboxw"); // now we have a pointer to a function, let's cast it to the right type var messageboxtype = ctypes.functiontype(ctypes.winapi_abi, ctypes.int32_t...
Version, UI, and Status Information - Plugins
ts the values from the plug-in rather than from the browser. void npn_version(int *plugin_major, int *plugin_minor, int *netscape_major, int *netscape_minor); this function returns the plug-in version number in plugin_major, the plug-in point release number in plugin_minor, the browser version number in netscape_major, and the browser point release number in netscape_minor. ...
...in plugin_major, the plug-in point release number in plugin_minor, the browser version number in netscape_major, and the browser point release number in netscape_minor. this code
declares variables to hold the version numbers and calls npn_version to return the major and minor version numbers for the browser and the plug-in api. int plugin_major, plugin_minor, netscape_major, netscape_minor; //
declare variables to hold version numbers void npn_version( &plugin_major, &plugin_minor, &netscape_major, &netscape_minor ); // find version numbers finding out if a feature exists a plug-in can figure out whether it is running in a version of the browser that supports a particular feature by using version or npvers constants (see version feature constants). each npvers constant represents a f...
EventTarget.addEventListener() - Web APIs
ener fired on programmatically from within the event listener. the primary benefit to doing this is that the event listener receives the data in much the same way that it would if you were to actually pass it through its argument list. getting data into an event listener using the outer scope property when an outer scope contains a variable declaration (with const, let), all the inner functions
declared in that scope have access to that variable (look here for information on outer/inner functions, and here for information on variable scope). therefore, one of the simplest ways to access data from outside of an event listener is to make it accessible to the scope in which the event listener is
declared. const mybutton = document.getelementbyid('my-button-id'); const somestring = 'data'; mybutt...
...i < els.length; i++){ els[i].addeventlistener("click", function(e){/*do something*/}, false); } // case 2 function processevent(e){ /* do something */ } for(let i=0 ; i < els.length; i++){ els[i].addeventlistener("click", processevent, false); } in the first case above, a new (anonymous) handler function is created with each iteration of the loop. in the second case, the same previously
declared function is used as an event handler, which results in smaller memory consumption because there is only one handler function created. moreover, in the first case, it is not possible to call removeeventlistener() because no reference to the anonymous function is kept (or here, not kept to any of the multiple anonymous functions the loop might create.) in the second case, it's possible to do myele...
HTMLElement: transitionend event - Web APIs
bubbles yes cancelable yes interface transitionevent event handler property ontransitionend the transitionend event is fired in both directions - as it finishes transitioning to the transitioned state, and when it fully reverts to the default or non-transitioned state. if there is no transition delay or duration, if both are 0s or neither is
declared, there is no transition, and none of the transition events are fired. if the transitioncancel event is fired, the transitionend event will not fire. examples this code gets an element that has a transition defined and adds a listener to the transitionend event: const transition = document.queryselector('.transition'); transition.addeventlistener('transitionend', () => { console.log('trans...
...ioncancel', function() { message.textcontent = 'transitioncancel fired'; }); el.addeventlistener('transitionend', function() { message.textcontent = 'transitionend fired'; }); the transitionend event is fired in both directions: when the box finishes turning and the opacity hits 0 or 1, depending on the direction. if there is no transition delay or duration, if both are 0s or neither is
declared, there is no transition, and none of the transition events are fired. if the transitioncancel event is fired, the transitionend event will not fire. specifications specification status comment css transitionsthe definition of 'transitionend' in that specification. working draft initial definition. ...
HTMLObjectElement - Web APIs
document of the object element's nested browsing context, if any; otherwise null. htmlobjectelement.contentwindow read only returns a windowproxy representing the window proxy of the object element's nested browsing context, if any; otherwise null. htmlobjectelement.data returns a domstring that reflects the data html attribute, specifying the address of a resource's data. htmlobjectelement.
declare is a boolean that reflects the
declare html attribute, indicating that this is a declaration, not an instantiation, of the object. htmlobjectelement.form read only retuns a htmlformelement representing the object element's form owner, or null if there isn't one. htmlobjectelement.height returns a domstring that reflects the height html attribute, specifying the displayed height of the res...
...telement' in that specification. living standard html5the definition of 'htmlobjectelement' in that specification. recommendation the w3c specification is a latest of a previous version of html living standard technically, the property tabindex is now defined on htmlelement. the following properties are now obsolete: align, archive, border, code, codebase, codetype,
declare, hspace, standby, and vspace. the following properties have been added: typemustmatch, contentwindow, willvalidate, validity, and validationmessage. the following methods have been added: checkvalidity() and setcustomvalidity(). document object model (dom) level 2 html specificationthe definition of 'htmlobjectelement' in that specification. obsolete the contentdocument pro...
IDBKeyRange.bound() - Web APIs
exception description dataerror the following conditions raise an exception: the lower or upper parameters were not passed a valid key. the lower key is greater than the upper key. the lower key and upper key match and either of the bounds are open. example the following example illustrates how you'd use a bound key range. here we
declare a keyrangevalue = idbkeyrange.bound("a", "f"); — a range between values of "a" and "f". we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. this means that the cursor will only retrieve records with keys inside that range. this range includes the values "a" and "f", as we hav...
...yrangevalue = idbkeyrange.bound("a", "f"); — a range between values of "a" and "f". we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. this means that the cursor will only retrieve records with keys inside that range. this range includes the values "a" and "f", as we haven't
declared that they should be open bounds. if we used idbkeyrange.bound("a", "f", true, true);, then the range would not include "a" and "f", only the values between them. note: for a more complete example allowing you to experiment with key range, have a look at the idbkeyrange directory in the indexeddb-examples repo (view the example live too.) function displaydata() { var keyrangevalue = idbkey...
IDBKeyRange - Web APIs
() creates a new key range containing a single value. idbkeyrange.lowerbound() creates a new key range with only a lower bound. idbkeyrange.upperbound() creates a new upper-bound key range. instance methods idbkeyrange.includes() returns a boolean indicating whether a specified key is inside the key range. examples the following example illustrates how you'd use a key range. ...
...if we used idbkeyrange.bound("a", "f", true, true);, then the range would not include "a" and "f", only the values between them. ...
USBDevice - Web APIs
been started with a paired usb device. usbdevice.productid read only the manufacturer-defined code that identifies a usb device. usbdevice.productname read only the manufacturer-defined name that identifies a usb device. usbdevice.serialnumber read only the manufacturer-defined serial number for the specific usb device. usbdevice.usbversionmajor read only one of three properties that
declare the usb protocol version supported by the device. the other two properties are usbdevice.usbversionminor and usbdevice.usbversionsubminor. usbdevice.usbversionminor read only one of three properties that
declare the usb protocol version supported by the device. the other two properties are usbdevice.usbversionmajor and usbdevice.usbversionsubminor. usbdevice.usbversionsubminor read only one...
...the other two properties are usbdevice.usbversionmajor and usbdevice.usbversionminor. usbdevice.vendorid read only the official usg.org-assigned vendor id. ...
WebGLRenderingContext.getActiveUniform() - Web APIs
t_sampler_cube gl.int_sampler_2d_array gl.unsigned_int_sampler_2d gl.unsigned_int_sampler_3d gl.unsigned_int_sampler_cube gl.unsigned_int_sampler_2d_array when gl.linkprogram is called, webgl creates a list of active uniforms. these are possible values of the name attribute of return values of getactiveuniform. webgl generates one or more entries in the list depending on the
declared type of the uniform in the shader: single basic type: one entry with the name of the uniform. e.g. uniform vec4 a; will result in a. array of basic type: one entry with the name of the uniform suffixed with [0]. e.g. uniform vec4 b[]; will result in b[0]. struct type: one entry for each member of the struct. e.g. uniform struct { float foo; vec4 bar; } c; will result in c.foo and c.bar. ...
...]; will result in: d[0].foo d[0].bar d[1].foo d[1].bar uniform blocks: one entry for each member. if the uniform block has an instance name, the block name is prefixed. e.g. uniform block { float foo; }; will result in foo, and uniform block { float bar; } e; will result in block.bar. the size attribute of the return value corresponds to the length of the array for uniforms
declared as arrays. otherwise, it is 1 (this includes interface blocks instanced with arrays). exceptions gl.invalid_value is generated if the program webglprogram is invalid (not linked, deleted, etc.). gl.invalid_value is generated if index is not in the range [0, gl.getprogramparameter(program, gl.active_uniforms) - 1]. examples const numuniforms = gl.getprogramparameter(program, gl.active_uni...
WebGLRenderingContext.getUniformLocation() - Web APIs
orm's value to the specified value, which may be a single floating point or integer number, or a 2-4 component vector specified either as a list of values or as a float32array or int32array. uniformmatrix[234][fv]() sets the uniform's value to the specified matrix, possibly with transposition. the value is represented as a sequence of glfloat values or as a float32array. the uniform itself is
declared in the shader program using glsl. syntax webgluniformlocation = webglrenderingcontext.getuniformlocation(program, name); parameters program the webglprogram in which to locate the specified uniform variable. name a domstring specifying the name of the uniform variable whose location is to be returned. the name can't have any whitespace in it, and you can't use this function to get the ...
...g specifying the name of the uniform variable whose location is to be returned. the name can't have any whitespace in it, and you can't use this function to get the location of any uniforms starting with the reserved string "gl_", since those are internal to the webgl layer. the possible values correspond to the uniform names returned by getactiveuniform; see that function for specifics on how
declared uniforms map to uniform location names. additionally, for uniforms
declared as arrays, the following names are also valid: the uniform name without the [0] suffix. e.g. the location returned for arrayuniform is equivalent to the one for arrayuniform[0]. the uniform name indexed with an integer. e.g. the location returned for arrayuniform[2] would point directly to the third entry of ...
WebGL best practices - Web APIs
essl300 int between shaders, and you need it to have 32-bits, you must use highp or you will have portability problems. ...
... while you can use mediump float instead, but be aware that this often result...
Movement, orientation, and motion: A WebXR example - Web APIs
_distance the distance to move in response to any of the keys used to move the viewer through the scene. note: this example always displays what it renders on the screen, even if using immersive-vr mode. this lets you compare any differences in rendering between the two modes, and lets you see output from immersive mode even if you don't have a headset. ...
...ion of the cube, while cubematrix and mousematrix are storage for matrices used during the rendering of the scene. inverseorientation is a quaternion which will be used to represent the rotation to apply to the reference space for the object in the frame being rendered. radians_per_degreee is the value to multiply an angle in degrees by to convert the angle into radians. the last four variables
declared are storage for references to the <div> elements into which we'll output the matrices when we want to show them to the user. logging errors a function called logglerror() is implemented to provide an easily customized way to output logging information for errors that occur while executing webgl functions. function logglerror(where) { let err = gl.geterror(); if (err) { console.error(`...
An overview of accessible web applications and widgets - Accessibility
o indicate the state of ui widget elements and use css attribute selectors to alter the visual appearance based on the state changes (rather than using script to change a class name on the element). visibility changes when content visibility is changed (i.e., an element is hidden or shown), developers should change the aria-hidden property value. the techniques described above should be used to
declare css to visually hide an element using display:none. here is an example of a tooltip that uses aria-hidden to control the visibility of the tooltip. the example shows a simple web form with tooltips containing instructions associated with the entry fields. in this example, the html for the tooltip has the form shown in example 2a. line 9 sets the aria-hidden state to true. example 2a. html for...
...one; } the javascript to update the aria-hidden property has the form shown in example 2c. note that the script only updates the aria-hidden attribute (line 2); it does not need to also add or remove a custom classname. example 2c. javascript to update the aria-checked attribute var showtip = function(el) { el.setattribute('aria-hidden', 'false'); } role changes aria allows developers to
declare a semantic role for an element that otherwise offers incorrect or no semantics. the role of an element should not change. instead, remove the original element and replace it with an element with the new role. for example, consider an "inline edit" widget: a component that allows users to edit a piece of text in place, without switching contexts. this component has a "view" mode, in which the tex...
Basic Concepts of Multicol - CSS: Cascading Style Sheets
re is a margin above each paragraph. you can see how this margin causes the first line of text to be pushed down. this is because a multicol container creates a new block formatting context (bfc) which means margins on child elements do not collapse with any margin on the container. the column-width property the column-width property is used to set the optimal width for every column box. ...
... in the below example we use the column-width property with a value of 200px. we get as many 200 pixel columns as will fit the container, with the extra space shared equally. ...
Using CSS gradients - CSS: Cascading Style Sheets
adient() functions are available to offer this functionality. the size of the gradient line or arc that repeats is the length between the first color stop value and the last color stop length value. if the first color stop just has a color and no color stop length, the value defaults to 0. if the last color stop has just a color and no color stop length, the value defaults to 100%. ...
... defaults to 0. if the last color stop has just a color and no color stop length, the value defaults to 100%. if neither is
declared, the gradient line is 100% meaning the linear and conic gradients will not repeat and the radial gradient will only repeat if the radius of the gradient is smaller than the length between the center of the gradient and the farthest corner. if the first color stop is
declared, and the value is greater than 0, the gradient will repeat, as the size of the line or arc is the difference between the first color stop and last color stop is less than 100% or 360 degrees. repeating linear gradients this example uses repeating-linear-gradient() to create a gradient that progresses repeatedly in a straight line. the colors get cycled over again as the gradient repeats. in t...
Specificity - CSS: Cascading Style Sheets
list of selector types increases by specificity: type selectors (e.g., h1) and pseudo-elements (e.g., ::before). class selectors (e.g., .example), attributes selectors (e.g., [type="radio"]) and pseudo-classes (e.g., :hover). id selectors (e.g., #example). universal selector (*), combinators (+, >, ~, ' ', ||) and negation pseudo-class (:not()) have no effect on specificity. (the selectors
declared inside :not() do, however.) for more information, visit: "specificity" in "cascade and inheritance", you can also visit: https://specifishity.com inline styles added to an element (e.g., style="font-weight: bold;") always overwrite any styles in external stylesheets, and thus can be thought of as having the highest specificity. the !important exception when an important rule is used on a sty...
...her elements that are referenced in a given selector has no impact on specificity. the following style declaration ... body h1 { color: green; } html h1 { color: purple; } ... with the following html ... <html> <body> <h1>here is a title!</h1> </body> </html> ... will render as: this is because the two declarations have equal selector type counts, but the html h1 selector is
declared last. directly targeted elements vs. inherited styles styles for a directly targeted element will always take precedence over inherited styles, regardless of the specificity of the inherited rule. this css ... #parent { color: green; } h1 { color: purple; } ... with the following html ... <html> <body id="parent"> <h1>here is a title!</h1> </body> </html> ... will also render ...
x-ms-acceleratorkey - HTML: Hypertext Markup Language
non-standard this feature is non-standard and is not on a standards track. do not use it on production sites facing the web: it will not work for every user. there may also be large incompatibilities between implementations and the behavior may change in the future. the x-ms-acceleratorkey attribute accessibly
declares that an accelerator key has been assigned to an element: the element is activated via javascript when the key(s) are pressed on a keyboard. this proprietary property is specific to internet explorer and microsoft edge. x-ms-acceleratorkey exposes a notification in the accessibility tree, for screen readers and other assistive technologies, that an accelerator key exists for that element. this attribute does not provide the accelerator key behavior...
...property is specific to internet explorer and microsoft edge. x-ms-acceleratorkey exposes a notification in the accessibility tree, for screen readers and other assistive technologies, that an accelerator key exists for that element. this attribute does not provide the accelerator key behavior. you must provide javascript event handlers, like onkeypress, onkeydown, or onkeyup, to listen for your
declared accelerator keys and activate the element accordingly. to provide a keyboard shortcut for an element that does not need javascript, use the accesskey attribute. syntax <button x-ms-acceleratorkey="[explanation of key combination]">…</button> value the accelerator key combination. for example: "ctrl+b" for a combination of the ctrl and b keys. "j" for just the j key. "ctrl+; then k" f...
HTTP headers - HTTP
document that the server should return. if-range creates a conditional range request that is only fulfilled if the given etag or date matches the remote resource. used to prevent downloading two ranges from incompatible version of the resource. content-range indicates where in a full body message a partial message belongs. security cross-origin-embedder-policy (coep) allows a server to
declare an embedder policy for a given document. cross-origin-opener-policy (coop) prevents other domains from opening/controlling a window. cross-origin-resource-policy (corp) prevents other domains from reading the response of the resources to which this header is applied. content-security-policy (csp) controls resources the user agent is allowed to load for a given page. content-security-...
...s the request's destination to a server. it is a structured header whose value is a token with possible values audio, audioworklet, document, embed, empty, font, image, manifest, object, paintworklet, report, script, serviceworker, sharedworker, style, track, video, worker, xslt, and nested-document. server-sent events last-event-id ... nel defines a mechanism that enables developers to
declare a network error reporting policy. ping-from ... ping-to ... report-to used to specify a server endpoint for the browser to send warning and error reports to. transfer coding transfer-encoding specifies the form of encoding used to safely transfer the entity to the user. te specifies the transfer encodings the user agent is willing to accept. trailer allows the sender to include ad...
Introduction - JavaScript
ead of the more common class-based object model. the prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. javascript also supports functions without any special declarative requirements. functions can be properties of objects, executing as loosely typed methods. javascript is a very free-form language compared to java. you do not have to
declare all variables, classes, and methods. you do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. variables, parameters, and function return types are not explicitly typed. java is a class-based programming language designed for fast execution and type safety. type safety means, for instance, that you can't cast a java integ...
... object-oriented. no distinction between types of objects. inheritance is through the prototype mechanism, and properties and methods can be added to any object dynamically. class-based. objects are divided into classes and instances with all inheritance through the class hierarchy. classes and instances cannot have properties or methods added dynamically. variable data types are not
declared (dynamic typing, loosely typed). variable data types must be
declared (static typing, strongly typed). cannot automatically write to hard disk. can automatically write to hard disk. for more information on the differences between javascript and java, see the chapter details of the object model. javascript and the ecmascript specification javascript is standardized at ecma...
Loops and iteration - JavaScript
loop. a for statement looks as follows: for ([initialexpression]; [conditionexpression]; [incrementexpression]) statement when a for loop executes, the following occurs: the initializing expression initialexpression, if any, is executed. this expression usually initializes one or more loop counters, but the syntax allows an expression of any degree of complexity. this expression can also
declare variables. the conditionexpression expression is evaluated. if the value of conditionexpression is true, the loop statements execute. if the value of condition is false, the for loop terminates. (if the condition expression is omitted entirely, the condition is assumed to be true.) the statement executes. to execute multiple statements, use a block statement ({ ... }) to group those statements.
...cutes. to execute multiple statements, use a block statement ({ ... }) to group those statements. if present, the update expression incrementexpression is executed. control returns to step 2. example in the example below, the function contains a for statement that counts the number of selected options in a scrolling list (a <select> element that allows multiple selections). the for statement
declares the variable i and initializes it to 0. it checks that i is less than the number of options in the <select> element, performs the succeeding if statement, and increments i by after each pass through the loop. <form name="selectform"> <p> <label for="musictypes">choose some music types, then click the button below:</label> <select id="musictypes" name="musictypes" multiple="multiple"> ...
Public class fields - JavaScript
c field' } class classwithpublicinstancemethod { publicmethod() { return 'hello world' } } examples public static fields public static fields are useful when you want a field to exist only once per class, not on every class instance you create. this is useful for caches, fixed-configuration, or any other data you don't need to be replicated across instances. public static fields are
declared using the static keyword. they are added to the class constructor at the time of class evaluation using object.defineproperty(). they are accessed again from the class constructor. class classwithstaticfield { static staticfield = 'static field' } console.log(classwithstaticfield.staticfield) // expected output: "static field" fields without initializers are initialized to undefined. c...
...hod() { return this.msg } } class subclass extends baseclass { subpublicmethod() { return super.basepublicmethod() } } const instance = new subclass() console.log(instance.subpublicmethod()) // expected output: "hello world" getters and setters are special methods that bind to a class property and are called when that property is accessed or set. use the get and set syntax to
declare a public instance getter or setter. class classwithgetset { #msg = 'hello world' get msg() { return this.#msg } set msg(x) { this.#msg = `hello ${x}` } } const instance = new classwithgetset() console.log(instance.msg) // expected output: "hello world" instance.msg = 'cake' console.log(instance.msg) // expected output: "hello cake" specifications specification...
TypeError: invalid assignment to const "x" - JavaScript
the javascript exception "invalid assignment to const" occurs when it was attempted to alter a constant value. javascript const declarations can't be re-assigned or re
declared. message typeerror: invalid assignment to const "x" (firefox) typeerror: assignment to constant variable. (chrome) typeerror: assignment to const (edge) typeerror: redeclaration of const 'x' (ie) error type typeerror what went wrong? a constant is a value that cannot be altered by the program during normal execution. it cannot change through re-assignment, and it can't be re
declared. in javascript, constants are
declared using the const keyword. examples invalid redeclaration assigning a value to the same constant name in the same block-scope will throw. const columns = 80; // ... columns = 120; // typeerror: ...
...red using the const keyword. examples invalid redeclaration assigning a value to the same constant name in the same block-scope will throw. const columns = 80; // ... columns = 120; // typeerror: invalid assignment to const `columns' fixing the error there are multiple options to fix this error. check what was intended to be achieved with the constant in question. rename if you meant to
declare another constant, pick another name and re-name. this constant name is already taken in this scope. const columns = 80; const wide_columns = 120; const, let or var? do not use const if you weren't meaning to
declare a constant. maybe you meant to
declare a block-scoped variable with let or global variable with var. let columns = 80; // ... let columns = 120; scoping check if you are in t...
SyntaxError: missing = in const declaration - JavaScript
provide one (const red_flag = '#ff0'). message syntaxerror: const must be initalized (edge) syntaxerror: missing = in const declaration (firefox) syntaxerror: missing initializer in const declaration (chrome) error type syntaxerror what went wrong? a constant is a value that cannot be altered by the program during normal execution. it cannot change through re-assignment, and it can't be re
declared. in javascript, constants are
declared using the const keyword. an initializer for a constant is required; that is, you must specify its value in the same statement in which it's
declared (which makes sense, given that it can't be changed later). examples missing const initializer unlike var or let, you must specify a value for a const declaration. this throws: const columns; // syntaxerror:...
...es missing const initializer unlike var or let, you must specify a value for a const declaration. this throws: const columns; // syntaxerror: missing = in const declaration fixing the error there are multiple options to fix this error. check what was intended to be achieved with the constant in question. adding a constant value specify the constant value in the same statement in which it's
declared: const columns = 80; const, let or var? do not use const if you weren't meaning to
declare a constant. maybe you meant to
declare a block-scoped variable with let or global variable with var. both don't require an initial value. let columns; ...
SyntaxError: redeclaration of formal parameter "x" - JavaScript
the javascript exception "redeclaration of formal parameter" occurs when the same variable name occurs as a function parameter and is then re
declared using a let assignment in a function body again. message syntaxerror: let/const redeclaration (edge) syntaxerror: redeclaration of formal parameter "x" (firefox) syntaxerror: identifier "x" has already been
declared (chrome) error type syntaxerror what went wrong? the same variable name occurs as a function parameter and is then re
declared using a let assignment in a function body again. redeclaring the same variable within the same function or block scope using let is not allowed in javascript. examples re
declared argument in this case, the variable "arg" re
declares the argument. function f(arg) { let arg = 'foo'; } // syntaxerror: r...
...in other words: you can omit the let keyword. ...
JavaScript error reference - JavaScript
are deprecatedsyntaxerror: "use strict" not allowed in function with non-simple parameterssyntaxe...
...ble property "x"typeerror: cannot use "in" operator to search for "x" in "y"typeerror: cyclic object valuetypeerror: invalid "instanceof" operand "x"typeerror: invalid array.prototype.sort argumenttypeerror: invalid argumentstypeerror: invalid assignment to const "x"typeerror: property "x" is non-configurable and can't be deletedtypeerror: setting getter-only property "x"typeerror: variable "x" re
declares argumenturierror: malformed uri sequencewarning: 08/09 is not a legal ecma-262 octal constantwarning: -file- is being assigned a //# sourcemappingurl, but already has onewarning: date.prototype.tolocaleformat is deprecatedwarning: javascript 1.6's for-each-in loops are deprecatedwarning: string.x is deprecated; use string.prototype.x insteadwarning: expression closures are deprecatedwarning: unr...
Arrow function expressions - JavaScript
with strict mode given that this comes from the surrounding lexical context, strict mode rules with regard to this are ignored. var f = () => { 'use strict'; return this; }; f() === window; // or the global object all other strict mode rules apply normally. correction: start note: the previous statement seems false. strict mode should prevent creating global variables when assigning to an un
declared identifier in a function. this code sample using chrome 81 demonstrates that arrow functions allow the creation of global variables in such situations (both for a concise body and for a normal function body): > f1 = x => { y = x; console.log(`x: ${x}, y: ${y}`); return x + 1; } x => { y = x; console.log(`x: ${x}, y: ${y}`); return x + 1; } > y vm51587:1 uncaught referenceerror: y is not defin...
... https://www.ecma-international.org/ecma-262/10.0/index.html#sec-strict-mode-code https://www.ecma-international.org/ecma-262/10.0/index.html#sec-arrow-function-definitions-runtime-semantics-evaluation correction: end invoked through call or apply since arrow functions do not have their own this, the methods call() and apply() can only pass in parameters. any this argument is ignor...
The arguments object - JavaScript
this technique is useful for functions that can be passed a variable number of arguments, such as math.min(). this example function accepts any number of string arguments and returns the longest one: function longeststring() { var longest = ''; for (var i=0; i < arguments.length; i++) { if (arguments[i].length > longest.length) { longest = arguments[i]; } } retu...
... string arguments and returns the longest one: function longeststring() { var longest = ''; for (var i=0; i < arguments.length; i++) { if (arguments[i].length > longest.length) { longest = arguments[i]; } } return longest; } you can use arguments.length to count how many arguments the function was called with. if you instead want to count how many parameters a function is
declared to accept, inspect that function's length property. using typeof with arguments the typeof operator returns 'object' when used with arguments console.log(typeof arguments); // 'object' the type of individual arguments can be determined by indexing arguments: console.log(typeof arguments[0]); // returns the type of the first argument properties arguments.callee reference to the current...
Function.prototype.bind() - JavaScript
rgument is ignored) with settimeout() by default within window.settimeout(), the this keyword will be set to the window (or global) object. when working with class methods that require this to refer to class instances, you may explicitly bind this to the callback function, in order to maintain the instance. ...
... to the window (or global) object. when working with class methods that require this to refer to class instances, you may explicitly bind this to the callback function, in order to maintain the instance. function latebloomer() { this.petalcount = math.floor(math.random() * 12) + 1; } //
declare bloom after a delay of 1 second latebloomer.prototype.bloom = function() { window.settimeout(this.
declare.bind(this), 1000); }; latebloomer.prototype.
declare = function() { console.log(`i am a beautiful flower with ${this.petalcount} petals!`); }; const flower = new latebloomer(); flower.bloom(); // after 1 second, calls 'flower.
declare()' bound functions used as constructors warning: this section demonstrates javascript capabilities and documents some edge cases of the bind() method. the m...
WebAssembly.instantiate() - JavaScript
promise<resultobject> webassembly.instantiate(buffersource, importobject); parameters buffersource a typed array or arraybuffer containing the binary code of the .wasm module you want to compile. importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects. there must be one matching property for each
declared import of the compiled module or else a webassembly.linkerror is thrown. return value a promise that resolves to a resultobject which contains two fields: module: a webassembly.module object representing the compiled webassembly module. this module can be instantiated again, shared via postmessage() or cached in indexeddb. instance: a webassembly.instance object that contains all the expo...
...dary overload — taking a module object instance promise<webassembly.instance> webassembly.instantiate(module, importobject); parameters module the webassembly.module object to be instantiated. importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects. there must be one matching property for each
declared import of module or else a webassembly.linkerror is thrown. return value a promise that resolves to an webassembly.instance object. exceptions if either of the parameters are not of the correct type or structure, a typeerror is thrown. if the operation fails, the promise rejects with a webassembly.compileerror, webassembly.linkerror, or webassembly.runtimeerror, depending on the cause of...
undefined - JavaScript
== undefined also checks whether x is null, while strict equality doesn't. this is because null is not equivalent to undefined. see comparison operators for details. typeof operator and undefined alternatively, typeof can be used: var x; if (typeof x === 'undefined') { // these statements execute } one reason to use typeof is that it does not throw an error if the variable has not been
declared. // x has not been
declared before if (typeof x === 'undefined') { // evaluates to true without errors // these statements execute } if (x === undefined) { // throws a referenceerror } however, there is another alternative. javascript is a statically scoped language, so knowing if a variable is
declared can be read by seeing whether it is
declared in an enclosing context. the global...
... ...
delete operator - JavaScript
s important to consider the following scenarios: if the property which you are trying to delete does not exist, delete will not have any effect and will return true. if a property with the same name exists on the object's prototype chain, then, after deletion, the object will use the property from the prototype chain (in other words, delete only has an effect on own properties). ...
... non-configurable properties cannot be removed. this includes properties of built-in objects like math, array, object and properties that are created as non-configurable with methods like object.defineproperty(). ...
export - JavaScript
modules to export live bindings to functions, objects, or primitive values from the module so they can be used by other programs with the import statement. bindings that are exported can still be modified locally; when imported, although they can only be read by the importing module the value updates whenever it is updated by the exporting module. exported modules are in strict mode whether you
declare them as such or not. the export statement cannot be used in embedded scripts. syntax there are two types of exports: named exports (zero or more exports per module) default exports (one per module) // exporting individual features export let name1, name2, …, namen; // also var, const export let name1 = …, name2 = …, …, namen; // also var, const export function functionname(){...} ...
...port2 as name2, …, namen } from …; export { default } from …; namen identifier to be exported (so that it can be imported via import in another script). description there are two different types of export, named and default. you can have multiple named exports per module but only one default export. each type corresponds to one of the above syntax: named exports: // export features
declared earlier export { myfunction, myvariable }; // export individual features (can export var, let, // const, function, class) export let myvariable = math.sqrt(2); export function myfunction() { ... }; default exports: // export feature
declared earlier as default export { myfunction as default }; // export individual features as default export default function () { ... } export default class {...
import - JavaScript
the import statement cannot be used in embedded scripts unless such script has a type="module". bindings imported are called live bindings because they are updated by the module that exported the binding. there is also a function-like dynamic import(), which does not require scripts of type="module". backward compatibility can be ensured using attribute nomodule on the <script> tag. ...
... have a default export (whether it is an object, a function, a class, etc.). the import statement may then be used to import such defaults. the simplest version directly imports the default: import mydefault from '/modules/my-module.js'; it is also possible to use the default syntax with the ones seen above (namespace imports or named imports). in such cases, the default import will have to be
declared first. for instance: import mydefault, * as mymodule from '/modules/my-module.js'; // mymodule used as a namespace or import mydefault, {foo, bar} from '/modules/my-module.js'; // specific, named imports when importing a default export with dynamic imports, it works a bit differently. you need to destructure and rename the "default" key from the returned object. (async () => { if (someth...
switch - JavaScript
take a look at this example: const action = 'say_hello'; switch (action) { case 'say_hello': let message = 'hello'; console.log(message); break; case 'say_hi': let message = 'hi'; console.log(message); break; default: console.log('empty action received.'); break; } this example will output the error uncaught syntaxerror: identifier ...
... this is because the first let message = 'hello'; conflicts with second let statement let message = 'hi'; even they're within their own separate case clauses case 'say_hello': and case 'say_hi':. ultimately, this is due to both let statements being interpreted as duplicate declarations of the same variable name within the same block scope. we can easily fi...
Index - XSLT: Extensible Stylesheet Language Transformations
g stylesheet. 35 <xsl:include> element, reference, xslt, include the <xsl:include> element merges the contents of one stylesheet with another. unlike the case of <xsl:import>, the contents of an included stylesheet have exactly the same precedence as the contents of the including stylesheet. 36 <xsl:key> element, key, reference, xslt the <xsl:key> element
declares a named key which can be used elsewhere in the stylesheet with the key( ) function. 37 <xsl:message> element, reference, xslt, message the <xsl:message> element outputs a message (to the javascript console in ns) and optionally terminates execution of the stylesheet. it can be useful for debugging. 38 <xsl:namespace-alias> element, reference, xslt, namespace-a...
...transform the <xsl:transform> element is exactly equivalent to the <xsl:stylesheet> element. 51 <xsl:value-of> element, reference, xslt, value-of the <xsl:value-of> element evaluates an xpath expression, converts it to a string, and writes that string to the result tree. 52 <xsl:variable> element, reference, xslt, variable the <xsl:variable> element
declares a global or local variable in a stylesheet and gives it a value. because xslt permits no side-effects, once the value of the variable has been established, it remains the same until the variable goes out of scope 53 <xsl:when> element, reference, xslt, when the <xsl:when> element always appears within an <xsl:choose> element, acting like a case statement. 54 <xsl:...
platform/xpcom - Archive of obsolete content
ion() { console.log('suspending...'); }, cancel: function() { console.log('canceling...'); } }); this component definition: specifies that we support nsirequest using the interfaces property. initializes pending in initialize() adds our implementation of the nsirequest interface although request also implements nsisupports, there is no need to add it here, because the base class unknown
declares support for nsisupports and this is accounted for when retrieving objects. we can register a factory for this component by using the factory class to associate its constructor with its contract id: var { factory } = require('sdk/platform/xpcom'); var { cc, ci } = require('chrome'); var contractid = '@me.org/request' // create and register the factory var factory = factory({ contract: contra...
Creating annotations - Archive of obsolete content
e content script a message with the current activation status add the worker to an array called selectors so we can send it messages later on assign a message handler for messages from this worker. if the message is show we will just log the content for the time being. if the message is detach we remove the worker from the selectors array. ...
Forms related code snippets - Archive of obsolete content
</p> </form> </body> </html> note: the current implementation of const (constant statement) is not part of ecmascript 5. it is supported in firefox & chrome (v8) and partially supported in opera 9+ and safari. it is not supported in internet explorer 6-9, or in the preview of internet explorer 10. const is going to be defined by ecmascript 6, but with different semantics. similar to variables
declared with the let statement, constants
declared with const will be block-scoped. we used it only for didactic purpose. if you want a full browser compatibility of this library, please replace all the const statements with the var statements. this date-picker code snippet will automatically create an html code like the following: <table id="zdp-cal-1" class="zdp-calendar" style="z-index: 1026; posi...
HTML to DOM - Archive of obsolete content
the most interesting piece of code here is the domcontentloaded event listener we define for the element. let's take a look at the donkeyfire.donkeybrowser_onpageload() handler: donkeybrowser_onpageload: function(aevent) { var doc = aevent.originaltarget; var url = doc.location.href; if (aevent.originaltarget.nodename == "#document") { // ok, it's a real page, let's do our ...
Rosetta - Archive of obsolete content
nt must be a function"); } if (!array.isarray(vmimetypes)) { odicts[(vmimetypes).tostring()] = fcompiler; return true; } for (var nidx = 0; nidx < vmimetypes.length; nidx++) { odicts[(vmimetypes[nidx]).tostring()] = fcompiler; } return true; }; })(); now, imagine you need a compiler for scripts written in c (mime type: text/x-c). first, you should
declare a function which will translate an input plain-text written in c to an output plain-text written in ecmascript. let us call this function createecmasrc() and let us associate it with the c mime types: rosetta_c.js: a c compiler /* c compiler for rosetta */ (function () { if (!window.rosetta) { return; } /* this function takes as argument a plain text (in this case, a code written in c) ...
Sidebar - Archive of obsolete content
requestor) .getinterface(components.interfaces.nsidomwindow); mainwindow.document.getelementbyid("sidebar-box").width=newwidth; } or function setsidebarwidth(newwidth) { window.top.document.getelementbyid("sidebar-box").width=newwidth; } you can also disable the ability to resize it manually, using the mouse, by hiding the sidebar's splitter element. for this snippet to work, you have to
declare mainwindow as in the previous code block then write: mainwindow.document.getelementbyid("sidebar-splitter").hidden = true; be aware that if you change the splitter's hidden attribute, you need to reset it to a safe value when your sidebar is closed, or replaced by another sidebar. for example, use this in your sidebar's unload event handler: mainwindow.document.getelementbyid("sidebar-splitte...
JavaScript Daemons Management - Archive of obsolete content
nternet explorer (which doesn't support sending additional parameters to timers' callback function, neither with settimeout() or setinterval()) we included the ie-specific compatibility code (commented code), which enables the html5 standard parameters' passage functionality in that browser for both timers (polyfill), at the end of the daemon.js module. daemon.js what follows is the module that
declares the daemon constructor (the core of this framework). the daemon constructor itself is nothing but a clone of the little framework minidaemon with added support for init and onstart functions (declarable during the instantiation of the daemon). so the minidaemon framework will remain the recommended way for simple animations, because daemon without its collection of methods is essentially a clone...
getAttributeNS - Archive of obsolete content
devalue; } } thisitem = thisitem.parentnode; } } } return ''; // if not found (some implementations return 'null' but this is not standard) } alert(getattributenswrapper (someelement, 'http://www.w3.org/1999/xlink', 'href')); // gets xlink:href, xl:href, etc. on current element, conditionally on whether its prefix matches a
declared namespace see also http://www.w3.org/tr/dom-level-3-cor...mespaceurialgo ...
Extension Etiquette - Archive of obsolete content
other code, and that it be indicative of the name of your add-on. generic prefixes such as myextension-, or short prefixes such as ffx-, are likely to be used elsewhere, and therefore unsuitable to the purpose. call .noconflict(true) where applicable many common libraries which create global variables provide a method called noconflict, or similar, which revert any global variables they've
declared, and return the object itself. for instance, calling jquery.noconflict(true) will remove the window.jquery and window.$ variables, and return the jquery object itself, for future use by the caller. when available, these methods should always be used to prevent conflicts with third-party code. names and metadata naming be creative! don't be redundant and include "extension," "mozilla/fire...
Install Manifests - Archive of obsolete content
base directory of the add-on. this allows your add-on's icon to be displayed even when the add-on is disabled, or if the manifest is missing an icon64url entry. localized allows you to localize the add-on's name, description, contributors and other metadata. the localized description must specify at least one em:locale which indicates which locales to use this information for. examples this
declares a set of add-on metadata to be displayed when the application is running in the de-de locale. <em:localized> <description> <em:locale>de-de</em:locale> <em:name>tab sidebar</em:name> <em:description>zeigt in einer sidebar vorschaubilder der inhalte aller offenen tabs an.</em:description> </description> </em:localized> the following properties which are described elsewhere in th...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
urself. the adopt and getter_copies methods do not work on abstract strings. instead of passing getter_copies(astring) to a method expecting a character pointer out parameter, you will need to use a temporary variable and copy the result.missing headers some headers are included from idl files only when mozilla_internal_api is defined (actually, they shouldn't be there at all). for errors about un
declared do_createinstance: #include "nscomponentmanagerutils.h" for errors about un
declared do_getservice: #include "nsservicemanagerutils.h" for errors about un
declared ns_getspecialdirectory: #include "nsdirectoryserviceutils.h" utility classes some utility classes could previously be created with ns_new* utility functions. these classes must now be created using xpcom: // nsisupportsarray is bad...
Multiple item extension packaging - Archive of obsolete content
for its install.rdf. the only required properties are em:id, em:targetapplication, and em:type. for the firefox and thunderbird 1.5 extension manager to determine that the package is a multiple item package, the em:type specified in your install.rdf must be 32 and specified as <em:type nc:parsetype="integer">32</em:type>. the xml namespace xmlns:nc="http://home.netscape.com/nc-rdf#" must also be
declared in your install.rdf as shown below. ... <rdf xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:nc="http://home.netscape.com/nc-rdf#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <description about="urn:mozilla:install-manifest"> <!-- nsiupdateitem type for a multiple item package --> <em:type nc:parsetype="integer">32</em:type> ... for the firefox and thunderbir...
Appendix B: Install and Uninstall Scripts - Archive of obsolete content
ed in the handling preferences section. so, if we were to use fuel, we can do the following in the init function: init : function() { let firstrunpref = "extensions.xulschoolhello.firstrundone"; if (!application.prefs.getvalue(firstrunpref, false)) { application.prefs.setvalue(firstrunpref, true); // all the rest of the first run code goes here. } } in this case you would need to
declare the first run preference in your default preferences file, with a default value of false. you should also change the preference value before you run any other first run code. keep in mind that the user could have set multiple firefox windows to open at startup, so there's a race condition on which window will run the first run code. if you need to run code on every update, or some of them, the c...
Using the Stylesheet Service - Archive of obsolete content
tup via the category manager stylesheets may also be registered on startup via the agent-style-sheets and user-style-sheets categories. the category names are ignored, and the values are the uris from which to load the stylesheets. the order the sheets are applied in is undefined. usage notes stylesheets added using this service get applied to both chrome and content documents. remember to
declare the correct namespace if you want to apply stylesheets to xul documents. registered style sheets are not remembered across restarts. loadandregistersheet fails if css contains #id. '#' must be percent-encoded, details see bug 659650. historical information nsistylesheetservice was introduced in firefox 1.5. in firefox 1.5 and 2, adding and removing such style sheets takes effect upon the nex...
An Interview With Douglas Bowman of Wired News - Archive of obsolete content
means content in one column begins to overlap another column. both of these put together weren't enough to dissuade me from the advantages of positioning over floats. how does the new design perform when the pages are printed? we have one css file specifically set up to cover most of the content throughout our pages for print media. by default, all links to screen media css files are explicitly
declared as "screen" media instead of "all" media. by doing this, we don't have to override any of the screen styles, giving us a blank slate to start with for print styles. the print styles present the page content in one column, rather than splitting content up into two or three columns. it also eliminates most of the background colors and images to save on printer ink. fonts are sized in point (pt) un...
Getting the page URL in NPAPI plugin - Archive of obsolete content
at that page url, i.e. the url of the html which embeds the plugin, i.e. which caused the plugin to load? there are at least 3 solutions (quoting newsgroup posts): via window location from robert platt: // get the dom window object. npn_getvalue( m_pnpinstance, npnvwindownpobject, &swindowobj ); // create a "location" identifier. npidentifier identifier = npn_getstringidentifier( "location" ); //
declare a local variant value. npvariant variantvalue; // get the location property from the window object (which is another object). bool b1 = npn_getproperty( m_pnpinstance, swindowobj, identifier, &variantvalue ); // get a pointer to the "location" object. npobject *locationobj = variantvalue.value.objectvalue; // create a "href" identifier. identifier = npn_getstringidentifier( "href" ); // get the l...
JXON - Archive of obsolete content
= /^(?:true|false)$/i; })(); note: the current implementation of const (constant statement) is not part of ecmascript 5. it is supported in firefox & chrome (v8) and partially supported in opera 9+ and safari. it is not supported in internet explorer 6-9, or in the preview of internet explorer 10. const is going to be defined by ecmascript 6, but with different semantics. similar to variables
declared with the let statement, constants
declared with const will be block-scoped. we used it only for didactic purpose. if you want a full browser compatibility of this library, please replace all the const statements with the var statements. usage the obtained non-native jxon global object will have two methods: method description jxon.build(document[, verbosity[, freeze[, nes...
Dehydra Function Reference - Archive of obsolete content
provided by the analysis script and will be called by dehydra while compiling. see the dehydra object reference for details on the available object properties. process_type(type) dehydra calls this for each class, struct, enum, union, and typedef declaration. process_type is called after process_function is called for all the member functions. type is a type object representing the type that was
declared. process_function(decl, body) dehydra calls this for each function definition (declarations without bodies are not included), including both top-level functions, class member functions, and inline class member functions. decl is a variable type object representing the function being processed body is an array of {loc:, statements:array of variable types} representing an outline of the function...
Building Firefox with Rust code - Archive of obsolete content
to live in-tree. the build system will check that there's only one copy of a given crate in a build; this was a deliberate decision to try and avoid code bloat in libxul. if this turns out to be a serious problem in practice, we can look into ways of relaxing that check. if you need to locally patch a third-party crate, you'll need to add a [replace] section to the referencing cargo.toml to
declare that the vendored source shouldn't match the upstream release. this works even if you use the existing vendored source location, but be aware that other vendor updates could clobber your patch in that case. testing rust code there's a simple linkage unit test in the tree. you can use it to check that rust is enabled and working with your build setup. ./mach gtest rust.* look for the rust.cal...
Style System Overview - Archive of obsolete content
text api allows data to be obtained through a set of structs (see nsstylestruct.h). a struct for a style context can be obtained through nsistylecontext::getstyledata. nsiframe::getstyledata does the same thing for the frame's mstylecontext member, and the global ::getstyledata is a typesafe helper that doesn't require the style struct id. this style struct is always const, and should always be
declared as such (evil old-style casts often used with the non-typesafe forms sometimes hide this error), since the struct may be shared with other elements. the rule tree as we call nsrulewalker::forward on all the rules that are matched, we build or walk along the rule tree. the rule tree is a lexicographic tree of matched rules, where each node in the tree is represented by a nsrulenode. some s...
GRE - Archive of obsolete content
libraries. if you link directly against xpcom.dll/libxpcom.so (xpcom.lib import lib), your application will not launch unless xpcom.dll is in your path. this prevents dynamically finding a compatible gre at runtime. find a compatible gre note: support for locating a standalone glue was removed in gecko 6.0. to find a compatible gre, you should use the function gre_getgrepathwithproperties() (
declared in xpcom/glue/standalone/nsxpcomglue.h). this allows the embedder to specify what version(s) of gre are appropriate, and to specify any special features the gre must have (currently there are no special features defined). statically link to xpcomglue.lib (the "standalone glue") the solution is to statically link against xpcomglue.lib, also known as the "standalone glue" (see xpcom glue). this ...
JavaScript OS.Shared - Archive of obsolete content
char jschar int unsigned_int int32_t uint32_t int64_t uint64_t long bool off_t size_t ssize_t fd (unix only) negativeone_or_fd (unix only) negativeone_or_nothing (unix only) string (unix only) null_or_string (unix only) handle (windows only) maybe_handle (windows only) dword (windows only) negative_or_dword (windows only) zero_or_dword (windows only) zero_or_nothing (windows only)
declareffi() intn_t() uintn_t()instances of os.shared.type convert_from_c() releasewith() attributes global object os.shared.hollowstructure in_ptr out_ptr inout_ptr ...
jspage - Archive of obsolete content
r q=[];while(o){if(o.nodetype==1&&(!m||element.match(o,m))){if(!p){return document.id(o,r); }q.push(o);}o=o[l];}return(p)?new elements(q,{ddup:false,cash:!r}):null;};var e={html:"innerhtml","class":"classname","for":"htmlfor",defaultvalue:"defaultvalue",text:(browser.engine.trident||(browser.engine.webkit&&browser.engine.version<420))?"innertext":"textcontent"}; var b=["compact","nowrap","ismap","
declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"];var k=["value","type","defaultvalue","accesskey","cellpadding","cellspacing","colspan","frameborder","maxlength","readonly","rowspan","tabindex","usemap"]; b=b.associate(b);hash.extend(e,b);hash.extend(e,k.associate(k.map(string.tolowercase)));var a={before:function(m,l){if(l.parentnode){l.parentnode.insertbefore...
Modularization techniques - Archive of obsolete content
ng and binding interfaces, all classes and interfaces are assigned unique ids. the ids are unique 128 bit numbers that are based on uuids. for those who like gory details, their structure is this: struct nsid { pruint32 m0; pruint16 m1, m2; pruint8 m3[8]; }; frequently you see them represented as strings, like this: {221ffe10-ae3c-11d1-b66c-00805f8a2676} to initialize an id struct you
declare them like this: id = {0x221ffe10, 0xae3c, 0x11d1, {0xb6, 0x6c, 0x00, 0x80, 0x5f, 0x8a, 0x26, 0x76}}; why the b66c couplet gets broken up and grouped with the last set of bytes is probably a footnote somewhere. on windows you can use the programs uuidgen and guidgen, which ship with visual c++, to generate ids. a simple example it is recommended that you use xpidl to define your inter...
Plug-n-Hack - Archive of obsolete content
of these steps are carried out incorrectly then the browser will typically fail to connect to any website – debugging such problems can be frustrating and time-consuming. without integration between security tools and browsers, a user must often switch between the tool and their browser several times to perform a simple task, such as intercepting an http(s) request. pnh allows security tools to
declare the functionality that they support which is suitable for invoking directly from the browser. a browser that supports pnh can then allow the user to invoke such functionality without having to switch to and from the tool. while some of the pnh capabilities do have a fixed meaning, particularly around proxy configuration, most of the capabilities are completely generic, allowing tools to expose wh...
Space Manager Detailed Design - Archive of obsolete content
ry goal of the space manager is to provide information about those bands of space to support the css notion of floated elements. there are three important parts to the space manager api: the parts that deal with the coordinate space of the space manager, the parts that deal with the regions managed by the space manager, and the parts that manage float impact intervals. the class nsspacemanager is
declared in the file nsspacemanger.h. the class is only used in the layout module and cannot be exported outside of that module (nor does it need to be). it is not a general purpose class, and is not intended to be subclasses . here is the class declaration, taken from the source file as of 01.08.02 /** * class for dealing with bands of available space. the space manager * defines a coordinate space w...
Space Manager High Level Design - Archive of obsolete content
should be private (compiles fine) nsblockframe::paint is mucking with nsblockbanddata in and #if 0 block - remove that and the include (compiles fine) nsspacemanger has no way of clearing the float damage interval set - this might be needed if the spacemanager persists beyond a reflow original document information author(s): marc attinasi other con...
String Quick Reference - Archive of obsolete content
assignwithconversion() nsautostring widestring; widestring.assignwithconversion("some string"); callwidefunction(widestring); // use widestring again, but need a const prunichar* callwidewithflatstring(widestring.get()) nsautostring widestring2; widestring2.assignwithconversion("another string"); callwidefunction(widestring2); new way: use ns_literal_string or ns_named_literal_string // pre-
declare the variable if you'll use it multiple times ns_named_literal_string(widestring, "some string"); callwidefunction(widestring); // use widestring again, but need a const prunichar* callwidewithflatstring(widestring.get()); // inline the string with ns_literal_string callwidefunction(ns_literal_string("another string")); converting literal strings to string objects what: converting from cons...
Tamarin-central rev 703:2cee46be9ce0 - Archive of obsolete content
the announcement sent to tamarin-devel can be read here. testing summary acceptance tests have passed on the following supported platforms: * windows, 32 & 64 bit * mac ox x ppc & intel, 32 bit * linux, 32 bit * windows mobile arm version asc-4200 of the actionscript compiler was used for all tests. performance testsuite time metric the following is a comparison of the current tamarin-central (tc-703) versus the prior build (tc-700) as well as current against the vm in flash player 10. the key takeaway is that the interpreter is much improved. ...
Venkman Introduction - Archive of obsolete content
r is stopped, the local variables view displays values for the current function. the scope object holds all arguments and local variables, and the this object holds the value of the this keyword. e enumerable property r read only property p permanent (cannot be deleted) a alias to another property a argument to a function v
declared with var figure 8. property flags properties of both scope and this objects are listed alphabetically, grouped by data type. figure 9 shows which icons represent which data types. properties which are of the type object are displayed with the name of their constructor function in curly braces as their value. you can locate the source code of the constructor by selecting "find construc...
Binding Implementations - Archive of obsolete content
can be specified using the src attribute. when the src attribute is specified, any children of the implementation element are ignored. methods methods are defined using the method element. the name given on the tag using the name attribute is the name that can be used to invoke the method on the element. a method with parameters specifies those parameters and their names with parameter elements
declared underneath the method element. the implementation of the method is contained inside a body element. the parameters specified are bound to their names in the method body. <method name="scrolltoindex"> <parameter name="index"/> <body> <![cdata[ if (index < 0) return; ... ]]> </body> </method> properties properties can also be defined on the bound element usin...
Additional Navigation - Archive of obsolete content
df:description> <rdf:description about="http://www.daml.org/2001/09/countries/iso#it" dc:title="italy"/> <rdf:description about="http://www.daml.org/2001/09/countries/iso#nl" dc:title="netherlands"/> </rdf:rdf> a new country predicate has been added to each photo pointing to another resource. note that this predicate uses a new namespace so it is
declared on the root rdf element. the titles of the two countries are defined near the end of the rdf data. now that we have countries for each photo, instead of starting at the node 'http://www.xulplanet.com/rdf/myphotos', we could start at a country resource and look for all photos that point to that country. the ref attribute will need to be changed to point to the country resource rather than the seq...
Filtering - Archive of obsolete content
examples of generating results from a container. an rdf type can be assigned to a node by using the predicate 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' set to a resource for that type. in rdf/xml, a syntax shortcut may be used which involves replacing the description tag with the type. we need to add the type to the two countries in the datasource, as well as ensure that the namespace is
declared on the root rdf tag: <nso:country about="http://www.daml.org/2001/09/countries/iso#it" dc:title="italy"/> <nso:country about="http://www.daml.org/2001/09/countries/iso#nl" dc:title="netherlands"/> the type of these two resources, when expanded with the namespace (not shown here), will be 'http://www.daml.org/2001/09/countries/country-ont#country'. the resulting rdf t...
Simple Query Syntax - Archive of obsolete content
bers are used here for the variable names, but they are really just randomly generated so you can't refer to them in any way. the member data, or results, are held in the variable represented here by '?2'. three matches have been found so the content will be duplicated three times. there are several attributes in the example xul content above that have values prefixed with 'rdf:'. since you can't
declare variables in the simple syntax, a different way is used to grab rdf data. the 'rdf:' prefix means look up a predicate pointing out of the node for that result (the child or member node). for example, the label's value attribute has a value of rdf:http://purl.org/dc/elements/1.1/title'. this means look up the value of the predicate http://purl.org/dc/elements/1.1/title' pointing out of the current...
Broadcasters and Observers - Archive of obsolete content
r elements. <broadcasterset> <broadcaster id="isoffline" label="offline"/> </broadcasterset> any elements that are watching the broadcaster will be modified automatically whenever the broadcaster has its label attribute changed. this results in these elements having a new label. like other non-displayed elements, the broadcasterset element serves as a placeholder for broadcasters. you should
declare all your broadcasters inside a broadcasterset element so that they are all kept together. making elements observers elements that are watching the broadcaster are called observers because they observe the state of the broadcaster. to make an element an observer, add an observes attribute to it. this is analogous to using the command attribute when attaching an element to a command element. for ...
Creating a Skin - Archive of obsolete content
good example.) you will notice that it has adopted the rules that we have added. some of the rules conflict with those already in the global stylesheets. for example, rules are already defined for buttons and tabs and so on and we defined additional rules for them. when changing the global skin, you would need to merge the changes into the existing rules. for the best skinnability, it is best to
declare appearance related style rules in the global directory rather than in individual style files. this includes colors, fonts and general widget appearances. if you change the color of something in a local skin file (such as findfile.css), the dialog may look odd if the user changes their global skin. don't expect the user to be using the default one. our find files example with this skin: source v...
Cross Package Overlays - Archive of obsolete content
toolbox> .. '</span></code> section with that id. to add this overlay to the manifest file, we need to add two resources. first, we add one for each window that we are applying an overlay to. the code below should be added into contents.rdf just before the closing rdf tag. <rdf:seq about="urn:mozilla:overlays"> <rdf:li resource="chrome://navigator/content/navigator.xul"/> </rdf:seq> this
declares that we are adding a overlay window, a child of the root overlay node (urn:mozilla:overlays). you can add additional nodes for any other windows that you want to apply overlays to by adding additional li nodes. next, we add a node for each overlay to apply to the window. in this case, we only have one, but we could apply others also. add these lines just after the previous lines. <rdf:seq ab...
Custom Tree Views - Archive of obsolete content
celltext() compares the id property of the column argument to the text 'namecol'. this text 'namecol' corresponds to the id of the first treecol in the example above. this example is very simple of course -- in reality you would have more complex data in each cell. the final step is to associate the view object with the tree. the tree has a property view, which can be assigned to the view object
declared above. we can assign a value to this property at any time to set or change the view. function setview(){ document.getelementbyid('my-tree').view = treeview; } the following presents the example together. an inline script has been used here to simplify the example. normally, you would put the script in an external script file. example custom tree source <?xml version="1.0"?> <?xml-sty...
More Tree Features - Archive of obsolete content
to create a set of nested rows, all we need to do is add a second treechildren element inside the parent treeitem. you can then add items inside that to specify the child rows of an item. don't put the inner treechildren element inside the treerow as this won't work. you can repeat this process to create deeply nested trees. essentially, a treeitem element can contain either single rows which are
declared with the treerow element or a set of rows which are
declared with the treechildren element. there are two other things you need to do to make sure the hierarchy works properly. first, you need to mark the treeitem element that has children as a container. you do this by adding the container attribute to it as follows: <treeitem container="true" /> this allows the user to click on the row that c...
Popup Menus - Archive of obsolete content
popup menu with three commands on it has been created. the menupopup element surrounds the three menuitem elements. you will also notice that the id has been set on the menupopup element itself. the popupset element surrounds the entire popup menu declaration. this is a generic container for popups, and is optional. it does not draw on screen but instead is used as a placeholder where you would
declare all of your popups. as the name popupset implies, you can put multiple popup declarations inside it. just add additional ones after the first menupopup element. you can have more than one popupset in a file, but usually you will have only one. associating a popup with an element now that we've created the popup, it's time to make the popup appear. to do this we need to associate the popup with ...
Skinning XUL Files by Hand - Archive of obsolete content
rules have to do with borders, font information, color, margin, native appearance. in general, these are the types of styles that should be defined only in the global skin of an application, since these are the styles that give an application a certain overall look, or skin. note that for any one class of element, there may be several pseudo-classes andattribute selector styles defined. when you
declare a button in your xul to be of a particular class, you take advantage of all of the styles defined for the various states of that button. for this reason, it can be very efficient to use button classes that appear in the global skin and to make new classes only when necessary. browse through the global skin to familiarize yourself with what's there. in the next few sections, you will be importing...
XBL Attribute Inheritance - Archive of obsolete content
tton to be different for each use of the binding. in addition, changing the value of the attributes on the searchbox with a script will update the textbox and button also. you can add the inherits attribute to as many elements as you wish, to inherit any number of attributes. note how the inherits attribute has been placed in the xbl namespace, by prefixing it with 'xbl:'. the namespace should be
declared somewhere earlier, usually on the bindings element. the next example demonstrates this. <bindings xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <xbl:binding id="buttonbinding"> <xbl:content> <xul:button label="ok" xbl:inherits="label"/> </xbl:content> </xbl:binding> in this example, the button inherits the la...
Using Visual Studio as your XUL IDE - Archive of obsolete content
implemented localization: < !doctype window system "chrome://loomo/locale/main.dtd"> visual studio doesn't recognize the chrome uri prefix, what will give you an error at the previous line ("the uri prefix is not recognized"). as vs doesn't know how the chrome protocol works it can't detect where the dtd file is really located and thus will give you errors wherever you use the entities that are
declared in this file. 5.2 text preprocessor the mozilla build system includes a text preprocessor. as preprocessor directives are not valid xml, visual studio will mark them as errors in your xul files. 5.3 javascript related you will get validation errors for javascript code whenever using the keywords "const" and "let". these keywords are mozilla-specific at the moment. vs just supports ecmascript 3rd...
Using multiple DTDs - Archive of obsolete content
assume you have an entity okbutton.label defined in file common.dtd. then accessing entities from both dtds would look like this: <button id="somebutton" label="&somebutton.label"> ... <button id="okbutton" label="&okbutton.label"> note that there is no such thing as namespaces with multiple dtds. you have to make sure by yourself that the entities defined in the v...
XML - Archive of obsolete content
of xul: all events and attributes must be written in lowercase. unlike html, xul is very sensitive to case. all of the events and attributes -- even the javascript event listeners normally formatted in the javascript world with uppercase verbs (e.g., onclick, onload) -- must be lowercase or they are invalid. all strings must be double quoted. all of the values for all of the attributes
declared in xul are strings. when an attribute is assigned a value (e.g., flex="1" or "onload='dointerestingstartupthing()'") that value must be double-quoted. every xul widget must use close tags to be well-formed. html allows some elements, such as <br> and <hr>, to be neither closed nor matched with a closing element. in xul, elements must either be of the form <tag></tag> or <tag/> to be valid. ...
assign - Archive of obsolete content
« xul reference home [ examples | attributes | properties | methods | related ] for xml templates, specifies an additional variable to assign a value to. for more information, see xml_assignments attributes expr, var examples (example needed) attributes expr type: string for xml queries, an xpath expression which returns results. any namespace prefixes
declared on the element may be used within the expression. var type: string for the xul assign attribute, this is the variable to assign the value to; otherwise it's a reference to a template variable such as "?name". inherited from xul element align, allowevents, allownegativeassertions, class, coalesceduplicatearcs, collapsed, container, containment, context, contextmenu, datasources, dir, empty, equa...
preference - Archive of obsolete content
this element must be placed inside a preferences element. each preference element corresponds to a preference which is stored in the user's preferences file. you can connect a user interface element such as a checkbox to a preference element using the user interface element's preference attribute. more information is available in the preferences system article. ...
prefwindow - Archive of obsolete content
it is, it specifies the default button in the dialog. typically, this means that the button will be activated when the enter key is pressed. this should be set to one of the same values as those for the buttons attribute. instantapply (readonly) indicates whether the window is in "instant apply" mode. the value is read from browser.preferences.instantapply boolean user preference. (?? it's
declared as a <field>, so you can set the value, however i don't believe it's valid to do that.) lastselected type: string set this to the id of the last selected pane. it will be opened by default the next time the preferences dialog is opened. preferencepanes type: dom nodelist holds a list of all the prefpane elements in the window. type type: string gets and set...
query - Archive of obsolete content
t element as well as member and/or triple elements. for xml datasources, the query should have an expr attribute and may optionally contain assign elements. for sql datasources, the query should contain an sql statement as text. attributes expr examples (example needed) attributes expr type: string for xml queries, an xpath expression which returns results. any namespace prefixes
declared on the element may be used within the expression. inherited from xul element align, allowevents, allownegativeassertions, class, coalesceduplicatearcs, collapsed, container, containment, context, contextmenu, datasources, dir, empty, equalsize, flags, flex, height, hidden, id, insertafter, insertbefore, left, maxheight, maxwidth, menu, minheight, minwidth, mousethrough, observes, ordinal, ...
rule - Archive of obsolete content
a rule may contain where, binding and/or action elements. a condition is defined used a where element. for each result that matches all of the conditions, content within the rule's action body is generated. the bindings element is optional and may specify additional variable bindings to be used. ...
script - Archive of obsolete content
you should usually put scripts in a separate file pointed to by the src attribute, but you may also place the script inline inside the opening and closing script tags. more information is available in the xul tutorial. attributes src, type examples <script src="test.js"/> <script src="http://example.com/js/test.js"/> <script> function foo(){ // code } </script> attributes src type: uri the uri of the script. ...
template - Archive of obsolete content
elements are constructed from a datasource. for more information see the rule element. more information is available in the xul tutorial. attributes container, member examples (example needed) attributes container type: string may optionally be set to the variable to use as the container or reference variable. if not specified, the variable specified in the uri attribute of the content tag in the template's first rule is used. ...
Dialogs in XULRunner - Archive of obsolete content
ike this on windows 2000, and will look similar on other operating systems: the first thing that caught my eye about dialog is the button-related attributes on the element. in an effort to make things easier for developers and more consistent for users, xul has a mechanism to automatically create and position the core dialog buttons ("ok," "cancel," and "help" for example). the developer just
declares the need for the button, the button's caption, and the access key for the button, as well as the javascript function to call if the button is pressed. xul handles placing and styling the buttons on the dialog. this is also nice for cross-platform applications, as each os has its own convention for where buttons should be placed on a dialog. here is a short list of the button attributes on dialo...
How to enable locale switching in a XULRunner application - Archive of obsolete content
bug #417961]. 2. include a xul control for the locale selection the next step is to add a xul control to your application which lists the available locales in the package and makes it possible for the user to select one of them. i chose a listbox with a button. screenshot of sample locale switching control 3. populate the xul control with the available locales the available package locales are
declared in the chrome manifest. sample chrome/chrome.manifest content localeswitchdemo content/ locale localeswitchdemo de-de locale/de-de/ locale localeswitchdemo en-gb locale/en-gb/ locale localeswitchdemo fr-fr locale/fr-fr/ how are you going to populate the xul listbox? you can hardwire the choices into the xul code using fixed list items, or could take the elegant approach and construc...
XULRunner tips - Archive of obsolete content
useful chrome urls most of these require branding. window url window type extension manager chrome://mozapps/content/extensions/extensions.xul?type=extensions extension:manager-extensions theme manager chrome://mozapps/content/extensions/ex...
2006-10-13 - Archive of obsolete content
cover toolbars from a popup window that disables it. user suggests 3 ways, and suggests a default. (no responses as of yet) selected tab looks too close to unselected tab discussion about how to change the colour of a selected tab and an unselected tab. it's suggested that its a os problem in the desktop theme, as opposed to problem with firefox. nsapprunner.o compile error: some_const not
declared in scope compile error while compiling first build. user was conservative on what libraries they used, but now they have a compile error and can't make sense of it. no responses as of yet. firefox browser problem: width:30ex does not respect font discussion about a font rendering problem with firefox print on the firefox context menu user would like discussion about why the bug https://...
Adobe Flash - Archive of obsolete content
javascript strings. the description string is broken into an array of constituent strings based on an invocation of the match method with a regular expression that assumes that the string format will be in the format flash major rminor where major can be a major revision such as "5" or "6" and minor is the subsidiary version number. example 1 also creates a constant flashversionosxscriptable that
declares (arbitrarily) that macromedia will fix flash to be scriptable in mach-o browsers (on os x) by version 12. this is currently not the case, but 12 is a sufficiently high version number (current versions are version 6r.79) to allow for some leeway for fixing this down the road. when information about when this problem on mac os x will be addressed becomes available, the constant can be updated to r...
Building a Theme - Archive of obsolete content
df> sample@example.net - the id of the extension. this is a value you come up with to identify your extension in email address format (note that it should not be your email). make it unique. you could also use a guid. note: this parameter must be in the format of an email address, although it does not have to be a valid email address. (example.example.example) 4 - the type of the add-on. '4'
declares that it is installing a theme. if you were to install an extension it would be 2 (see install manifests#type for other type codes). {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - firefox's application id. 29.0 - the exact version number of the earliest version of firefox you're saying this extension will work with. never use a * in a minversion, it almost certainly will not do what you expect it to.
Scratchpad - Archive of obsolete content
to the mdn documentation for the symbol. executing once you've written your code, select the code you want to run. if you don't select anything, all the code in the window will be run. then choose the way you want the code to run using the buttons along the top, using the execute menu, or using the context menu. the code is executed in the scope of the currently selected tab. any variables you
declare outside of a function will be added to the global object for that tab. there are four execution options available. run when you choose the run option, the selected code is executed. this is what you'd use to execute a function or other code that manipulates the content of your page without needing to see the result. inspect the inspect option executes the code just like the run option; howe...
Array comprehensions - Archive of obsolete content
that filters just the even numbers, then creates an array containing their doubles: var numbers = [1, 2, 3, 21, 22, 30]; var doubledevens = [for (i of numbers) if (i % 2 === 0) i * 2]; console.log(doubledevens); // logs 4,44,60 the square brackets of an array comprehension introduce an implicit block for scoping purposes. new variables (such as i in the example) are treated as if they had been
declared using let. this means that they will not be available outside of the comprehension. the input to an array comprehension does not itself need to be an array; iterators and generators can also be used. even strings may be used as input; to achieve the filter and map actions (under array-like objects) above: var str = 'abcdef'; var consonantsonlystr = [for (c of str) if (!(/[aeiouaeiou]/).test(c...
Legacy generator function - Archive of obsolete content
you can also define functions using the function constructor with functionbody and at least one yield expression, and a legacy generator function expression. syntax function name([param,[, param,[..., param]]]) { [statements] } name the function name. param the name of an argument to be passed to the function. ...
New in JavaScript 1.5 - Archive of obsolete content
tead of capturing parentheses, (x). when non-capturing parentheses are used, matched subexpressions are not available as back-references. positive and negative lookahead assertions are supported. both assert a match depending on what follows the string being matched. the m flag has been added to specify that the regular expression should match over multiple lines. functions can now be
declared inside an if clause. functions can now be
declared inside an expression. ...
for each...in - Archive of obsolete content
tarting with firefox 57. please see warning: javascript 1.6's for-each-in loops are deprecated for migration help. the for each...in statement iterates a specified variable over all values of object's properties. for each distinct property, a specified statement is executed. syntax for each (variable in object) { statement } variable variable to iterate over property values, optionally
declared with the var keyword. this variable is local to the function, not to the loop. object object for which the properties are iterated. statement a statement to execute for each property. to execute multiple statements within the loop, use a block statement ({ ... }) to group those statements. description some built-in properties are not iterated over. these include all built-in methods...
Archived JavaScript Reference - Archive of obsolete content
w generator function based on an existing iterable object. however, it has been removed from the standard and the firefox implementation. do not use it!handler.enumerate()the handler.enumerate() method used to be a trap for for...in statements, but has been removed from the ecmascript standard in es2016 and is deprecated in browsers.legacy generator functionthe legacy generator function statement
declares legacy generator functions with the specified parameters.legacy generator function expressionthe function keyword can be used to define a legacy generator function inside an expression. to make the function a legacy generator, the function body should contain at least one yield expression.microsoft javascript extensionsmicrosoft browsers (internet explorer, and in a few cases, microsoft edge) su...
JSException - Archive of obsolete content
the value that the javascript actually threw. javascript can throw any type of value. use getwrappedexception() to determine what kind of value the object return type represents. ...
Common causes of memory leaks in extensions - Extensions
mpartments will live for the whole life of the session. a similar problem is holding onto window objects or dom nodes (such as window.document) for too long by storing them in a javascript module. for example: var windows = []; function injavascriptcodemodule(window) { // forgetting or failing to pop the window again windows.push(window); } both of these cases can happen if you forget to
declare local variables with var or let, which means they end up belonging to the global scope. for example: function implicitdeclarationleak(window) { // implicit variable declaration in the js global, holding a strong ref to the document doc = window.document; } implicitly
declared variables can be avoided by using ecmascript 5's strict mode. strict mode also excludes several other error-prone ...
Anatomy of a video game - Game development
le continues from the previous line. the leading semicolon * marks the beginning of our new line if the previous one was not empty or terminated. * * let us also assume that mygame is previously defined. */ ;(function () { function main() { mygame.stopmain = window.requestanimationframe( main ); // your main loop contents } main(); // start the cycle })(); we now have a variable
declared in our mygame namespace, which we call stopmain, that contains the id returned from our main loop's most recent call to requestanimationframe(). at any point, we can stop the main loop by telling the browser to cancel the request that corresponds to our token. window.cancelanimationframe( mygame.stopmain ); the key to programming a main loop, in javascript, is to attach it to whatever event sh...
Efficient animation for web games - Game development
things multiple times per frame. we would recommend keeping track of when requestanimationframe has been called and only having a single handler for it. there aren’t solid guarantees of what order things will be called in with requestanimationframe (though, in our experience, it is in the order in which they were requested), so this also helps cut out any ambiguity. an easy way to do this is to
declare your own refresh function that sets a flag when it calls requestanimationframe. when the callback is executed, you can unset that flag so that calls to that function will request a new frame again, like this: function redraw() { drawpending = false; // do drawing ... } var drawpending = false; function requestredraw() { if (!drawpending) { drawpending = true; requestanimationframe...
Build the brick field - Game development
etting up the brick variables the overall aim of this lesson is to render a few lines of code for the bricks, using a nested loop that works through a two-dimensional array. first however we need to set up some variables to define information about the bricks such as their width and height, rows and columns, etc. add the following lines to your code below the variables which you have previously
declared in your program. var brickrowcount = 3; var brickcolumncount = 5; var brickwidth = 75; var brickheight = 20; var brickpadding = 10; var brickoffsettop = 30; var brickoffsetleft = 30; here we've defined the number of rows and columns of bricks , their width and height, the padding between the bricks so they won't touch each other and a top and left offset so they won't start being drawn right f...
Finishing up - Game development
.html. there's always room for improvements in any game we write. for example, we can offer more than one life to the player. they could make a mistake or two and still be able to finish the game. we could also improve our code rendering. giving the player some lives implementing lives is quite straightforward. ...
Constructor - MDN Web Docs Glossary: Definitions of Web-related terms
a constructor belongs to a particular class object that is instantiated. the constructor initializes this object and can provide access to its private information. the concept of a constructor can be applied to most object-oriented programming languages. essentially, a constructor in javascript is usually
declared at the instance of a class. syntax // this is a generic default constructor class default function default() { } // this is an overloaded constructor class overloaded // with parameter arguments function overloaded(arg1, arg2, ...,argn){ } to call the constructor of the class in javascript, use a new operator to assign a new object reference to a variable. function default() { } // a new reference of a default object assigned to a // local variable defaultreference var de...
Function - MDN Web Docs Glossary: Definitions of Web-related terms
op(x + 1); }; //using ecmascript 2015 arrow notation const loop = x => { if (x >= 10) return; loop(x + 1); }; an immediately invoked function expressions (iife) is a function that is called directly after the function is loaded into the browser’s compiler. the way to identify an iife is by locating the extra left and right parenthesis at the end of the function’s definition. ...
Character encoding - MDN Web Docs Glossary: Definitions of Web-related terms
an encoding defines a mapping between bytes and text. a sequence of bytes allows for different textual interpretations. by specifying a particular encoding (such as utf-8), we specify how the sequence of bytes is to be interpreted. for example, in html we normally
declare a character encoding of utf-8, using the following line: <meta charset="utf-8"> this ensures that you can use characters from just about any human language in your html document, and they will display reliably. learn more general knowledge character encoding on w3c character encoding on wikipedia ...
undefined - MDN Web Docs Glossary: Definitions of Web-related terms
undefined is a primitive value automatically assigned to variables that have just been
declared, or to formal arguments for which there are no actual arguments. example var x; //create a variable but assign it no value console.log("x's value is", x) //logs "x's value is undefined" learn more general knowledge undefined value on wikipedia technical reference javascript data types and data structures ...
Web fonts - Learn web development
hat it does: font-family: this line specifies the name you want to refer to the font as. you can put this as anything you like, as long as you use it consistently throughout your css. src: these lines specify the paths to the font files to be imported into your css (the url part), and the format of each font file (the format part). the latter part in each case is optional, but it is useful to
declare it because it allows browsers to find a font they can use faster. multiple declarations can be listed, separated by commas — the browser will search through them and use the first one it can find that it understands — it is therefore best to put newer, better formats like woff2 earlier on, and older, not so good formats like ttf later on. the one exception to this is the eot fonts — they ar...
How can we design for all types of users? - Learn web development
xceeds the minimum standard (4.5:1) and should enable many visually-impaired people to read this page. font size you can specify font size on a website either through relative units or absolute units. absolute units absolute units are not proportionally calculated but refer to a size set in stone, so to speak, and are expressed most of the time in pixels (px). for instance, if in your css you
declare this: body { font-size:16px; } … you are telling the browser that whatever happens, the font size must be 16 pixels. modern browsers get around this rule by pretending that you're asking for "16 pixels when the user sets a zoom factor of 100%". yet, for many years internet explorer adamantly displayed 16 pixels as 16 pixels. in this case, zooming did nothing, even as late as internet explore...
Debugging HTML - Learn web development
or messages the error messages are usually helpful, but sometimes they are not so helpful; with a bit of practice you can work out how to interpret these to fix your code. let's go through the error messages and see what they mean. you'll see that each message comes with a line and column number to help you to locate the error easily. "consider adding a lang attribute to the html start tag to
declare the language of this document.": this is not an error but a warning. the recommendation is to always define a language, and this warning explains how to do it. "end tag li implied, but there were open elements" (2 instances): these messages indicate that an element is open that should be closed. the ending tag is implied, but not actually there. the line/column information points to the first li...
Responsive images - Learn web development
ser can immediately reject unsupported file types: <picture> <source type="image/svg+xml" srcset="pyramid.svg"> <source type="image/webp" srcset="pyramid.webp"> <img src="pyramid.png" alt="regular pyramid built from four equilateral triangles"> </picture> do not use the media attribute, unless you also need art direction. in a <source> element, you can only refer to images of the type
declared in type. use comma-separated lists with srcset and sizes, as needed. active learning: implementing your own responsive images for this active learning, we're expecting you to be brave and go it alone ... mostly. we want you to implement your own suitable art directed narrow screen/wide screen shot using <picture>, and a resolution switching example that uses srcset. write some simple html...
Making asynchronous programming easier with async and await - Learn web development
or even just shorthand such as hello().then(console.log) like we saw in the last article. so the async keyword is added to functions to tell them to return a promise rather than directly returning the value. in addition, this lets synchronous functions avoid any potential overhead that comes with running with support for using await. by only adding the necessary handling when the function is
declared async, the javascript engine can optimize your program for you. sweet! the await keyword the real advantage of async functions becomes apparent when you combine it with the await keyword — in fact, await only works inside async functions. this can be put in front of any async promise-based function to pause your code on that line until the promise fulfills, then return the resulting value. i...
Functions — reusable blocks of code - Learn web development
// first.js let name = 'chris'; function greeting() { alert('hello ' + name + ': welcome to our company.'); } // second.js let name = 'zaptec'; function greeting() { alert('our company is called ' + name + '.'); } both functions you want to call are called greeting(), but you can only ever access the first.js file's greeting() function (the second one is ignored). in addition, attempting to
declare the name variable a second time with the let keyword in the second.js file results in an error. note: you can see this example running live on github (see also the source code). keeping parts of your code locked away in functions avoids such problems, and is considered the best practice. it is a bit like a zoo. the lions, zebras, tigers, and penguins are kept in their own enclosures, and on...
A first splash into JavaScript - Learn web development
olor = 'red'; if(userguess < randomnumber) { loworhi.textcontent = 'last guess was too low!'; } else if(userguess > randomnumber) { loworhi.textcontent = 'last guess was too high!'; } } guesscount++; guessfield.value = ''; guessfield.focus(); } this is a lot of code — phew! let's go through each section and explain what it does. the first line (line 2 above)
declares a variable called userguess and sets its value to the current value entered inside the text field. we also run this value through the built-in number() constructor, just to make sure the value is definitely a number. next, we encounter our first conditional code block (lines 3–5 above). a conditional code block allows you to run code selectively, depending on whether a certain condition is tr...
Basic math in JavaScript — numbers and operators - Learn web development
e way. note: actually, javascript has a second number type, bigint, used for very, very large integers. but for the purposes of this course, we'll just worry about number values. it's all numbers to me let's quickly play with some numbers to reacquaint ourselves with the basic syntax we need. enter the commands listed below into your developer tools javascript console. first of all, let's
declare a couple of variables and initialize them with an integer and a float, respectively, then type the variable names back in to check that everything is in order: let myint = 5; let myfloat = 6.667; myint; myfloat; number values are typed in without quote marks — try declaring and initializing a couple more variables containing numbers before you move on. now let's check that both our origin...
Test your skills: variables - Learn web development
stuck, then ask us for help — see the assessment or further help section at the bottom of this page. note: in the examples below, if there is an error in your code it will be outputted into the results panel on the page, to help you try to figure out the answer (or into the browser's javascript console, in the case of the downloadable version). variables 1 in this task we want you to:
declare a variable called myname. initialize myname with a suitable value, on a separate line (you can use your actual name, or something else).
declare a variable called myage and initialize it with a value, on the same line. try updating the live code below to recreate the finished example: download the starting point for this task to work in your own editor or in an online editor. variables ...
What went wrong? Troubleshooting JavaScript - Learn web development
for more details about this error. syntax errors round two save your page and refresh, and you should see the error has gone. now if you try to enter a guess and press the submit guess button, you'll see ... another error! this time the error being reported is "typeerror: loworhi is null", on line 78. note: null is a special value that means "nothing", or "no value". so loworhi has been
declared and initialised, but not with any meaningful value — it has no type or value. note: this error didn't come up as soon as the page was loaded because this error occurred inside a function (inside the checkguess() { ... } block). as you'll learn in more detail in our later functions article, code inside functions runs in a separate scope than code outside functions. in this case, the code was...
Multimedia: video - Learn web development
and ogg/theora. your video editing software probably has a feature to reduce file size. if not, there are online tools, such as ffmpeg (discussed in section below), that encode, decode, convert, and perform other optimization functions. optimize <source> order order video source from smallest to largest. for example, given video compressions in three different formats at 10mb, 12mb, and 13mb,
declare the smallest first and the largest last: <video width="400" height="300" controls="controls"> <!-- webm: 10 mb --> <source src="video.webm" type="video/webm" /> <!-- mpeg-4/h.264: 12 mb --> <source src="video.mp4" type="video/mp4" /> <!-- ogg/theora: 13 mb --> <source src="video.ogv" type="video/ogv" /> </video> the browser downloads the first format it understands. the goal is to o...
Ember Interactivity: Footer functionality, conditional rendering - Learn web development
wing how many are left), and clear the completed todos out of the list (which is what the “clear completed” functionality needs). in todo-data.js, add the following getter underneath the existing all() getter to define what the incomplete todos actually are: get incomplete() { return this.todos.filter(todo => { return todo.iscompleted === false; }); } using array.filter(), we
declare that "incomplete" todos are ones that have iscompleted equal to false. next, add the following action underneath the existing add(text) action: @action clearcompleted() { this.todos = this.incomplete; } this is rather nice for clearing the todos — we just need to set the todos array to equal the list of incomplete todos. finally, we need to make use of this new functionality...
Ember resources and troubleshooting - Learn web development
ate of the mut helper? mut was not covered in this tutorial and is really baggage from a transitional time when ember was moving from two-way bound data to the more common and easier-to-reason-about one-way bound data flow. it could be thought of as a build-time transform that wraps its argument with a setter function. ...
Accessibility in React - Learn web development
ck to. the next best thing is an intuitive location somewhere nearby. the list heading is our best choice because it's close to the list item the user will delete, and focusing on it will tell the user how many tasks are left. creating our ref import the useref() and useeffect() hooks into app.js — you'll need them both below: import react, { usestate, useref, useeffect } from "react"; then
declare a new ref inside the app() function. just above the return statement is a good place: const listheadingref = useref(null); prepare the heading heading elements like our <h2> are not usually focusable. this isn't a problem — we can make any element programmatically focusable by adding the attribute tabindex="-1" to it. this means only focusable with javascript. you can't press tab to focus on...
Creating our first Vue component - Learn web development
where you can manage local state in a component, it lives inside the component object alongside the props property and has the following structure: data() { return { key: value } } you'll note that the data property is a function. this is to keep the data values unique for each instance of a component at runtime — the function is invoked separately for each component instance. if you
declared data as just an object, all instances of that component would share the same values. this is a side-effect of the way vue registers components and something you do not want. you use this to access a component's props and other properties from inside data, as you may expect. we'll see an example of this shortly. note: because of the way that this works in arrow functions (binding to the parent...
Handling common JavaScript problems - Learn web development
dy familiar with the basics of troubleshooting javascript, you should study that article before moving on. there are a number of common javascript problems that you will want to be mindful of, such as: basic syntax and logic problems (again, check out troubleshooting javascript). making sure variables, etc. are defined in the correct scope, and you are not running into conflicts between items
declared in different places (see function scope and conflicts). confusion about this, in terms of what scope it applies to, and therefore if its value is what you intended. you can read what is "this"? for a light introduction; you should also study examples like this one, which shows a typical pattern of saving a this scope to a separate variable, then using that variable in nested functions so you ca...
Chrome Worker Modules
/gre/modules/workers/require.js"); note: although you only need to do this once for each worker, it doesn't hurt if you do it more than once. this defines a global value require(), that you may now use as follows: // import the module // (here, we import the core of os.file) let core = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm"); // we may now use module core. core.
declareffi(...) note that, for the moment, require() only accepts absolute uris. if the your module uri ends with “.js”, you can omit the extension. creating modules creating a module is just as simple. a module is a file, whose filename generally ends with either “.js” or “.jsm”, and designed to be opened through require(). any value you define in that file is private by default. to make the...
A bird's-eye view of the Mozilla framework
.getelementbyid("help-toc-panel"); the document object is a xuldocument, and toctree is thecontents panel xulelement. using the database attribute of the xulelement, getlink() obtains an nsirdfcompositedatasource, which presents the individual datasources of the xulelement as a single rdf graph. var tocds = toctree.database; nsirdfcompositedatasource inherits from nsirdfdatasource. help.js
declares an nsirdfservice as a compile time constant at the beginning of the file. const rdf = components.classes["@mozilla.org/rdf/rdf-service;1"].getservice(components.interfaces.nsirdfservice); the components object is made available to javascript via xpconnect; it serves as a bridge connecting javascript and xpcom. getlink() uses the nsirdfservice to obtain an nsirdfresource for the requested li...
Gecko Logging
l c++ logging framework is provided for use in core gecko code. it is enabled for all builds, thread-safe, and the preferred alternative to nspr logging. some other mostly-useless information on logging can be found on the nspr logging page. logging framework declaring a log module lazylogmodule defers the creation the backing logmodule in a thread-safe manner and is the preferred method to
declare a log module. multiple lazylogmodules with the same name can be
declared, all will share the same backing logmodule. this makes it much simpler to share a log module across multiple translation units. lazyloglodule provides a conversion operator to logmodule* and is suitable for passing into the logging macros detailed below. note: log module names can only contain specific characters. the first...
Cross Process Object Wrappers
one of these shims provides the following behavior: whenever chrome code tries to access content directly (for example, through window.content or browser.contentdocument), it is given back a cpow that wraps the content object. this means that examples like this will actually work, even in multiprocess firefox: g...
Performance
pt("framescript.js", true) // framescript.js const precomputedconstants = // ... function helper(window, action) { // ... do some work on the window } function dosomething(message) { result = helper(content, message.data) sendasyncmessage("my-addon:response-from-child", {something: result}) } addmessagelistener("my-addon:request-from-parent", dosomething) why is this bad? because
declared functions are also objects. and since frame scripts get evaluated for each tab this means new function objects get instantiated, new constants get computed, block scopes must be set up etc. while it may seem fairly innocencous in this toy example, real scripts often have a lot more functions and initialize some fairly heavyweight objects. better: addon.js as above // framescript.js component...
Using the Browser API
d.addeventlistener('touchend',function() { if(stopreload.textcontent === 'x') { browser.stop(); } else { browser.reload(); } }); implementing the search bar let's now turn our attention to implementing browser search using the browser api. tap the "s" button and try it out. try searching for "firefox" on the default page when the app first loads. so how do we do this? first, we
declare a searchactive variable as false, which influences behaviour later on. then, we disable the "previous" and "next" search item buttons so that they don't run anything unless there are search items to cycle between. var searchactive = false; prev.disabled = true; next.disabled = true; next, we add an event listener to the searchform so that when it is submitted, the htmliframeelement.findall() me...
HTMLIFrameElement.findAll()
. note: use of the browser api requires a privileged app, and browser and/or embed-apps permissions, depending on what you want to do. see using the browser api for more details. syntax instanceofhtmliframeelement.findall(searchstring, casesensitivity); returns void. parameters searchstring the string you want to search for in the browser <iframe>'s text. casesensitivity a string to
declare whether you want the search to be case sensitive (case-sensitive) or insensitive (case-insensitive.) example the following function is taken from our browser api demo, and executes a search when a search form is submitted. see implementing the search bar for more explanation. searchform.addeventlistener('submit', function(e) { e.preventdefault(); browser.findall(searchbar.value, 'case-sen...
HTML parser threading
ml5streamparser has fields that hold objects that aren't safe to release except from the main thread. the runnables use nshtml5refptr<nshtml5streamparser>. nshtml5refptr sends runnables back to the main thread to call release on nshtml5streamparser on the main thread. normal (non-speculative) parsing initially, dodataavailable performs character encoding sniffing on the data if an encoding wasn't
declared on the enclosing protocol (http) level. once a unicode decoder has been set up, dodataavailable passes the byte data to the decoder whose output is accumulated into a linked list of nshtml5owningutf16buffer objects. nshtml5owningutf16buffer objects are then passed to the tokenizer in sequence by the parseavailabledata() method. the tokenizer calls into the tree builder which outputs nshtml5treeo...
IPDL Type Serialization
each type specializes ipc::paramtraits as follows: namespace ipc { template <> struct paramtraits<mytype> { typedef mytype paramtype; static void write(message* amsg, const paramtype& aparam) { // implement serialization here } static bool read(const message* amsg, void** aiter, paramtype* aresult) { // implement deserialization here. ...
IPC Protocol Definition Language (IPDL)
ipdl, short for "ipc (inter-process communication) protocol definition language", is a mozilla-specific language allowing c++ code to pass messages between processes or threads in an organized and secure way. all messages for multi-process plugins and tabs in firefox are
declared in the ipdl language. current docs ipdl tutorial quick start: creating a new protocol quick start: extending a protocol ipdl type serialization ipdl best practices ipdl glossary pbackground future planned docs ipdl language reference error and shutdown handling in ipdl protocols how ipdl uses processes, threads, and sockets ipdl shared memory ...
JavaScript Tips
the original variable if it succeeds. xpconnect knows all about tearoffs and modifies the object that you queryinterface or instanceof to cache all its known interfaces. when passing an object to an xpcom method it is helpful if the object you pass is an xpcom object, so that the c++ method access a c++ object. however, this is not always necessary or desirable. for instance the offline observer
declared above is a javascript object that is registered with an xpcom object, so that the call back from xpcom executes the javascript method. some xpcom methods expect an object that implements several interfaces thus requiring you to write a queryinterface method. however, in javascript this is quite simple even in the case of a weak reference which in c++ requires a helper class: var weakobserver =...
Downloads.jsm
ager. by default it is not enabled. it will be enabled when the bug 851471 will be closed. if you don't activate it, you could use downloads.jsm, but your view will not be called by the external helper app service (when a user click on a file to download, in a web page). to enable the new download manager : first you have to set the pref browser.download.usejstransfer to true. then you should
declare the new nsitransfer object during the startup of your app. components.manager.queryinterface(components.interfaces.nsicomponentregistrar) .registerfactory(components.id("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"), "", "@mozilla.org/transfer;1", null); ...
Task.jsm
}); // behaves the same spawn() creates and starts a new task. promise spawn( atask ); parameters atask this parameter accepts d...
gettext
ike this." msgstr[0] "" msgstr[1] "" depending on the localizer's target language and its rules for creating plural forms, there might be another field for translation, e.g. msgstr[2]. gettext will return one of the msgstrs, depending on the number passed to the gettext function in the code ($num in the above example). to determine which form to return, gettext uses a plural rule, which should be
declared in the po file header. for example, for english, the plural rule is of the following form: plural-forms: nplurals=2; plural=n != 1; the first part defines the number of different plural forms (2). the second part is evaluated and the result of the evaluation is used to choose the right msgstr. in the rule above, if n equals 1, the expression is evaluated to false, or 0, so msgstr[0] will be use...
Mozilla Web Developer FAQ
-formedness constraints are enforced. despite common allegations to the contrary, the document is not checked for validity. externally defined character entities other than the five pre-defined ones (<, >, &, " and ') are only supported if the document references a public identifier for which there is a mapping in mozilla’s pseudo-dtd catalog and the document has not been
declared standalone. in older versions of mozilla as well as in old mozilla-based products, there is no pseudo-dtd catalog and the use of externally defined character entities (other than the five pre-defined ones) leads to an xml parsing error. there are also other xhtml user agents that do not support externally defined character entities (other than the five pre-defined ones). since non-validating ...
mozilla::MonitorAutoEnter
the mozilla::monitorautoenter constructor will enter() the underlying mozilla::monitor automatically. when the mozilla::monitorautoenter goes out of scope, its destructor will exit() the underlying mozilla::monitorautoenter. important: when a mozilla::monitorautoenter is live on the stack, your code is guaranteed to own the underlying mozilla::monitor. ...
mozilla::MutexAutoLock
the mozilla::mutexautolock constructor will lock() the underlying mozilla::mutex automatically. when the mozilla::mutexautolock goes out of scope, its destructor will unlock() the underlying mozilla::mutex. because of mozilla::mutexautounlock, the rule for determining if your code owns the mutex underlying the mutexautolock is slightly more complicated than that for monitorautoenter. ...
mozilla::MutexAutoUnlock
the mozilla::mutexautounlock constructor will unlock() the underlying mozilla::mutex automatically. when the mozilla::mutexautounlock goes out of scope, its destructor will lock() the underlying mozilla::mutex. because of mozilla::mutexautolock, the rule for determining if your code does not own the mutex underlying the mutexautounlock is slightly more complicated than that for monitorautoenter. ...
JS::PerfMeasurement
all presently-measurable events are measured with counters, not timers; that is, there is no defined relation between the numbers you get from this interface, and wall-clock time. perfmeasurement* js::extractperfmeasurement(jsval wrapper) if you are the c++ side of an xpcom interface, and you want to benchmark only part of your execution time but make the results available to javascript, you can
declare a bare jsval argument in your .idl file and have javascript pass a perfmeasurement object that it created in that argument slot. the jsval you receive points to a javascript wrapper object. to extract the c++-level perfmeasurement object, call this function. it will return null if javascript passed in something with the wrong dynamic type. jsobject* js::registerperfmeasurement(jscontext* cx, j...
javascript.options.strict
time error, but is non-standard, poorly written, or prone to cause logic errors. this preference controls whether javascript warnings are logged to the javascript console. example : <html> <head> <title>sample</title> </head> <body> <label id="name">enter you first name</label> <p id ="sample"></p> <script> "use strict" name1= "john" ; // this will cause and an error as variable not
declared . var name2= "peter"; document.getelementbyid("sample").innerhtml = name1; </script> </body> </html> possible values and their effects: true: show javascript errors and warnings. false: show javascript errors only. (default) see also: http://kb.mozillazine.org/javascript.options.strict ...
About NSPR
relying on threads to provide the concurrency needed for complex applications. that method of operation is preferred though it is possible to configure the network i/o channels as non-blocking in the traditional sense. network addresses part of nspr deals with manipulation of network addresses. nspr defines a network address object that is internet protocol (ip) centric. while the object is not
declared as opaque, the api provides methods that allow and encourage clients to treat the addresses as polymorphic items. the goal in this area is to provide a migration path between ipv4 and ipv6. to that end it is possible to perform translations of ascii strings (dns names) into nspr's network address structures, with no regard to whether the addressing technology is ipv4 or ipv6. time timing facil...
NSPR Poll Method
tocols. how to use the poll method the poll method should only be used with a nspr file descriptor in non-blocking mode. most nspr clients call pr_poll and do not call the poll method directly. however, pr_poll can only used with a stack whose bottom layer is nspr's reference implementation. if you are using your own implementation of the bottom layer, you must call the poll method as follows.
declare two print16 variables to receive the return value and the out_flags output argument of the poll method. print16 new_flags, out_flags; if you are going to call pr_recv, pass pr_poll_read as the in_flags argument. new_flags = fd->methods->poll(fd, pr_poll_read, &out_flags); if you are going to call pr_send, pass pr_poll_write as the in_flags argument. new_flags = fd->methods->poll(fd, pr_poll_...
Nonblocking IO In NSPR
d()</tt> and <tt>pr_transmitfile()</tt> only work on blocking sockets. they do not make sense in nonblocking mode. <tt>pr_write()</tt>, <tt>pr_send()</tt>, <tt>pr_writev()</tt> in blocking mode block until the entire buffer is sent. in nonblocking mode, they cannot block, so they may return with just sending part of the buffer. pr_poll() or pr_select()? <tt>pr_select()</tt> is deprecated, now
declared in <tt>private/pprio.h</tt>. use <tt>pr_poll()</tt> instead. the current implementation of <tt>pr_select()</tt> simply calls <tt>pr_poll()</tt>, so it is sure to have worse performance. also, native file descriptors (socket handles) cannot be added to <tt>pr_fd_set</tt>, i.e., the functions <tt>pr_fd_nset</tt>, <tt>pr_fd_nclr</tt>, <tt>pr_fd_nisset</tt> do not work. pr_available() when <tt>pr...
Optimizing Applications For NSPR
functions return an error when invoked on windows 3.1. functions called in an application by a shared library require an additional function prolog. the prolog is presented in the macro <tt>pr_callback</tt>. for any function made available to any shared library (most likely passed in as a function pointer), that function must have the <tt>pr_callback</tt> qualifier. nspr functions are normally
declared <tt>__cdecl</tt>. these declarations are hidden in the <tt>pr_extern()</tt> declarations in nspr's header files. nspr functions returning floating point types and structs by value, including the derived types print64, are
declared <tt>__pascal</tt>. these different declarations are to accommodate restrictions in watcom's c/c++ version 11.0 and 11.0a compiler. windows 3.1 does not provide a non-...
Floating Point Number to String Conversion
nspr provides functions that convert double-precision floating point numbers to and from their character string representations. these conversion functions were originally written by david m. gay of at&t. they use ieee double-precision (not ieee double-extended) arithmetic. the header file prdtoa.h
declares these functions. the functions are: pr_strtod pr_dtoa pr_cnvtf references gay's implementation is inspired by these two papers. [1] william d. clinger, "how to read floating point numbers accurately," proc. acm sigplan '90, pp. 92-101. [2] guy l. steele, jr. and jon l. white, "how to print floating-point numbers accurately," proc. acm sigplan '90, pp. 112-126. ...
Hash Tables
warning: the nspr hash table library functions are not thread safe. a hash table lookup may change the internal organization of the hash table (to speed up future lookups). ...
PR_CALLBACK
used to define pointers to functions that will be implemented by the client but called from a (different) shared library. syntax #include <prtypes.h>type pr_callbackimplementation description functions that are implemented in an application (or shared library) that are intended to be called from another shared library (such as nspr) must be
declared with the pr_callback attribute. normally such functions are passed by reference (pointer to function). the pr_callback attribute is included as part of the function's definition between its return value type and the function's name. ...
PR_EXTERN
used to define the prototypes for functions or variables that are to be exported from a shared library. syntax #include <prtypes.h> pr_extern(type)prototype description pr_extern is used to define externally visible routines and globals. for syntax details for each platform, see prtypes.h. the macro includes the proper specifications to
declare the target extern and set up other required linkages. warning: some platforms do not allow the use of the underscore character (_) as the first character of an exported symbol. ...
PR ImportTCPSocket
filedesc object created for the newly imported native tcp socket. if the import of the native tcp socket failed, null. description a native tcp socket osfd can be imported into nspr with pr_importtcpsocket. the caller gives up control of the native tcp socket osfd and should use the prfiledesc* returned by pr_importtcpsocket instead. although pr_importtcpsocket is a supported function, it is
declared in "private/pprio.h" to stress the fact that this function depends on the internals of the nspr implementation. the caller needs to understand what nspr will do to the native file descriptor and make sure that nspr can use the native file descriptor successfully. for example, on posix systems, nspr will put the native file descriptor (an int) in non-blocking mode by calling fcntl to set the o_n...
Index
er new password: re-enter new password: token "communicator certificate db" password changed successfully. jar installation file format when a jar file is run by a server, by modutil, or by any program that does not interpret javascript, a special information file must be included to install the libraries. there are several things to keep in mind with this file: o it must be
declared in the jar archive's manifest file. o the script can have any name. o the metainfo tag for this is pkcs11_install_script. to
declare meta-information in the manifest file, put it in a file that is passed to signtool. sample script for example, the pkcs #11 installer script could be in the file pk11install. if so, the metainfo file for signtool includes a line...
4.3 Release Notes
hash_value_alert new tls cipher suites (see http://mxr.mozilla.org/security/sour...sslsocket.java): tls_rsa_with_camellia_128_cbc_sha tls_dhe_dss_with_camellia_128_cbc_sha tls_dhe_rsa_with_camellia_128_cbc_sha tls_rsa_with_camellia_256_cbc_sha tls_dhe_dss_with_camellia_256_cbc_sha tls_dhe_rsa_with_camellia_256_cbc_sha note: the following tls cipher suites are
declared but are not yet implemented: tls_dh_dss_with_camellia_128_cbc_sha tls_dh_rsa_with_camellia_128_cbc_sha tls_dh_anon_with_camellia_128_cbc_sha tls_dh_dss_with_camellia_256_cbc_sha tls_dh_rsa_with_camellia_256_cbc_sha tls_dh_anon_with_camellia_256_cbc_sha tls_ecdh_anon_with_null_sha tls_ecdh_anon_with_rc4_128_sha tls_ecdh_anon_with_3des_ede_cbc_sha tls_ecdh...
NSS 3.15 release notes
security/nss/releases/nss_3_15_rtm/src/ new in nss 3.15 new functionality support for ocsp stapling (rfc 6066, certificate status request) has been added for both client and server sockets. tls client applications may enable this via a call to ssl_optionsetdefault(ssl_enable_ocsp_stapling, pr_true); added function secitem_reallocitemv2. it replaces function secitem_reallocitem, which is now
declared as obsolete. support for single-operation (eg: not multi-part) symmetric key encryption and decryption, via pk11_encrypt and pk11_decrypt. certutil has been updated to support creating name constraints extensions. new functions in ssl.h ssl_peerstapledocspresponse - returns the server's stapled ocsp response, when used with a tls client socket that negotiated the status_reques...
NSS 3.16.3 release notes
16_3_rtm/src/ new in nss 3.16.3 this release consists primarily of ca certificate changes as listed below, and fixes an issue with a recently added utility function. new functions in cert.h cert_getgeneralnametypefromstring - an utlity function to lookup a value of type certgeneralnametype given a human readable string. this function was already added in nss 3.16.2, however, it wasn't
declared in a public header file. notable changes in nss 3.16.3 the following 1024-bit ca certificates were removed cn = entrust.net secure server certification authority sha1 fingerprint: 99:a6:9b:e6:1a:fe:88:6b:4d:2b:82:00:7c:b8:54:fc:31:7e:15:39 cn = gte cybertrust global root sha1 fingerprint: 97:81:79:50:d8:1c:96:70:cc:34:d8:09:cf:79:44:31:36:7e:f4:74 ...
NSS 3.20 release notes
ptionally supports the use of weak dhe parameters with dhe ciphersuites in order to support legacy clients. to enable this support, the new api ssl_enableweakdheprimegroup must be used. each time this api is called for the first time in a process, a fresh set of weak dhe parameters will be randomly created, which may take a long amount of time. please refer to the comments in the header file that
declares the ssl_enableweakdheprimegroup api for additional details. the size of the default pqg parameters used by certutil when creating dsa keys has been increased to use 2048 bit parameters. the selfserv utility has been enhanced to support the new dhe features. nss no longer supports c compilers that predate the ansi c standard (c89). bugs fixed in nss 3.20 this bugzilla query returns all the ...
NSS 3.24 release notes
s) certificates has been added. although these certificates can be configured, they will not be used by nss in this version. for functions that use temporary arenas, allocating a portcheaparena on the stack is more performant than allocating a plarenapool on the heap. rather than declaring a plarenapool pointer and calling port_newarena/port_freearena to allocate or free an instance on the heap,
declare a portcheaparenapool on the stack and use port_initcheaparena/port_destroycheaparena to initialize and destroy it. items allocated from the arena are still created on the heap, only the arena itself is stack-allocated. note: this approach is only useful when the arena use is tightly bounded, for example, if it is only used in a single function. new elements this section lists and briefly descr...
NSS API Guidelines
oints should check pointers in a debug, wherever possible. pointers to user-supplied buffers, and templates, should be checked against null. pointers to context-style functions should be checked using special debug macros. these macros only define code when debug is turned on, providing a way for systems to register, deregister, and check valid pointers. secport_decl_ptr_class(classname, size) -
declare a class of pointers (labelled classname) this object file needs to check. this class is local only to this object file. size is the expected number of pointers of type classname. secport_decl_global_ptr_class(classname, size) - same as above except classname can be used in other object files. secport_add_pointer(classname, pointer) - add pointer as a valid pointer for classclassname. this is us...
nss tech note8
ontained the expected session lifetimes for ssl2 and ssl3 sessions. extern pruint32 ssl_sid_timeout; (the ssl2 session lifetime) extern pruint32 ssl3_sid_timeout; (the ssl3 session lifetime) each of these variables applied to both client and server sessions. that is, the client session lifetime was not separately settable from the server session lifetime. these two variables were private,
declared in a private header file. there was no api function by which client programs could set these values. however since nss was delivered as archive libraries, client programs merely
declared these two variables for themselves, and then were able to alter those variables directly. for server programs, the function for initializing the server session cache would set these two variables according to t...
NSS tools : modutil
password: enter new password: re-enter new password: token "communicator certificate db" password changed successfully. jar installation file format when a jar file is run by a server, by modutil, or by any program that does not interpret javascript, a special information file must be included to install the libraries. there are several things to keep in mind with this file: o it must be
declared in the jar archive's manifest file. o the script can have any name. o the metainfo tag for this is pkcs11_install_script. to
declare meta-information in the manifest file, put it in a file that is passed to signtool. sample script for example, the pkcs #11 installer script could be in the file pk11install. if so, the metainfo file for signtool includes a line such as this: + pkcs11_inst...
sslfnc.html
e of nss. applications will find it desirable to determine, at run time, what ssl2 cipher kinds and ssl3 cipher suites are actually implememted in a particular release. applications may disable any cipher suites that they don't know about (for example, that they cannot present to the user via a gui). to that end, nss provides a table that can be examined at run time. all aspects of this table are
declared in ssl.h. ssl_implementedciphers[] is an external array of unsigned 16-bit integers whose values are either ssl2 cipher kinds or ssl3 cipher suites. the values are the same as the values used to enable or disable a cipher suite via calls to ssl_cipherprefsetdefault, and are defined in sslproto.h. the number of values in the table is contained in an external 16-bit integer named ssl_numimplemen...
NSS Tools modutil
bling interactive prompts for the security module database tool, to support scripted operation: -force jar installation file when a jar file is run by a server, by the security module database tool, or by any program that does not interpret javascript, a special information file must be included in the format described below. this information file contains special scripting and must be
declared in the jar archive's manifest file. the script can have any name. the metainfo tag for this is pkcs11_install_script. to
declare meta-information in the manifest file, put it in a file that is passed to the netscape signing tool. sample script for example, the pkcs #11 installer script could be in the file pk11install. if so, the metainfo file for the netscape signing tool would include ...
NSS tools : modutil
er new password: re-enter new password: token "communicator certificate db" password changed successfully. jar installation file format when a jar file is run by a server, by modutil, or by any program that does not interpret javascript, a special information file must be included to install the libraries. there are several things to keep in mind with this file: o it must be
declared in the jar archive's manifest file. o the script can have any name. o the metainfo tag for this is pkcs11_install_script. to
declare meta-information in the manifest file, put it in a file that is passed to signtool. sample script for example, the pkcs #11 installer script could be in the file pk11install. if so, the metainfo file for signtool includes a line...
Hacking Tips
ains a list of roots, one per line. each root has the form "0xabcd1234 <color> <description>", where <color> is the color of the given gc thing (b for black, g for gray, w for white) and <description> is a string. the list of roots ends with a line containing "==========". after the roots come a series of zones. a zone starts with several "comment lines" that start with hashes. the first comment
declares the zone. it is followed by lines listing each compartment within the zone. after all the compartments come arenas, which is where the gc things are actually stored. each arena is followed by all the gc things in the arena. a gc thing starts with a line giving its address, its color, and the thing kind (object, function, whatever). after this come a list of addresses that the gc thing points to,...
Exact Stack Rooting
. since it is never correct to implicitly copy a js::rootedt (more on this in a second) we have deleted the copy constructor from these classes. therefore, we are forced to force you to initialize with constructor syntax. sorry. note 2: in c++, destructors are required to run in declaration order, nicely maintaining our lifo property. however, this does not hold true for temporaries: they are un
declared, after all. some compilers maintain lifo order, some do not. incorrect use of js::rootedt as a temporary will crash at run time. there is also a static constructor method frommarkedlocation() that creates a handle from an arbitrary location. this is used to make handles for things like scope chain objects, which aren't explicitly rooted themselves, but are always reachable from the implicit st...
SpiderMonkey Internals
l. js.msg spidermonkey error messages. jsarray.*, jsbool.*, jsdate.*, jsfun.*, jsmath.*, jsnum.*, jsstr.* these file pairs implement the standard classes and (where they exist) their underlying primitive types. they have similar structure, generally starting with class definitions and continuing with internal constructors, finalizers, and helper functions. jsobj.*, jsscope.* these two pairs
declare and implement the js object system. all of the following happen here: creating objects by class and prototype, and finalizing objects; defining, looking up, getting, setting, and deleting properties; creating and destroying properties and binding names to them. the details of a native object's map (scope) are mostly hidden in jsscope.[ch]. jsatom.cpp, jsatom.h the atom manager. contains ...
JIT Optimization Outcomes
if delete is used to remove one of the object's properties. singleton one of the types present in the typeset was a singleton type, preventing the optimization from being enabled. notsingleton optimization failed because the object containing the property did not have a 'singleton' type. singleton types are assigned to objects that are "one of a kind", such as global objects, literal objects
declared in the global scope, and top-level function objects. notfixedslot the property being accessed is not stored at a known location in the object. this can occur if one of the expected types of objects to be used in this operation has unknown properties, or if different instances of the object store the property at different locations (for example, some instances have the property assigned in a di...
JIT Optimization Strategies
ss is eliminated entirely and replaced with an inline constant. getprop_constant attempts to optimize reading a property that contains a uniquely-typed (or "singleton") object. with uniquely-typed objects, it is guaranteed that no other object has that same type. unique (or "singleton") types are assigned to certain kinds of objects, like global objects, top-level functions, and object literals
declared at the top-level of a script. if a property has always contained the same uniquely-typed object, then the engine can use the unique type to map back to a specific object, and eliminate the property access, replacing it with a constant reference to the object. when this optimization is successful, property access is eliminated entirely and replaced with an inline constant. the different success ...
JS::Rooted
t operator->() const t *address() returns a pointer to ptr. const t *address() const t &operator=(t value) sets the value of ptr to value. t &operator=(const rooted &value) void set(t value) bool operator!=(const t &other) const compares ptr and other. bool operator==(const t &other) const description js::rooted<t>
declares a local variable of type t whose value is always rooted. this is typically used for local variables, or for non-rooted values being passed to a function that requires a handle, e.g. foo(js::rooted<t>(cx, x)). js::rooted<t> may be automatically coerced to a js::handle<t>. js::rooted<t> should be used whenever a local variable's value may be held live across a call which can trigger a gc. ...
JSNewResolveOp
t-hand side of an assignment. jsresolve_detecting obsolete since jsapi 20 the property is being used in code like "if (o.p)...", or a similar idiom where the apparent purpose of the property access is to detect whether the property exists. (this flag has been replaced with the jsclass_emulates_undefined mechanism.) jsresolve_declaring obsolete since jsapi 15 the property is being
declared in a var, const, or function declaration. jsresolve_classname obsolete since javascript 1.8.8 class name used when constructing. jsresolve_with obsolete since javascript 1.8.8 the lookup is occurring for a name evaluated inside a with statement. see also jsclass bug 547140 - removed flags bug 993026 - obsoleted ...
JS_FS
flags. selfhostedname const char * the function's name in self-hosted javascript code. description use these macros to define an array of jsfunctionspecs to pass to js_definefunctions or js_initclass. js_fn (whose name pays homage to the old jsnative/jsfastnative split) simply adds the flag jsfun_stub_gsops. js_fninfo allows the simple adding of jsjitinfos. js_self_hosted_fn
declares a self-hosted function. finally js_fnspec has slots for all the fields. the _sym variants allow defining a function with a symbol key rather than a string key. for example, use js_sym_fn(iterator, ...) to define an @@iterator method. (in builds without es6 symbols, it defines a method with the string id "@@iterator".) see an example in the jsapi user guide. see also mxr id search for js_fs mx...
JS_LookupProperty
property name appeared on the left-hand side of an assignment. jsresolve_detecting behave as though the name appeared in an idiom like "if (obj.name) ..." or "obj.name ? ... : ...". objects may pretend that the property does not exist when this flag is set. for example, mozilla's document.all property is hidden in this way. jsresolve_declaring behave as though the name were being
declared in a var, const, or function declaration. jsresolve_classname search for the initial value of a standard class such as object, array, or error. do not automatically infer and enable other flags by looking at the currently executing bytecode. notes js_lookupproperty does not distinguish between a property with a value of undefined and a property that does not exist. use js_getpropertyatt...
SavedFrame
script call stack at a past moment of execution. younger frames hold a reference to the frames that invoked them. the older tails are shared across many younger frames. savedframe stacks should generally be captured, allocated, and live within the compartment that is being observed or debugged. usually this is a content compartment. capturing savedframe stacks from c++ use js::capturecurrentstack
declared in jsapi.h. from js use savestack, accessible via components.utils.getjstestingfunction(). including and excluding chrome frames consider the following savedframe stack. arrows represent links from child to parent frame, content.js is from a compartment with content principals, and chrome.js is from a compartment with chrome principals. function a from content.js | v func...
TPS Tests
e: var phases = { "phase1": "profile1", "phase2": "profile2", "phase3": "profile1" }; between { and } it must be strict json. e.g. quoted keys, no trailing parentheses, etc. the python testrunner will be parsing it with an unforgiving call to json.loads, so anything other than strict json will fail. you can use as many profiles or phases as you need, but every phase you define later must be
declared here, or it will not be run by the python test runner. any phases
declared here but not implemented later will cause the test to fail when it hits that phase. asset lists a test file will contain one or more asset lists, which are lists of bookmarks, passwords, or other types of browser data that are relevant to sync. the format of these asset lists vary somwhat depending on asset type. boo...
Using RAII classes in Mozilla
tutils::addscriptblocker(cx); } ~nsautoscriptblocker() { nscontentutils::removescriptblocker(); } private: moz_decl_use_guard_object_notifier }; moz_guard_object_notifier_param is added to the end of the constructor's parameter list. moz_guard_object_notifier_init is added as a statement in the constructor. moz_decl_use_guard_object_notifier is added where private members should be
declared. however, there are some variations for special cases: first, if the constructor (otherwise) takes no arguments, then you have to use the moz_guard_object_notifier_only_param macro instead. (this is needed because the macro adds a parameter only when debug is defined, and in this case, it can't add the leading comma.) class moz_raii nsautoscriptblocker { public: explicit nsautoscriptblocker...
Using the Places annotation service
s in case of collisions. the annotation protocol the annotation service provides a protocol handler for the "moz-anno:" protocol. this allows you to link directly to data stored in the annotation service. you can get an annotation uri for a given uri/name pair by calling: getannotationuri(auri, aname); in order for the annotation protocol to work, the annotation in question must have been
declared with a mime type. annotations with no mime type will not work. the annotation service also provides special-case handling of favicons. when the annotation name is "favicon," the annotation protocol handler will pass the request through to the favicon service for handling. to get a favicon annotation uri for a given favicon, use nsifaviconservice.getfaviconlinkforicon and to get the favicon anno...
How to build an XPCOM component in JavaScript
see xpcom changes in gecko 2.0 for more details. installation for extensions: copy helloworld.js, and helloworld.xpt (only if you defined and compiled the idl) to {extensiondir}/components/. delete compreg.dat and xpti.dat from your profile directory. restart application.
Building the WebLock UI
ectly in from the user interface, or we can do a check on the string and verify that it's a valid url. in this tutorial, focusing as it is on the weblock functionality (rather than the ui), we'll assume the strings we get from the ui itself are urls we actually want to write to the white list: function addthissite() { var tf = document.getelementbyid("dialog.input"); // weblock is global and
declared above weblock.addsite(tf.value); } this javascript function can be called directly from the xul widget, where the input string is retrieved as the value property of the textbox element. you also need to create the function that displays the weblock window itself when the user clicks the weblock icon in the statusbar. that function uses the opendialog method from the window object and takes ...
Creating the Component Code
nsimodule** result); xpcom expects a successful call to nsgetmodule to return an implementation of the interface nsimodule. when you write a xpcom component, you implement nsimodule to do all of the necessary registration, unregistration, and object creation. nsimodule has four methods that must be implemented. the registration methods two closely related registration methods are
declared below. ns_imethod registerself(nsicomponentmanager *acompmgr, nsifile *alocation, const char *aloaderstr, const char *atype) = 0; ns_imethod unregisterself(nsicomponentmanager *acompmgr, nsifile *alocation, const char *aloaderstr) = 0; registerself is called when a comp...
Making cross-thread calls using runnables
e passing should be asynchronous. for example, let's say we have a function, calculatepi(int digits), which will calculate π to an arbitrary number of digits: void calculatepi(int digits, nscstring& result); // this is synchronous this can take a while, so we don't want to run this on the main thread. instead, we want to run it on a new thread and be notified when the result is available. so we
declare an asynchronous version of the same function: typedef void (*picallback)(const nscstring& result); // callback function void calculatepiasynchronously(int digits, picallback callback); creating a runnable nsrunnable is a helper class: it already implements threadsafe refcounting, so all you need to do is override the run() function. in our example, we actually need two runnables: one dispatched ...
Index
zilla.org/filepicker;1. to create an instance, use: 656 nsifileprotocolhandler file i/o, interfaces, interfaces:scriptable, reference, référence(2), xpcom, xpcom api reference, xpcom interface reference converts the url string into the corresponding nsifile if possible. a local file will be created if the url string begins with file://. 657 nsifilespec
declared in xpcom/obsolete/nsifilespec.idl 658 nsifilestreams file i/o, interfaces, interfaces:scriptable, streams, xpcom, xpcom api reference, xpcom interface reference no summary! 659 nsifileurl interfaces, interfaces:scriptable, needscontent, xpcom interface reference no summary! 660 nsifileutilities long gone. 661 nsifileview ...
Components.utils
hout sharing a scope. importglobalproperties() specify a list of constructors to import into the scope. isxraywrapper() test whether a given object is an xray or not. unload() unloads a js module loaded with import(). isdeadwrapper() determines whether this object is backed by a deadobjectproxy. lookupmethod() looks up a native (i.e.
declared in the interface) method or property of an xpcom object. serves the same purpose as xpcnativewrapper. makeobjectpropsnormal() ensures that all functions come from the specified object's scope, and aren't cross-compartment wrappers. may only be called from javascript code. nondeterministicgetweakmapkeys() return the keys in a weak map. this operation is non-determini...
Components object
getglobalforobject returns the global object with which a given object is associated (through its prototype chain at birth, for example). utils.getweakreference gets a weak reference for the object passed in. utils.import loads a javascript module into the current script, without sharing a scope. utils.lookupmethod looks up a native (i.e.
declared in the interface) method or property of an xpcom object. serves the same purpose as xpcnativewrapper. utils.makeobjectpropsnormal ensures that all functions come from the specified object's scope, and aren't cross-compartment wrappers. may only be called from javascript code. utils.methodjit obsolete since gecko 24.0 provides access to the value of the meth...
XPConnect wrappers
js is created around your object. c++ calls are routed through xpcwrappedjs code into your javascript implementation. these wrappers are created by xpconnect, so you should not have to worry about how to construct them or whether to construct them. double wrapping. there is one case where an xpcwrappednative wraps another wrapper object. this case is where a js object was passed in via some idl-
declared interface, creating an xpcwrappedjs, and is now being returned to javascript via some other interface. in order to preserve api compatibility, an xpcwrappednative is created around the xpcwrappedjs. security wrappers exposed to chrome to learn about security wrappers, see the article on script security in gecko. note that a previous version of the current page recommended using __exposedprops...
mozIAsyncFavicons
the auri parameter will be the favicon uri, or null when no favicon is associated with the page or an error occurred while fetching it. if auri is not null, the other parameters may contain the favicon data. however, if no favicon data is currently associated with the favicon uri, adatalen will be 0, adata will be an empty array, and amimetype will be an empty string. setandfetchfaviconforpage()
declares that a given page uses a favicon with the given uri and attempts to fetch and save the icon data by loading the favicon uri through a asynchronous network request. if the icon data already exists, we will not try to reload the icon unless aforcereload is true. similarly, if the icon is in the failed favicon cache we will not do anything unless aforcereload is true, in which case we'll try to rel...
nsIAccessibleStateChangeEvent
accessible/public/nsiaccessibleevent.idlscriptable please add a summary to this article. 1.0 66 introduced gecko 1.9 inherits from: nsisupports last changed in gecko 1.9 (firefox 3) method overview boolean isenabled(); boolean isextrastate(); attributes attribute type description state unsigned long returns the state of accessible (see constants
declared in nsiaccessiblestates). read only. methods isenabled() boolean isenabled(); parameters none. return value returns true if the state is turned on. isextrastate() boolean isextrastate(); parameters none. return value returns true if the state is extra state. ...
nsIConsoleService
's not applicable. asourceline — the line #alinenumber from asourcename file. you are responsible for providing this line. you may pass null if you are lazy; this will prevent the source line showing in the error console. alinenumber and acolumnnumber — specify the exact location of an error. acolumnnumber is used to draw the arrow pointing to the problem character. aflags — one of flags
declared in nsiscripterror. at the time of writing, possible values are: nsiscripterror.errorflag = 0 nsiscripterror.warningflag = 1 nsiscripterror.exceptionflag = 2 and nsiscripterror.strictflag = 4. acategory — a string indicating what kind of code caused the error message. there are quite a few category strings and they do not currently seem to be listed in a single place. hopef...
nsIEditor
e); void joinnodes(in nsidomnode leftnode, in nsidomnode rightnode, in nsidomnode parent); void deletenode(in nsidomnode child); void marknodedirty(in nsidomnode node); direction controller void switchtextdirection(); output methods astring outputtostring(in astring formattype, in unsigned long flags); example: // flags are
declared in base/public/nsidocumentencoder.idl // outputselectiononly = 1, outputformatted = 2, // outputraw = 4, outputbodyonly = 8, // outputpreformatted = 16, outputwrap = 32, // outputformatflowed = 64, outputabsolutelinks = 258, // outputencodew3centities = 256, outputcrlinebreak = 512, // outputlflinebreak = 1024, outputnoscriptcontent = 2048, // o...
nsIFaviconService
vicon again. exceptions thrown ns_error_failure thrown if the favicon is overbloated and won't be saved to the db. setfaviconurlforpage() obsolete since gecko 22.0 (firefox 22.0 / thunderbird 22.0 / seamonkey 2.19) note: this method was removed in gecko 22.0. you should use the new async api moziasyncfavicons.setandfetchfaviconforpage() instead. this method
declares that a given page uses a favicon with the given uri. you needn't have any specified data at this point. an entry linking the favicon with the page will be create with no data. you can populate it later with setfavicondata(). however, any favicons not associated with a visited web page, a bookmark, or a "place:" uri will be expired when history cleanup is done * (typically at app shutdown, but al...
nsIFrameScriptLoader
r example data:,dump("foo\n"); aallowdelayedload boolean if true, this flag means that the frame script will be loaded into any new frames opened after the loadframescript() call, until removedelayedframescript() is called for that script. aruninglobalscope boolean optional, defaults to false. by default, frame scripts each have their own scope, so they can
declare global variables without causing conflicts with any other frame scripts. if present and set to true, this flag switches off that behavior, meaning that the script's scope is shared with any other frame scripts in the same frame that have also set the flag. removedelayedframescript() removes aurl from the list of scripts which support delayed load. this cancels the effect of the aallo...
nsINavHistoryService
hods getpagetitle() this method retrieves the original title of the page. astring getpagetitle( in nsiuri auri ); parameters auri the page whose title needs to be retrieved. return value returns the original title of the page. markpageasfollowedbookmark() this method is just like markpageastyped (in nsibrowserhistory, also implemented by the history service), but for bookmarks. it
declares that the given uri is being opened as a result of following a bookmark. if this uri is loaded soon after this message has been received, that transition will be marked as following a bookmark. void markpageasfollowedbookmark( in nsiuri auri ); parameters auri the page that is to be marked as followed by a bookmark. markpageastyped() this method designates the url as having been expli...
nsIScriptError
e the message was created. read only. flag constants constant value description errorflag 0x0 error messages. a pseudo-flag for the default, error case. warningflag 0x1 warning messages. exceptionflag 0x2 an exception was thrown for this case - exception-aware hosts can ignore this. strictflag 0x4 one of the flags
declared in nsiscripterror. infoflag 0x8 just a log message methods init() initializes the object with information describing the error which occurred. void init( in wstring message, in wstring sourcename, in wstring sourceline, in pruint32 linenumber, in pruint32 columnnumber, in pruint32 flags, in string category ); parameters message the text of the message...
nsIXULTemplateBuilder
a tree builder, for example, the content within the action body is used to create the tree rows instead. a matching result must have its rulematched() method called. when a result no longer matches, the result's hasbeenremoved() method must be called. optionally, the rule may have a <bindings> section which may be used to define additional variables to be used within an action body. each of these
declared bindings must be supplied to the query processor via its addbinding() method. the bindings are evaluated after a rule has matched. templates may generate content recursively, using the previous iteration's results as reference point to invoke the same queries. since the reference point is different, different output will typically be generated. the reference point nsixultemplateresult object for...
Troubleshooting XPCOM components registration
ilure by running firefox from a command prompt: rem close all firefox windows! set nspr_log_modules=nsnativemoduleloader:5 set nspr_log_file=c:\path\to\logfile "c:\program files\mozilla firefox\firefox.exe" examining this log for warning and errors may provide valuable clues why the component failed to load. if using firefox 4 / xulrunner 2.0, make sure that your extension is unpacked and you
declared the binary component in your chrome.manifest. see xpcom changes in gecko 2.0 parsing errors in javascript components the most common reason for components written in javascript to fail is that there are parsing errors. these parsing errors should show up in the error console if chrome errors are enabled. to learn more about enabling chrome errors, see "how can i see errors in my code" in the e...
Frequently Asked Questions
e answer will just refer back into the reference manual, above. no need to explain things twice :-). buildtime errors the build just broke. it's not in your code, or it's not on your platform, but there's an nscomptr on the line where the error is and you're suspicious. you're looking in the right place. comparing an nscomptr to a raw xpcom interface pointer declaring an nscomptr to a forward-
declared class not linking to xpcom not including nscomptr.h different settings of nscap_feature_debug_ptr_types runtime errors ns_assertion "queryinterface needed" may be caused by a class that derives from a given interface, when you forgetting to also specify the interface name in the ns_impl_isupports / ns_impl_threadsafe_isupports macro. for example, the assertion occurs when you convert the ...
Getting Started Guide
nd has the same impact as passing an nscomptr by value if the caller only supplied a raw pointer. void f( nscomptr<t>* ) avoid passing an nscomptr by address, if possible this practice requires callers to have an nscomptr, and requires them to do a little extra work, as operator& for nscomptrs is private (to help prevent leaks caused by casting; also see bug 59414). this is an acceptable way to
declare `in/out' parameters, but prefer passing nscomptrs by reference, as below. // passing an |nscomptr| by pointer requires extra work... void f( nscomptr<nsifoo>* ); // ... nscomptr<nsifoo> myfoo = ...; f( address_of(myfoo) ); void f( nscomptr<t>& ) do pass an nscomptr by reference for `in/out' parameters this is the prefered scheme for providing `in/out' parameters. if...
Reference Manual
inter "in" parameters "out" parameters: getter_addrefs assignment into an nscomptr is fairly easy to understand. the nscomptr releases its old value, if any, and then assigns in the new value, addrefing, and/or calling queryinterface as you specified with the directives described above. these rules apply equally to the "assignment" that happens when copying parameters or function results that are
declared to be nscomptrs. if we want nscomptrs to be a viable substitute for raw xpcom interface pointers, however, we will need to deal with the issue of "out" parameters. many xpcom functions return interface pointers as results through parameters, e.g., // getters can return interface pointers through "out" parameters... nsresult getfoo( nsifoo** ); // a standard getter n...
XPCOM ABI
concern to an extension developer.) extension installation when the application (e.g. firefox) is built, the name of the abi it supports is embedded into it. later on, it could use this value to check compatibility with third-party binary xpcom components. a common point of compatibility check is during the installation of extensions. if an extension provides binary xpcom components, it should
declare their xpcom abi in the install manifest. an extension author may build (compile) the xpcom component for each and every supported machine and pack all the builds into a single xpi, each into its distinctive platform-specific subdirectory. at extension installation time, the application will choose the most fitting component build for its own abi. if no such build is found, the extension will be d...
wrappedJSObject
rappers which are used to protect the chrome code working with content objects. see xpcnativewrapper for detailed documentation. regular xpconnect wrappers which you can encounter, for example, when using xpcom components implemented in js. this article focuses on the latter kind of wrappers, which hide any properties or methods on the component that are not part of the supported interfaces as
declared in xpidl. the rest of this article demonstrates what xpconnect wrappers do and how wrappedjsobject can be used to bypass them. example component to see how the wrappedjsobject property works, we need an example xpcom component implemented in js. see how to build an xpcom component in javascript for details on creating one. for simplicity we omit the component registration code. suppose we re...
Xptcall Porting Guide
same stubs. the stubs forward calls to a platform specific method that uses the interface information supplied by the overridden getinterfaceinfo to extract the parameters and build an array of platform independent nsxptcminivariant structs which are in turn passed on to the overridden callmethod. the platform dependent code is responsible for doing any cleanup and returning. the stub methods are
declared in xptcall/public/xptcstubsdecl.inc. these are '#included' into the declaration of nsxptcstubbase. a similar include file (xptcall/public/xptcstubsdef.inc) is expanded using platform specific macros to define the stub functions. these '.inc' files are checked into cvs. however, they can be regenerated as necessary (i.e. to change the number of stubs or to change their specific declaration) using...
Xptcall Porting Status
p.hp.com> mike gleeson <mgleeson1@netscape.com> i hear that this code is checked in and working. though, there is some doubt - see bug #17997 <font color="white">done</font> aix ppc jim dunn <jdunn@netscape.com> philip k. warren writes: we have gone through several releases of aix without any problems. <font color="white">done</font> irix jason heirtzler <jasonh@m7.engr.sgi.com> jason has
declared this done. jason is no longer working at sgi and will not be maintaining this code. there is some doubt as to whether or not this is working for everyone - see bug #10061. mike shaver <shaver@mozilla.org> is the interim maintainer until someone more suitable can be found. <font color="white">done</font> beos x86 duncan wilcox <duncan@be.com> unix (yet another reuse of the linux 86 code!) dunc...
XUL Overlays
can overlay the xul file in which these buttons are defined, dialogoverlay.xul. (actually, the implementation is one step more complicated than this: base files overlay dialogoverlay.xul from the global component directory, which in turn overlays a platform-specific xul file such as platformdialogoverlay.xul. the mechanism is the same, however.) any dialog that wants to overlay these buttons just
declares the overlay at the top: <?xul-overlay href="chrome://global/content/dialogoverlay.xul"?> and includes an empty box with an id of okcancelbuttons in the ui. the following snippet shows a dialog with custom ui elements at the top and a reference to the overlay's ok and cancel buttons at the bottom: <box align="horizontal" id="bx1" flex="100%" style="margin-bottom: 1em; width: 100%;"> <html:input ...
The libmime module
h" #define mime_superclass parentlclass mimedefclass(foobar, foobarclass, foobarclass, &mime_superclass); the definition of mime_superclass is just to move most of the knowlege of the exact class hierarchy up to the file's header, instead of it being scattered through the various methods; see below. method declarations we will be putting function pointers into the class object, so we
declare them here. they can generally all be static, since nobody outside of this file needs to reference them by name; all references to these routines should be through the class object. extern int foobarmethod(foobar *); ...etc... class initialization function the mimedefclass macro expects us to define a function which will finish up any initialization of the class object that needs to h...
Using C struct and pointers
er is an array of field descriptors. each field descriptor contains the name and field type of the corresponding field of the c struct. the call to structtype() returns a ctype object, and we then apply the new operator to it to create a specific instance of this newly defined type - a javascript representation of the c struct. using c strings with js-ctypes a pointer to char in javascript is
declared as follows: var str = ctypes.pointertype(ctypes.char); now imagine you call a c function that returns a c string and you want to modify the contents of this string. in the js-ctypes context, you can only operate on buffers of known capacity. therefore, the size of the buffer must be specified. additionally, the js-ctypes pointer must be casted to reflect the size of the buffer: var ptr = ctyp...
Declaring and Using Callbacks
function as the callback. this is very powerful, since it allows native code to transparently call into javascript. warning: callbacks must be invoked on the same thread with which they were registered. there is no concurrency logic in js-ctypes, so invoking callbacks on other threads will cause things to crash. prerequiste understanding abi functiontype declaring callbacks a callback is
declared by using ctypes.functiontype. the first argument is the calling convention, the second argument is the return type, and the third is an array of arguments the callback expects. the return type of the javascript callback must match the return type
declared, otherwise js-ctypes will throw an error saying "unexpected return type". examples example 1 this callback that returns bool and has two a...
Memory Management
js code must make sure to free that memory with the correct allocator. it is usually best to expose a freeing function from the binary. keeping objects alive the following js-ctypes objects will hold references to objects, keeping them alive. this is not an exhaustive list, but will help you to understand memory management and how it affects your use of js-ctypes: a function or static data
declared using the
declare() method will hold that library alive. a ctype will hold referent ctype objects alive. a cdata will hold referent cdata objects alive, under specific circumstances. for example, a cdata object produced by accessing a field of a structure or the internals of an array will hold the referent objects alive. what won't keep objects alive it's important to note that getting dire...
Type conversion
implicit convert in js-ctypes, data could be converted implicitly when passing to or returning from a functiontype call, or setting pointer content, an array element or a struct field. ...
Working with ArrayBuffers
ctypes.winapi_abi : ctypes.default_abi, ctypes.void_t, // return ctypes.void_t.ptr, // *dest ctypes.void_t.ptr, // *src ctypes.size_t // count ); } catch (ex) { throw new error('i dont know where to memcpy is defined on your operating system, "' + os.constants.sys.name + '"'); lib.close...
ctypes.open
lla\firefox\profiles\aksozfjt.unnamed profile 10\extensions\asynczip@jetpack" var filepath_mylib = os.path.join(filepath_folder, 'mysubfolder', 'mycfunctionsforunix.so'); var jarpath_mylib = jarpath_folder + 'mysubfolder/mycfunctionsforunix.so'; } this can then be opened and the c functions within can be used from js-ctypes. ...
ABI
the js-ctypes scope. three different abis exist: ctypes.default_abi, ctypes.stdcall_abi, and ctypes.winapi_abi. ctypes.default_abi corresponds to cdecl; standard libraries use this abi. you can also use this for various system calls,including those on mac os x and linux. ctypes.thiscall_abi more information is available at bugzilla :: 552533. ctypes.stdcall_abi used for calling functions
declared with stdcall on windows. these functions' names are automatically mangled for you by js-ctypes. ctypes.winapi_abi used for calling windows system functions. these are
declared as stdcall on windows, but do not have mangled names like those used by stdcall_abi above. os specific win32 and os2 callbacks in js-ctypes under these operating systems use a different abi than regular function decla...
ArrayType
ctype arraytype() type[ length] ); parameters type: it represents the type of the elements or variable which is going to be present in an array length optional it denotes the number of entries present in an array or the number of elements that an array should contain. if you don't specify this parameter, the array's length is unspecified. return value a ctype represents the newly
declared array type. exceptions thrown typeerror type is not a ctype, or type.size is undefined.if the length is specifed but if it is not a valid one,then it is also thrown rangeerror the size of the resulting array can't be represented as both a size_t and as a javascript number. properties property type description elementtype ctype the data type of the elements...
PointerType
return value a ctype object describing the newly created data type. exceptions thrown typeerror thrown if the parameter isn't a ctype. ...
StructType
pe(the_type). read only. size number the size of the type, in bytes. this is the same value as the c sizeof. read only. note: ctypes.void_t.size is undefined. method overview define(fields) methods inherited from ctype ctype array([n]) string tosource() string tostring() methods define() defines a previously
declared opaque type's fields. this lets you convert an opaque structure type into a defined structure type. define( fields ); parameters fields a field specification, as described above. structtype cdata syntax cdata structtype(); structtype is structtype ctype. return value a cdata representing the newly allocated struct. exceptions thrown error fields are not yet defined. struct...
Mozilla
introduction to layout in mozilla ipc protocol definition language (ipdl) ipdl, short for "ipc (inter-process communication) protocol definition language", is a mozilla-specific language allowing c++ code to pass messages between processes or threads in an organized and secure way. all messages for multi-process plugins and tabs in firefox are
declared in the ipdl language. javascript code modules javascript code modules let multiple privileged javascript scopes share code. for example, a module could be used by firefox itself as well as by extensions, in order to avoid code duplication. javascript libraries from mozilla projects in addition to firefox and other applications, mozilla developer...
Debugger.Object - Firefox Developer Tools
this is undefined. if the referent is a host function for which parameter names are not available, return an array with one element per parameter, each of which is undefined. if the referent is a function proxy, return an empty array. if the referent uses destructuring parameters, then the array’s elements reflect the structure of the parameters. for example, if the referent is a function
declared in this way: function f(a, [b, c], {d, e:f}) { ... } then this debugger.object instance’s parameternames property would have the value: ["a", ["b", "c"], {d:"d", e:"f"}] script if the referent is a function that is debuggee code, this is that function’s script, as a debugger.script instance. if the referent is a function proxy or not debuggee code, this is undefined. environment ...
Debugger.Object - Firefox Developer Tools
, this is undefined. if the referent is a host function for which parameter names are not available, return an array with one element per parameter, each of which is undefined. if the referent is a function proxy, return an empty array. if the referent uses destructuring parameters, then the array's elements reflect the structure of the parameters. for example, if the referent is a function
declared in this way: function f(a, [b, c], {d, e:f}) { ... } then this debugger.object instance's parameternames property would have the value: ["a", ["b", "c"], {d:"d", e:"f"}] script if the referent is a function that is debuggee code, this is that function's script, as a debugger.script instance. if the referent is a function proxy or not debuggee code, this is undefined. environment ...
Examine and edit CSS - Firefox Developer Tools
ny changes you make are temporary: reloading the page will restore the original styling. while you're editing css, the context menu you'll see is the normal one for working with editable text: css variable autocompletion css variable names will auto-complete depending on the variables defined in the css. if you enter var( into a property value and then type a dash (-), any variables you have
declared in your css will then appear in an autocomplete list, which shows a color swatch so you can see exactly what color each variable choice is storing (bug 1451211). in addition, hovering over a css variable name brings up a tooltip showing what color value is stored in that variable (bug 1431949). editing keyboard shortcuts you can use the arrow and page up/down keys (along with others) to...
AddressErrors - Web APIs
lete, working version of the example above (except of course that it's not connected to an actual payment handler, so no payments are actually processed). in the example, we're handling a donation to an organization that will be sending a "thank you" gift to the donor, so it requests shipping information along with allowing the donation payment itself. javascript payment request data first, we
declare the variables supportedhandlers, which is compatible with paymentmethoddata, and defaultpaymentdetails, which is a paymentdetailsupdate object. let supportedhandlers = [ { supportedmethods: "basic-card", data: { supportednetworks: ["visa", "mastercard", "amex", "discover"], supportedtypes: ["credit", "debit"] } } ]; let defaultpaymentdetails = { total: {label: 'don...
AudioTrackList.getTrackById() - Web APIs
hin the track list. return value an audiotrack object indicating the first track found within the audiotracklist whose id matches the specified string. if no match is found, this method returns null. the tracks are searched in their natural order; that is, in the order defined by the media resource itself, or, if the resource doesn't define an order, the relative order in which the tracks are
declared by the media resource. example this example suggests a hypothetical game in which movies are used as cut-scenes or other key set pieces within the game. each movie has one audio track for each character, as well as one for the music, sound effects, and so forth. this function allows the game to disable a specific character's audio in order to adjust the movie's performance based on occurrences...
Body - Web APIs
body is implemented by both request and response. this provides these objects with an associated body (a stream), a used flag (initially unset), and a mime type (initially the empty byte sequence). properties body.body read only a simple getter used to expose a readablestream of the body contents. body.bodyused read only a boolean that indicates whether the body has been read. methods body.arraybuffer() takes a response stream and reads it to completion. it returns a promise that resolves with an arraybuffer. ...
Using the CSS Painting API - Web APIs
%, 0.3); } and we register our worklet css.paintworklet.addmodule('https://mdn.github.io/houdini-examples/csspaint/intro/03partthree/header-highlight.js'); while you can't edit the worklet itself, you can play around with the css and html. maybe try float and clear on the headers? you could try making the background images above without the css paint api. it is doable, but you would have to
declare a different, fairly complex linear gradient for each different color you wanted to create. with the css paint api, one worklet can be re-used, with different colors passed in this case. passing parameters with the css paint api, we not only have access to custom properties and regular properties, but we can pass custom arguments to the paint() function as well. we can add these extra argument...
Using the CSS Typed Object Model - Web APIs
e 16 px font-stretch 100 percent animation-duration 0 s animation-iteration-count 1 number width auto undefined height auto undefined you'll note the <length> unit returned is px, the <percentage> unit returned is percent, the <time> unit is s for 'seconds', and the unitless <number> unit is number. we didn't
declare a width or a height for the paragraph, both of which default to auto and therefore return a csskeywordvalue instead of a cssunitvalue. csskeywordvalues do not have a unit property, so in these cases our get().unit returns undefined. had the width or height been defined in a <length> or <percent>, the cssunitvalue unit would have been px or percent respectively. there are other types available:...
Document.onbeforescriptexecute - Web APIs
does not fire if the element is added dynamically, eg with appendchild(). syntax document.onbeforescriptexecute = funcref; funcref is a function reference, called when the event is fired. the event's target attribute is set to the script element that is about to be executed. ...
Document: transitionend event - Web APIs
bubbles yes cancelable yes interface transitionevent event handler property ontransitionend the transitionend event is fired in both directions - as it finishes transitioning to the transitioned state, and when it fully reverts to the default or non-transitioned state. if there is no transition delay or duration, if both are 0s or neither is
declared, there is no transition, and none of the transition events are fired. if the transitioncancel event is fired, the transitionend event will not fire. the original target for this event is the element that had the transition applied. you can listen for this event on the document interface to handle it in the capture or bubbling phases. for full details on this event please see the page on htmlele...
DocumentType - Web APIs
y="30" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">documenttype</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits properties from its parent, node, and implements the childnode interface. documenttype.entities read only a namednodemap of entities
declared in the dtd. every node in this map implements the entity interface. documenttype.internalsubset read only a domstring of the internal subset, or null if there is none. eg "<!element foo (bar)>". documenttype.name read only a domstring, eg "html" for <!doctype html>. documenttype.notations read only a namednodemap with notations
declared in the dtd. every node in this map implements ...
Fetch API - Web APIs
windoworworkerglobalscope.fetch() the fetch() method used to fetch a resource. headers represents response/request headers, allowing you to query them and take different actions depending on the results. request represents a resource request. response represents the response to a request. fetch mixin body provides methods relating to the body of the response/request, allowing you to
declare what its content type is and how it should be handled. specifications specification status comment fetch living standard initial definition ...
Using the Gamepad API - Web APIs
ed every time the gamepad's state changes. using button information let's look at a simple example that displays connection information for one gamepad (it ignores subsequent gamepad connections) and allows you to move a ball around the screen using the four gamepad buttons on the right hand side of the gamepad. you can view the demo live, and find the source code on github. to start with, we
declare some variables: the gamepadinfo paragraph that the connection info is written into, the ball that we want to move, the start variable that acts as the id for requestanimation frame, the a and b variables that act as position modifiers for moving the ball, and the shorthand variables that will be used for the requestanimationframe() and cancelanimationframe() cross browser forks. var gamepadinfo ...
HTMLElement: transitioncancel event - Web APIs
{ message.textcontent = 'transitioncancel fired'; }); el.addeventlistener('transitionend', function() { message.textcontent = 'transitionend fired'; }); the transitioncancel event is fired if the transition is cancelled in either direction after the transitionrun event occurs and before the transitionend is fired. if there is no transition delay or duration, if both are 0s or neither is
declared, there is no transition, and none of the transition events are fired. if the transitioncancel event is fired, the transitionend event will not fire. specifications specification status comment css transitionsthe definition of 'transitioncancel' in that specification. working draft initial definition. ...
IDBDatabase.transaction() - Web APIs
can use to access your object store. note: this feature is available in web workers. syntax idbdatabase.transaction(storenames); idbdatabase.transaction(storenames, mode); parameters "durability" -- the durability constrints for the transction. valid values are: "default", "strict", and "relaxed". storenames the names of object stores that are in the scope of the new transaction,
declared as an array of strings. specify only the object stores that you need to access. if you need to access only one object store, you can specify its name as a string. therefore the following lines are equivalent: var transaction = db.transaction(['my-store-name']); var transaction = db.transaction('my-store-name'); if you need to access all object stores in the database, you can use the prope...
IDBKeyRange.lower - Web APIs
the lower read-only property of the idbkeyrange interface returns the lower bound of the key range. note: this feature is available in web workers. syntax var lower = mykeyrange.lower value the lower bound of the key range (can be any type.) example the following example illustrates how you'd use a key range. here we
declare keyrangevalue = idbkeyrange.upperbound("f", "w", true, true); — a range that includes everything between "f" and "w" but not including them — since both the upper and lower bounds have been
declared as open (true). we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. after declaring the key range, we log its lower property value to the console...
IDBKeyRange.lowerBound() - Web APIs
des the endpoint value. the default is false. return value idbkeyrange: the newly created key range. exceptions this method may raise a domexception of the following type: exception description dataerror the value parameter passed was not a valid key. example the following example illustrates how you'd use a lower bound key range. here we
declare keyrangevalue = idbkeyrange.lowerbound("f", false); — a range that includes the value "f" and everthing after it. we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. this means that the cursor will only retrieve the record with the key value "f" and all that come after it. if...
IDBKeyRange.lowerOpen - Web APIs
n the key range. note: this feature is available in web workers. syntax var loweropen = mykeyrange.loweropen value a boolean: value indication true the lower-bound value is not included in the key range. false the lower-bound value is included in the key range. example the following example illustrates how you'd use a key range. here we
declare keyrangevalue = idbkeyrange.upperbound("f", "w", true, true); — a range that includes everything between "f" and "w" but not including them — since both the upper and lower bounds have been
declared as open (true). we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. after ...
IDBKeyRange.only() - Web APIs
arameters value is the value for the new key range. return value idbkeyrange: the newly created key range. exceptions this method may raise a domexception of the following types: exception description dataerror the value parameter passed was not a valid key. example the following example illustrates how you'd use an only key range. here we
declare a keyrangevalue = idbkeyrange.only("a"); — a range that only includes the value "a". we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. this means that the cursor will only retrieve the record with the key value "a". note: for a more complete example allowing you to experi...
IDBKeyRange.upper - Web APIs
the upper read-only property of the idbkeyrange interface returns the upper bound of the key range. note: this feature is available in web workers. syntax var upper = mykeyrange.upper value the upper bound of the key range (can be any type.) example the following example illustrates how you'd use a key range. here we
declare keyrangevalue = idbkeyrange.upperbound("f", "w", true, true); — a range that includes everything between "f" and "w" but not including them — since both the upper and lower bounds have been
declared as open (true). we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. after declaring the key range, we log its upper property value to the console...
IDBKeyRange.upperBound() - Web APIs
s the endpoint value. the default is false. optional return value idbkeyrange: the newly created key range. exceptions this method may raise a domexception of the following type: exception description dataerror the value parameter passed was not a valid key. example the following example illustrates how you'd use an upper bound key range. here we
declare keyrangevalue = idbkeyrange.upperbound("f"); — a range that includes the value "f" and everything before it. we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. if we used idbkeyrange.upperbound("f", true);, then the range excludes "f"; and instead only includes the values ...
IDBKeyRange.upperOpen - Web APIs
n the key range. note: this feature is available in web workers. syntax var upperopen = mykeyrange.upperopen value a boolean: value indication true the upper-bound value is not included in the key range. false the upper-bound value is included in the key range. example the following example illustrates how you'd use a key range. here we
declare keyrangevalue = idbkeyrange.upperbound("f", "w", true, true); — a range that includes everything between "f" and "w" but not including them — since both the upper and lower bounds have been
declared as open (true). we open a transaction (using idbtransaction) and an object store, and open a cursor with idbobjectstore.opencursor, declaring keyrangevalue as its optional key range value. after ...
MSSiteModeEvent - Web APIs
target. target gets the element that is the target of the event. timestamp gets the time, in milliseconds, when an event occurred. ...
Using the MediaStream Recording API - Web APIs
ts horizontal translation value changed and transition smoothly into view: input[type=checkbox]:checked ~ aside { transform: translatex(0); } basic app setup to grab the media stream we want to capture, we use getusermedia(). we then use the mediarecorder api to record the stream, and output each recorded snippet into the source of a generated <audio> element so it can be played back. ...
Notation - Web APIs
inherits methods and properties from node. its nodename is the notation name. has no parent. properties notation.publicid read only is a domstring. notation.systemid read only is a domstring. specifications specification status comment document object model (dom) level 3 core specificationthe definition of 'notation' in that specification. obsolete no change document object model (dom) level 2 core specificationthe definition of 'notation' in that specification. ...
OfflineAudioContext.startRendering() - Web APIs
chanisms are provided for legacy reasons. syntax event-based version: offlineaudioctx.startrendering(); offlineaudioctx.oncomplete = function(e) { // e.renderedbuffer contains the output buffer } promise-based version: offlineaudioctx.startrendering().then(function(buffer) { // buffer contains the output buffer }); parameters none. returns void. example in this simple example, we
declare both an audiocontext and an offlineaudiocontext object. we use the audiocontext to load an audio track via xhr (audiocontext.decodeaudiodata), then the offlineaudiocontext to render the audio into an audiobuffersourcenode and play the track through. after the offline audio graph is set up, you need to render it to an audiobuffer using offlineaudiocontext.startrendering. when the startrendering()...
OfflineAudioContext - Web APIs
thus can be accessed by both the audiocontext and offlineaudiocontext interfaces. events listen to these events using addeventlistener() or by assigning an event listener to the oneventname property of this interface: complete fired when the rendering of an offline audio context is complete. also available using the oncomplete event handler property. examples in this simple example, we
declare both an audiocontext and an offlineaudiocontext object. we use the audiocontext to load an audio track via xhr (audiocontext.decodeaudiodata), then the offlineaudiocontext to render the audio into an audiobuffersourcenode and play the track through. after the offline audio graph is set up, you need to render it to an audiobuffer using offlineaudiocontext.startrendering. when the startrendering()...
Path2D - Web APIs
the path methods of the canvasrenderingcontext2d interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. constructors path2d() path2d constructor. creates a new path2d object. methods path2d.addpath() adds a path to the current path. path2d.closepath() causes the point of the pen to move back to the start of the current sub-path. it tries to draw a straight line from the current point to the start. if the shape has already been closed or has only one point, this function does nothing. ...
Pointer Lock API - Web APIs
events regardless of mouse button state. it hides the cursor. method/properties overview this section provides a brief description of each property and method related to the pointer lock specification. requestpointerlock() the pointer lock api, similar to the fullscreen api, extends dom elements by adding a new method, requestpointerlock(). ...
Request - Web APIs
er of the request (e.g., client). request.referrerpolicy read only contains the referrer policy of the request (e.g., no-referrer). request.url read only contains the url of the request. request implements body, so it also inherits the following properties: body read only a simple getter used to expose a readablestream of the body contents. bodyused read only stores a boolean that
declares whether the body has been used in a response yet. methods request.clone() creates a copy of the current request object. request implements body, so it also has the following methods available to it: body.arraybuffer() returns a promise that resolves with an arraybuffer representation of the request body. body.blob() returns a promise that resolves with a blob representation of the ...
Response - Web APIs
cors). response.url read only the url of the response. response.usefinalurl a boolean indicating whether this is the final url of the response. body interface properties response implements body, so it also has the following properties available to it: body.body read only a simple getter exposing a readablestream of the body contents. body.bodyused read only stores a boolean that
declares whether the body has been used in a response yet. methods response.clone() creates a clone of a response object. response.error() returns a new response object associated with a network error. response.redirect() creates a new response with a different url. body interface methods response implements body, so it also has the following methods available to it: body.arraybuffer() t...
SVGAnimatedString - Web APIs
properties svganimatedstring.animval read only this is a domstring representing the animation value. if the given attribute or property is being animated it contains the current animated value of the attribute or property. if the given attribute or property is not currently being animated, it contains the same value as baseval. ...
getTrackById() - Web APIs
within the track list. return value a texttrack object indicating the first track found within the texttracklist whose id matches the specified string. if no match is found, this method returns null. the tracks are searched in their natural order; that is, in the order defined by the media resource itself, or, if the resource doesn't define an order, the relative order in which the tracks are
declared by the media resource. specifications specification status comment html living standardthe definition of 'texttracklist.gettrackbyid()' in that specification. living standard ...
USBDevice.usbVersionMajor - Web APIs
the usbversionmajor read only property of the usbdevice interface is one of three properties that
declare the usb protocol version supported by the device. the other two properties are usbdevice.usbversionminor and usbdevice.usbversionsubminor. syntax var serialnumber = usbdevice.usbversionmajor value the last of three properties that
declare the usb protocol version supported by the device. specifications specification status comment webusbthe definition of 'usbversionmajor' in that specification. draft initial definition. ...
USBDevice.usbVersionMinor - Web APIs
the usbversionminor read only property of the usbdevice interface is one of three properties that
declare the usb protocol version supported by the device. the other two properties are usbdevice.usbversionmajor and usbdevice.usbversionsubminor. syntax var serialnumber = usbdevice.usbversionminor value the second of three properties that
declare the usb protocol version supported by the device. specifications specification status comment webusbthe definition of 'usbversionminor' in that specification. draft initial definition. ...
USBDevice.usbVersionSubminor - Web APIs
the usbversionsubminor read only property of the usbdevice interface is one of three properties that
declare the usb protocol version supported by the device. the other two properties are usbdevice.usbversionmajor and usbdevice.usbversionminor. syntax var serialnumber = usbdevice.usbversionsubminor value the first of three properties that
declare the usb protocol version supported by the device. specifications specification status comment webusbthe definition of 'usbversionsubminor' in that specification. draft initial definition. ...
getTrackById - Web APIs
thin the track list. return value a videotrack object indicating the first track found within the videotracklist whose id matches the specified string. if no match is found, this method returns null. the tracks are searched in their natural order; that is, in the order defined by the media resource itself, or, if the resource doesn't define an order, the relative order in which the tracks are
declared by the media resource. specifications specification status comment html living standardthe definition of 'videotracklist.gettrackbyid()' in that specification. living standard ...
Data in WebGL - Web APIs
this is commonly used to share a vertex's normal vector after it has been computed by the vertex shader. <<how to use>> uniforms uniforms are set by the javascript code and are available to both the vertex and fragment shaders. they're used to provide values that will be the same for everything drawn in ...
Getting started with WebGL - Web APIs
github repository. it's worth noting here that this series of articles introduces webgl itself; however, there are a number of frameworks available that encapsulate webgl's capabilities, making it easier to build 3d applications and games, such as three.js and babylon.js. preparing to render in 3d the first thing you need in order to use webgl for rendering is a canvas. the html fragment below
declares a canvas that our sample will draw into. <body> <canvas id="glcanvas" width="640" height="480"></canvas> </body> preparing the webgl context the main() function in our javascript code, is called when our script is loaded. its purpose is to set up the webgl context and start rendering content. // // start here // function main() { const canvas = document.queryselector("#glcanvas"); // ...
Using the Web Speech API - Web APIs
rammar format (jsgf) — you can find a lot more about it at the previous link to its spec. however, for now let's just run through it quickly: the lines are separated by semi-colons, just like in javascript. the first line — #jsgf v1.0; — states the format and version used. this always needs to be included first. the second line indicates a type of term that we want to recognise. public
declares that it is a public rule, the string in angle brackets defines the recognised name for this term (color), and the list of items that follow the equals sign are the alternative values that will be recognised and accepted as appropriate values for the term. note how each is separated by a pipe character. you can have as many terms defined as you want on separate lines following the above structur...
Window: transitionend event - Web APIs
bubbles yes cancelable yes interface transitionevent event handler property ontransitionend the transitionend event is fired in both directions - as it finishes transitioning to the transitioned state, and when it fully reverts to the default or non-transitioned state. if there is no transition delay or duration, if both are 0s or neither is
declared, there is no transition, and none of the transition events are fired. if the transitioncancel event is fired, the transitionend event will not fire. the original target for this event is the element that had the transition applied. you can listen for this event on the window interface to handle it in the capture or bubbling phases. for full details on this event please see the page on htmleleme...
WindowOrWorkerGlobalScope.setInterval() - Web APIs
of other issues could prevent the request from completing in its allotted time. as such, you may find yourself with queued up xhr requests that won't necessarily return in order. in these cases, a recursive settimeout() pattern is preferred: (function loop(){ settimeout(function() { // your logic here loop(); }, delay); })(); in the above snippet, a named function loop() is
declared and is immediately executed. loop() is recursively called inside settimeout() after the logic has completed executing. while this pattern does not guarantee execution on a fixed interval, it does guarantee that the previous interval has completed before recursing. specifications specification status comment html living standardthe definition of 'windoworworkerglobalscop...
HTML in XMLHttpRequest - Web APIs
ch (e) { window.settimeout(function() { if (!done) { done = true; callback(false); } }, 0); } } the argument callback is a function that will be called asynchronously with true as the only argument if html parsing is supported and false as the only argument if html parsing is not supported. view on jsfiddle character encoding if the character encoding is
declared in the http content-type header, that character encoding is used. failing that, if there is a byte order mark, the encoding indicated by the byte order mark is used. failing that, if there is a <meta> element that
declares the encoding within the first 1024 bytes of the file, that encoding is used. otherwise, the file is decoded as utf-8. handling html on older browsers xmlhttprequest original...
Using the group role - Accessibility
aria attributes used group related aria techniques region role compatibility tbd: add support information for common ua and at product combinations additional resources aria authoring practices – acc...
ARIA: form role - Accessibility
ecommended to use <form> instead. <form id="send-comment" aria-label="add a comment"> .... </form> accessibility concerns use sparingly landmark roles are intended to identify larger overall sections of the document. using too many landmark roles can create "noise" in screen readers, making it difficult to understand the overall layout of the page. inputs are not forms you do not need to
declare role="form" on every form element (inputs, text areas, selects, etc.). it should be
declared on the html element that wraps the form elements. ideally, use the <form> element as the wrapping element and do not
declare role="form". search if a form is used to search, you should use the more specialized role="search" value. labeling landmarks each <form> element and form role that needs to be e...
ARIA: Region role - Accessibility
re</h3> <!-- content --> </div> in this example, the region's label is being generated by the aria-labelledby attribute. scrolling content areas with overflow text if there is a content area with tabindex="0", add role="region" to convey to screen reader users that is a generic region. this is done to allow keyboard-only users to scroll regions with overflow text. svg role="region" can be
declared on areas of svg along with an aria-label to allow individual sections of the svg to be described. added benefits certain technologies such as browser extensions can generate lists of all landmark roles present on a page, allowing non-screen reader users to also quickly identify and navigate to large sections of the document. landmarks browser extension specifications specificati...
Cognitive accessibility - Accessibility
meaning. for these users, the ability to read and understand may depend on the availability of specific definitions or the expanded forms of acronyms or abbreviations. some users may experience great difficulty in recognizing written words yet they understand extremely complex and sophisticated documents when the text is read aloud, or when key processes and ideas are illustrated visually.
declare the language of the page and any content not in that main language. the language of every page must be
declared by using the lang attribute on the <html> element. include the lang attribute again on text that is in a language other than the main language of the document. proper use of lang allows some screen readers to announce the text properly when converting it into synthetic speech. it a...
Custom properties (--*): CSS variables - CSS: Cascading Style Sheets
property names that are prefixed with --, like --example-name, represent custom properties that contain a value that can be used in other declarations using the var() function. custom properties are scoped to the element(s) they are
declared on, and participate in the cascade: the value of such a custom property is that from the declaration decided by the cascading algorithm. initial valuesee proseapplies toall elementsinheritedyescomputed valueas specified with variables substitutedanimation typediscrete syntax --somekeyword: left; --somecolor: #0000ff; --somecomplexvalue: 3px 6px rgb(20, 32, 54); <declaration-value> this value matches any sequence of one or more tokens, so long as the sequence does not contain an unallowed token. it represents the entirety of what a valid declaration ...
-webkit-mask-composite - CSS: Cascading Style Sheets
the -webkit-mask-composite property specifies the manner in which multiple mask images applied to the same element are composited with one another. mask images are composited in the opposite order that they are
declared with the -webkit-mask-image property. /* keyword values */ -webkit-mask-composite: clear; -webkit-mask-composite: copy; -webkit-mask-composite: source-over; -webkit-mask-composite: source-in; -webkit-mask-composite: source-out; -webkit-mask-composite: source-atop; -webkit-mask-composite: destination-over; -webkit-mask-composite: destination-in; -webkit-mask-composite: destination-out; -webkit-mask-composite: destination-atop; -webkit-mask-composite: xor; /* global values */ -webkit-mask-composite: inherit; -webkit-mask-composite: initial; -webkit-mask-composite: unset...
@font-face - CSS: Cascading Style Sheets
format mime type truetype font/ttf opentype font/otf web open font format font/woff web open font format 2 font/woff2 notes web fonts are subject to the same domain restriction (font files must be on the same domain as the page using them), unless http access controls are used to relax this restriction. @font-face cannot be
declared within a css selector. for example, the following will not work: .classname { @font-face { font-family: myhelvetica; src: local("helvetica neue bold"), local("helveticaneue-bold"), url(mgopenmodernabold.ttf); font-weight: bold; } } formal syntax @font-face { [ font-family: <family-name>; ] | [ src: <src>; ] | [ unicode-range: <unicode-range>; ] | ...
any-pointer - CSS: Cascading Style Sheets
des an accurate pointing device. note: more than one value can match if the available devices have different characteristics, although none only matches when none of them are pointing devices. examples this example creates a small checkbox for users with at least one fine pointer and a large checkbox for users with at least one coarse pointer. the big checkbox takes precedence because it is
declared after the small one. html <input id="test" type="checkbox" /> <label for="test">look at me!</label> css input[type="checkbox"]:checked { background: gray; } @media (any-pointer: fine) { input[type="checkbox"] { -moz-appearance: none; -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border: 1px solid blue; } } @media (any-pointer: coarse) ...
Handling Overflow in Multicol - CSS: Cascading Style Sheets
ls with overflow, both inside the column boxes and in situations where there is more content than will fit into the container. overflow inside column boxes an overflow situation happens when an item's size is larger than the column box. for example, the situation could happen when an image in a column is wider than the column-width value or the width of the column based on the number of columns
declared with column-count. in this situation, the content should visibly overflow into the next column, rather than be clipped by the column box. you can see an example of this below, with an image of the expected rendering as, at the time of writing, browsers deal with this differently. if you want an image to size down to fit the column box, the standard responsive images solution of setting max...
Spanning and Balancing Columns - CSS: Cascading Style Sheets
ntent to create columns after the spanner. use spanning carefully and test at various breakpoints to make sure you get the intended effect. column filling and balancing a balanced set of columns is where all columns have approximately the same amount of content. filling and balancing comes into play when the amount of content does not match the amount of space provided, such as when a height is
declared on the container. the initial value of multicol for column-fill is balance. the value of balance means all columns are as balanced as is possible. in fragmented contexts such as paged media, only the last fragment is balanced. this means that on the last page the final set of column boxes will be balanced. there is a second value for balancing, balance-all, which attempts to balance all column...
Aligning Items in a Flex Container - CSS: Cascading Style Sheets
flex-end align-items: center align-items: stretch align-items: baseline in the live example below, the value of align-items is stretch. try the other values and see how all of the items align against each other in the flex container. aligning one item with align-self the align-items property sets the align-self property on all of the flex items as a group. this means you can explicitly
declare the align-self property to target a single item. the align-self property accepts all of the same values as align-items plus a value of auto, which will reset the value to that which is defined on the flex container. in this next live example, the flex container has align-items: flex-start, which means the items are all aligned to the start of the cross axis. i have targeted the first item using ...
Backwards Compatibility of Flexbox - CSS: Cascading Style Sheets
you use display: table-cell on an item in your html it takes on the styling of an html table cell. css creates anonymous boxes to represent these items so that you do not need to wrap each item in a wrapper to represent the html table row, and a second one to represent the table element itself, you can’t see or style these anonymous boxes; they are there purely to fix up the tree. if you then
declare display: flex on the parent item, these anonymous boxes do not get created and so your item remains a direct child and can become a flex item — losing any of the table display features. “note: some values of display normally trigger the creation of anonymous boxes around the original box. if such a box is a flex item, it is blockified first, and so anonymous box creation will not happen. fo...
Basic concepts of flexbox - CSS: Cascading Style Sheets
the size of that item in terms of the space it leaves as available space. the initial value of this property is auto — in this case the browser looks to see if the items have a size. in the example above, all of the items have a width of 100 pixels and so this is used as the flex-basis. if the items don’t have a size then the content's size is used as the flex-basis. this is why when we just
declare display: flex on the parent to create flex items, the items all move into a row and take only as much space as they need to display their contents. the flex-grow property with the flex-grow property set to a positive integer, flex items can grow along the main axis from their flex-basis. this will cause the item to stretch and take up any available space on that axis, or a proportion of the ava...
OpenType font features guide - CSS: Cascading Style Sheets
ng is on by default, it will still be on even with a value of none being supplied here.) font feature settings font-feature-settings is the 'low level syntax' that allows explicit access to every named available opentype feature. this gives a lot of control, but has some disadvantages in how it impacts inheritance and — as mentioned above — if you wish to change one setting, you have to re
declare the entire string (unless you're using css custom properties to set the values). because of this, it's best to use the standard properties shown above wherever possible. there a huge number of possible features. you can see examples of a number of them above, and there are several resources available for finding more of them. the general syntax looks like this: .small-caps { font-feature-set...
Variable fonts guide - CSS: Cascading Style Sheets
ings it is important to note that axis names are case-sensitive. the registered axis names must be in lower case, and custom axes must be in upper case. for example: font-variation-settings: 'wght' 375, 'grad' 88; wght (weight) is a registered axis, and grad (grade) is a custom one. if you have set values using font-variation-settings and want to change one of those values, you must re
declare all of them (in the same way as when you set opentype font features using font-feature-settings). you can work around this limitation by using css custom properties (css variables) for the individual values, and simply modifying the value of an individual custom property. example code follows at the end of the guide. weight weight (represented by the wght tag) defines the design axis of how ...
Grid template areas - CSS: Cascading Style Sheets
out created earlier in this guide. .wrapper { display: grid; grid-template: "hd hd hd hd hd hd hd hd hd" minmax(100px, auto) "sd sd sd main main main main main main" minmax(100px, auto) "ft ft ft ft ft ft ft ft ft" minmax(100px, auto) / 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ; } the first value is our grid-template-areas value but we also
declare the size of the row at the end of each row. this is what the minmax(100px, auto) is doing. then after grid-template-areas we have a forward slash, after that is an explicit track listing of column tracks. grid the grid shorthand goes a step further and also sets properties used by the implicit grid. so you will be setting: grid-template-rows grid-template-columns grid-template-areas grid...
Subgrid - CSS: Cascading Style Sheets
id uses the tracks defined on the parent. for example, if you use grid-template-columns: subgrid and the nested grid spans three column tracks of the parent, the nested grid will have three column tracks of the same size as the parent grid. gaps are inherited but can also be overridden with a different gap value. line names can be passed from the parent into the subgrid, and the subgrid can also
declare its own line names. subgrid for columns in the example below i have a grid layout with nine 1fr column tracks and four rows that are a minimum of 100px tall. i place .item from column line 2 to 7, and row 2 to 4. i then make this grid item into a grid, giving it column tracks that are a subgrid and defining rows as normal. as the item spans five column tracks, this means that the subgrid has f...
Consistent list indentation - CSS: Cascading Style Sheets
one of the most common style changes made to lists is a change in the indentation distance—that is, how far the list items are pushed over to the right. this often leads to frustration, because what works in one browser often doesn't have the same effect in another. for example, if you
declare that lists have no left margin, they move over in internet explorer, but sit stubbornly in place in gecko-based browsers.this article will help you understand the problems that can occur and how to avoid them. in order to understand why this is the case, and more importantly how to avoid the problem altogether, it's necessary to examine the details of list construction. making a list first, we consider a single, pure list item. this list item has no marker (otherwise known as a "bullet") and is not ye...
Using CSS custom properties (variables) - CSS: Cascading Style Sheets
: brown; } we'll apply it to this html: <div> <div class="one">1:</div> <div class="two">2: text <span class="five">5 - more text</span></div> <input class="three"> <textarea class="four">4: lorem ipsum</textarea> </div> ... which leads us to this: notice the repetition in the css. the background color is set to brown in several places. for some css declarations, it is possible to
declare this higher in the cascade and let css inheritance solve this problem naturally. for non-trivial projects, this is not always possible. by declaring a custom property on the :root pseudo-class and using it where needed throughout the document, a css author can reduce the need for repetition: :root { --main-bg-color: brown; } .one { color: white; background-color: var(--main-bg-color); ...
Visual formatting model - CSS: Cascading Style Sheets
n to the principal box, for example display: list-item generates more than one box (e.g. a principal block box and a child marker box). and some values (such as none or contents) cause the element and/or its descendants to not generate any boxes at all. anonymous boxes an anonymous box is created when there is not an html element to use for the box. this situation happens when, for example, you
declare display: flex on a parent element, and directly inside there is a run of text not contained in another element. in order to fix the box tree, an anonymous box is created around that run of text. it will then behave as a flex item, however, it cannot be targeted and styled like a regular box because there is no element to target. the same thing happens when you have text runs interspersed with ...
conic-gradient() - CSS: Cascading Style Sheets
e over 80% of the turn, with the final 10% being solid blue. the midpoint of the red to blue gradient change, however, is at the 20% mark rather than the 50% mark as would have happened without the 80grad, or 20%, color hint. conic-gradient(red 40grad, 80grad, blue 360grad); if two or more color stops are at the same location, the transition will be a hard line between the first and last colors
declared at that location. to use conic gradients to create pie charts --- which is not the correct way to create pie charts as background images are not accessible -- use hard color stops, where the color stop angles for two adjacent color stops are the same. the easiest way to do this is to use multip position colors stops. the following two declarations are equivalent: conic-gradient(#fff 0.09turn, #...
display - CSS: Cascading Style Sheets
the layout used for its children, such as flow layout, grid or flex. formally, the display property sets an element's inner and outer display types. the outer type sets an element's participation in flow layout; the inner type sets the layout of children. some values of display are fully defined in their own individual specifications; for example the detail of what happens when display: flex is
declared is defined in the css flexible box model specification. see the table at the end of this document for all of the individual specifications. syntax the css display property is specified using keyword values. keyword values are grouped into six value categories: .container { display: [ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <displa...
env() - CSS: Cascading Style Sheets
the env() css function can be used to insert the value of a user agent-defined environment variable into your css, in a similar fashion to the var() function and custom properties. the difference is that, as well as being user-agent defined rather than user-defined, environment variables are globally scoped to a document, whereas custom properties are scoped to the element(s) on which they are
declared. to tell the browser to use the whole available space on the screen, and so enabling us to use the env() variables, we need to add a new viewport meta value: <meta name="viewport" content="viewport-fit=cover" /> body { padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px); } in addition, unl...
image() - CSS: Cascading Style Sheets
ntage><hue> = <number> | <angle> where: image-tagsoptional the directionality of the image, either ltr for left-to-right or rtl for right-to-left. image-src optional zero or more <url>s or <string>s specifying the image sources, with optional image fragment identifiers. coloroptional a color, specifying a solid background color to use as a fallback if no image-src is found, supported, or
declared. bi-directional awareness the first, optional parameter of the image() notation is the directionality of the image. if included, and the image is used on an element with opposite directionality, the image will be flipped horizontally in horizontal writing modes. if the directionality is omitted, the image won't be flipped if the language direction is changed. image fragments one key differe...
left - CSS: Cascading Style Sheets
nt.</p> <div id="example_4"> <pre> position: absolute; bottom: 10px; right: 20px; </pre> <p>absolute position inside of a parent with relative position</p> </div> <div id="example_5"> <pre> position: absolute; right: 0; left: 0; top: 200px; </pre> <p>absolute position with both left and right
declared</p> </div> </div> </div> css #wrap { width: 700px; margin: 0 auto; background: #5c5c5c; } pre { white-space: pre; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; } #example_1 { width: 200px; height: 200px; position: absolute; left: 20px; top: 20px; background-color: #d8f5ff; } #example_2 { width: 200px; height: 200px; position: relative...
list-style-position - CSS: Cascading Style Sheets
hand list-style. note: this property is applied to list items, i.e., elements with display: list-item;. by default this includes <li> elements. because this property is inherited, it can be set on the parent element (normally <ol> or <ul>) to let it apply to all list items. note that there is variance among browsers regarding behavior when a block element is placed first within a list element
declared as list-style-position: inside. chrome and safari both place this element on the same line as the marker box, whereas firefox, internet explorer, and opera place it on the next line. for more information on this, see bug 36854. syntax /* keyword values */ list-style-position: inside; list-style-position: outside; /* global values */ list-style-position: inherit; list-style-position: initial; ...
min() - CSS: Cascading Style Sheets
labels and inputs to shrink as the width of the form shrinks. let's look at some css: input, label { padding: 2px; box-sizing: border-box; display: inline-block; width: min(40%, 400px); background-color: pink; } form { margin: 4px; border: 1px solid black; padding: 4px; } here, the form itself, along with the margin, border, and padding, will be 100% of its parent's width. we
declare the input and label to be the lesser of 40% of the form width up to the padding or 400px wide, whichever is smaller. in other words, the widest that the label and input can be is 400px. the narrowest they will be is 40% of the form's width, which on a smartwatch's screen is very small. <form> <label>type something:</label> <input type="text"> </form> specifications specificati...
EXSLT
ns (regexp)the exslt regular expressions package provides functions that allow testing, matching, and replacing text using javascript style regular expressions.sets (set)the exslt sets package offers functions that let you perform set manipulation.strings (str)the exslt strings package provides functions that allow the manipulation of strings. exslt modules to use an exslt function, you need to
declare the namespace the function is in, and then use the appropriate prefix when calling the function. for example, to use the regular expressions package: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:regexp="http://exslt.org/regular-expressions"> <xsl:template match="/"> ... <xsl:value-of select="regexp:replace(/root/@v...
Constraint validation - Developer guides
, invalid ones can still be sent by non-compliant browsers (for instance, browsers without html5 and without javascript) or by bad people trying to trick your web application. therefore, like with html4, you need to also validate input constraints on the server side, in a way that is consistent with what is done on the client side. intrinsic and basic constraints in html5, basic constraints are
declared in two ways: by choosing the most semantically appropriate value for the type attribute of the <input> element, e.g., choosing the email type automatically creates a constraint that checks whether the value is a valid e-mail address. by setting values on validation-related attributes, allowing basic constraints to be described in a simple way, without the need for javascript. semantic inpu...
Introduction to HTML5 - Developer guides
f bytes that must be downloaded. declaring the character set with the <meta charset> the first thing done on a page is usually indicating the character set that is used. in previous versions of html, it was done using a very complex <meta> element. now, it is very simple: <meta charset="utf-8"> place this right after your <head>, as some browsers restart the parsing of an html document if the
declared character set is different from what they had anticipated. also, if you are not currently using utf-8, it's recommended that you switch to it in your web pages, as it simplifies character handling in documents using different scripts. note that html5 restricts character sets to those compatible with ascii and using at least 8 bits. this was done to tighten security and prevent some types of att...
Index - Developer guides
odings, html, localization, needsmarkupwork browsers process text as unicode internally. however, a way of representing characters in terms of bytes (character encoding) is used for transferring text over the network to the browser. the html specification recommends the use of the utf-8 encoding (which can represent all of unicode) and regardless of the encoding used requires web content to
declare what encoding was used. 32 mobile web development intermediate, needsexample this page provides an overview of some of the main techniques needed to design web sites that work well on mobile devices. 33 a hybrid approach mobile, responsive design, web development no approach is a one-size-fits-all solution. web applications that want to heavily modify the...
Writing forward-compatible websites - Developer guides
e first happens on the element itself, then on the element's form if the element is a form control, then on the document, and then on the window (where the global variables you have defined are). for example, if you have this markup: <div onclick="alert(ownerdocument)">click me</div> then clicking on the text alerts the ownerdocument of the div. this happens even if there is a var ownerdocument
declared in global scope. what this means is that any time you access a global variable in an event handler content attribute, including calling any function
declared globally, you can end up with a name collision if a specification adds a new dom property to elements or documents which has the same name as your function or variable, and a browser implements it. if that happens, then suddenly your funct...
Developer guides
the web. localizations and character encodings browsers process text as unicode internally. however, a way of representing characters in terms of bytes (character encoding) is used for transferring text over the network to the browser. the html specification recommends the use of the utf-8 encoding (which can represent all of unicode), and regardless of the encoding used requires web content to
declare that encoding. mobile web development this article provides an overview of some of the main techniques needed to design web sites that work well on mobile devices. progressive web apps progressive web apps (pwas) use modern web apis along with traditional progressive enhancement strategy to create cross-platform web applications. these apps work everywhere and provide several features th...
disabled - HTML: Hypertext Markup Language
<input>. this boolean disabled attribute indicates that the user cannot interact with the control or it's descendant controls. if this attribute is not specified, the control inherits its setting from the containing element, for example fieldset; if there is no containing element with the disabled attribute set, and the control itself does not have the attribute, then the control is enabled. if
declared on an <optgroup>, the select is still interactive (unless otherwise disabled), but none of the items in the option group are selectable. note: if a <fieldset> is disabled, the descendant form controls are all disabled, with the exception of form controls within the <legend>. when a supporting element has the disabled attribute applied, the :disabled pseudo-class also applies to it. conversel...
HTML attribute: rel - HTML: Hypertext Markup Language
ription+xml the resource is an opensearch plugin that can be easily added to the interface of some browsers like firefox or internet explorer. stylesheet valid for the <link> element, it imports an external resource to be used as a stylesheet. the type attribute is not needed as it's a text/css stylesheet, as that is the default value. if it's not a stylesheet of type text/css it is best to
declare the type. while this attribute defines the link as being a stylesheet, the interaction with other attributes and other keyterms within the rel value impact whether the stylesheet is downloaded and / or used. when used with the alternate keyword, it defines an alternative style sheet. in this case, include a non-empty title. the external stylesheet will not be used or even downloaded if the ...
HTML attribute: required - HTML: Hypertext Markup Language
t values. it is also not supported on hidden as it can not be expected that a user to fill out a form that is hidden. nor is it supported on any of the button types, including image. note color and range don't support required, but type color defaults to #00000, and range defaults to the midpoint between min and max -- with min and max defaulting to 0 and 100 respectively in most browsers if not
declared -- so always has a value. when an input has the required attribute, the :required pseudo-class also applies to it. conversely, inputs that support the required attribute but don't have the attribute set match the :optional pseudo-class. in the case of a same named group of radio buttons, if a single radio button in the group has the required attribute, a radio button in that group must be chec...
HTML attribute reference - HTML: Hypertext Markup Language
d. buffered <audio>, <video> contains the time range of already buffered media. capture <input> from the html media capturethe definition of 'media capture' in that specification.spec, specifies a new file can be captured. challenge <keygen> a challenge string that is submitted along with the public key. charset <meta>, <script>
declares the character encoding of the page or script. checked <command>, <input> indicates whether the element should be checked on page load. cite <blockquote>, <del>, <ins>, <q> contains a uri which points to the source of the quote or change. class global attribute often used with css to style elements with common properties. code <applet> s...
<button>: The Button element - HTML: Hypertext Markup Language
mity to each other should have space separating them. this spacing is beneficial for people who are experiencing motor control issues, who may accidentally activate the wrong interactive content. spacing may be created using css properties such as margin. hand tremors and the giant-button-problem - axess lab firefox firefox will add a small dotted border on a focused button. this border is
declared through css in the browser stylesheet, but you can override it to add your own focused style using button::-moz-focus-inner { }. if overridden, it is important to ensure that the state change when focus is moved to the button is high enough that people experiencing low vision conditions will be able to perceive it. color contrast ratio is determined by comparing the luminosity of the button te...
<img>: The Image Embed element - HTML: Hypertext Markup Language
ls alt-texts: the ultimate guide — axess lab how to design great alt text: an introduction | deque mdn understanding wcag, guideline 1.1 explanations understanding success criterion 1.1.1 | w3c understanding wcag 2.0 the title attribute the title attribute is not an acceptable substitute for the alt attribute. additionally, avoid duplicating the alt attribute's value in a title attribute
declared on the same image. doing so may cause some screen readers to announce the description twice, creating a confusing experience. the title attribute should also not be used as supplemental captioning information to accompany an image's alt description. if an image needs a caption, use the figure and figcaption elements. the value of the title attribute is usually presented to the user as a toolti...
<menu> - HTML: Hypertext Markup Language
r or tree dom interface htmlmenuelement attributes this element includes the global attributes. label the name of the menu as shown to the user. used within nested menus, to provide a label through which the submenu can be accessed. must only be specified when the parent element is a <menu> in the context menu state. type this attribute indicates the kind of menu being
declared, and can be one of two values. context : indicates the popup menu state, which represents a group of commands activated through another element. this might be as a button menu referenced by a menu attribute of a <button> element, or as context menu for an element with a contextmenu attribute. this value is the default if the attribute is missing and the parent element is also a <menu> elem...
<meta>: The Document-level Metadata element - HTML: Hypertext Markup Language
e document is encoded. if the itemprop attribute is set, the meta element provides user-defined metadata. attributes this element includes the global attributes. note: the attribute name has a specific meaning for the <meta> element, and the itemprop attribute must not be set on the same <meta> element that has any existing name, http-equiv or charset attributes. charset this attribute
declares the document's character encoding. if the attribute is present, its value must be an ascii case-insensitive match for the string "utf-8". content this attribute contains the value for the http-equiv or name attribute, depending on which is used. http-equiv defines a pragma directive. the attribute is named http-equiv(alent) because all the allowed values are names of particular http header...
<object> - HTML: Hypertext Markup Language
attribute. codebasehtml 4 onlyobsolete since html5 the base path used to resolve relative uris specified by classid, data, or archive. if not specified, the default is the base uri of the current document. codetypehtml 4 onlyobsolete since html5 the content type of the data specified by classid. data the address of the resource as a valid url. at least one of data and type must be defined.
declarehtml 4 onlyobsolete since html5 the presence of this boolean attribute makes this element a declaration only. the object must be instantiated by a subsequent <object> element. in html5, repeat the <object> element completely each that that the resource is reused. formhtml5 the form element, if any, that the object element is associated with (its form owner). the value of the attribute must be a...
itemprop - HTML: Hypertext Markup Language
</div> </div> similarly, for date- and time-related data, the time element and its datetime attribute can be used. an item with one property, "birthday", whose value is a date <div itemscope> i was born on <time itemprop="birthday" datetime="2009-05-10">may 10th 2009</time>. </div> properties can also be groups of name-value pairs, by putting the itemscope attribute on the element that
declares the property. each value is either a string or a group of name-value pairs (i.e. an item). an outer item representing a person, and an inner one representing a band <div itemscope> <p>name: <span itemprop="name">amanda</span></p> <p>band: <span itemprop="band" itemscope> <span itemprop="name">jazz band</span> (<span itemprop="size">12</span> players)</span></p> </div> t...
Preloading content with rel="preload" - HTML: Hypertext Markup Language
this ensures they are available earlier and are less likely to block the page's render, improving performance. this article provides a basic guide to how <link rel="preload"> works. the basics you most commonly use <link> to load a css file to style your page with: <link rel="stylesheet" href="styles/main.css"> here however, we will use a rel value of preload, which turns <link> into a preloader for any resource we want. ...
Content negotiation - HTTP
e amount of device memory with the server. the value is given in miliseconds and it's use is optional. the accept-encoding header the accept-encoding header defines the acceptable content-encoding (supported compressions). the value is a q-factor list (e.g.: br, gzip;q=0.8) that indicates the priority of the encoding values. the default value identity is at the lowest priority (unless otherwise
declared). compressing http messages is one of the most important ways to improve the performance of a web site, it shrinks the size of the data transmitted and makes better use of the available bandwidth; browsers always send this header and the server should be configured to abide to it and to use compression. the accept-language header the accept-language header is used to indicate the language pre...
Feature Policy - HTTP
y enable, disable, and modify the behavior of certain features and apis in the browser. it is similar to content security policy but controls features instead of security behavior. the feature-policy header has now been renamed to permissions-policy in the spec, and this article will eventually be updated to reflect that change. in a nutshell feature policy provides a mechanism to explicitly
declare what functionality is used (or not used), throughout your website. this allows you to lock in best practices, even as the codebase evolves over time — as well as to more safely compose third-party content — by limiting which features are available. with feature policy, you opt-in to a set of "policies" for the browser to enforce on specific features used throughout a website. these policies ...
CSP: plugin-types - HTTP
the http content-security-policy (csp) plugin-types directive restricts the set of plugins that can be embedded into a document by limiting the types of resources which can be loaded. instantiation of an <embed>, <object> or <applet> element will fail if: the element to load does not
declare a valid mime type, the
declared type does not match one of specified types in the plugin-types directive, the fetched resource does not match the
declared type. csp version 2 directive type document directive default-src fallback no. not setting this allows anything. syntax one or more mime types can be set for the plugin-types policy: content-security-policy: plugin-types <type>/<subtype>; content-security-policy: plugin-types <type>/<subtype> <type>/<sub...
CSP: trusted-types - HTTP
e instructs user agents to restrict usage of known dom xss sinks to a predefined set of functions that only accept non-spoofable, typed values in place of strings. this allows authors to define rules guarding writing values to the dom and thus reducing the dom xss attack surface to small, isolated parts of the web application codebase, facilitating their monitoring and code review. this directive
declares a white-list of trusted type policy names created with trustedtypes.createpolicy from trusted types api. syntax content-security-policy: trusted-types; content-security-policy: trusted-types <policyname>; content-security-policy: trusted-types <policyname> <policyname> 'allow-duplicates'; <domstring> any string can be a trusted type policy name. 'allow-duplicates' allows for creating po...
SameSite cookies - HTTP
values the samesite attribute accepts three values: lax cookies are allowed to be sent with top-level navigations and will be sent along with get request initiated by third party website. this is the default value in modern browsers. strict cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. none cookies will be sent in all contexts, i.e sending cross-origin is allowed. ...
HTTP Index - HTTP
e instructs user agents to restrict usage of known dom xss sinks to a predefined set of functions that only accept non-spoofable, typed values in place of strings. this allows authors to define rules guarding writing values to the dom and thus reducing the dom xss attack surface to small, isolated parts of the web application codebase, facilitating their monitoring and code review. this directive
declares a white-list of trusted type policy names created with trustedtypes.createpolicy from trusted types api. 105 csp: upgrade-insecure-requests csp, content-security-policy, directive, http, reference, requests, security, upgrade, upgrade-insecure-requests the http content-security-policy (csp) upgrade-insecure-requests directive instructs user agents to treat all of a site's in...
Expressions and operators - JavaScript
object. trying to access it afterwards will yield undefined. the delete operator returns true if the operation is possible; it returns false if the operation is not possible. x = 42; // implicitly creates window.x var y = 43; var myobj = {h: 4}; // create object with property h delete x; // returns true (can delete if created implicitly) delete y; // returns false (cannot delete if
declared with var) delete math.pi; // returns false (cannot delete non-configurable properties) delete myobj.h; // returns true (can delete user-defined properties) deleting array elements since arrays are just objects, it's technically possible to delete elements from them. this is however regarded as a bad practice, try to avoid it. when you delete an array property, the array length is not affected...
JavaScript modules - JavaScript
tures are imported as live bindings, meaning that they can change in value even if you cannot modify the binding unlike const. applying the module to your html now we just need to apply the main.js module to our html page. this is very similar to how we apply a regular script to a page, with a few notable differences. first of all, you need to include type="module" in the <script> element, to
declare this script as a module. to import the main.js script, we use this: <script type="module" src="main.js"></script> you can also embed the module's script directly into the html file by placing the javascript code within the body of the <script> element: <script type="module"> /* javascript module code here */ </script> the script into which you import the module features basically acts as th...
Working with objects - JavaScript
lete operator. the following code shows how to remove a property. // creates a new object, myobj, with two properties, a and b. var myobj = new object; myobj.a = 5; myobj.b = 12; // removes the a property, leaving myobj with only the b property. delete myobj.a; console.log ('a' in myobj); // output: "false" you can also use delete to delete a global variable if the var keyword was not used to
declare the variable: g = 17; delete g; comparing objects in javascript, objects are a reference type. two distinct objects are never equal, even if they have the same properties. only comparing the same object reference with itself yields true. // two variables, two distinct objects with the same properties var fruit = {name: 'apple'}; var fruitbear = {name: 'apple'}; fruit == fruitbear; // return...
Inheritance and the prototype chain - JavaScript
hat you open a console, navigate to the "console" tab, copy-and-paste in the below javascript code, and run it by pressing the enter/return key. (the console is included in most web browser's developer tools. more information is available for firefox developer tools, chrome devtools, and edge devtools.) function dosomething(){} console.log( dosomething.prototype ); // it does not matter how you
declare the function, a // function in javascript will always have a default // prototype property. // (ps: there is one exception that arrow function doesn't have a default prototype property) var dosomething = function(){}; console.log( dosomething.prototype ); as seen above, dosomething() has a default prototype property, as demonstrated by the console. after running this code, the console should...
Memory Management - JavaScript
e allocated memory when it is not needed anymore the second part is explicit in all languages. the first and last parts are explicit in low-level languages but are mostly implicit in high-level languages like javascript. allocation in javascript value initialization in order to not bother the programmer with allocations, javascript will automatically allocate memory when values are initially
declared. var n = 123; // allocates memory for a number var s = 'azerty'; // allocates memory for a string var o = { a: 1, b: null }; // allocates memory for an object and contained values // (like object) allocates memory for the array and // contained values var a = [1, null, 'abra']; function f(a) { return a + 2; } // allocates a function (which is a callable object) // function expressions...
Private class fields - JavaScript
the # is a part of the name itself. it is used for declaration and accessing as well. the encapsulation is enforced by the language. it is a syntax error to refer to # names from out of scope. class classwithprivatefield { #privatefield constructor() { this.#privatefield = 42 this.#randomfield = 666 // ...
ReferenceError: can't access lexical declaration`X' before initialization - JavaScript
rror: can't access lexical declaration `x' before initialization (firefox) referenceerror: 'x' is not defined (chrome) error type referenceerror what went wrong? a lexical variable was accessed before it was initialized. this happens within any block statement, when let or const declarations are accessed before they are defined. examples invalid cases in this case, the variable "foo" is re
declared in the block statement using let. function test() { let foo = 33; if (true) { let foo = (foo + 55); // referenceerror: can't access lexical // declaration `foo' before initialization } } test(); valid cases to change "foo" inside the if statement, you need to remove the let that causes the redeclaration. function test(){ let foo = 33; if (true) { foo = (foo + 5...
SyntaxError: for-in loop head declarations may not have initializers - JavaScript
ssage syntaxerror: for-in loop head declarations cannot have an initializer (edge) syntaxerror: for-in loop head declarations may not have initializers (firefox) syntaxerror: for-in loop variable declaration may not have an initializer. (chrome) error type syntaxerror in strict mode only. what went wrong? the head of a for...in loop contains an initializer expression. that is, a variable is
declared and assigned a value |for (var i = 0 in obj)|. in non-strict mode, this head declaration is silently ignored and behaves like |for (var i in obj)|. in strict mode, however, a syntaxerror is thrown. examples this example throws a syntaxerror: "use strict"; var obj = {a: 1, b: 2, c: 3 }; for (var i = 0 in obj) { console.log(obj[i]); } // syntaxerror: for-in loop head declarations may not h...
SyntaxError: a declaration in the head of a for-of loop can't have an initializer - JavaScript
ops. message syntaxerror: for-of loop head declarations cannot have an initializer (edge) syntaxerror: a declaration in the head of a for-of loop can't have an initializer (firefox) syntaxerror: for-of loop variable declaration may not have an initializer. (chrome) error type syntaxerror what went wrong? the head of a for...of loop contains an initializer expression. that is, a variable is
declared and assigned a value |for (var i = 0 of iterable)|. this is not allowed in for-of loops. you might want a for loop that does allow an initializer. examples invalid for-of loop let iterable = [10, 20, 30]; for (let value = 50 of iterable) { console.log(value); } // syntaxerror: a declaration in the head of a for-of loop can't // have an initializer valid for-of loop you need to remove th...
SyntaxError: missing ; before statement - JavaScript
s thrown. examples unescaped strings this error can occur easily when not escaping strings properly and the javascript engine is expecting the end of your string already. for example: var foo = 'tom's bar'; // syntaxerror: missing ; before statement you can use double quotes, or escape the apostrophe: var foo = "tom's bar"; var foo = 'tom\'s bar'; declaring properties with var you cannot
declare properties of an object or array with a var declaration. var obj = {}; var obj.foo = 'hi'; // syntaxerror missing ; before statement var array = []; var array[0] = 'there'; // syntaxerror missing ; before statement instead, omit the var keyword: var obj = {}; obj.foo = 'hi'; var array = []; array[0] = 'there'; bad keywords if you come from another programming language, it is also common ...
ReferenceError: "x" is not defined - JavaScript
the javascript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere. message referenceerror: "x" is not defined error type referenceerror. what went wrong? there is a non-existent variable referenced somewhere. this variable needs to be
declared, or you need to make sure it is available in your current script or scope. note: when loading a library (such as jquery), make sure it is loaded before you access library variables, such as "$". put the <script> tag that loads the library before your code that uses it. examples variable not
declared foo.substring(1); // referenceerror: foo is not defined the "foo" variable isn't defined anywhere. it needs to be some string, so that the string.prototype.substring() method will work. var foo ...
Default parameters - JavaScript
houtdefaults.call({value: '=^_^='}); // [undefined, 5, 5, ":p", {value:"=^_^="}, arguments, "=^_^="] scope effects if default parameters are defined for one or more parameter, then a second scope (environment record) is created, specifically for the identifiers within the parameter list. this scope is a parent of the scope created for the function body. this means that functions and variables
declared in the function body cannot be referred to from default value parameter initializers; attempting to do so throws a run-time referenceerror. it also means that variables
declared inside the function body using var will mask parameters of the same name, instead of the usual behavior of duplicate var declarations having no effect. the following function will throw a referenceerror when invoked, b...
Array.prototype.find() - JavaScript
2; while (start <= math.sqrt(element)) { if (element % start++ < 1) { return false; } } return element > 1; } console.log([4, 6, 8, 12].find(isprime)); // undefined, not found console.log([4, 5, 8, 12].find(isprime)); // 5 the following examples show that nonexistent and deleted elements are visited, and that the value passed to the callback is their value when visited: //
declare array with no elements at indexes 2, 3, and 4 const array = [0,1,,,,5,6]; // shows all indexes, not just those with assigned values array.find(function(value, index) { console.log('visited index ', index, ' with value ', value); }); // shows all indexes, including deleted array.find(function(value, index) { // delete element 5 on first iteration if (index === 0) { console.log('deletin...
Error - JavaScript
r to be able to throw new myerror() and use instanceof myerror to check the kind of error in the exception handler. this results in cleaner and more consistent error handling code. see "what's a good way to extend error in javascript?" on stackoverflow for an in-depth discussion. es6 custom error class versions of babel prior to 7 can handle customerror class methods, but only when they are
declared with object.defineproperty(). otherwise, old versions of babel and other transpilers will not correctly handle the following code without additional configuration. some browsers include the customerror constructor in the stack trace when using es2015 classes. class customerror extends error { constructor(foo = 'bar', ...params) { // pass remaining arguments (including vendor specific ...
Promise.prototype.finally() - JavaScript
to the specified function, onfinally. description the finally() method can be useful if you want to do some processing or cleanup once the promise is settled, regardless of its outcome. the finally() method is very similar to calling .then(onfinally, onfinally) however there are a couple of differences: when creating a function inline, you can pass it once, instead of being forced to either
declare it twice, or create a variable for it a finally callback will not receive any argument, since there's no reliable means of determining if the promise was fulfilled or rejected. this use case is for precisely when you do not care about the rejection reason, or the fulfillment value, and so there's no need to provide it. so for example: unlike promise.resolve(2).then(() => {}, () => {}) (whi...
String.prototype.match() - JavaScript
arameter is a string or a number, it is implicitly converted to a regexp by using new regexp(regexp). if it is a positive number with a positive sign, regexp() will ignore the positive sign. const str1 = "nan means not a number. infinity contains -infinity and +infinity in javascript.", str2 = "my grandfather is 65 years old and my grandmother is 63 years old.", str3 = "the contract was
declared null and void."; str1.match("number"); // "number" is a string. returns ["number"] str1.match(nan); // the type of nan is the number. returns ["nan"] str1.match(infinity); // the type of infinity is the number. returns ["infinity"] str1.match(+infinity); // returns ["infinity"] str1.match(-infinity); // returns ["-infinity"] str2.match(65); // returns ["65"] str2.match(+65);...
WebAssembly.Instance() constructor - JavaScript
s webassembly.instantiatestreaming() method should be used at all other times. new webassembly.instance(module, importobject); parameters module the webassembly.module object to be instantiated. importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects. there must be one matching property for each
declared import of module or else a webassembly.linkerror is thrown. examples synchronously instantiating a webassembly module the webassembly.instance() constructor function can be called to synchronously instantiate a given webassembly.module object, for example: const importobject = { imports: { imported_func: function(arg) { console.log(arg); } } }; fetch('simple.wasm').then(r...
WebAssembly.Module.exports() - JavaScript
syntax webassembly.module.exports(module); parameters module a webassembly.module object. return value an array containing objects representing the exported functions of the given module. exceptions if module is not a webassembly.module object instance, a typeerror is thrown. examples using exports the following example (see our index-compile.html demo on github, and view it live also) compiles the loaded simple.wasm byte code using the webassembly.compilestreaming() method and then sends it to a worker using postmessage(). ...
WebAssembly.Module.imports() - JavaScript
syntax webassembly.module.imports(module); parameters module a webassembly.module object. return value an array containing objects representing the imported functions of the given module. exceptions if module is not a webassembly.module object instance, a typeerror is thrown. examples using imports the following example (see imports.html source code; see it live also) compiles the loaded simple.wasm module. this module is then queried for its imports. ...
WebAssembly.Module - JavaScript
ed with workers, and instantiated multiple times. constructor webassembly.module() creates a new module object. static properties webassembly.module.customsections() given a module and string, returns a copy of the contents of all custom sections in the module with the given string name. webassembly.module.exports() given a module, returns an array containing descriptions of all the
declared exports. webassembly.module.imports() given a module, returns an array containing descriptions of all the
declared imports. examples sending a compiled module to a worker the following example (see our index-compile.html demo on github, and view it live also) compiles the loaded simple.wasm byte code using the webassembly.compilestreaming() method and then sends the resulting module instan...
WebAssembly.instantiateStreaming() - JavaScript
urce, importobject); parameters source a response object or a promise that will fulfill with one, representing the underlying source of a .wasm module you want to stream, compile, and instantiate. importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects. there must be one matching property for each
declared import of the compiled module or else a webassembly.linkerror is thrown. return value a promise that resolves to a resultobject which contains two fields: module: a webassembly.module object representing the compiled webassembly module. this module can be instantiated again or shared via postmessage(). instance: a webassembly.instance object that contains all the exported webassembly func...
class expression - JavaScript
expression has a similar syntax to a class declaration (statement). as with class statements, the body of a class expression is executed in strict mode. there are several differences between class expressions and class statements, however: class expressions may omit the class name ("binding identifier"), which is not possible with class statements. class expressions allow you to redefine (re-
declare) classes without throwing a syntaxerror. this is not the case with class statements. the constructor method is optional. classes generated with class expressions will always respond to typeof with the value "function". 'use strict'; let foo = class {}; // constructor property is optional foo = class {}; // re-declaration is allowed typeof foo; // returns "function" typeof cl...
this - JavaScript
ructor at all. class base {} class good extends base {} class alsogood extends base { constructor() { return {a: 5}; } } class bad extends base { constructor() {} } new good(); new alsogood(); new bad(); // referenceerror examples this in function contexts // an object can be passed as the first argument to call or apply and this will be bound to it. var obj = {a: 'custom'}; // we
declare a variable and the variable is assigned to the global window as its property. var a = 'global'; function whatsthis() { return this.a; // the value of this is dependent on how the function is called } whatsthis(); // 'global' as this in the function isn't set, so it defaults to the global/window object whatsthis.call(obj); // 'custom' as this in the function is set to obj whatsthis.
async function - JavaScript
async functions are instances of the asyncfunction constructor, and the await keyword is permitted within them. the async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains. async functions may also be defined as expressions. the source for this interactive demo is stored in a github repository. if you'd like to contribute to the interactive demo project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax async function name([param[, param[, ...param]]]) { statements } parameters name the function’s name. ...
for await...of - JavaScript
ts to be executed for the value of each distinct property of the object. like the await operator, the statement can only be used inside an async function. for await...of doesn't work with async iterators that are not async iterables. syntax for await (variable of iterable) { statement } variable on each iteration a value of a different property is assigned to variable. variable may be
declared with const, let, or var. iterable object whose iterable properties are to be iterated over. examples iterating over async iterables you can also iterate over an object that explicitly implements async iterable protocol: const asynciterable = { [symbol.asynciterator]() { return { i: 0, next() { if (this.i < 3) { return promise.resolve({ value: this.i++, ...
for...of - JavaScript
of the object. the source for this interactive example is stored in a github repository. if you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax for (variable of iterable) { statement } variable on each iteration a value of a different property is assigned to variable. variable may be
declared with const, let, or var. iterable object whose iterable properties are iterated. examples iterating over an array const iterable = [10, 20, 30]; for (const value of iterable) { console.log(value); } // 10 // 20 // 30 you can use let instead of const too, if you reassign the variable inside the block. const iterable = [10, 20, 30]; for (let value of iterable) { value += 1; consol...
for - JavaScript
ractive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. syntax for ([initialization]; [condition]; [final-expression]) statement initialization an expression (including assignment expressions) or variable declaration evaluated once before the loop begins. typically used to initialize a counter variable. this expression may optionally
declare new variables with var or let keywords. variables
declared with var are not local to the loop, i.e. they are in the same scope the for loop is in. variables
declared with let are local to the statement. the result of this expression is discarded. condition an expression to be evaluated before each loop iteration. if this expression evaluates to true, statement is executed. this conditional tes...
Transitioning to strict mode - JavaScript
se they reveal plain errors or bad practices. they occur before the code is running. new runtime errors javascript used to silently fail in contexts where what was done was an error. strict mode throws in such cases. if your code base contains such cases, testing will be necessary to be sure nothing is broken. once again, it can happen at the function granularity level. setting a value to an un
declared variable function f(x) { 'use strict'; var a = 12; b = a + x * 35; // error! } f(42); this used to change a value on the global object which is rarely the expected effect. if you really want to set a value to the global object, pass it as an argument and explicitly assign it as a property: var global = this; // in the top-level context, "this" always // refers to the...
JavaScript
about javascript. javascript data structures overview of available data structures in javascript. equality comparisons and sameness javascript provides three different value-comparison operations: strict equality using ===, loose equality using ==, and the object.is() method. closures a closure is the combination of a function and the lexical environment within which that function was
declared. advanced inheritance and the prototype chain explanation of the widely misunderstood and under-estimated prototype-based inheritance. strict mode strict mode defines that you can not use any variable before initializing it. it is a restricted variant of ecmascript 5, for faster performance and easier debugging. javascript typed arrays javascript typed arrays provide a mechanism for ...
Performance fundamentals - Web Performance
erformance. to improve power usage, simple scenes are rendered using special dedicated composition hardware, while the gpu idles or turns off. fully static content is the exception rather than the rule for rich applications. rich applications use dynamic content with animation and transition effects. transitions and animations are particularly important to applications: developers can use css to
declare complicated behaviour with a simple, high-level syntax. in turn, gecko's graphics pipeline is highly optimized to render common animations efficiently. common-case animations are "offloaded" to the system compositor, which can render them in a performant, power-efficient fashion. an app's startup performance matters just as much as its runtime performance. gecko is optimized to load a wide varie...
Populating the page: how browsers work - Web Performance
, with each element's box model properties, providing placeholder space for replaced elements it doesn’t know the dimensions of, such as our image. the first time the size and position of nodes are determined is called layout. subsequent recalculations of node size and locations are called reflows. in our example, suppose the initial layout occurs before the image is returned. since we didn't
declare the size of our image, there will be a reflow once the image size is known. paint the last step in the critical rendering path is painting the individual nodes to the screen, the first occurence of which is called the first meaningful paint. in the painting or rasterization phase, the browser converts each box calculated in the layout phase to actual pixels on the screen. painting involves draw...
Add to Home screen - Progressive web apps (PWAs)
able automatically on desktop apps, and the installation needs to be triggered by a user gesture: <button class="add-button">add to home screen</button> we then gave it some simple styling: .add-button { position: absolute; top: 1px; left: 1px; } javascript for handling the install at the bottom of our index.js file, we added some javascript to handle the installation. first of all, we
declare a deferredprompt variable (which we'll explain later on), get a reference to our install button, and set it to display: none initially: let deferredprompt; const addbtn = document.queryselector('.add-button'); addbtn.style.display = 'none'; we hide the button initially because the pwa will not be available for install until it follows the a2hs criteria. when this happens, supporting browsers wi...
contentStyleType - SVG: Scalable Vector Graphics
ia types default value text/css animatable no since css is the only widely deployed style sheet language for online styling and it's already defined as default value if contentstyletype is ommitted, the attribute is not well supported in user agents. if other style sheet languages become more popular they might not use the style attribute, instead it could be easily
declared which style language is used in the <style>'s type attribute. the use of contentstyletype is therefore deprecated. specifications specification status comment scalable vector graphics (svg) 1.1 (second edition)the definition of 'contentscripttype' in that specification. recommendation initial definition ...
text-decoration - SVG: Scalable Vector Graphics
the text-decoration attribute defines whether text is decorated with an underline, overline and/or strike-through. it is a shorthand for the text-decoration-line and text-decoration-style properties. the fill and stroke of the text decoration are given by the fill and stroke of the text at the point where the text decoration is
declared. the paint order of the text decoration, i.e. the fill and stroke, is determined by the value of the paint-order attribute at the point where the text decoration is
declared. note: as a presentation attribute, text-decoration can be used as a css property. see the css text-decoration property for more information. as a presentation attribute, it can be applied to any element but it has effect only on the following five elements: <altglyph>, <text>, <textpath>...
SVG In HTML Introduction - SVG: Scalable Vector Graphics
in" offset="0%"/> <stop class="end" offset="100%"/> </lineargradient> <rect x="0" y="0" width="100" height="100" style="fill:url(#gradient)" /> <circle cx="50" cy="50" r="30" style="fill:url(#gradient)" /> </svg> </body> </html> discussion the page is mainly regular html, css and javascript. the only interesting part is the <svg> element it contains. this element and its children are
declared to be in the svg namespace. the element contains a gradient and two shapes filled with the gradient. the gradient color stops have their colors set by css. when the user enters something incorrect into the form, the script sets the invalid attribute on the <body>, and a style rule changes the gradient end-stop color to red. (another style rule makes an error message appear.) this approach has t...
XML introduction - XML: Extensible Markup Language
n sign which is used for tags). there are five of these characters that you should know: entity character description < < less than sign > > greater than sign & & ampersand " " one double-quotation mark ' ' one apostrophe (or single-quotation mark) even though there are only 5
declared entities, more can be added using the document's document type definition. for example, to create a new &warning; entity, you can do this: <?xml version="1.0" encoding="utf-8"?> <!doctype body [ <!entity warning "warning: something bad happened... please refresh and try again."> ]> <body> <message> &warning; </message> </body> you can also use numeric character references to specify speci...
<xsl:key> - XSLT: Extensible Stylesheet Language Transformations
syntax <xsl:key name=name match=expression use=expression /> required attributes name specifies a name for this key. must be a qname. match defines the nodes for which this key is applicable. use specifies an xpath expression that will be used to determine the value of the key for each of the applicable nodes. optional attributes none. ...
<xsl:variable> - XSLT: Extensible Stylesheet Language Transformations
because xslt permits no side-effects, once the value of the variable has been established, it remains the same until the variable goes out of scope syntax <xsl:variable name=name select=expression > template </xsl:variable> required attributes name gives the variable a name. optional attributes select defines the value of the variable through an xpath expression. if the element contains a template, this attribute is ignored. type top-level or instruction. ...
An Overview - XSLT: Extensible Stylesheet Language Transformations
this can continue for several levels. there are certain constraints on which type of nodes can occur where: for example, text nodes can have no children. the result of the processor's action is also a tree. netscape uses this tree to render the contents in the browser window. xslt is a high-level declarative language. in essence, an xslt stylesheet is a set of rules, called templates, which
declare that any node that matches this specific pattern should be manipulated in this specific way and end up in this specific position in the result tree. the particulars of how this is to be accomplished are left up to the processor. because the order of execution of the stylesheet cannot be guaranteed, xslt does not support any functionality that produces side-effects. in this it is like lisp or sche...
WebAssembly Concepts - WebAssembly
re are several key concepts needed to understand how webassembly runs in the browser. all of these concepts are reflected 1:1 in the webassembly javascript api. module: represents a webassembly binary that has been compiled by the browser into executable machine code. a module is stateless and thus, like a blob, can be explicitly shared between windows and workers (via postmessage()). a module
declares imports and exports just like an es2015module. memory: a resizable arraybuffer that contains the linear array of bytes read and written by webassembly’s low-level memory access instructions. table: a resizable typed array of references (e.g. to functions) that could not otherwise be stored as raw bytes in memory (for safety and portability reasons). instance: a module paired with all the st...
Exported WebAssembly functions - WebAssembly
u can then go on to do pretty much anything to this function that you can do to other functions in javascript — call(), bind(), etc. testfunc.tostring() returns an interesting result: function 0() { [native code] } this gives you more of an idea of its wrapper-type nature. some other particulars to be aware of with exported webassembly functions: their length property is the number of
declared arguments in the wasm function signature. their name property is the tostring() result of the function's index in the wasm module. if you try to call a exported wasm function that takes or returns an i64 type value, it currently throws an error because javascript currently has no precise way to represent an i64. this may well change in the future though — a new int64 type is being considered...