+2004-12-23 Darin Adler <darin@apple.com>
+
+ Reviewed by Ken.
+
+ - re-fixed <rdar://problem/3760910> Request to include support for custom tag names in HTML (they already work in XML)
+
+ * khtml/css/cssstyleselector.cpp: (khtml::CSSStyleSelector::checkOneSelector): Changed
+ some code that used ID_LAST_TAG in a slightly wrong, but harmless, way.
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::debugPosition): Use nodeName rather than getTagName, since the latter works for
+ per-document tags and is just better all around for things like the document.
+ (khtml::debugNode): Ditto.
+ * khtml/editing/selection.cpp: (khtml::Selection::debugPosition): Ditto.
+ * khtml/editing/visible_position.cpp: (khtml::VisiblePosition::debugPosition): Ditto.
+ * khtml/xml/dom_nodeimpl.cpp: (NodeImpl::displayNode): Ditto.
+ * khtml/xml/dom_position.cpp: (DOM::Position::debugPosition): Ditto.
+
+ * khtml/html/dtd.cpp: (DOM::checkChild): Use ID_LAST_TAG rather than 1000 for the check that allows
+ non-HTML elements to be nested as desired.
+
+ * khtml/html/htmlparser.h: Change forbidden tag array to be allocated in the object rather than on
+ the heap. Also use ID_LAST_TAG for the array size; the old code used ID_CLOSE_TAG which is now a
+ much larger number.
+ * khtml/html/htmlparser.cpp:
+ (KHTMLParser::KHTMLParser): Remove code that creates the forbidden tag array on the heap; makes more
+ sense to just have the array be a member so we don't have to use new and delete on it. Also needed
+ to eliminate code that used ID_CLOSE_TAG for an array size.
+ (KHTMLParser::~KHTMLParser): Remove code that deletes the forbidden tag array. Also changed the code
+ that manages isindex to use deref instead of delete.
+ (KHTMLParser::reset): Use safer sizeof for clearing the forbidden tag array. Old code had the
+ mistake of using ID_CLOSE_TAG for the array size too.
+ (KHTMLParser::parseToken): Removed code that checks for bogus tags; it's not clear why it was ever
+ there and it would prevent custom tags from working. Added range check before using the forbidden
+ tag array with the token ID since custom tags will use index values past the end of the array.
+ (KHTMLParser::getElement): Removed most of the code that makes an element by ID; now the work is done
+ inside the DocumentImpl createHTMLElement. Any code that needs to be different than a dynamic
+ createElement call is still here. Last time I left out a few form element types from this switch;
+ fixed now.
+ * khtml/html/htmltokenizer.cpp: (khtml::HTMLTokenizer::parseTag): Call the tagId function in the
+ document if getTagID fails; this creates a unique per-document ID.
+
+ * khtml/misc/htmlhashes.h: Changed return types to unsigned short.
+ * khtml/misc/htmlhashes.cpp:
+ (khtml::getTagID): Changed return type to unsigned short.
+ (khtml::getAttrID): Ditto.
+
+ * khtml/misc/htmltags.c: Regenerated.
+ * khtml/misc/htmltags.h: Regenerated.
+
+ * khtml/misc/maketags: Changed the generated constants to use "const unsigned short" instead of "#define".
+ Changed ID_CLOSE_TAG to be a fixed value of 32000 rather than being just past the IDs of the HTML tags.
+ Also rewrote getTagName to work with the new scheme.
+
+ * khtml/xml/dom_docimpl.h: Added overload of createHTMLElement, made it non-virtual since it's not overriden.
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::createHTMLElement): Refactored into two separate functions, one that takes the tag ID.
+ Also updated for a few tags that the parser handled but this did not.
+
+ * kwq/KWQRenderTreeDebug.cpp:
+ (getTagName): Added. Works for custom nodes, because it calls nodeName rather than using getTagName on
+ the tag ID directly, which only works for standard nodes.
+ (operator<<): Update to call getTagName.
+ (nodePositionRelativeToRoot): Ditto.
+ (writeSelection): Ditto.
+
=== Safari-177 ===
2004-12-22 Darin Adler <darin@apple.com>
Q_UINT16 selLocalName = localNamePart(sel->tag);
Q_UINT16 selNS = namespacePart(sel->tag);
- if (localName < ID_LAST_TAG && e->isHTMLElement())
+ if (localName <= ID_LAST_TAG && e->isHTMLElement())
ns = xhtmlNamespace; // FIXME: Really want to move away from this complicated hackery and just
// switch tags and attr names over to AtomicStrings.
Position pos = m_start;
Position upstream = pos.upstream();
Position downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "pos: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "pos: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
}
else {
Position pos = m_start;
Position upstream = pos.upstream();
Position downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "start: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "start: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
fprintf(stderr, "-----------------------------------\n");
pos = m_end;
upstream = pos.upstream();
downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "end: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "end: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
fprintf(stderr, "-----------------------------------\n");
}
if (pos.isNull())
LOG(Editing, "%s <null>", prefix);
else
- LOG(Editing, "%s%s %p : %d", prefix, getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
+ LOG(Editing, "%s%s %p : %d", prefix, pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
}
static void debugNode(const char *prefix, const NodeImpl *node)
if (!node)
LOG(Editing, "%s <null>", prefix);
else
- LOG(Editing, "%s%s %p", prefix, getTagName(node->id()).string().latin1(), node);
+ LOG(Editing, "%s%s %p", prefix, node->nodeName().string().latin1(), node);
}
//------------------------------------------------------------------------------------------
Position pos = m_start;
Position upstream = pos.upstream();
Position downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "pos: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "pos: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
}
else {
Position pos = m_start;
Position upstream = pos.upstream();
Position downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "start: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "start: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
fprintf(stderr, "-----------------------------------\n");
pos = m_end;
upstream = pos.upstream();
downstream = pos.downstream();
- fprintf(stderr, "upstream: %s %p:%d\n", getTagName(upstream.node()->id()).string().latin1(), upstream.node(), upstream.offset());
- fprintf(stderr, "end: %s %p:%d\n", getTagName(pos.node()->id()).string().latin1(), pos.node(), pos.offset());
- fprintf(stderr, "downstream: %s %p:%d\n", getTagName(downstream.node()->id()).string().latin1(), downstream.node(), downstream.offset());
+ fprintf(stderr, "upstream: %s %p:%d\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
+ fprintf(stderr, "end: %s %p:%d\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
+ fprintf(stderr, "downstream: %s %p:%d\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
fprintf(stderr, "-----------------------------------\n");
}
if (isNull())
fprintf(stderr, "Position [%s]: null\n", msg);
else
- fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, getTagName(m_deepPosition.node()->id()).string().latin1(), m_deepPosition.node(), m_deepPosition.offset());
+ fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, m_deepPosition.node()->nodeName().string().latin1(), m_deepPosition.node(), m_deepPosition.offset());
}
#ifndef NDEBUG
// ### allow comments inside ANY node that can contain children
- if (tagID >= 1000 || childID >= 1000)
- return true; // one or both of the elements in an XML element; just allow for now
+ if (tagID > ID_LAST_TAG || childID > ID_LAST_TAG)
+ return true; // one or both of the elements is an XML element; just allow for now
switch(tagID)
{
blockStack = 0;
- // ID_CLOSE_TAG == Num of tags
- forbiddenTag = new ushort[ID_CLOSE_TAG+1];
-
reset();
}
document = doc;
document->ref();
- forbiddenTag = new ushort[ID_CLOSE_TAG+1];
-
blockStack = 0;
reset();
document->deref();
- delete [] forbiddenTag;
- delete isindex;
+ if (isindex)
+ isindex->deref();
}
void KHTMLParser::reset()
freeBlock();
- // before parsing no tags are forbidden...
- memset(forbiddenTag, 0, (ID_CLOSE_TAG+1)*sizeof(ushort));
+ // before parsing, no tags are forbidden
+ memset(forbiddenTag, 0, sizeof(forbiddenTag));
inBody = false;
haveFrameSet = false;
void KHTMLParser::parseToken(Token *t)
{
- if (t->id > 2*ID_CLOSE_TAG)
- {
- kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->id << endl;
- return;
- }
if(discard_until) {
if(t->id == discard_until)
discard_until = 0;
// holy shit. apparently some sites use </br> instead of <br>
// be compatible with IE and NS
- if(t->id == ID_BR+ID_CLOSE_TAG && doc()->inCompatMode())
- t->id -= ID_CLOSE_TAG;
+ if (t->id == ID_BR + ID_CLOSE_TAG && doc()->inCompatMode())
+ t->id = ID_BR;
- if(t->id > ID_CLOSE_TAG)
+ if (t->id > ID_CLOSE_TAG)
{
processCloseTag(t);
return;
// if this tag is forbidden inside the current context, pop
// blocks until we are allowed to add it...
- while(forbiddenTag[t->id]) {
+ while (t->id <= ID_LAST_TAG && forbiddenTag[t->id]) {
#ifdef PARSER_DEBUG
kdDebug( 6035 ) << "t->id: " << t->id << " is forbidden :-( " << endl;
#endif
} // end switch
break;
case ID_OBJECT:
- discard_until = id + ID_CLOSE_TAG;
+ discard_until = ID_OBJECT + ID_CLOSE_TAG;
return false;
case ID_UL:
case ID_OL:
}
}
-// FIXME: getElement looks like copied code of DocumentImpl::createHTMLElement or vice versa.
-// This has been the cause of bugs. They should share the same code.
NodeImpl *KHTMLParser::getElement(Token* t)
{
- NodeImpl *n = 0;
-
- switch(t->id)
+ switch (t->id)
{
- case ID_HTML:
- n = new HTMLHtmlElementImpl(document);
- break;
case ID_HEAD:
- if(!head && current->id() == ID_HTML) {
+ if (!head && current->id() == ID_HTML) {
head = new HTMLHeadElementImpl(document);
- n = head;
+ return head;
}
- break;
+ return 0;
case ID_BODY:
// body no longer allowed if we have a frameset
- if(haveFrameSet) break;
+ if (haveFrameSet)
+ return 0;
popBlock(ID_HEAD);
- n = new HTMLBodyElementImpl(document);
startBody();
- break;
-
-// head elements
- case ID_BASE:
- n = new HTMLBaseElementImpl(document);
- break;
- case ID_LINK:
- n = new HTMLLinkElementImpl(document);
- break;
- case ID_META:
- n = new HTMLMetaElementImpl(document);
- break;
- case ID_STYLE:
- n = new HTMLStyleElementImpl(document);
- break;
- case ID_TITLE:
- n = new HTMLTitleElementImpl(document);
- break;
+ return new HTMLBodyElementImpl(document);
// frames
- case ID_FRAME:
- n = new HTMLFrameElementImpl(document);
- break;
case ID_FRAMESET:
popBlock(ID_HEAD);
- if ( inBody && !haveFrameSet && !haveContent) {
- popBlock( ID_BODY );
+ if (inBody && !haveFrameSet && !haveContent) {
+ popBlock(ID_BODY);
// ### actually for IE document.body returns the now hidden "body" element
// we can't implement that behaviour now because it could cause too many
// regressions and the headaches are not worth the work as long as there is
doc()->body()->setAttribute(ATTR_STYLE, "display:none");
inBody = false;
}
- if ( (haveContent || haveFrameSet) && current->id() == ID_HTML)
- break;
- n = new HTMLFrameSetElementImpl(document);
+ if ((haveContent || haveFrameSet) && current->id() == ID_HTML)
+ return 0;
haveFrameSet = true;
startBody();
- break;
- // a bit a special case, since the frame is inlined...
+ return new HTMLFrameSetElementImpl(document);
+
+ // a bit of a special case, since the frame is inlined
case ID_IFRAME:
- n = new HTMLIFrameElementImpl(document);
- discard_until = ID_IFRAME+ID_CLOSE_TAG;
+ discard_until = ID_IFRAME + ID_CLOSE_TAG;
break;
// form elements
case ID_FORM:
- if (!form) {
- // Only create a new form if we're not already inside one.
- // This is consistent with other browsers' behavior.
- form = new HTMLFormElementImpl(document);
- n = form;
- }
- break;
+ // Only create a new form if we're not already inside one.
+ // This is consistent with other browsers' behavior.
+ if (form)
+ return 0;
+ form = new HTMLFormElementImpl(document);
+ return form;
case ID_BUTTON:
- n = new HTMLButtonElementImpl(document, form);
- break;
+ return new HTMLButtonElementImpl(document, form);
case ID_FIELDSET:
- n = new HTMLFieldSetElementImpl(document, form);
- break;
+ return new HTMLFieldSetElementImpl(document, form);
case ID_INPUT:
- n = new HTMLInputElementImpl(document, form);
- break;
- case ID_ISINDEX:
- n = handleIsindex(t);
- if( !inBody ) {
+ return new HTMLInputElementImpl(document, form);
+ case ID_ISINDEX: {
+ NodeImpl *n = handleIsindex(t);
+ if (!inBody) {
+ if (isindex)
+ isindex->deref();
isindex = n;
- n = 0;
- } else
- t->flat = true;
- break;
+ isindex->ref();
+ return 0;
+ }
+ t->flat = true;
+ return n;
+ }
case ID_KEYGEN:
- n = new HTMLKeygenElementImpl(document, form);
- break;
- case ID_LABEL:
- n = new HTMLLabelElementImpl(document);
- break;
+ return new HTMLKeygenElementImpl(document, form);
case ID_LEGEND:
- n = new HTMLLegendElementImpl(document, form);
- break;
+ return new HTMLLegendElementImpl(document, form);
case ID_OPTGROUP:
- n = new HTMLOptGroupElementImpl(document, form);
- break;
+ return new HTMLOptGroupElementImpl(document, form);
case ID_OPTION:
- n = new HTMLOptionElementImpl(document, form);
- break;
+ return new HTMLOptionElementImpl(document, form);
case ID_SELECT:
inSelect = true;
- n = new HTMLSelectElementImpl(document, form);
- break;
+ return new HTMLSelectElementImpl(document, form);
case ID_TEXTAREA:
- n = new HTMLTextAreaElementImpl(document, form);
- break;
+ return new HTMLTextAreaElementImpl(document, form);
// lists
- case ID_DL:
- n = new HTMLDListElementImpl(document);
- break;
case ID_DD:
- n = new HTMLGenericElementImpl(document, t->id);
popBlock(ID_DT);
popBlock(ID_DD);
break;
case ID_DT:
- n = new HTMLGenericElementImpl(document, t->id);
popBlock(ID_DD);
popBlock(ID_DT);
break;
- case ID_UL:
- {
- n = new HTMLUListElementImpl(document);
- break;
- }
- case ID_OL:
- {
- n = new HTMLOListElementImpl(document);
- break;
- }
- case ID_DIR:
- n = new HTMLDirectoryElementImpl(document);
- break;
- case ID_MENU:
- n = new HTMLMenuElementImpl(document);
- break;
case ID_LI:
- {
popBlock(ID_LI);
- n = new HTMLLIElementImpl(document);
- break;
- }
-// formatting elements (block)
- case ID_BLOCKQUOTE:
- n = new HTMLBlockquoteElementImpl(document);
- break;
- case ID_DIV:
- n = new HTMLDivElementImpl(document);
- break;
- case ID_LAYER:
- n = new HTMLLayerElementImpl(document);
- break;
- case ID_H1:
- case ID_H2:
- case ID_H3:
- case ID_H4:
- case ID_H5:
- case ID_H6:
- n = new HTMLHeadingElementImpl(document, t->id);
- break;
- case ID_HR:
- n = new HTMLHRElementImpl(document);
- break;
- case ID_P:
- n = new HTMLParagraphElementImpl(document);
- break;
- case ID_XMP:
- case ID_PRE:
- case ID_PLAINTEXT:
- n = new HTMLPreElementImpl(document, t->id);
- break;
-
-// font stuff
- case ID_BASEFONT:
- n = new HTMLBaseFontElementImpl(document);
- break;
- case ID_FONT:
- n = new HTMLFontElementImpl(document);
- break;
-
-// ins/del
- case ID_DEL:
- case ID_INS:
- n = new HTMLGenericElementImpl(document, t->id);
break;
// anchor
case ID_A:
// Never allow nested <a>s.
popBlock(ID_A);
-
- n = new HTMLAnchorElementImpl(document);
- break;
-
-// canvas
- case ID_CANVAS:
- n = new HTMLCanvasElementImpl(document);
break;
// images
case ID_IMG:
- n = new HTMLImageElementImpl(document, form);
- break;
+ return new HTMLImageElementImpl(document, form);
case ID_MAP:
map = new HTMLMapElementImpl(document);
- n = map;
- break;
- case ID_AREA:
- n = new HTMLAreaElementImpl(document);
- break;
-
-// objects, applets and scripts
- case ID_APPLET:
- n = new HTMLAppletElementImpl(document);
- break;
- case ID_EMBED:
- n = new HTMLEmbedElementImpl(document);
- break;
- case ID_OBJECT:
- n = new HTMLObjectElementImpl(document);
- break;
- case ID_PARAM:
- n = new HTMLParamElementImpl(document);
- break;
- case ID_SCRIPT:
- n = new HTMLScriptElementImpl(document);
- break;
+ return map;
// tables
- case ID_TABLE:
- n = new HTMLTableElementImpl(document);
- break;
- case ID_CAPTION:
- n = new HTMLTableCaptionElementImpl(document);
- break;
- case ID_COLGROUP:
- case ID_COL:
- n = new HTMLTableColElementImpl(document, t->id);
- break;
case ID_TR:
popBlock(ID_TR);
- n = new HTMLTableRowElementImpl(document);
break;
case ID_TD:
case ID_TH:
popBlock(ID_TH);
popBlock(ID_TD);
- n = new HTMLTableCellElementImpl(document, t->id);
break;
case ID_TBODY:
case ID_THEAD:
case ID_TFOOT:
- popBlock( ID_THEAD );
- popBlock( ID_TBODY );
- popBlock( ID_TFOOT );
- n = new HTMLTableSectionElementImpl(document, t->id, false);
- break;
-
-// inline elements
- case ID_BR:
- n = new HTMLBRElementImpl(document);
- break;
- case ID_Q:
- n = new HTMLGenericElementImpl(document, t->id);
+ popBlock(ID_THEAD);
+ popBlock(ID_TBODY);
+ popBlock(ID_TFOOT);
break;
// elements with no special representation in the DOM
-
-// block:
- case ID_ADDRESS:
- case ID_CENTER:
- n = new HTMLGenericElementImpl(document, t->id);
- break;
-// inline
- // %fontstyle
case ID_TT:
case ID_U:
case ID_B:
case ID_SMALL:
if (!allowNestedRedundantTag(t->id))
return 0;
- // Fall through and get handled with the rest of the tags
- // %phrase
- case ID_EM:
- case ID_STRONG:
- case ID_DFN:
- case ID_CODE:
- case ID_SAMP:
- case ID_KBD:
- case ID_VAR:
- case ID_CITE:
- case ID_ABBR:
- case ID_ACRONYM:
-
- // %special
- case ID_SUB:
- case ID_SUP:
- case ID_SPAN:
- case ID_NOBR:
- case ID_WBR:
- if (t->id == ID_NOBR || t->id == ID_WBR)
- popBlock(t->id); // Don't allow nested <nobr> or <wbr>
- n = new HTMLGenericElementImpl(document, t->id);
break;
- case ID_BDO:
+ case ID_NOBR:
+ case ID_WBR:
+ popBlock(t->id); // Don't allow nested <nobr> or <wbr>
break;
- // these are special, and normally not rendered
+// these are special, and normally not rendered
case ID_NOEMBED:
discard_until = ID_NOEMBED + ID_CLOSE_TAG;
return 0;
discard_until = ID_NOFRAMES + ID_CLOSE_TAG;
return 0;
case ID_NOSCRIPT:
- if(HTMLWidget && HTMLWidget->part()->jScriptEnabled())
+ if (HTMLWidget && HTMLWidget->part()->jScriptEnabled())
discard_until = ID_NOSCRIPT + ID_CLOSE_TAG;
return 0;
case ID_NOLAYER:
-// discard_until = ID_NOLAYER + ID_CLOSE_TAG;
+ //discard_until = ID_NOLAYER + ID_CLOSE_TAG;
return 0;
- break;
- case ID_MARQUEE:
- n = new HTMLMarqueeElementImpl(document);
- break;
-// text
case ID_TEXT:
- n = new TextImpl(document, t->text);
- break;
+ return new TextImpl(document, t->text);
case ID_COMMENT:
- if (includesCommentsInDOM)
- n = new CommentImpl(document, t->text);
+ if (!includesCommentsInDOM)
+ return 0;
break;
- default:
- kdDebug( 6035 ) << "Unknown tag " << t->id << "!" << endl;
}
- return n;
+
+ return document->document()->createHTMLElement(t->id);
}
#define MAX_REDUNDANT 20
(C) 1997 Torben Weis (weis@kde.org)
(C) 1998 Waldo Bastian (bastian@kde.org)
(C) 1999 Lars Knoll (knoll@kde.org)
- Copyright (C) 2003 Apple Computer, Inc.
+ Copyright (C) 2004 Apple Computer, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
#include <qdatetime.h>
#endif
-
#include "dom/dom_string.h"
#include "xml/dom_nodeimpl.h"
#include "html/html_documentimpl.h"
+#include "misc/htmltags.h"
class KHTMLView;
class HTMLStackElem;
static bool isHeaderTag(int _id);
void popNestedHeaderTag();
- ushort *forbiddenTag;
-
/*
* currently active form
*/
bool includesCommentsInDOM;
+ ushort forbiddenTag[ID_LAST_TAG + 1];
+
#if SPEED_DEBUG > 0
QTime qt;
#endif
};
#endif // HTMLPARSER_H
-
// Look up the tagID for the specified tag name (now that we've shaved off any
// invalid / that might have followed the name).
- uint tagID = getTagID(ptr, len);
+ unsigned short tagID = getTagID(ptr, len);
if (!tagID) {
-#ifdef TOKEN_DEBUG
- QCString tmp(ptr, len+1);
- kdDebug( 6036 ) << "Unknown tag: \"" << tmp.data() << "\"" << endl;
-#endif
- dest = buffer;
+ DOMString tagName(ptr);
+ DocumentImpl *doc = parser->docPtr()->document();
+ if (doc->isValidName(tagName))
+ tagID = parser->docPtr()->document()->tagId(0, tagName.implementation(), false);
}
- else
- {
+ if (tagID) {
#ifdef TOKEN_DEBUG
QCString tmp(ptr, len+1);
kdDebug( 6036 ) << "found tag id=" << tagID << ": " << tmp.data() << endl;
#endif
currToken.id = beginTag ? tagID : tagID + ID_CLOSE_TAG;
- dest = buffer;
}
+ dest = buffer;
tag = SearchAttribute;
cBufferPos = 0;
}
#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0
kdDebug( 6036 ) << "appending Tag: " << tagID << endl;
#endif
- bool beginTag = !currToken.flat && (tagID < ID_CLOSE_TAG);
+ bool beginTag = !currToken.flat && (tagID <= ID_CLOSE_TAG);
- if (tagID >= ID_CLOSE_TAG)
+ if (tagID > ID_CLOSE_TAG)
tagID -= ID_CLOSE_TAG;
else if (tagID == ID_SCRIPT) {
AttributeImpl* a = 0;
script = true;
parseSpecial(src);
}
- else if (tagID < ID_CLOSE_TAG) // Handle <script src="foo"/>
+ else if (tagID <= ID_CLOSE_TAG) // Handle <script src="foo"/>
scriptHandler();
break;
case ID_STYLE:
This file is part of the KDE libraries
Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
+ Copyright (C) 2004 Apple Computer, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
#include "htmlattrs.c"
#undef __inline
-int khtml::getTagID(const char *tagStr, int len)
+unsigned short khtml::getTagID(const char *tagStr, int len)
{
const struct tags *tagPtr = findTag(tagStr, len);
if (!tagPtr)
return 0;
-
return tagPtr->id;
}
-int khtml::getAttrID(const char *tagStr, int len)
+unsigned short khtml::getAttrID(const char *tagStr, int len)
{
const struct attrs *tagPtr = findAttr(tagStr, len);
if (!tagPtr)
return 0;
-
return tagPtr->id;
}
-
+/*
+ This file is part of the KDE libraries
+
+ Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
+ Copyright (C) 2004 Apple Computer, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
#ifndef HTMLHASHES_H
#define HTMLHASHES_H
-#include "xml/dom_stringimpl.h"
-#include "htmlattrs.h"
#include "htmltags.h"
+#include "htmlattrs.h"
namespace khtml
{
- int getTagID(const char *tagStr, int len);
- int getAttrID(const char *tagStr, int len);
-};
+ unsigned short getTagID(const char *tagStr, int len);
+ unsigned short getAttrID(const char *tagStr, int len);
+}
#endif
}
#line 116 "htmltags.gperf"
+#line 426 "htmltags.c"
+using DOM::DOMString;
-static const char * const tagList[] = {
-"",
+static const char * const openTagNames[] = {
+ 0,
"A",
"ABBR",
"ACRONYM",
"VAR",
"WBR",
"XMP",
-"TEXT",
-"COMMENT",
+ "TEXT",
+ "COMMENT"
+};
+
+static const char * const closeTagNames[] = {
+ 0,
"/A",
"/ABBR",
"/ACRONYM",
"/VAR",
"/WBR",
"/XMP",
- 0
};
-DOM::DOMString getTagName(unsigned short id)
+
+DOMString getTagName(unsigned short id)
{
- if(id > ID_CLOSE_TAG*2) id = ID_CLOSE_TAG+1;
- return DOM::DOMString(tagList[id]);
+ if (id > ID_CLOSE_TAG) {
+ int index = id - ID_CLOSE_TAG;
+ if (index >= ID_TEXT)
+ return DOMString();
+ return closeTagNames[index];
+ }
+ if (id > ID_LAST_TAG)
+ return DOMString();
+ return openTagNames[id];
}
/* This file is automatically generated from
htmltags.in by maketags, do not edit */
/* Copyright 1999 Lars Knoll */
+/* Copyright 2004 Apple Computer, Inc. */
#ifndef KHTML_TAGS_H
#define KHTML_TAGS_H
#include "dom/dom_string.h"
DOM::DOMString getTagName(unsigned short id);
-#define ID_A 1
-#define ID_ABBR 2
-#define ID_ACRONYM 3
-#define ID_ADDRESS 4
-#define ID_APPLET 5
-#define ID_AREA 6
-#define ID_B 7
-#define ID_BASE 8
-#define ID_BASEFONT 9
-#define ID_BDO 10
-#define ID_BIG 11
-#define ID_BLOCKQUOTE 12
-#define ID_BODY 13
-#define ID_BR 14
-#define ID_BUTTON 15
-#define ID_CANVAS 16
-#define ID_CAPTION 17
-#define ID_CENTER 18
-#define ID_CITE 19
-#define ID_CODE 20
-#define ID_COL 21
-#define ID_COLGROUP 22
-#define ID_DD 23
-#define ID_DEL 24
-#define ID_DFN 25
-#define ID_DIR 26
-#define ID_DIV 27
-#define ID_DL 28
-#define ID_DT 29
-#define ID_EM 30
-#define ID_EMBED 31
-#define ID_FIELDSET 32
-#define ID_FONT 33
-#define ID_FORM 34
-#define ID_FRAME 35
-#define ID_FRAMESET 36
-#define ID_H1 37
-#define ID_H2 38
-#define ID_H3 39
-#define ID_H4 40
-#define ID_H5 41
-#define ID_H6 42
-#define ID_HEAD 43
-#define ID_HR 44
-#define ID_HTML 45
-#define ID_I 46
-#define ID_IFRAME 47
-#define ID_IMG 48
-#define ID_INPUT 49
-#define ID_INS 50
-#define ID_ISINDEX 51
-#define ID_KBD 52
-#define ID_KEYGEN 53
-#define ID_LABEL 54
-#define ID_LAYER 55
-#define ID_LEGEND 56
-#define ID_LI 57
-#define ID_LINK 58
-#define ID_MAP 59
-#define ID_MARQUEE 60
-#define ID_MENU 61
-#define ID_META 62
-#define ID_NOBR 63
-#define ID_NOEMBED 64
-#define ID_NOFRAMES 65
-#define ID_NOSCRIPT 66
-#define ID_NOLAYER 67
-#define ID_OBJECT 68
-#define ID_OL 69
-#define ID_OPTGROUP 70
-#define ID_OPTION 71
-#define ID_P 72
-#define ID_PARAM 73
-#define ID_PLAINTEXT 74
-#define ID_PRE 75
-#define ID_Q 76
-#define ID_S 77
-#define ID_SAMP 78
-#define ID_SCRIPT 79
-#define ID_SELECT 80
-#define ID_SMALL 81
-#define ID_SPAN 82
-#define ID_STRIKE 83
-#define ID_STRONG 84
-#define ID_STYLE 85
-#define ID_SUB 86
-#define ID_SUP 87
-#define ID_TABLE 88
-#define ID_TBODY 89
-#define ID_TD 90
-#define ID_TEXTAREA 91
-#define ID_TFOOT 92
-#define ID_TH 93
-#define ID_THEAD 94
-#define ID_TITLE 95
-#define ID_TR 96
-#define ID_TT 97
-#define ID_U 98
-#define ID_UL 99
-#define ID_VAR 100
-#define ID_WBR 101
-#define ID_XMP 102
-#define ID_TEXT 103
-#define ID_COMMENT 104
-#define ID_CLOSE_TAG 104
-#define ID_LAST_TAG 104
+
+const unsigned short ID_A = 1;
+const unsigned short ID_ABBR = 2;
+const unsigned short ID_ACRONYM = 3;
+const unsigned short ID_ADDRESS = 4;
+const unsigned short ID_APPLET = 5;
+const unsigned short ID_AREA = 6;
+const unsigned short ID_B = 7;
+const unsigned short ID_BASE = 8;
+const unsigned short ID_BASEFONT = 9;
+const unsigned short ID_BDO = 10;
+const unsigned short ID_BIG = 11;
+const unsigned short ID_BLOCKQUOTE = 12;
+const unsigned short ID_BODY = 13;
+const unsigned short ID_BR = 14;
+const unsigned short ID_BUTTON = 15;
+const unsigned short ID_CANVAS = 16;
+const unsigned short ID_CAPTION = 17;
+const unsigned short ID_CENTER = 18;
+const unsigned short ID_CITE = 19;
+const unsigned short ID_CODE = 20;
+const unsigned short ID_COL = 21;
+const unsigned short ID_COLGROUP = 22;
+const unsigned short ID_DD = 23;
+const unsigned short ID_DEL = 24;
+const unsigned short ID_DFN = 25;
+const unsigned short ID_DIR = 26;
+const unsigned short ID_DIV = 27;
+const unsigned short ID_DL = 28;
+const unsigned short ID_DT = 29;
+const unsigned short ID_EM = 30;
+const unsigned short ID_EMBED = 31;
+const unsigned short ID_FIELDSET = 32;
+const unsigned short ID_FONT = 33;
+const unsigned short ID_FORM = 34;
+const unsigned short ID_FRAME = 35;
+const unsigned short ID_FRAMESET = 36;
+const unsigned short ID_H1 = 37;
+const unsigned short ID_H2 = 38;
+const unsigned short ID_H3 = 39;
+const unsigned short ID_H4 = 40;
+const unsigned short ID_H5 = 41;
+const unsigned short ID_H6 = 42;
+const unsigned short ID_HEAD = 43;
+const unsigned short ID_HR = 44;
+const unsigned short ID_HTML = 45;
+const unsigned short ID_I = 46;
+const unsigned short ID_IFRAME = 47;
+const unsigned short ID_IMG = 48;
+const unsigned short ID_INPUT = 49;
+const unsigned short ID_INS = 50;
+const unsigned short ID_ISINDEX = 51;
+const unsigned short ID_KBD = 52;
+const unsigned short ID_KEYGEN = 53;
+const unsigned short ID_LABEL = 54;
+const unsigned short ID_LAYER = 55;
+const unsigned short ID_LEGEND = 56;
+const unsigned short ID_LI = 57;
+const unsigned short ID_LINK = 58;
+const unsigned short ID_MAP = 59;
+const unsigned short ID_MARQUEE = 60;
+const unsigned short ID_MENU = 61;
+const unsigned short ID_META = 62;
+const unsigned short ID_NOBR = 63;
+const unsigned short ID_NOEMBED = 64;
+const unsigned short ID_NOFRAMES = 65;
+const unsigned short ID_NOSCRIPT = 66;
+const unsigned short ID_NOLAYER = 67;
+const unsigned short ID_OBJECT = 68;
+const unsigned short ID_OL = 69;
+const unsigned short ID_OPTGROUP = 70;
+const unsigned short ID_OPTION = 71;
+const unsigned short ID_P = 72;
+const unsigned short ID_PARAM = 73;
+const unsigned short ID_PLAINTEXT = 74;
+const unsigned short ID_PRE = 75;
+const unsigned short ID_Q = 76;
+const unsigned short ID_S = 77;
+const unsigned short ID_SAMP = 78;
+const unsigned short ID_SCRIPT = 79;
+const unsigned short ID_SELECT = 80;
+const unsigned short ID_SMALL = 81;
+const unsigned short ID_SPAN = 82;
+const unsigned short ID_STRIKE = 83;
+const unsigned short ID_STRONG = 84;
+const unsigned short ID_STYLE = 85;
+const unsigned short ID_SUB = 86;
+const unsigned short ID_SUP = 87;
+const unsigned short ID_TABLE = 88;
+const unsigned short ID_TBODY = 89;
+const unsigned short ID_TD = 90;
+const unsigned short ID_TEXTAREA = 91;
+const unsigned short ID_TFOOT = 92;
+const unsigned short ID_TH = 93;
+const unsigned short ID_THEAD = 94;
+const unsigned short ID_TITLE = 95;
+const unsigned short ID_TR = 96;
+const unsigned short ID_TT = 97;
+const unsigned short ID_U = 98;
+const unsigned short ID_UL = 99;
+const unsigned short ID_VAR = 100;
+const unsigned short ID_WBR = 101;
+const unsigned short ID_XMP = 102;
+const unsigned short ID_TEXT = 103;
+const unsigned short ID_COMMENT = 104;
+const unsigned short ID_LAST_TAG = 104;
+const unsigned short ID_CLOSE_TAG = 32000;
#endif
#
# Copyright (C) 1998 Waldo Bastian (bastian@kde.org)
# 1999 Lars Knoll (knoll@kde.org)
+# Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
#
# KDE HTML Widget -- Script to generate htmltags.c and htmltags.h
#
+
+use strict;
+
open IN, "htmltags.in"
or die "Can't open in\n";
open header, ">htmltags.h"
print out "struct tags {\n const char *name;\n int id;\n};\n%%\n";
print header "/* This file is automatically generated from
-htmltags.in by maketags, do not edit */\n/* Copyright 1999 Lars Knoll */\n\n#ifndef KHTML_TAGS_H\n#define KHTML_TAGS_H\n\n#include \"dom/dom_string.h\"\n\n";
+htmltags.in by maketags, do not edit */\n/* Copyright 1999 Lars Knoll */\n/* Copyright 2004 Apple Computer, Inc. */\n\n#ifndef KHTML_TAGS_H\n#define KHTML_TAGS_H\n\n#include \"dom/dom_string.h\"\n\n";
-print header "DOM::DOMString getTagName(unsigned short id);\n";
+print header "DOM::DOMString getTagName(unsigned short id);\n\n";
-$num = 0;
+my $num = 0;
+my $openTags = "";
+my $closeTags = "";
while (<IN>) {
chomp;
- $attr = $_;
- $num = $num + 1;
- $up = uc($attr);
- push(@a, " \"$up\",");
- push(@b, " \"/$up\",");
+ my $attr = $_;
+ $num += 1;
+ my $up = uc($attr);
+ $openTags .= " \"$up\",\n";
+ $closeTags .= " \"/$up\",\n";
$up =~ s/-/_/;
print out $attr . ", ID_" . $up . "\n";
- print header "#define ID_" . $up . " " . $num . "\n";
+ print header "const unsigned short ID_$up = $num;\n";
}
print out "anchor, ID_A\n";
print out "image, ID_IMG\n";
print out "listing, ID_PRE\n";
-$num = $num+1;
-print header "#define ID_TEXT $num\n";
-$num = $num+1;
-print header "#define ID_COMMENT $num\n";
-print header "#define ID_CLOSE_TAG $num\n";
-print header "#define ID_LAST_TAG $num\n";
+$num += 1;
+print header "const unsigned short ID_TEXT = $num;\n";
+$num += 1;
+print header "const unsigned short ID_COMMENT = $num;\n";
+print header "const unsigned short ID_LAST_TAG = $num;\n";
+print header "const unsigned short ID_CLOSE_TAG = 32000;\n";
print out "%%\n";
close out;
exit $result;
}
-open(OUT, ">>htmltags.c");
-print OUT "\n\nstatic const char * const tagList[] = {\n";
-print OUT "\"\",\n";
-while(defined ($line = shift @a))
-{
- print OUT $line."\n";
+open IN, "htmltags.c" or die;
+
+my $numLines = 0;
+while (<IN>) {
+ $numLines++;
}
-print OUT "\"TEXT\",\n";
-print OUT "\"COMMENT\",\n";
-while(defined ($line = shift @b))
+$numLines += 2;
+
+chomp $openTags;
+chomp $closeTags;
+
+open OUT, ">>htmltags.c" or die;
+print OUT <<END
+#line $numLines "htmltags.c"
+
+using DOM::DOMString;
+
+static const char * const openTagNames[] = {
+ 0,
+$openTags
+ "TEXT",
+ "COMMENT"
+};
+
+static const char * const closeTagNames[] = {
+ 0,
+$closeTags
+};
+
+DOMString getTagName(unsigned short id)
{
- print OUT $line."\n";
+ if (id > ID_CLOSE_TAG) {
+ int index = id - ID_CLOSE_TAG;
+ if (index >= ID_TEXT)
+ return DOMString();
+ return closeTagNames[index];
+ }
+ if (id > ID_LAST_TAG)
+ return DOMString();
+ return openTagNames[id];
}
-print OUT " 0\n};\n";
-print OUT "DOM::DOMString getTagName(unsigned short id)\n{\n";
-print OUT " if(id > ID_CLOSE_TAG*2) id = ID_CLOSE_TAG+1;\n";
-print OUT " return DOM::DOMString(tagList[id]);\n";
-print OUT "}\n";
+END
return Node::DOCUMENT_NODE;
}
-// FIXME: createHTMLElement looks like copied code of KHTMLParser::getElement or vice versa.
-// This has been the cause of bugs. They should share the same code.
ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name, int &exceptioncode )
{
if (!isValidName(name)) {
exceptioncode = DOMException::INVALID_CHARACTER_ERR;
return 0;
}
+ return createHTMLElement(tagId(0, name.implementation(), false));
+}
- uint id = khtml::getTagID( name.string().lower().latin1(), name.string().length() );
-
- ElementImpl *n = 0;
- switch(id)
+ElementImpl *DocumentImpl::createHTMLElement(unsigned short tagID)
+{
+ switch (tagID)
{
case ID_HTML:
- n = new HTMLHtmlElementImpl(docPtr());
- break;
+ return new HTMLHtmlElementImpl(docPtr());
case ID_HEAD:
- n = new HTMLHeadElementImpl(docPtr());
- break;
+ return new HTMLHeadElementImpl(docPtr());
case ID_BODY:
- n = new HTMLBodyElementImpl(docPtr());
- break;
+ return new HTMLBodyElementImpl(docPtr());
// head elements
case ID_BASE:
- n = new HTMLBaseElementImpl(docPtr());
- break;
+ return new HTMLBaseElementImpl(docPtr());
case ID_LINK:
- n = new HTMLLinkElementImpl(docPtr());
- break;
+ return new HTMLLinkElementImpl(docPtr());
case ID_META:
- n = new HTMLMetaElementImpl(docPtr());
- break;
+ return new HTMLMetaElementImpl(docPtr());
case ID_STYLE:
- n = new HTMLStyleElementImpl(docPtr());
- break;
+ return new HTMLStyleElementImpl(docPtr());
case ID_TITLE:
- n = new HTMLTitleElementImpl(docPtr());
- break;
+ return new HTMLTitleElementImpl(docPtr());
// frames
case ID_FRAME:
- n = new HTMLFrameElementImpl(docPtr());
- break;
+ return new HTMLFrameElementImpl(docPtr());
case ID_FRAMESET:
- n = new HTMLFrameSetElementImpl(docPtr());
- break;
+ return new HTMLFrameSetElementImpl(docPtr());
case ID_IFRAME:
- n = new HTMLIFrameElementImpl(docPtr());
- break;
+ return new HTMLIFrameElementImpl(docPtr());
// form elements
// ### FIXME: we need a way to set form dependency after we have made the form elements
case ID_FORM:
- n = new HTMLFormElementImpl(docPtr());
- break;
+ return new HTMLFormElementImpl(docPtr());
case ID_BUTTON:
- n = new HTMLButtonElementImpl(docPtr());
- break;
+ return new HTMLButtonElementImpl(docPtr());
case ID_FIELDSET:
- n = new HTMLFieldSetElementImpl(docPtr());
- break;
+ return new HTMLFieldSetElementImpl(docPtr());
case ID_INPUT:
- n = new HTMLInputElementImpl(docPtr());
- break;
+ return new HTMLInputElementImpl(docPtr());
case ID_ISINDEX:
- n = new HTMLIsIndexElementImpl(docPtr());
- break;
+ return new HTMLIsIndexElementImpl(docPtr());
case ID_LABEL:
- n = new HTMLLabelElementImpl(docPtr());
- break;
+ return new HTMLLabelElementImpl(docPtr());
case ID_LEGEND:
- n = new HTMLLegendElementImpl(docPtr());
- break;
+ return new HTMLLegendElementImpl(docPtr());
case ID_OPTGROUP:
- n = new HTMLOptGroupElementImpl(docPtr());
- break;
+ return new HTMLOptGroupElementImpl(docPtr());
case ID_OPTION:
- n = new HTMLOptionElementImpl(docPtr());
- break;
+ return new HTMLOptionElementImpl(docPtr());
case ID_SELECT:
- n = new HTMLSelectElementImpl(docPtr());
- break;
+ return new HTMLSelectElementImpl(docPtr());
case ID_TEXTAREA:
- n = new HTMLTextAreaElementImpl(docPtr());
- break;
+ return new HTMLTextAreaElementImpl(docPtr());
// lists
case ID_DL:
- n = new HTMLDListElementImpl(docPtr());
- break;
+ return new HTMLDListElementImpl(docPtr());
case ID_DD:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+ return new HTMLGenericElementImpl(docPtr(), tagID);
case ID_DT:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+ return new HTMLGenericElementImpl(docPtr(), tagID);
case ID_UL:
- n = new HTMLUListElementImpl(docPtr());
- break;
+ return new HTMLUListElementImpl(docPtr());
case ID_OL:
- n = new HTMLOListElementImpl(docPtr());
- break;
+ return new HTMLOListElementImpl(docPtr());
case ID_DIR:
- n = new HTMLDirectoryElementImpl(docPtr());
- break;
+ return new HTMLDirectoryElementImpl(docPtr());
case ID_MENU:
- n = new HTMLMenuElementImpl(docPtr());
- break;
+ return new HTMLMenuElementImpl(docPtr());
case ID_LI:
- n = new HTMLLIElementImpl(docPtr());
- break;
+ return new HTMLLIElementImpl(docPtr());
// formatting elements (block)
case ID_BLOCKQUOTE:
- n = new HTMLBlockquoteElementImpl(docPtr());
- break;
+ return new HTMLBlockquoteElementImpl(docPtr());
case ID_DIV:
- n = new HTMLDivElementImpl(docPtr());
- break;
+ return new HTMLDivElementImpl(docPtr());
case ID_H1:
case ID_H2:
case ID_H3:
case ID_H4:
case ID_H5:
case ID_H6:
- n = new HTMLHeadingElementImpl(docPtr(), id);
- break;
+ return new HTMLHeadingElementImpl(docPtr(), tagID);
case ID_HR:
- n = new HTMLHRElementImpl(docPtr());
- break;
+ return new HTMLHRElementImpl(docPtr());
case ID_P:
- n = new HTMLParagraphElementImpl(docPtr());
- break;
+ return new HTMLParagraphElementImpl(docPtr());
case ID_PRE:
- n = new HTMLPreElementImpl(docPtr(), id);
- break;
+ case ID_XMP:
+ case ID_PLAINTEXT:
+ return new HTMLPreElementImpl(docPtr(), tagID);
+ case ID_LAYER:
+ return new HTMLLayerElementImpl(docPtr());
// font stuff
case ID_BASEFONT:
- n = new HTMLBaseFontElementImpl(docPtr());
- break;
+ return new HTMLBaseFontElementImpl(docPtr());
case ID_FONT:
- n = new HTMLFontElementImpl(docPtr());
- break;
+ return new HTMLFontElementImpl(docPtr());
// ins/del
case ID_DEL:
case ID_INS:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+ return new HTMLGenericElementImpl(docPtr(), tagID);
// anchor
case ID_A:
- n = new HTMLAnchorElementImpl(docPtr());
- break;
+ return new HTMLAnchorElementImpl(docPtr());
// images
case ID_IMG:
- n = new HTMLImageElementImpl(docPtr());
- break;
+ return new HTMLImageElementImpl(docPtr());
case ID_MAP:
- n = new HTMLMapElementImpl(docPtr());
- /*n = map;*/
- break;
+ return new HTMLMapElementImpl(docPtr());
case ID_AREA:
- n = new HTMLAreaElementImpl(docPtr());
- break;
+ return new HTMLAreaElementImpl(docPtr());
case ID_CANVAS:
- n = new HTMLCanvasElementImpl(docPtr());
- break;
+ return new HTMLCanvasElementImpl(docPtr());
// objects, applets and scripts
case ID_APPLET:
- n = new HTMLAppletElementImpl(docPtr());
- break;
+ return new HTMLAppletElementImpl(docPtr());
case ID_EMBED:
- n = new HTMLEmbedElementImpl(docPtr());
- break;
+ return new HTMLEmbedElementImpl(docPtr());
case ID_OBJECT:
- n = new HTMLObjectElementImpl(docPtr());
- break;
+ return new HTMLObjectElementImpl(docPtr());
case ID_PARAM:
- n = new HTMLParamElementImpl(docPtr());
- break;
+ return new HTMLParamElementImpl(docPtr());
case ID_SCRIPT:
- n = new HTMLScriptElementImpl(docPtr());
- break;
+ return new HTMLScriptElementImpl(docPtr());
// tables
case ID_TABLE:
- n = new HTMLTableElementImpl(docPtr());
- break;
+ return new HTMLTableElementImpl(docPtr());
case ID_CAPTION:
- n = new HTMLTableCaptionElementImpl(docPtr());
- break;
+ return new HTMLTableCaptionElementImpl(docPtr());
case ID_COLGROUP:
case ID_COL:
- n = new HTMLTableColElementImpl(docPtr(), id);
- break;
+ return new HTMLTableColElementImpl(docPtr(), tagID);
case ID_TR:
- n = new HTMLTableRowElementImpl(docPtr());
- break;
+ return new HTMLTableRowElementImpl(docPtr());
case ID_TD:
case ID_TH:
- n = new HTMLTableCellElementImpl(docPtr(), id);
- break;
+ return new HTMLTableCellElementImpl(docPtr(), tagID);
case ID_THEAD:
case ID_TBODY:
case ID_TFOOT:
- n = new HTMLTableSectionElementImpl(docPtr(), id, false);
- break;
+ return new HTMLTableSectionElementImpl(docPtr(), tagID, false);
// inline elements
case ID_BR:
- n = new HTMLBRElementImpl(docPtr());
- break;
+ return new HTMLBRElementImpl(docPtr());
case ID_Q:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+ return new HTMLGenericElementImpl(docPtr(), tagID);
// elements with no special representation in the DOM
// block:
case ID_ADDRESS:
case ID_CENTER:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+
// inline
// %fontstyle
case ID_TT:
case ID_SPAN:
case ID_NOBR:
case ID_WBR:
- n = new HTMLGenericElementImpl(docPtr(), id);
- break;
+
+ case ID_BDO:
+ default:
+ return new HTMLGenericElementImpl(docPtr(), tagID);
case ID_MARQUEE:
- n = new HTMLMarqueeElementImpl(docPtr());
- break;
+ return new HTMLMarqueeElementImpl(docPtr());
- case ID_BDO: // FIXME: make an element here. "bdo" with dir adds the CSS direction and unicode-bidi with override.
- break;
-
// text
case ID_TEXT:
kdDebug( 6020 ) << "Use document->createTextNode()" << endl;
- break;
-
- default:
- break;
+ return 0;
}
- return n;
+
+ return 0;
}
QString DocumentImpl::nextState()
case Node::COMMENT_NODE:
case Node::DOCUMENT_TYPE_NODE:
return true;
- break;
default:
return false;
}
if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {
// we're in HTML namespace if we know the tag.
// xhtml is lower case - case sensitive, easy to implement
- if ( htmlMode() == XHtml && (id = khtml::getAttrID(n.string().ascii(), _name->l)) )
+ if ( htmlMode() == XHtml && (id = getAttrID(n.string().ascii(), _name->l)) )
return id;
// compatibility: upper case - case insensitive
- if ( htmlMode() != XHtml && (id = khtml::getAttrID(n.string().lower().ascii(), _name->l )) )
+ if ( htmlMode() != XHtml && (id = getAttrID(n.string().lower().ascii(), _name->l )) )
return id;
// ok, the fast path didn't work out, we need the full check
if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {
// we're in HTML namespace if we know the tag.
// xhtml is lower case - case sensitive, easy to implement
- if ( htmlMode() == XHtml && (id = khtml::getTagID(n.string().ascii(), _name->l)) )
+ if ( htmlMode() == XHtml && (id = getTagID(n.string().ascii(), _name->l)) )
return id;
// compatibility: upper case - case insensitive
- if ( htmlMode() != XHtml && (id = khtml::getTagID(n.string().lower().ascii(), _name->l )) )
+ if ( htmlMode() != XHtml && (id = getTagID(n.string().lower().ascii(), _name->l )) )
return id;
// ok, the fast path didn't work out, we need the full check
case Node::CDATA_SECTION_NODE:
case Node::ENTITY_REFERENCE_NODE:
return true;
- break;
default:
return false;
}
virtual bool isDocumentNode() const { return true; }
virtual bool isHTMLDocument() const { return false; }
- virtual ElementImpl *createHTMLElement ( const DOMString &tagName, int &exceptioncode );
+ ElementImpl *createHTMLElement(const DOMString &tagName, int &exceptioncode);
+ ElementImpl *createHTMLElement(unsigned short tagID);
khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; }
if (!prefix)
prefix = "";
if (isTextNode())
- fprintf(stderr, "%s%s\t%p %s\n", prefix, getTagName(id()).string().latin1(), this, nodeValue().ascii());
+ fprintf(stderr, "%s%s\t%p %s\n", prefix, nodeName().string().latin1(), this, nodeValue().string().latin1());
else
- fprintf(stderr, "%s%s\t%p\n", prefix, getTagName(id()).string().latin1(), this);
+ fprintf(stderr, "%s%s\t%p\n", prefix, nodeName().string().latin1(), this);
}
void NodeImpl::displayTree()
if (isNull())
fprintf(stderr, "Position [%s]: null\n", msg);
else
- fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, getTagName(node()->id()).string().latin1(), node(), offset());
+ fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, node()->nodeName().string().latin1(), node(), offset());
}
#ifndef NDEBUG
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
ts << " ";
}
+static QString getTagName(NodeImpl *n)
+{
+ if (n->isDocumentNode())
+ return "";
+ if (n->id() <= ID_LAST_TAG)
+ return getTagName(n->id()).string();
+ return n->nodeName().string();
+}
+
static QTextStream &operator<<(QTextStream &ts, const RenderObject &o)
{
ts << o.renderName();
}
if (o.element()) {
- QString tagName(getTagName(o.element()->id()).string());
+ QString tagName = getTagName(o.element());
if (!tagName.isEmpty()) {
ts << " {" << tagName << "}";
}
while (1) {
NodeImpl *p = n->parentNode();
if (!p || n == root) {
- result += " of root {" + getTagName(n->id()).string() + "}";
+ result += " of root {" + getTagName(n) + "}";
break;
}
if (n != node)
int count = 1;
for (NodeImpl *search = p->firstChild(); search != n; search = search->nextSibling())
count++;
- result += "child " + QString::number(count) + " {" + getTagName(n->id()).string() + "}";
+ result += "child " + QString::number(count) + " {" + getTagName(n) + "}";
n = p;
}
Position startPosition = selection.start();
Position endPosition = selection.end();
- QString startNodeTagName(getTagName(startPosition.node()->id()).string());
- QString endNodeTagName(getTagName(endPosition.node()->id()).string());
+ QString startNodeTagName(getTagName(startPosition.node()));
+ QString endNodeTagName(getTagName(endPosition.node()));
NodeImpl *rootNode = doc->getElementById("root");
[path insertString:@"<!--framePath " atIndex:0];
[self _addFramePathToString:path];
// The new child's path component is all but the 1st char and the last 3 chars
+ // FIXME: Shouldn't this number be the index of this frame in its parent rather than the child count?
[path appendFormat:@"/<!--frame%d-->-->", _private->children ? [_private->children count] : 0];
return path;
}