зеркало из https://github.com/mozilla/pjs.git
- Update Unix make goo to handle our new MOZILLA_CLIENT dependencies.
- Added TODO and STYLE_NOTES - Added style data to DOM_Element - Added GetCleanEntryData convenience function - Added internal dom_SetElementAttribute with optional suppressing of callback invocation - Added style init code - Style support (everything) - Fix text initialization thinko
This commit is contained in:
Родитель
7ba71e0c36
Коммит
7c5ad30549
|
@ -20,9 +20,16 @@ DEPTH = ../..
|
|||
MODULE = dom
|
||||
LIBRARY_NAME = dom
|
||||
|
||||
REQUIRES = js
|
||||
REQUIRES = js dom
|
||||
|
||||
EXPORTS = dom.h
|
||||
ifdef MOZILLA_CLIENT
|
||||
REQUIRES += lay img layer util
|
||||
|
||||
# hack until PERIGNON takes over the world
|
||||
REQUIRES += style
|
||||
endif
|
||||
|
||||
EXPORTS = dom.h domstyle.h
|
||||
|
||||
CSRCS = domattr.c \
|
||||
domcore.c \
|
||||
|
@ -34,3 +41,5 @@ CSRCS = domattr.c \
|
|||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
DEFINES += -DDOM
|
||||
|
|
|
@ -26,8 +26,14 @@ MODULE = dom
|
|||
LIBRARY_NAME = dom
|
||||
|
||||
REQUIRES = js
|
||||
#ifdef MOZILLA_CLIENT
|
||||
REQUIRES += lay img layer util
|
||||
|
||||
EXPORTS = $(srcdir)/dom.h
|
||||
# hack until PERIGNON takes over the world
|
||||
REQUIRES += style
|
||||
#endif
|
||||
|
||||
EXPORTS = $(srcdir)/dom.h $(srcdir)/domstyle.h
|
||||
|
||||
CSRCS = domattr.c \
|
||||
domcore.c \
|
||||
|
@ -39,3 +45,5 @@ CSRCS = domattr.c \
|
|||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DDOM
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
General:
|
||||
- document.create*
|
||||
- escape HTML entities (JS entities?) coming into the text functions
|
||||
|
||||
Style:
|
||||
- add a CSS-parsing input API, or extract CSS->JS conversion from
|
||||
libstyle
|
||||
- DOM_StyleIsDirty/DOM_LockStyle/DOM_UnlockStyle to allow global
|
||||
caching of style data during document layout without racing with
|
||||
alterations from mocha thread.
|
||||
|
||||
Layout:
|
||||
- make proper LO_Elements for table stuff (pollmann)
|
||||
- stick the DOM_StyleGetElementProperty stuff in all the right places
|
||||
(reflow?)
|
||||
- make <HR> honour inherited style (colour, etc.)
|
||||
|
||||
libmocha:
|
||||
- move destruction into LM_ReleaseDocument
|
||||
- add destruction of style db
|
||||
- look closely at the implicit pop stuff in DOM_HTMLPushNode
|
||||
- wire up node reordering
|
||||
- put single <HTML> element child on #document at creation (and never
|
||||
pop it off)
|
||||
|
||||
XML:
|
||||
- everything, really
|
|
@ -224,8 +224,9 @@ struct DOM_Element {
|
|||
DOM_ElementOps *ops;
|
||||
const char *tagName;
|
||||
uintN nattrs;
|
||||
DOM_AttributeEntry *attrs;
|
||||
void *style; /* later, later... */
|
||||
DOM_AttributeEntry *attrs;
|
||||
char *styleClass;
|
||||
char *styleID;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -235,7 +236,7 @@ struct DOM_Element {
|
|||
|
||||
DOM_Element *
|
||||
DOM_NewElement(const char *tagName, DOM_ElementOps *eleops, char *name,
|
||||
DOM_NodeOps *nodeops);
|
||||
char *styleClass, char *styleID, DOM_NodeOps *nodeops);
|
||||
|
||||
JSObject *
|
||||
DOM_NewElementObject(JSContext *cx, DOM_Element *element);
|
||||
|
@ -251,6 +252,12 @@ JSBool
|
|||
DOM_SetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value);
|
||||
|
||||
typedef JSBool(*DOM_DataParser)(const char *str, uint32 *data, void *closure);
|
||||
|
||||
JSBool
|
||||
DOM_GetCleanEntryData(JSContext *cx, DOM_AttributeEntry *entry,
|
||||
DOM_DataParser parser, uint32 *data, void *closure);
|
||||
|
||||
/*
|
||||
* Set the attributes from a pair of synchronized lists.
|
||||
* (This is what PA_FetchAllNameValues provides, handily enough.)
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Module-private stuff for the DOM lib.
|
||||
*/
|
||||
|
||||
#ifndef DOM_PRIV_H
|
||||
#define DOM_PRIV_H
|
||||
|
||||
#include "dom.h"
|
||||
#ifdef XP_PC
|
||||
/* XXX this pulls in half the freaking client! but it's needed for some bogus
|
||||
reason probably to do with compiled headers, to avoid unresolved refs
|
||||
to XP_MEMCPY and XP_STRDUP */
|
||||
#include "xp.h"
|
||||
#else
|
||||
#include "xpassert.h"
|
||||
#include "xp_mem.h"
|
||||
#include "xp_str.h"
|
||||
#endif
|
||||
|
||||
JSObject *
|
||||
dom_NodeInit(JSContext *cx, JSObject *obj);
|
||||
|
||||
JSObject *
|
||||
dom_ElementInit(JSContext *cx, JSObject *obj, JSObject *node_proto);
|
||||
|
||||
JSObject *
|
||||
dom_AttributeInit(JSContext *cx, JSObject *scope, JSObject *node_proto);
|
||||
|
||||
JSObject *
|
||||
dom_CharacterDataInit(JSContext *cx, JSObject *scope, JSObject *node_proto);
|
||||
|
||||
JSObject *
|
||||
dom_TextInit(JSContext *cx, JSObject *scope, JSObject *data_proto);
|
||||
|
||||
JSObject *
|
||||
dom_CommentInit(JSContext *cx, JSObject *scope, JSObject *data_proto);
|
||||
|
||||
JSBool
|
||||
dom_node_getter(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
JSBool
|
||||
dom_node_setter(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
void
|
||||
dom_node_finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
/* if you adjust these enums, be sure to adjust the various setters */
|
||||
enum {
|
||||
DOM_NODE_NODENAME = -1,
|
||||
DOM_NODE_NODEVALUE = -2,
|
||||
DOM_NODE_NODETYPE = -3,
|
||||
DOM_NODE_PARENTNODE = -4,
|
||||
DOM_NODE_CHILDNODES = -5,
|
||||
DOM_NODE_FIRSTCHILD = -6,
|
||||
DOM_NODE_LASTCHILD = -7,
|
||||
DOM_NODE_PREVIOUSSIBLING = -8,
|
||||
DOM_NODE_NEXTSIBLING = -9,
|
||||
DOM_NODE_ATTRIBUTES = -10,
|
||||
DOM_NODE_HASCHILDNODES = -11,
|
||||
DOM_ELEMENT_TAGNAME = -12,
|
||||
};
|
||||
|
||||
extern JSPropertySpec dom_node_props[];
|
||||
|
||||
#endif /* DOM_PRIV_H */
|
|
@ -1,193 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Core DOM stuff -- initialization, stub functions, DOMImplementation, etc.
|
||||
*/
|
||||
|
||||
#include "dom_priv.h"
|
||||
|
||||
JSBool
|
||||
DOM_Init(JSContext *cx, JSObject *scope) {
|
||||
JSObject *node, *cdata;
|
||||
return (( node = dom_NodeInit(cx, scope)) &&
|
||||
dom_AttributeInit(cx, scope, node) &&
|
||||
dom_ElementInit(cx, scope, node) &&
|
||||
( cdata = dom_CharacterDataInit(cx, scope, node)) &&
|
||||
dom_TextInit(cx, scope, cdata) &&
|
||||
dom_CommentInit(cx, scope, cdata));
|
||||
}
|
||||
|
||||
static char *exception_names[] = {
|
||||
"NO_ERR",
|
||||
"INDEX_SIZE_ERR",
|
||||
"WSTRING_SIZE_ERR",
|
||||
"HIERARCHY_REQUEST_ERR",
|
||||
"WRONG_DOCUMENT_ERR",
|
||||
"INVALID_NAME_ERR",
|
||||
"NO_DATA_ALLOWED_ERR",
|
||||
"NO_MODIFICATION_ALLOWED_ERR",
|
||||
"NOT_FOUND_ERR",
|
||||
"NOT_SUPPORTED_ERR",
|
||||
"INUSE_ATTRIBUTE_ERR",
|
||||
"UNSUPPORTED_DOCUMENT_ERR"
|
||||
};
|
||||
|
||||
JSBool
|
||||
DOM_SignalException(JSContext *cx, DOM_ExceptionCode exception)
|
||||
{
|
||||
JS_ReportError(cx, "DOM Exception: %s", exception_names[exception]);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_InsertBeforeStub(JSContext *cx, DOM_Node *node, DOM_Node *child,
|
||||
DOM_Node *ref, JSBool before)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_ReplaceChildStub(JSContext *cx, DOM_Node *node, DOM_Node *child,
|
||||
DOM_Node *old, JSBool before)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_RemoveChildStub(JSContext *cx, DOM_Node *node, DOM_Node *old,
|
||||
JSBool before)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_AppendChildStub(JSContext *cx, DOM_Node *node, DOM_Node *child,
|
||||
JSBool before)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
DOM_DestroyNodeStub(JSContext *cx, DOM_Node *node)
|
||||
{
|
||||
if (node->data)
|
||||
JS_free(cx, node->data);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
DOM_ReflectNodeStub(JSContext *cx, DOM_Node *node)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_SetAttributeStub(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
const char *
|
||||
DOM_GetAttributeStub(JSContext *cx, DOM_Element *element, const char *name,
|
||||
JSBool *cacheable)
|
||||
{
|
||||
*cacheable = JS_FALSE;
|
||||
return "#none";
|
||||
}
|
||||
|
||||
intN
|
||||
DOM_GetNumAttrsStub(JSContext *cx, DOM_Element *element, JSBool *cacheable)
|
||||
{
|
||||
*cacheable = JS_FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_shaver
|
||||
int LM_Node_indent = 0;
|
||||
#endif
|
||||
|
||||
JSObject *
|
||||
DOM_ObjectForNodeDowncast(JSContext *cx, DOM_Node *node)
|
||||
{
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
if (!node->mocha_object)
|
||||
node->mocha_object = node->ops->reflectNode(cx, node);
|
||||
return node->mocha_object;
|
||||
}
|
||||
|
||||
void
|
||||
DOM_DestroyTree(JSContext *cx, DOM_Node *top)
|
||||
{
|
||||
DOM_Node *iter, *next;
|
||||
for (iter = top->child; iter; iter = next) {
|
||||
next = iter->sibling;
|
||||
if (iter->mocha_object) {
|
||||
iter->prev_sibling = iter->parent = iter->sibling =
|
||||
iter->child = NULL;
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "node %s type %d has mocha_object\n",
|
||||
iter->name ? iter->name : "<none>", iter->type);
|
||||
#endif
|
||||
} else {
|
||||
DOM_DestroyTree(cx, iter);
|
||||
}
|
||||
}
|
||||
DOM_DestroyNode(cx, top);
|
||||
}
|
||||
|
||||
/*
|
||||
* DOMImplementation
|
||||
*/
|
||||
|
||||
static void
|
||||
dom_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
}
|
||||
|
||||
JSClass DOM_DOMClass = {
|
||||
"DOM", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, dom_finalize
|
||||
};
|
||||
|
||||
#if 0
|
||||
static JSBool
|
||||
dom_hasFeature(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
char *feature, *version;
|
||||
if (!JS_ConvertArguments(cx, argc, argv, "ss", &feature, &version))
|
||||
return JS_TRUE;
|
||||
|
||||
if (!strcmp(feature, "HTML") &&
|
||||
!strcmp(version, "1"))
|
||||
*rval = JSVAL_TRUE;
|
||||
else
|
||||
*rval = JSVAL_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec dom_methods[] = {
|
||||
{"hasFeature", dom_hasFeature, 2},
|
||||
{0}
|
||||
};
|
||||
#endif
|
||||
|
|
@ -188,7 +188,7 @@ static JSFunctionSpec element_methods[] = {
|
|||
|
||||
DOM_Element *
|
||||
DOM_NewElement(const char *tagName, DOM_ElementOps *eleops, char *name,
|
||||
DOM_NodeOps *nodeops)
|
||||
char *styleClass, char *styleID, DOM_NodeOps *nodeops)
|
||||
{
|
||||
DOM_Node *node;
|
||||
DOM_Element *element = XP_NEW_ZAP(DOM_Element);
|
||||
|
@ -201,7 +201,10 @@ DOM_NewElement(const char *tagName, DOM_ElementOps *eleops, char *name,
|
|||
node->ops = nodeops;
|
||||
|
||||
element->tagName = tagName;
|
||||
element->styleClass = styleClass;
|
||||
element->styleID = styleID;
|
||||
element->ops = eleops;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -290,7 +293,22 @@ DOM_GetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
JSBool
|
||||
DOM_GetCleanEntryData(JSContext *cx, DOM_AttributeEntry *entry,
|
||||
DOM_DataParser parser, uint32 *data, void *closure)
|
||||
{
|
||||
if (entry->dirty) {
|
||||
uint32 newdata;
|
||||
if (!parser(entry->value, &newdata, closure))
|
||||
return JS_FALSE;
|
||||
entry->data = newdata;
|
||||
entry->dirty = JS_FALSE;
|
||||
}
|
||||
*data = entry->data;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static DOM_AttributeEntry *
|
||||
AddAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value)
|
||||
{
|
||||
|
@ -299,29 +317,31 @@ AddAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
|||
if (!element->attrs) {
|
||||
element->attrs = JS_malloc(cx, sizeof(DOM_AttributeEntry));
|
||||
if (!element->attrs)
|
||||
return JS_FALSE;
|
||||
return NULL;
|
||||
element->nattrs = 1;
|
||||
} else {
|
||||
element->attrs = XP_REALLOC(element->attrs,
|
||||
(element->nattrs++) * sizeof(DOM_AttributeEntry));
|
||||
if (!element->attrs)
|
||||
return JS_FALSE;
|
||||
return NULL;
|
||||
}
|
||||
entry = element->attrs + element->nattrs - 1;
|
||||
entry->name = name;
|
||||
entry->value = value;
|
||||
return JS_TRUE;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_SetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value)
|
||||
dom_SetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value, JSBool runCallback)
|
||||
{
|
||||
DOM_AttributeEntry *entry;
|
||||
if (!DOM_GetElementAttribute(cx, element, name, &entry))
|
||||
return JS_FALSE;
|
||||
if (!entry) {
|
||||
if (!AddAttribute(cx, element, name, value))
|
||||
entry = AddAttribute(cx, element, name, value);
|
||||
if (!entry)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
if (entry->value)
|
||||
|
@ -330,9 +350,18 @@ DOM_SetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
|||
}
|
||||
entry->dirty = JS_TRUE;
|
||||
|
||||
if (!runCallback)
|
||||
return JS_TRUE;
|
||||
return element->ops->setAttribute(cx, element, name, value);
|
||||
}
|
||||
|
||||
JSBool
|
||||
DOM_SetElementAttribute(JSContext *cx, DOM_Element *element, const char *name,
|
||||
const char *value)
|
||||
{
|
||||
return dom_SetElementAttribute(cx, element, name, value, JS_TRUE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Element(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *vp)
|
||||
{
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -17,8 +17,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Style things for the DOM.
|
||||
* Very purty. Makes it all go.
|
||||
* Perignon: store style information in the DOM, using CSS-1 selectors.
|
||||
*/
|
||||
|
||||
#include "jsapi.h"
|
||||
|
@ -40,11 +39,6 @@ typedef struct DOM_StyleRule DOM_StyleRule;
|
|||
/* this may become int or something later, for speed */
|
||||
typedef const char *DOM_StyleToken;
|
||||
|
||||
#define DOM_STYLE_PSEUDO_TAG (1 << 7)
|
||||
#define DOM_SELECTOR_IS_PSEUDO(sel) ((sel) & DOM_STYLE_PSEUDO_TAG)
|
||||
#define DOM_STYLE_SELECTOR_TYPE(sel) ((sel) & ~DOM_STYLE_PSEUDO_TAG)
|
||||
#define DOM_PSEUDOIZE(sel) ((sel) | DOM_STYLE_PSEUDO_TAG)
|
||||
|
||||
enum {
|
||||
SELECTOR_UNKNOWN = 0,
|
||||
SELECTOR_ID,
|
||||
|
@ -53,19 +47,33 @@ enum {
|
|||
};
|
||||
|
||||
struct DOM_StyleDatabase {
|
||||
PLHashTable *ht; /* PRHash, from js/ref or nsprpub, depending? */
|
||||
PLHashTable *ht;
|
||||
};
|
||||
|
||||
DOM_StyleDatabase *
|
||||
DOM_NewStyleDatabase(JSContext *cx);
|
||||
|
||||
void
|
||||
DOM_DestroyStyleDatabase(JSContext *cx, DOM_StyleDatabase *db);
|
||||
|
||||
/*
|
||||
* Find or create the StyleDatabase for the given JSContext.
|
||||
* The embedder must provide an implementation, or #define MOZILLA_CLIENT
|
||||
* to get the Mozilla-specific one which depends on MochaDecoder and
|
||||
* MWContext and lo_TopState and stuff.
|
||||
*/
|
||||
DOM_StyleDatabase *
|
||||
DOM_StyleDatabaseFromContext(JSContext *cx);
|
||||
|
||||
struct DOM_StyleSelector {
|
||||
int8 type;
|
||||
DOM_StyleToken selector;
|
||||
DOM_StyleToken pseudo;
|
||||
DOM_StyleToken extra;
|
||||
DOM_StyleSelector *enclosing;
|
||||
DOM_StyleSelector *sibling;
|
||||
DOM_StyleRule *rules;
|
||||
JSObject *mocha_object; /* reflection for this selector's rules */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -80,14 +88,25 @@ struct DOM_StyleSelector {
|
|||
* Now find/create a selector for "CODE B":
|
||||
* sel2 = DOM_StyleFindSelector(cx, db, sel, "CODE", NULL);
|
||||
*
|
||||
* And for "A:visited CODE B":
|
||||
* sel3 = DOM_StyleFindSelector(cx, db, sel2, "A", "visited");
|
||||
* And ".myclass CODE B":
|
||||
* sel3 = DOM_StyleFindSelector(cx, db, sel2, ".myclass", NULL);
|
||||
*/
|
||||
DOM_StyleSelector *
|
||||
DOM_StyleFindSelector(JSContext *cx, DOM_StyleDatabase *db,
|
||||
DOM_StyleSelector *base, DOM_StyleToken enclosing,
|
||||
DOM_StyleToken pseudo);
|
||||
|
||||
/*
|
||||
* As above, but take type explicitly rather than parsing leading # or . for
|
||||
* ID or class. For classes or extra is a tag or NULL. For tags, extra is an
|
||||
* ID or NULL. (For ID, extra is ignored.)
|
||||
*/
|
||||
DOM_StyleSelector *
|
||||
DOM_StyleFindSelectorFull(JSContext *cx, DOM_StyleDatabase *db,
|
||||
DOM_StyleSelector *base, uint8 type,
|
||||
DOM_StyleToken enclosing, DOM_StyleToken extra,
|
||||
DOM_StyleToken pseudo);
|
||||
|
||||
struct DOM_StyleRule {
|
||||
DOM_AttributeEntry entry;
|
||||
int16 weight;
|
||||
|
@ -96,7 +115,7 @@ struct DOM_StyleRule {
|
|||
|
||||
/*
|
||||
* Parses a style rule and adds it to the style database.
|
||||
* If len is 0, rule is presumed to be NUL-terminated.
|
||||
* If len is 0, rule is presumed to be NUL-terminated. (XXX NYI)
|
||||
*
|
||||
* Usage example:
|
||||
*
|
||||
|
@ -119,6 +138,8 @@ DOM_StyleParseRule(JSContext *cx, DOM_StyleDatabase *db, const char *rule,
|
|||
* enclosing Element is used for finding matches. The implementation is
|
||||
* necessarily somewhat hairy. See domstyle.c for details.
|
||||
*
|
||||
* If db is NULL, DOM_StyleDatabaseFromContext is used to find it.
|
||||
*
|
||||
* Usage examples:
|
||||
*
|
||||
* Get the color for a section of text:
|
||||
|
@ -130,16 +151,38 @@ DOM_StyleParseRule(JSContext *cx, DOM_StyleDatabase *db, const char *rule,
|
|||
|
||||
JSBool
|
||||
DOM_StyleGetProperty(JSContext *cx, DOM_StyleDatabase *db, DOM_Node *node,
|
||||
DOM_StyleToken property, DOM_StyleToken psuedo,
|
||||
DOM_AttributeEntry **entryp);
|
||||
DOM_StyleToken property, DOM_AttributeEntry **entryp);
|
||||
|
||||
/*
|
||||
* Get/set the pseudoclass for an element
|
||||
*/
|
||||
DOM_StyleToken
|
||||
DOM_GetElementPseudo(JSContext *cx, DOM_Element *element);
|
||||
|
||||
JSBool
|
||||
DOM_SetElementPseudo(JSContext *cx, DOM_Element *element,
|
||||
DOM_StyleToken pseudo);
|
||||
|
||||
/*
|
||||
* Add a property to the provided selector.
|
||||
*
|
||||
* DOM_StyleAddRule(cx, db, sel, "color", "blue");
|
||||
*/
|
||||
JSBool
|
||||
DOM_AttributeEntry *
|
||||
DOM_StyleAddRule(JSContext *cx, DOM_StyleDatabase *db, DOM_StyleSelector *sel,
|
||||
DOM_StyleToken name, const char *value);
|
||||
|
||||
/*
|
||||
* Resolve classes, tags, ids, contextual on the given object.
|
||||
*/
|
||||
JSBool
|
||||
DOM_DocObjectResolveStyleProps(JSContext *cx, JSObject *obj, jsval id);
|
||||
|
||||
/*
|
||||
* The contextual selector JS function: contextual("H1", "EM");
|
||||
*/
|
||||
JSBool
|
||||
DOM_JSContextual(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
#endif /* DOM_STYLE_H */
|
||||
|
|
|
@ -373,6 +373,7 @@ DOM_NewText(const char *data, int64 length, DOM_CDataOp notify,
|
|||
|
||||
LL_L2I(nbytes, length);
|
||||
cdata = (DOM_CharacterData *)text;
|
||||
cdata->len = length;
|
||||
cdata->data = XP_ALLOC(nbytes);
|
||||
cdata->notify = notify;
|
||||
if (!cdata->data) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче