+2005-01-05 Darin Adler <darin@apple.com>
+
+ Reviewed by Ken.
+
+ - re-landing a subset of my custom tag change that does not fix the bug, but also does
+ not introduce a performance regression
+
+ * 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/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/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.
+
2005-01-05 Ken Kocienda <kocienda@apple.com>
Reviewed by Hyatt
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)
{
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
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");