summaryrefslogtreecommitdiffstats
path: root/WebCore/dom
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/dom')
-rw-r--r--WebCore/dom/Attr.cpp6
-rw-r--r--WebCore/dom/CanvasSurface.cpp2
-rw-r--r--WebCore/dom/CanvasSurface.h5
-rw-r--r--WebCore/dom/ContainerNode.cpp1
-rw-r--r--WebCore/dom/CustomEvent.idl2
-rw-r--r--WebCore/dom/Document.cpp74
-rw-r--r--WebCore/dom/Document.h15
-rw-r--r--WebCore/dom/Document.idl8
-rw-r--r--WebCore/dom/DocumentParser.h (renamed from WebCore/dom/Tokenizer.h)34
-rw-r--r--WebCore/dom/DynamicNodeList.cpp5
-rw-r--r--WebCore/dom/Element.cpp55
-rw-r--r--WebCore/dom/Element.h52
-rw-r--r--WebCore/dom/ElementRareData.h6
-rw-r--r--WebCore/dom/Event.idl7
-rw-r--r--WebCore/dom/EventListener.h19
-rw-r--r--WebCore/dom/EventTarget.h2
-rw-r--r--WebCore/dom/NamedNodeMap.cpp4
-rw-r--r--WebCore/dom/NamedNodeMap.h16
-rw-r--r--WebCore/dom/Node.cpp2
-rw-r--r--WebCore/dom/Node.idl14
-rw-r--r--WebCore/dom/PopStateEvent.idl2
-rw-r--r--WebCore/dom/ProcessingInstruction.cpp2
-rw-r--r--WebCore/dom/StaticNodeList.cpp5
-rw-r--r--WebCore/dom/StyledElement.cpp12
-rw-r--r--WebCore/dom/ViewportArguments.cpp6
-rw-r--r--WebCore/dom/XMLDocumentParser.cpp (renamed from WebCore/dom/XMLTokenizer.cpp)68
-rw-r--r--WebCore/dom/XMLDocumentParser.h (renamed from WebCore/dom/XMLTokenizer.h)14
-rw-r--r--WebCore/dom/XMLDocumentParserLibxml2.cpp (renamed from WebCore/dom/XMLTokenizerLibxml2.cpp)375
-rw-r--r--WebCore/dom/XMLDocumentParserQt.cpp (renamed from WebCore/dom/XMLTokenizerQt.cpp)94
-rw-r--r--WebCore/dom/XMLDocumentParserScope.cpp (renamed from WebCore/dom/XMLTokenizerScope.cpp)12
-rw-r--r--WebCore/dom/XMLDocumentParserScope.h (renamed from WebCore/dom/XMLTokenizerScope.h)10
-rwxr-xr-xWebCore/dom/make_names.pl2
32 files changed, 487 insertions, 444 deletions
diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp
index 597f9ba..59daa59 100644
--- a/WebCore/dom/Attr.cpp
+++ b/WebCore/dom/Attr.cpp
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple 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
@@ -23,9 +23,9 @@
#include "config.h"
#include "Attr.h"
-#include "Document.h"
#include "Element.h"
#include "ExceptionCode.h"
+#include "HTMLNames.h"
#include "Text.h"
#include "XMLNSNames.h"
@@ -175,7 +175,7 @@ void Attr::childrenChanged(bool changedByParser, Node* beforeChange, Node* after
bool Attr::isId() const
{
- return qualifiedName().matches(m_element ? m_element->idAttributeName() : idAttr);
+ return qualifiedName().matches(document()->idAttributeName());
}
}
diff --git a/WebCore/dom/CanvasSurface.cpp b/WebCore/dom/CanvasSurface.cpp
index ea29113..988864b 100644
--- a/WebCore/dom/CanvasSurface.cpp
+++ b/WebCore/dom/CanvasSurface.cpp
@@ -78,7 +78,7 @@ void CanvasSurface::setSurfaceSize(const IntSize& size)
m_imageBuffer.clear();
}
-String CanvasSurface::toDataURL(const String& mimeType, double quality, ExceptionCode& ec)
+String CanvasSurface::toDataURL(const String& mimeType, const double* quality, ExceptionCode& ec)
{
if (!m_originClean) {
ec = SECURITY_ERR;
diff --git a/WebCore/dom/CanvasSurface.h b/WebCore/dom/CanvasSurface.h
index 3660c05..3601381 100644
--- a/WebCore/dom/CanvasSurface.h
+++ b/WebCore/dom/CanvasSurface.h
@@ -59,9 +59,8 @@ public:
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
- String toDataURL(const String& mimeType, double quality, ExceptionCode&);
-
- String toDataURL(const String& mimeType, ExceptionCode& ec) { return toDataURL(mimeType, 1.0, ec); }
+ String toDataURL(const String& mimeType, const double* quality, ExceptionCode&);
+ String toDataURL(const String& mimeType, ExceptionCode& ec) { return toDataURL(mimeType, 0, ec); }
const IntSize& size() const { return m_size; }
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index 9e27dea..fddccdd 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -36,6 +36,7 @@
#include "InspectorController.h"
#include "MutationEvent.h"
#include "Page.h"
+#include "RenderBox.h"
#include "RenderTheme.h"
#include "RootInlineBox.h"
#include "loader.h"
diff --git a/WebCore/dom/CustomEvent.idl b/WebCore/dom/CustomEvent.idl
index 1ab468c..aa673b8 100644
--- a/WebCore/dom/CustomEvent.idl
+++ b/WebCore/dom/CustomEvent.idl
@@ -25,6 +25,7 @@
module events {
+#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
// Introduced in DOM Level 3:
interface CustomEvent : Event {
@@ -35,5 +36,6 @@ module events {
in boolean cancelableArg,
in DOMObject detailArg);
};
+#endif
}
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 4500626..c41b87e 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -76,10 +76,10 @@
#include "HTMLMapElement.h"
#include "HTMLNameCollection.h"
#include "HTMLNames.h"
-#include "HTMLParser.h"
+#include "LegacyHTMLTreeConstructor.h"
#include "HTMLStyleElement.h"
#include "HTMLTitleElement.h"
-#include "HTMLTokenizer.h"
+#include "HTMLDocumentParser.h"
#include "HTTPParsers.h"
#include "HistoryItem.h"
#include "HitTestRequest.h"
@@ -107,6 +107,7 @@
#include "ProgressEvent.h"
#include "RegisteredEventListener.h"
#include "RenderArena.h"
+#include "RenderLayer.h"
#include "RenderTextControl.h"
#include "RenderView.h"
#include "RenderWidget.h"
@@ -134,7 +135,7 @@
#include "XMLHttpRequest.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
-#include "XMLTokenizer.h"
+#include "XMLDocumentParser.h"
#include "htmlediting.h"
#include <wtf/CurrentTime.h>
#include <wtf/HashFunctions.h>
@@ -418,6 +419,7 @@ Document::Document(Frame* frame, bool isXHTML, bool isHTML)
, m_containsWMLContent(false)
#endif
, m_weakReference(DocumentWeakReference::create(this))
+ , m_idAttributeName(idAttr)
{
m_document = this;
@@ -508,7 +510,7 @@ void Document::removedLastRef()
deleteAllValues(m_markers);
m_markers.clear();
- m_tokenizer.clear();
+ m_parser.clear();
m_cssCanvasElements.clear();
@@ -542,7 +544,7 @@ Document::~Document()
destroyAllWrapperCaches();
#endif
- m_tokenizer.clear();
+ m_parser.clear();
m_document = 0;
m_docLoader.clear();
@@ -903,7 +905,7 @@ PassRefPtr<Element> Document::createElement(const QualifiedName& qName, bool cre
else if (qName.namespaceURI() == MathMLNames::mathmlNamespaceURI)
e = MathMLElementFactory::createMathMLElement(qName, this, createdByParser);
#endif
-
+
if (!e)
e = Element::create(qName, document());
@@ -947,7 +949,7 @@ Element* Document::getElementById(const AtomicString& elementId) const
for (Node *n = traverseNextNode(); n != 0; n = n->traverseNextNode()) {
if (n->isElementNode()) {
element = static_cast<Element*>(n);
- if (element->hasID() && element->getAttribute(element->idAttributeName()) == elementId) {
+ if (element->hasID() && element->getIdAttribute() == elementId) {
m_duplicateIds.remove(elementId.impl());
m_elementsById.set(elementId.impl(), element);
return element;
@@ -1706,10 +1708,10 @@ void Document::setVisuallyOrdered()
renderer()->style()->setVisuallyOrdered(true);
}
-Tokenizer* Document::createTokenizer()
+DocumentParser* Document::createParser()
{
// FIXME: this should probably pass the frame instead
- return new XMLTokenizer(this, view());
+ return new XMLDocumentParser(this, view());
}
void Document::open(Document* ownerDocument)
@@ -1721,7 +1723,7 @@ void Document::open(Document* ownerDocument)
}
if (m_frame) {
- if (m_frame->loader()->isLoadingMainResource() || (tokenizer() && tokenizer()->executingScript()))
+ if (m_frame->loader()->isLoadingMainResource() || (parser() && parser()->executingScript()))
return;
if (m_frame->loader()->state() == FrameStateProvisional)
@@ -1739,12 +1741,12 @@ void Document::open(Document* ownerDocument)
void Document::cancelParsing()
{
- if (m_tokenizer) {
- // We have to clear the tokenizer to avoid possibly triggering
+ if (m_parser) {
+ // We have to clear the parser to avoid possibly triggering
// the onload handler when closing as a side effect of a cancel-style
// change, such as opening a new document or closing the window while
// still parsing
- m_tokenizer.clear();
+ m_parser.clear();
close();
}
}
@@ -1753,15 +1755,15 @@ void Document::implicitOpen()
{
cancelParsing();
- m_tokenizer.clear();
+ m_parser.clear();
removeChildren();
- m_tokenizer = createTokenizer();
+ m_parser = createParser();
setParsing(true);
if (m_frame)
- m_tokenizer->setXSSAuditor(m_frame->script()->xssAuditor());
+ m_parser->setXSSAuditor(m_frame->script()->xssAuditor());
// If we reload, the animation controller sticks around and has
// a stale animation time. We need to update it here.
@@ -1839,18 +1841,18 @@ void Document::implicitClose()
}
bool wasLocationChangePending = frame() && frame()->redirectScheduler()->locationChangePending();
- bool doload = !parsing() && m_tokenizer && !m_processingLoadEvent && !wasLocationChangePending;
+ bool doload = !parsing() && m_parser && !m_processingLoadEvent && !wasLocationChangePending;
if (!doload)
return;
m_processingLoadEvent = true;
- m_wellFormed = m_tokenizer && m_tokenizer->wellFormed();
+ m_wellFormed = m_parser && m_parser->wellFormed();
- // We have to clear the tokenizer, in case someone document.write()s from the
+ // We have to clear the parser, in case someone document.write()s from the
// onLoad event handler, as in Radar 3206524.
- m_tokenizer.clear();
+ m_parser.clear();
// Parser should have picked up all preloads by now
m_docLoader->clearPreloads();
@@ -1998,21 +2000,21 @@ void Document::write(const SegmentedString& text, Document* ownerDocument)
printf("Beginning a document.write at %d\n", elapsedTime());
#endif
- if (!m_tokenizer)
+ if (!m_parser)
open(ownerDocument);
- ASSERT(m_tokenizer);
+ ASSERT(m_parser);
bool wasForcedSynchronous = false;
- HTMLTokenizer* tokenizer = m_tokenizer->asHTMLTokenizer();
- if (tokenizer) {
- wasForcedSynchronous = tokenizer->forceSynchronous();
- tokenizer->setForceSynchronous(true);
+ HTMLDocumentParser* parser = m_parser->asHTMLDocumentParser();
+ if (parser) {
+ wasForcedSynchronous = parser->forceSynchronous();
+ parser->setForceSynchronous(true);
}
- m_tokenizer->write(text, false);
+ m_parser->write(text, false);
- if (m_tokenizer && tokenizer && m_tokenizer->asHTMLTokenizer() == tokenizer)
- tokenizer->setForceSynchronous(wasForcedSynchronous);
+ if (m_parser && parser && m_parser->asHTMLDocumentParser() == parser)
+ parser->setForceSynchronous(wasForcedSynchronous);
#ifdef INSTRUMENT_LAYOUT_SCHEDULING
if (!ownerElement())
@@ -2038,13 +2040,13 @@ void Document::finishParsing()
printf("Received all data at %d\n", elapsedTime());
#endif
- // Let the tokenizer go through as much data as it can. There will be three possible outcomes after
+ // Let the parser go through as much data as it can. There will be three possible outcomes after
// finish() is called:
// (1) All remaining data is parsed, document isn't loaded yet
- // (2) All remaining data is parsed, document is loaded, tokenizer gets deleted
+ // (2) All remaining data is parsed, document is loaded, parser gets deleted
// (3) Data is still remaining to be parsed.
- if (m_tokenizer)
- m_tokenizer->finish();
+ if (m_parser)
+ m_parser->finish();
}
const KURL& Document::virtualURL() const
@@ -2622,8 +2624,8 @@ void Document::removePendingSheet()
updateStyleSelector();
- if (!m_pendingStylesheets && m_tokenizer)
- m_tokenizer->executeScriptsWaitingForStylesheets();
+ if (!m_pendingStylesheets && m_parser)
+ m_parser->executeScriptsWaitingForStylesheets();
if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view())
view()->scrollToFragment(m_frame->loader()->url());
@@ -4715,7 +4717,9 @@ void Document::updateURLForPushOrReplaceState(const KURL& url)
if (!f)
return;
+ // FIXME: Eliminate this redundancy.
setURL(url);
+ f->loader()->setURL(url);
f->loader()->documentLoader()->replaceRequestURLForSameDocumentNavigation(url);
}
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index e772233..0e86df4 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -34,6 +34,7 @@
#include "Color.h"
#include "Document.h"
#include "DocumentMarker.h"
+#include "QualifiedName.h"
#include "ScriptExecutionContext.h"
#include "Timer.h"
#include <wtf/HashCountedSet.h>
@@ -108,7 +109,7 @@ namespace WebCore {
class StyleSheetList;
class Text;
class TextResourceDecoder;
- class Tokenizer;
+ class DocumentParser;
class TreeWalker;
class XMLHttpRequest;
@@ -319,7 +320,7 @@ public:
String xmlVersion() const { return m_xmlVersion; }
bool xmlStandalone() const { return m_xmlStandalone; }
- void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLTokenizer
+ void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
void setXMLVersion(const String&, ExceptionCode&);
void setXMLStandalone(bool, ExceptionCode&);
@@ -535,8 +536,8 @@ public:
CSSStyleSheet* elementSheet();
CSSStyleSheet* mappedElementSheet();
- virtual Tokenizer* createTokenizer();
- Tokenizer* tokenizer() { return m_tokenizer.get(); }
+ virtual DocumentParser* createParser();
+ DocumentParser* parser() { return m_parser.get(); }
bool printing() const { return m_printing; }
void setPrinting(bool p) { m_printing = p; }
@@ -988,6 +989,8 @@ public:
void removeMediaCanStartListener(MediaCanStartListener*);
MediaCanStartListener* takeAnyMediaCanStartListener();
+ const QualifiedName& idAttributeName() const { return m_idAttributeName; }
+
protected:
Document(Frame*, bool isXHTML, bool isHTML);
@@ -1039,7 +1042,7 @@ private:
Frame* m_frame;
OwnPtr<DocLoader> m_docLoader;
- OwnPtr<Tokenizer> m_tokenizer;
+ OwnPtr<DocumentParser> m_parser;
bool m_wellFormed;
// Document URLs.
@@ -1267,6 +1270,8 @@ private:
RefPtr<DocumentWeakReference> m_weakReference;
HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
+
+ QualifiedName m_idAttributeName;
};
inline bool Document::hasElementWithId(AtomicStringImpl* id) const
diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl
index cd877b3..9599d76 100644
--- a/WebCore/dom/Document.idl
+++ b/WebCore/dom/Document.idl
@@ -219,9 +219,11 @@ module core {
#endif
+#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
[V8Custom] DOMObject getCSSCanvasContext(in DOMString contextId, in DOMString name, in long width, in long height);
#endif
+#endif
// HTML 5
NodeList getElementsByClassName(in DOMString tagname);
@@ -311,6 +313,12 @@ module core {
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
#endif
+
+#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
+ // Extra WebCore methods exposed to allow compile-time casting in C++
+ boolean isHTMLDocument();
+#endif
+
};
}
diff --git a/WebCore/dom/Tokenizer.h b/WebCore/dom/DocumentParser.h
index d6ac1a8..c7eea06 100644
--- a/WebCore/dom/Tokenizer.h
+++ b/WebCore/dom/DocumentParser.h
@@ -20,21 +20,19 @@
*
*/
-#ifndef Tokenizer_h
-#define Tokenizer_h
+#ifndef DocumentParser_h
+#define DocumentParser_h
namespace WebCore {
- class HTMLTokenizer;
+ class LegacyHTMLTreeConstructor;
+ class HTMLDocumentParser;
class SegmentedString;
class XSSAuditor;
- // FIXME: This class should renamed DocumentParser or similar to express
- // that it does more than tokenizing. It manages the lifetime of of the
- // parser as well as handles various tag-handling hacks for HTML/XML.
- class Tokenizer : public Noncopyable {
+ class DocumentParser : public Noncopyable {
public:
- virtual ~Tokenizer() { }
+ virtual ~DocumentParser() { }
// Script output must be prepended, while new data
// received during executing a script must be appended, hence the
@@ -57,33 +55,33 @@ namespace WebCore {
virtual int lineNumber() const { return -1; }
virtual int columnNumber() const { return -1; }
-
+
virtual void executeScriptsWaitingForStylesheets() {}
- virtual bool isHTMLTokenizer() const { return false; }
- virtual HTMLTokenizer* asHTMLTokenizer() { return 0; }
-
+ virtual LegacyHTMLTreeConstructor* htmlTreeConstructor() const { return 0; }
+ virtual HTMLDocumentParser* asHTMLDocumentParser() { return 0; }
+
XSSAuditor* xssAuditor() const { return m_XSSAuditor; }
void setXSSAuditor(XSSAuditor* auditor) { m_XSSAuditor = auditor; }
protected:
- Tokenizer(bool viewSourceMode = false)
+ DocumentParser(bool viewSourceMode = false)
: m_parserStopped(false)
, m_inViewSourceMode(viewSourceMode)
, m_XSSAuditor(0)
{
}
- // The tokenizer has buffers, so parsing may continue even after
- // it stops receiving data. We use m_parserStopped to stop the tokenizer
+ // The parser has buffers, so parsing may continue even after
+ // it stops receiving data. We use m_parserStopped to stop the parser
// even when it has buffered data.
bool m_parserStopped;
bool m_inViewSourceMode;
-
- // The XSSAuditor associated with this tokenizer.
+
+ // The XSSAuditor associated with this document parser.
XSSAuditor* m_XSSAuditor;
};
} // namespace WebCore
-#endif // Tokenizer_h
+#endif // DocumentParser_h
diff --git a/WebCore/dom/DynamicNodeList.cpp b/WebCore/dom/DynamicNodeList.cpp
index 3f0744b..c7609a1 100644
--- a/WebCore/dom/DynamicNodeList.cpp
+++ b/WebCore/dom/DynamicNodeList.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2010 Apple 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
@@ -137,7 +137,8 @@ Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const
unsigned length = this->length();
for (unsigned i = 0; i < length; i++) {
Node* node = item(i);
- if (node->isElementNode() && static_cast<Element*>(node)->getIDAttribute() == elementId)
+ // FIXME: This should probably be using getIdAttribute instead of idForStyleResolution.
+ if (node->hasID() && static_cast<Element*>(node)->idForStyleResolution() == elementId)
return node;
}
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index d95403a..c1c798b 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -42,16 +42,17 @@
#include "FrameView.h"
#include "HTMLElement.h"
#include "HTMLNames.h"
-#include "HTMLTokenizer.h"
+#include "HTMLDocumentParser.h"
#include "InspectorController.h"
#include "NodeList.h"
#include "NodeRenderStyle.h"
#include "Page.h"
+#include "RenderLayer.h"
#include "RenderView.h"
#include "RenderWidget.h"
#include "TextIterator.h"
#include "XMLNames.h"
-#include "XMLTokenizer.h"
+#include "XMLDocumentParser.h"
#include <wtf/text/CString.h>
#if ENABLE(SVG)
@@ -206,21 +207,6 @@ Node::NodeType Element::nodeType() const
return ELEMENT_NODE;
}
-const AtomicString& Element::getIDAttribute() const
-{
- // FIXME: There are two problems with this function for general purpose use.
- //
- // 1) If this is not a StyledElement, then the result will always be null.
- // 2) If the document this element is part of is in compatibility mode
- // (inCompatMode), then the ID will be lowercased.
- //
- // See StyledElement::parseMappedAttribute for details. Because of these issues,
- // this function and NamedNodeMap::id should both probably be renamed to make it
- // clear this does not give the same result as getAttribute.
-
- return namedAttrMap ? namedAttrMap->id() : nullAtom;
-}
-
bool Element::hasAttribute(const QualifiedName& name) const
{
return hasAttributeNS(name.namespaceURI(), name.localName());
@@ -541,10 +527,11 @@ const AtomicString& Element::getAttribute(const String& name) const
}
#endif
- if (namedAttrMap)
+ if (namedAttrMap) {
if (Attribute* attribute = namedAttrMap->getAttributeItem(name, ignoreCase))
return attribute->value();
-
+ }
+
return nullAtom;
}
@@ -562,12 +549,15 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value,
const AtomicString& localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
- // allocate attributemap if necessary
+ // Allocate attribute map if necessary.
Attribute* old = attributes(false)->getAttributeItem(localName, false);
document()->incDOMTreeVersion();
- if (localName == idAttributeName().localName())
+ // FIXME: This check is probably not correct for the case where the document has an id attribute
+ // with a non-null namespace, because it will return true if the local name happens to match
+ // but the namespace does not.
+ if (localName == document()->idAttributeName().localName())
updateId(old ? old->value() : nullAtom, value);
if (old && value.isNull())
@@ -593,10 +583,10 @@ void Element::setAttribute(const QualifiedName& name, const AtomicString& value,
{
document()->incDOMTreeVersion();
- // allocate attributemap if necessary
+ // Allocate attribute map if necessary.
Attribute* old = attributes(false)->getAttributeItem(name);
- if (name == idAttributeName())
+ if (isIdAttributeName(name))
updateId(old ? old->value() : nullAtom, value);
if (old && value.isNull())
@@ -678,7 +668,7 @@ void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list, FragmentScriptingPe
// If setting the whole map changes the id attribute, we need to call updateId.
- const QualifiedName& idName = idAttributeName();
+ const QualifiedName& idName = document()->idAttributeName();
Attribute* oldId = namedAttrMap ? namedAttrMap->getAttributeItem(idName) : 0;
Attribute* newId = list ? list->getAttributeItem(idName) : 0;
@@ -802,7 +792,7 @@ void Element::insertedIntoDocument()
if (hasID()) {
if (NamedNodeMap* attrs = namedAttrMap.get()) {
- Attribute* idItem = attrs->getAttributeItem(idAttributeName());
+ Attribute* idItem = attrs->getAttributeItem(document()->idAttributeName());
if (idItem && !idItem->isNull())
updateId(nullAtom, idItem->value());
}
@@ -813,7 +803,7 @@ void Element::removedFromDocument()
{
if (hasID()) {
if (NamedNodeMap* attrs = namedAttrMap.get()) {
- Attribute* idItem = attrs->getAttributeItem(idAttributeName());
+ Attribute* idItem = attrs->getAttributeItem(document()->idAttributeName());
if (idItem && !idItem->isNull())
updateId(idItem->value(), nullAtom);
}
@@ -1162,7 +1152,7 @@ void Element::formatForDebugger(char* buffer, unsigned length) const
result += s;
}
- s = getAttribute(idAttributeName());
+ s = getIdAttribute();
if (s.length() > 0) {
if (result.length() > 0)
result += "; ";
@@ -1320,8 +1310,12 @@ void Element::focus(bool restorePreviousSelection)
return;
}
- if (Page* page = doc->page())
+ RefPtr<Node> protect;
+ if (Page* page = doc->page()) {
+ // Focus and change event handlers can cause us to lose our last ref.
+ protect = this;
page->focusController()->setFocusedNode(this, doc->frame());
+ }
// Setting the focused node above might have invalidated the layout due to scripts.
doc->updateLayoutIgnorePendingStylesheets();
@@ -1537,9 +1531,4 @@ KURL Element::getURLAttribute(const QualifiedName& name) const
return document()->completeURL(deprecatedParseURL(getAttribute(name)));
}
-const QualifiedName& Element::rareIDAttributeName() const
-{
- return rareData()->m_idAttributeName;
-}
-
} // namespace WebCore
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index 8da2892..c6eebcb 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple 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
@@ -25,19 +25,14 @@
#ifndef Element_h
#define Element_h
-#include "ContainerNode.h"
#include "Document.h"
-#include "HTMLNames.h"
#include "MappedAttributeEntry.h"
#include "NamedNodeMap.h"
-#include "QualifiedName.h"
#include "ScrollTypes.h"
namespace WebCore {
-class Attr;
class Attribute;
-class CSSStyleDeclaration;
class ClientRect;
class ClientRectList;
class ElementRareData;
@@ -111,9 +106,6 @@ public:
bool fastHasAttribute(const QualifiedName&) const;
const AtomicString& fastGetAttribute(const QualifiedName&) const;
- // Call this to get the value of the id attribute. Faster than calling fastGetAttribute.
- const AtomicString& getIDAttribute() const;
-
bool hasAttributes() const;
bool hasAttribute(const String& name) const;
@@ -125,7 +117,14 @@ public:
void setAttribute(const AtomicString& name, const AtomicString& value, ExceptionCode&);
void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode&, FragmentScriptingPermission = FragmentScriptingAllowed);
- const QualifiedName& idAttributeName() const;
+ bool isIdAttributeName(const QualifiedName&) const;
+ const AtomicString& getIdAttribute() const;
+ void setIdAttribute(const AtomicString&);
+
+ // Call this to get the value of the id attribute for style resolution purposes.
+ // The value will already be lowercased if the document is in compatibility mode,
+ // so this function is not suitable for non-style uses.
+ const AtomicString& idForStyleResolution() const;
void scrollIntoView(bool alignToTop = true);
void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
@@ -304,7 +303,6 @@ private:
virtual bool childTypeAllowed(NodeType);
virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value);
- const QualifiedName& rareIDAttributeName() const;
#ifndef NDEBUG
virtual void formatForDebugger(char* buffer, unsigned length) const;
@@ -362,11 +360,6 @@ inline Element* Node::parentElement() const
return parent && parent->isElementNode() ? static_cast<Element*>(parent) : 0;
}
-inline const QualifiedName& Element::idAttributeName() const
-{
- return hasRareData() ? rareIDAttributeName() : HTMLNames::idAttr;
-}
-
inline NamedNodeMap* Element::attributes(bool readonly) const
{
if (!isStyleAttributeValid())
@@ -411,6 +404,31 @@ inline const AtomicString& Element::fastGetAttribute(const QualifiedName& name)
return nullAtom;
}
-} //namespace
+inline const AtomicString& Element::idForStyleResolution() const
+{
+ ASSERT(hasID());
+ return namedAttrMap->idForStyleResolution();
+}
+
+inline bool Element::isIdAttributeName(const QualifiedName& attributeName) const
+{
+ // FIXME: This check is probably not correct for the case where the document has an id attribute
+ // with a non-null namespace, because it will return false, a false negative, if the prefixes
+ // don't match but the local name and namespace both do. However, since this has been like this
+ // for a while and the code paths may be hot, we'll have to measure performance if we fix it.
+ return attributeName == document()->idAttributeName();
+}
+
+inline const AtomicString& Element::getIdAttribute() const
+{
+ return fastGetAttribute(document()->idAttributeName());
+}
+
+inline void Element::setIdAttribute(const AtomicString& value)
+{
+ setAttribute(document()->idAttributeName(), value);
+}
+
+} // namespace
#endif
diff --git a/WebCore/dom/ElementRareData.h b/WebCore/dom/ElementRareData.h
index f23ad8e..b444d99 100644
--- a/WebCore/dom/ElementRareData.h
+++ b/WebCore/dom/ElementRareData.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 David Smith <catfish.man@gmail.com>
*
* This library is free software; you can redistribute it and/or
@@ -27,8 +27,6 @@
namespace WebCore {
-using namespace HTMLNames;
-
class ElementRareData : public NodeRareData {
public:
ElementRareData();
@@ -40,7 +38,6 @@ public:
IntSize m_minimumSizeForResizing;
RefPtr<RenderStyle> m_computedStyle;
- QualifiedName m_idAttributeName;
};
inline IntSize defaultMinimumSizeForResizing()
@@ -50,7 +47,6 @@ inline IntSize defaultMinimumSizeForResizing()
inline ElementRareData::ElementRareData()
: m_minimumSizeForResizing(defaultMinimumSizeForResizing())
- , m_idAttributeName(idAttr)
{
}
diff --git a/WebCore/dom/Event.idl b/WebCore/dom/Event.idl
index 919fc90..b8b590f 100644
--- a/WebCore/dom/Event.idl
+++ b/WebCore/dom/Event.idl
@@ -79,6 +79,13 @@ module events {
readonly attribute [Custom] Clipboard clipboardData;
#endif
+#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
+ // Extra WebCore methods exposed to allow compile-time casting in C++
+ boolean isMutationEvent();
+ boolean isMouseEvent();
+ boolean isUIEvent();
+#endif
+
};
}
diff --git a/WebCore/dom/EventListener.h b/WebCore/dom/EventListener.h
index 3ecfae7..ff02204 100644
--- a/WebCore/dom/EventListener.h
+++ b/WebCore/dom/EventListener.h
@@ -36,14 +36,17 @@ namespace WebCore {
class EventListener : public RefCounted<EventListener> {
public:
- enum Type { JSEventListenerType,
- ImageEventListenerType,
- InspectorDOMAgentType,
- InspectorDOMStorageResourceType,
- ObjCEventListenerType,
- ConditionEventListenerType,
- GObjectEventListenerType };
-
+ enum Type {
+ JSEventListenerType,
+ ImageEventListenerType,
+ InspectorDOMAgentType,
+ InspectorDOMStorageResourceType,
+ ObjCEventListenerType,
+ CPPEventListenerType,
+ ConditionEventListenerType,
+ GObjectEventListenerType
+ };
+
virtual ~EventListener() { }
virtual bool operator==(const EventListener&) = 0;
virtual void handleEvent(ScriptExecutionContext*, Event*) = 0;
diff --git a/WebCore/dom/EventTarget.h b/WebCore/dom/EventTarget.h
index 2aaeef5..0e8c343 100644
--- a/WebCore/dom/EventTarget.h
+++ b/WebCore/dom/EventTarget.h
@@ -166,6 +166,8 @@ namespace WebCore {
void fireEventListeners(Event*, EventTargetData*, EventListenerVector&);
};
+ // FIXME: These macros should be split into separate DEFINE and DECLARE
+ // macros to avoid causing so many header includes.
#define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
EventListener* on##attribute() { return getAttributeEventListener(eventNames().attribute##Event); } \
void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEventListener(eventNames().attribute##Event, listener); } \
diff --git a/WebCore/dom/NamedNodeMap.cpp b/WebCore/dom/NamedNodeMap.cpp
index e310ff8..7c9298a 100644
--- a/WebCore/dom/NamedNodeMap.cpp
+++ b/WebCore/dom/NamedNodeMap.cpp
@@ -225,8 +225,8 @@ void NamedNodeMap::setAttributes(const NamedNodeMap& other)
// If assigning the map changes the id attribute, we need to call
// updateId.
- Attribute* oldId = getAttributeItem(m_element->idAttributeName());
- Attribute* newId = other.getAttributeItem(m_element->idAttributeName());
+ Attribute* oldId = getAttributeItem(m_element->document()->idAttributeName());
+ Attribute* newId = other.getAttributeItem(m_element->document()->idAttributeName());
if (oldId || newId)
m_element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom);
diff --git a/WebCore/dom/NamedNodeMap.h b/WebCore/dom/NamedNodeMap.h
index 50cb4cb..c3c2cd9 100644
--- a/WebCore/dom/NamedNodeMap.h
+++ b/WebCore/dom/NamedNodeMap.h
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple 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
@@ -28,10 +28,6 @@
#include "Attribute.h"
#include "SpaceSplitString.h"
-#ifdef __OBJC__
-#define id id_AVOID_KEYWORD
-#endif
-
namespace WebCore {
class Node;
@@ -85,8 +81,8 @@ public:
addAttribute(newAttribute);
}
- const AtomicString& id() const { return m_id; }
- void setID(const AtomicString& newId) { m_id = newId; }
+ const AtomicString& idForStyleResolution() const { return m_idForStyleResolution; }
+ void setIdForStyleResolution(const AtomicString& newId) { m_idForStyleResolution = newId; }
// FIXME: These two functions should be merged if possible.
bool mapsEquivalent(const NamedNodeMap* otherMap) const;
@@ -124,7 +120,7 @@ private:
SpaceSplitString m_classNames;
Element* m_element;
Vector<RefPtr<Attribute> > m_attributes;
- AtomicString m_id;
+ AtomicString m_idForStyleResolution;
};
inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) const
@@ -138,7 +134,7 @@ inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) cons
}
// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
-// can tune the behaviour (hasAttribute is case sensitive whereas getAttribute is not).
+// can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not).
inline Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const
{
unsigned len = length();
@@ -161,6 +157,4 @@ inline Attribute* NamedNodeMap::getAttributeItem(const String& name, bool should
} // namespace WebCore
-#undef id
-
#endif // NamedNodeMap_h
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 2fe4bfb..840b967 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -71,7 +71,7 @@
#include "ProcessingInstruction.h"
#include "ProgressEvent.h"
#include "RegisteredEventListener.h"
-#include "RenderObject.h"
+#include "RenderBox.h"
#include "ScriptController.h"
#include "SelectorNodeList.h"
#include "StringBuilder.h"
diff --git a/WebCore/dom/Node.idl b/WebCore/dom/Node.idl
index 2db9c27..dec6b19 100644
--- a/WebCore/dom/Node.idl
+++ b/WebCore/dom/Node.idl
@@ -132,6 +132,7 @@ module core {
readonly attribute boolean isContentEditable;
#endif /* defined(LANGUAGE_OBJECTIVE_C) */
+#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
void addEventListener(in DOMString type,
@@ -144,6 +145,19 @@ module core {
raises(EventException);
#endif
#endif
+#endif
+
+#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
+ [Custom] void addEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ [Custom] void removeEventListener(in DOMString type,
+ in EventListener listener,
+ in boolean useCapture);
+ boolean dispatchEvent(in Event event)
+ raises(EventException);
+#endif
+
};
}
diff --git a/WebCore/dom/PopStateEvent.idl b/WebCore/dom/PopStateEvent.idl
index 28da9e6..adc9074 100644
--- a/WebCore/dom/PopStateEvent.idl
+++ b/WebCore/dom/PopStateEvent.idl
@@ -26,6 +26,7 @@
module events {
+#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
interface PopStateEvent : Event {
void initPopStateEvent(in DOMString typeArg,
in boolean canBubbleArg,
@@ -34,5 +35,6 @@ module events {
readonly attribute [V8CustomGetter] any state;
};
+#endif
}
diff --git a/WebCore/dom/ProcessingInstruction.cpp b/WebCore/dom/ProcessingInstruction.cpp
index 544882c..739d62f 100644
--- a/WebCore/dom/ProcessingInstruction.cpp
+++ b/WebCore/dom/ProcessingInstruction.cpp
@@ -30,7 +30,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "XSLStyleSheet.h"
-#include "XMLTokenizer.h" // for parseAttributes()
+#include "XMLDocumentParser.h" // for parseAttributes()
#include "MediaList.h"
namespace WebCore {
diff --git a/WebCore/dom/StaticNodeList.cpp b/WebCore/dom/StaticNodeList.cpp
index 99fd818..0a19a05 100644
--- a/WebCore/dom/StaticNodeList.cpp
+++ b/WebCore/dom/StaticNodeList.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,7 +50,8 @@ Node* StaticNodeList::itemWithName(const AtomicString& elementId) const
size_t length = m_nodes.size();
for (size_t i = 0; i < length; ++i) {
Node* node = m_nodes[i].get();
- if (node->isElementNode() && static_cast<Element*>(node)->getIDAttribute() == elementId)
+ // FIXME: This should probably be using getIdAttribute instead of idForStyleResolution.
+ if (node->hasID() && static_cast<Element*>(node)->getIdAttribute() == elementId)
return node;
}
diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp
index 34a593c..994b084 100644
--- a/WebCore/dom/StyledElement.cpp
+++ b/WebCore/dom/StyledElement.cpp
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2010 Apple 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
@@ -194,6 +194,7 @@ void StyledElement::attributeChanged(Attribute* attr, bool preserveDecls)
if (namedAttrMap)
mappedAttributes()->declAdded();
}
+
updateAfterAttributeChanged(attr);
}
@@ -227,16 +228,15 @@ void StyledElement::classAttributeChanged(const AtomicString& newClassString)
void StyledElement::parseMappedAttribute(Attribute* attr)
{
- if (attr->name() == idAttributeName()) {
- // unique id
+ if (isIdAttributeName(attr->name())) {
setHasID(!attr->isNull());
if (namedAttrMap) {
if (attr->isNull())
- namedAttrMap->setID(nullAtom);
+ namedAttrMap->setIdForStyleResolution(nullAtom);
else if (document()->inCompatMode())
- namedAttrMap->setID(attr->value().lower());
+ namedAttrMap->setIdForStyleResolution(attr->value().lower());
else
- namedAttrMap->setID(attr->value());
+ namedAttrMap->setIdForStyleResolution(attr->value());
}
setNeedsStyleRecalc();
} else if (attr->name() == classAttr)
diff --git a/WebCore/dom/ViewportArguments.cpp b/WebCore/dom/ViewportArguments.cpp
index d585896..23d0297 100644
--- a/WebCore/dom/ViewportArguments.cpp
+++ b/WebCore/dom/ViewportArguments.cpp
@@ -33,7 +33,7 @@
#include "Frame.h"
#include "Page.h"
#include "PlatformString.h"
-#include "Tokenizer.h"
+#include "DocumentParser.h"
namespace WebCore {
@@ -105,7 +105,7 @@ static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode)
void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement)
{
- Tokenizer* tokenizer = document->tokenizer();
+ DocumentParser* parser = document->parser();
Frame* frame = document->frame();
if (!frame)
@@ -114,7 +114,7 @@ void reportViewportWarning(Document* document, ViewportErrorCode errorCode, cons
String message = viewportErrorMessageTemplate(errorCode);
message.replace("%replacement", replacement);
- frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, tokenizer ? tokenizer->lineNumber() + 1 : 0, document->url().string());
+ frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parser ? parser->lineNumber() + 1 : 0, document->url().string());
}
} // namespace WebCore
diff --git a/WebCore/dom/XMLTokenizer.cpp b/WebCore/dom/XMLDocumentParser.cpp
index 1d98dfe..987e9b1 100644
--- a/WebCore/dom/XMLTokenizer.cpp
+++ b/WebCore/dom/XMLDocumentParser.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "XMLTokenizer.h"
+#include "XMLDocumentParser.h"
#include "CDATASection.h"
#include "CachedScript.h"
@@ -70,7 +70,7 @@ using namespace HTMLNames;
const int maxErrors = 25;
#if ENABLE(WML)
-bool XMLTokenizer::isWMLDocument() const
+bool XMLDocumentParser::isWMLDocument() const
{
if (m_doc)
return m_doc->isWMLDocument();
@@ -79,7 +79,7 @@ bool XMLTokenizer::isWMLDocument() const
}
#endif
-void XMLTokenizer::pushCurrentNode(Node* n)
+void XMLDocumentParser::pushCurrentNode(Node* n)
{
ASSERT(n);
ASSERT(m_currentNode);
@@ -91,7 +91,7 @@ void XMLTokenizer::pushCurrentNode(Node* n)
handleError(fatal, "Excessive node nesting.", lineNumber(), columnNumber());
}
-void XMLTokenizer::popCurrentNode()
+void XMLDocumentParser::popCurrentNode()
{
if (!m_currentNode)
return;
@@ -104,7 +104,7 @@ void XMLTokenizer::popCurrentNode()
m_currentNodeStack.removeLast();
}
-void XMLTokenizer::clearCurrentNodeStack()
+void XMLDocumentParser::clearCurrentNodeStack()
{
if (m_currentNode && m_currentNode != m_doc)
m_currentNode->deref();
@@ -119,28 +119,28 @@ void XMLTokenizer::clearCurrentNodeStack()
}
}
-void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/)
+void XMLDocumentParser::write(const SegmentedString& s, bool /*appendData*/)
{
String parseString = s.toString();
-
+
if (m_sawXSLTransform || !m_sawFirstElement)
m_originalSourceForTransform += parseString;
if (m_parserStopped || m_sawXSLTransform)
return;
-
+
if (m_parserPaused) {
m_pendingSrc.append(s);
return;
}
-
+
doWrite(s.toString());
-
+
// After parsing, go ahead and dispatch image beforeload events.
ImageLoader::dispatchPendingBeforeLoadEvents();
}
-void XMLTokenizer::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
+void XMLDocumentParser::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
{
if (type == fatal || (m_errorCount < maxErrors && m_lastErrorLine != lineNumber && m_lastErrorColumn != columnNumber)) {
switch (type) {
@@ -151,20 +151,20 @@ void XMLTokenizer::handleError(ErrorType type, const char* m, int lineNumber, in
case nonFatal:
m_errorMessages += String::format("error on line %d at column %d: %s", lineNumber, columnNumber, m);
}
-
+
m_lastErrorLine = lineNumber;
m_lastErrorColumn = columnNumber;
++m_errorCount;
}
-
+
if (type != warning)
m_sawError = true;
-
+
if (type == fatal)
- stopParsing();
+ stopParsing();
}
-bool XMLTokenizer::enterText()
+bool XMLDocumentParser::enterText()
{
#if !USE(QXMLSTREAM)
ASSERT(m_bufferedText.size() == 0);
@@ -184,7 +184,7 @@ static inline String toString(const xmlChar* str, unsigned len)
#endif
-void XMLTokenizer::exitText()
+void XMLDocumentParser::exitText()
{
if (m_parserStopped)
return;
@@ -205,7 +205,7 @@ void XMLTokenizer::exitText()
popCurrentNode();
}
-void XMLTokenizer::end()
+void XMLDocumentParser::end()
{
doEnd();
@@ -219,13 +219,13 @@ void XMLTokenizer::end()
exitText();
m_doc->updateStyleSelector();
}
-
+
clearCurrentNodeStack();
if (!m_parsingFragment)
- m_doc->finishedParsing();
+ m_doc->finishedParsing();
}
-void XMLTokenizer::finish()
+void XMLDocumentParser::finish()
{
if (m_parserPaused)
m_finishCalled = true;
@@ -233,11 +233,11 @@ void XMLTokenizer::finish()
end();
}
-static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
+static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
{
RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), false);
reportElement->setAttribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black");
-
+
ExceptionCode ec = 0;
RefPtr<Element> h3 = doc->createElement(h3Tag, false);
reportElement->appendChild(h3.get(), ec);
@@ -251,18 +251,18 @@ static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const
h3 = doc->createElement(h3Tag, false);
reportElement->appendChild(h3.get(), ec);
h3->appendChild(doc->createTextNode("Below is a rendering of the page up to the first error."), ec);
-
+
return reportElement;
}
-void XMLTokenizer::insertErrorMessageBlock()
+void XMLDocumentParser::insertErrorMessageBlock()
{
#if USE(QXMLSTREAM)
if (m_parsingFragment)
return;
#endif
// One or more errors occurred during parsing of the code. Display an error block to the user above
- // the normal content (the DOM tree is created manually and includes line/col info regarding
+ // the normal content (the DOM tree is created manually and includes line/col info regarding
// where the errors are located)
// Create elements for display
@@ -310,24 +310,24 @@ void XMLTokenizer::insertErrorMessageBlock()
doc->updateStyleIfNeeded();
}
-void XMLTokenizer::notifyFinished(CachedResource* unusedResource)
+void XMLDocumentParser::notifyFinished(CachedResource* unusedResource)
{
ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript);
ASSERT(m_pendingScript->accessCount() > 0);
-
+
ScriptSourceCode sourceCode(m_pendingScript.get());
bool errorOccurred = m_pendingScript->errorOccurred();
m_pendingScript->removeClient(this);
m_pendingScript = 0;
-
+
RefPtr<Element> e = m_scriptElement;
m_scriptElement = 0;
ScriptElement* scriptElement = toScriptElement(e.get());
ASSERT(scriptElement);
- if (errorOccurred)
+ if (errorOccurred)
scriptElement->dispatchErrorEvent();
else {
m_view->frame()->script()->executeScript(sourceCode);
@@ -335,21 +335,21 @@ void XMLTokenizer::notifyFinished(CachedResource* unusedResource)
}
m_scriptElement = 0;
-
+
if (!m_requestingScript)
resumeParsing();
}
-bool XMLTokenizer::isWaitingForScripts() const
+bool XMLDocumentParser::isWaitingForScripts() const
{
return m_pendingScript;
}
-void XMLTokenizer::pauseParsing()
+void XMLDocumentParser::pauseParsing()
{
if (m_parsingFragment)
return;
-
+
m_parserPaused = true;
}
diff --git a/WebCore/dom/XMLTokenizer.h b/WebCore/dom/XMLDocumentParser.h
index 92e2830..bc10415 100644
--- a/WebCore/dom/XMLTokenizer.h
+++ b/WebCore/dom/XMLDocumentParser.h
@@ -139,7 +139,7 @@ bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element* parent
#include "MappedAttributeEntry.h"
#include "SegmentedString.h"
#include "StringHash.h"
-#include "Tokenizer.h"
+#include "DocumentParser.h"
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
@@ -179,15 +179,15 @@ namespace WebCore {
};
#endif
- class XMLTokenizer : public Tokenizer, public CachedResourceClient {
+ class XMLDocumentParser : public DocumentParser, public CachedResourceClient {
public:
- XMLTokenizer(Document*, FrameView* = 0);
- XMLTokenizer(DocumentFragment*, Element*, FragmentScriptingPermission);
- ~XMLTokenizer();
+ XMLDocumentParser(Document*, FrameView* = 0);
+ XMLDocumentParser(DocumentFragment*, Element*, FragmentScriptingPermission);
+ ~XMLDocumentParser();
enum ErrorType { warning, nonFatal, fatal };
- // from Tokenizer
+ // from DocumentParser
virtual void write(const SegmentedString&, bool appendData);
virtual void finish();
virtual bool isWaitingForScripts() const;
@@ -235,7 +235,7 @@ private:
#else
public:
// callbacks from parser SAX
- void error(ErrorType, const char* message, va_list args) WTF_ATTRIBUTE_PRINTF(3, 0);
+ void error(ErrorType, const char* message, va_list args) WTF_ATTRIBUTE_PRINTF(3, 0);
void startElementNs(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** libxmlAttributes);
void endElementNs();
diff --git a/WebCore/dom/XMLTokenizerLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp
index 06cf4a5..2a1bac6 100644
--- a/WebCore/dom/XMLTokenizerLibxml2.cpp
+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "XMLTokenizer.h"
+#include "XMLDocumentParser.h"
#include "CDATASection.h"
#include "CachedScript.h"
@@ -38,7 +38,7 @@
#include "FrameView.h"
#include "HTMLLinkElement.h"
#include "HTMLStyleElement.h"
-#include "HTMLTokenizer.h" // for decodeNamedEntity
+#include "HTMLDocumentParser.h" // for decodeNamedEntity
#include "ProcessingInstruction.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
@@ -51,7 +51,7 @@
#include "TextResourceDecoder.h"
#include "TransformSource.h"
#include "XMLNSNames.h"
-#include "XMLTokenizerScope.h"
+#include "XMLDocumentParserScope.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <wtf/text/CString.h>
@@ -79,12 +79,12 @@ public:
{
deleteAllValues(m_callbacks);
}
-
+
void appendStartElementNSCallback(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** attributes)
{
PendingStartElementNSCallback* callback = new PendingStartElementNSCallback;
-
+
callback->xmlLocalName = xmlStrdup(xmlLocalName);
callback->xmlPrefix = xmlStrdup(xmlPrefix);
callback->xmlURI = xmlStrdup(xmlURI);
@@ -98,103 +98,102 @@ public:
for (int i = 0; i < nb_attributes; i++) {
// Each attribute has 5 elements in the array:
// name, prefix, uri, value and an end pointer.
-
+
for (int j = 0; j < 3; j++)
callback->attributes[i * 5 + j] = xmlStrdup(attributes[i * 5 + j]);
-
+
int len = attributes[i * 5 + 4] - attributes[i * 5 + 3];
callback->attributes[i * 5 + 3] = xmlStrndup(attributes[i * 5 + 3], len);
callback->attributes[i * 5 + 4] = callback->attributes[i * 5 + 3] + len;
}
-
+
m_callbacks.append(callback);
}
void appendEndElementNSCallback()
{
PendingEndElementNSCallback* callback = new PendingEndElementNSCallback;
-
+
m_callbacks.append(callback);
}
-
+
void appendCharactersCallback(const xmlChar* s, int len)
{
PendingCharactersCallback* callback = new PendingCharactersCallback;
-
+
callback->s = xmlStrndup(s, len);
callback->len = len;
-
+
m_callbacks.append(callback);
}
-
+
void appendProcessingInstructionCallback(const xmlChar* target, const xmlChar* data)
{
PendingProcessingInstructionCallback* callback = new PendingProcessingInstructionCallback;
-
+
callback->target = xmlStrdup(target);
callback->data = xmlStrdup(data);
-
+
m_callbacks.append(callback);
}
-
+
void appendCDATABlockCallback(const xmlChar* s, int len)
{
PendingCDATABlockCallback* callback = new PendingCDATABlockCallback;
-
+
callback->s = xmlStrndup(s, len);
callback->len = len;
-
- m_callbacks.append(callback);
+
+ m_callbacks.append(callback);
}
void appendCommentCallback(const xmlChar* s)
{
PendingCommentCallback* callback = new PendingCommentCallback;
-
+
callback->s = xmlStrdup(s);
-
- m_callbacks.append(callback);
+
+ m_callbacks.append(callback);
}
void appendInternalSubsetCallback(const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
{
PendingInternalSubsetCallback* callback = new PendingInternalSubsetCallback;
-
+
callback->name = xmlStrdup(name);
callback->externalID = xmlStrdup(externalID);
callback->systemID = xmlStrdup(systemID);
-
- m_callbacks.append(callback);
+
+ m_callbacks.append(callback);
}
-
- void appendErrorCallback(XMLTokenizer::ErrorType type, const xmlChar* message, int lineNumber, int columnNumber)
+
+ void appendErrorCallback(XMLDocumentParser::ErrorType type, const xmlChar* message, int lineNumber, int columnNumber)
{
PendingErrorCallback* callback = new PendingErrorCallback;
-
+
callback->message = xmlStrdup(message);
callback->type = type;
callback->lineNumber = lineNumber;
callback->columnNumber = columnNumber;
-
+
m_callbacks.append(callback);
}
- void callAndRemoveFirstCallback(XMLTokenizer* tokenizer)
+ void callAndRemoveFirstCallback(XMLDocumentParser* parser)
{
- OwnPtr<PendingCallback> callback(m_callbacks.first());
- m_callbacks.removeFirst();
- callback->call(tokenizer);
+ OwnPtr<PendingCallback> callback(m_callbacks.takeFirst());
+ callback->call(parser);
}
-
+
bool isEmpty() const { return m_callbacks.isEmpty(); }
-
-private:
- struct PendingCallback {
+
+private:
+ struct PendingCallback {
virtual ~PendingCallback() { }
- virtual void call(XMLTokenizer* tokenizer) = 0;
- };
-
+ virtual void call(XMLDocumentParser* parser) = 0;
+ };
+
struct PendingStartElementNSCallback : public PendingCallback {
virtual ~PendingStartElementNSCallback()
{
@@ -205,14 +204,14 @@ private:
xmlFree(namespaces[i]);
xmlFree(namespaces);
for (int i = 0; i < nb_attributes; i++)
- for (int j = 0; j < 4; j++)
+ for (int j = 0; j < 4; j++)
xmlFree(attributes[i * 5 + j]);
xmlFree(attributes);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->startElementNs(xmlLocalName, xmlPrefix, xmlURI,
+ parser->startElementNs(xmlLocalName, xmlPrefix, xmlURI,
nb_namespaces, const_cast<const xmlChar**>(namespaces),
nb_attributes, nb_defaulted, const_cast<const xmlChar**>(attributes));
}
@@ -226,109 +225,109 @@ private:
int nb_defaulted;
xmlChar** attributes;
};
-
+
struct PendingEndElementNSCallback : public PendingCallback {
- virtual void call(XMLTokenizer* tokenizer)
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->endElementNs();
+ parser->endElementNs();
}
};
-
+
struct PendingCharactersCallback : public PendingCallback {
- virtual ~PendingCharactersCallback()
+ virtual ~PendingCharactersCallback()
{
xmlFree(s);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->characters(s, len);
+ parser->characters(s, len);
}
-
+
xmlChar* s;
int len;
};
struct PendingProcessingInstructionCallback : public PendingCallback {
- virtual ~PendingProcessingInstructionCallback()
+ virtual ~PendingProcessingInstructionCallback()
{
xmlFree(target);
xmlFree(data);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->processingInstruction(target, data);
+ parser->processingInstruction(target, data);
}
-
+
xmlChar* target;
xmlChar* data;
};
-
+
struct PendingCDATABlockCallback : public PendingCallback {
- virtual ~PendingCDATABlockCallback()
+ virtual ~PendingCDATABlockCallback()
{
xmlFree(s);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->cdataBlock(s, len);
+ parser->cdataBlock(s, len);
}
-
+
xmlChar* s;
int len;
};
struct PendingCommentCallback : public PendingCallback {
- virtual ~PendingCommentCallback()
+ virtual ~PendingCommentCallback()
{
xmlFree(s);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->comment(s);
+ parser->comment(s);
}
xmlChar* s;
};
-
+
struct PendingInternalSubsetCallback : public PendingCallback {
- virtual ~PendingInternalSubsetCallback()
+ virtual ~PendingInternalSubsetCallback()
{
xmlFree(name);
xmlFree(externalID);
xmlFree(systemID);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->internalSubset(name, externalID, systemID);
+ parser->internalSubset(name, externalID, systemID);
}
-
+
xmlChar* name;
xmlChar* externalID;
- xmlChar* systemID;
+ xmlChar* systemID;
};
-
+
struct PendingErrorCallback: public PendingCallback {
- virtual ~PendingErrorCallback()
+ virtual ~PendingErrorCallback()
{
xmlFree(message);
}
-
- virtual void call(XMLTokenizer* tokenizer)
+
+ virtual void call(XMLDocumentParser* parser)
{
- tokenizer->handleError(type, reinterpret_cast<char*>(message), lineNumber, columnNumber);
+ parser->handleError(type, reinterpret_cast<char*>(message), lineNumber, columnNumber);
}
-
- XMLTokenizer::ErrorType type;
+
+ XMLDocumentParser::ErrorType type;
xmlChar* message;
int lineNumber;
int columnNumber;
};
-
+
Deque<PendingCallback*> m_callbacks;
};
// --------------------------------
@@ -338,15 +337,15 @@ static ThreadIdentifier libxmlLoaderThread = 0;
static int matchFunc(const char*)
{
- // Only match loads initiated due to uses of libxml2 from within XMLTokenizer to avoid
+ // Only match loads initiated due to uses of libxml2 from within XMLDocumentParser to avoid
// interfering with client applications that also use libxml2. http://bugs.webkit.org/show_bug.cgi?id=17353
- return XMLTokenizerScope::currentDocLoader && currentThread() == libxmlLoaderThread;
+ return XMLDocumentParserScope::currentDocLoader && currentThread() == libxmlLoaderThread;
}
class OffsetBuffer {
public:
OffsetBuffer(const Vector<char>& b) : m_buffer(b), m_currentOffset(0) { }
-
+
int readOutBytes(char* outputBuffer, unsigned askedToRead)
{
unsigned bytesLeft = m_buffer.size() - m_currentOffset;
@@ -391,8 +390,8 @@ static bool shouldAllowExternalLoad(const KURL& url)
// retrieved content. If we had more context, we could potentially allow
// the parser to load a DTD. As things stand, we take the conservative
// route and allow same-origin requests only.
- if (!XMLTokenizerScope::currentDocLoader->doc()->securityOrigin()->canRequest(url)) {
- XMLTokenizerScope::currentDocLoader->printAccessDeniedMessage(url);
+ if (!XMLDocumentParserScope::currentDocLoader->doc()->securityOrigin()->canRequest(url)) {
+ XMLDocumentParserScope::currentDocLoader->printAccessDeniedMessage(url);
return false;
}
@@ -401,7 +400,7 @@ static bool shouldAllowExternalLoad(const KURL& url)
static void* openFunc(const char* uri)
{
- ASSERT(XMLTokenizerScope::currentDocLoader);
+ ASSERT(XMLDocumentParserScope::currentDocLoader);
ASSERT(currentThread() == libxmlLoaderThread);
KURL url(KURL(), uri);
@@ -415,11 +414,11 @@ static void* openFunc(const char* uri)
{
- DocLoader* docLoader = XMLTokenizerScope::currentDocLoader;
- XMLTokenizerScope scope(0);
+ DocLoader* docLoader = XMLDocumentParserScope::currentDocLoader;
+ XMLDocumentParserScope scope(0);
// FIXME: We should restore the original global error handler as well.
- if (docLoader->frame())
+ if (docLoader->frame())
docLoader->frame()->loader()->loadResourceSynchronously(url, AllowStoredCredentials, error, response, data);
}
@@ -436,7 +435,7 @@ static int readFunc(void* context, char* buffer, int len)
// Do 0-byte reads in case of a null descriptor
if (context == &globalDescriptor)
return 0;
-
+
OffsetBuffer* data = static_cast<OffsetBuffer*>(context);
return data->readOutBytes(buffer, len);
}
@@ -518,13 +517,13 @@ PassRefPtr<XMLParserContext> XMLParserContext::createMemoryParser(xmlSAXHandlerP
parser->str_xmlns = xmlDictLookup(parser->dict, BAD_CAST "xmlns", 5);
parser->str_xml_ns = xmlDictLookup(parser->dict, XML_XML_NAMESPACE, 36);
parser->_private = userData;
-
+
return adoptRef(new XMLParserContext(parser));
}
// --------------------------------
-XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view)
+XMLDocumentParser::XMLDocumentParser(Document* _doc, FrameView* _view)
: m_doc(_doc)
, m_view(_view)
, m_context(0)
@@ -551,7 +550,7 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view)
{
}
-XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission scriptingPermission)
+XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission scriptingPermission)
: m_doc(fragment->document())
, m_view(0)
, m_context(0)
@@ -579,21 +578,21 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, F
fragment->ref();
if (m_doc)
m_doc->ref();
-
+
// Add namespaces based on the parent node
Vector<Element*> elemStack;
while (parentElement) {
elemStack.append(parentElement);
-
+
Node* n = parentElement->parentNode();
if (!n || !n->isElementNode())
break;
parentElement = static_cast<Element*>(n);
}
-
+
if (elemStack.isEmpty())
return;
-
+
for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) {
if (NamedNodeMap* attrs = element->attributes()) {
for (unsigned i = 0; i < attrs->length(); i++) {
@@ -618,7 +617,7 @@ XMLParserContext::~XMLParserContext()
xmlFreeParserCtxt(m_context);
}
-XMLTokenizer::~XMLTokenizer()
+XMLDocumentParser::~XMLDocumentParser()
{
clearCurrentNodeStack();
if (m_parsingFragment && m_doc)
@@ -627,7 +626,7 @@ XMLTokenizer::~XMLTokenizer()
m_pendingScript->removeClient(this);
}
-void XMLTokenizer::doWrite(const String& parseString)
+void XMLDocumentParser::doWrite(const String& parseString)
{
if (!m_context)
initializeParserContext();
@@ -639,16 +638,16 @@ void XMLTokenizer::doWrite(const String& parseString)
if (parseString.length()) {
// Hack around libxml2's lack of encoding overide support by manually
// resetting the encoding to UTF-16 before every chunk. Otherwise libxml
- // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
+ // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
// and switch encodings, causing the parse to fail.
const UChar BOM = 0xFEFF;
const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
xmlSwitchEncoding(context->context(), BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
- XMLTokenizerScope scope(m_doc->docLoader());
+ XMLDocumentParserScope scope(m_doc->docLoader());
xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseString.characters()), sizeof(UChar) * parseString.length(), 0);
}
-
+
if (m_doc->decoder() && m_doc->decoder()->sawError()) {
// If the decoder saw an error, report it as fatal (stops parsing)
handleError(fatal, "Encoding error", context->context()->input->line, context->context()->input->col);
@@ -666,7 +665,7 @@ static inline String toString(const xmlChar* str)
{
if (!str)
return String();
-
+
return UTF8Encoding().decode(reinterpret_cast<const char*>(str), strlen(reinterpret_cast<const char*>(str)));
}
@@ -709,26 +708,26 @@ static inline void handleElementAttributes(Element* newElement, const xmlChar**
String attrPrefix = toString(attributes[i].prefix);
String attrURI = attrPrefix.isEmpty() ? String() : toString(attributes[i].uri);
String attrQName = attrPrefix.isEmpty() ? attrLocalName : attrPrefix + ":" + attrLocalName;
-
+
newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingPermission);
if (ec) // exception setting attributes
return;
}
}
-void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
+void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
const xmlChar** libxmlNamespaces, int nb_attributes, int nb_defaulted, const xmlChar** libxmlAttributes)
{
if (m_parserStopped)
return;
-
+
if (m_parserPaused) {
m_pendingCallbacks->appendStartElementNSCallback(xmlLocalName, xmlPrefix, xmlURI, nb_namespaces, libxmlNamespaces,
nb_attributes, nb_defaulted, libxmlAttributes);
return;
}
-#if ENABLE(XHTMLMP)
+#if ENABLE(XHTMLMP)
// check if the DOCTYPE Declaration of XHTMLMP document exists
if (!m_hasDocTypeDeclaration && m_doc->isXHTMLMPDocument()) {
handleError(fatal, "DOCTYPE declaration lost.", lineNumber(), columnNumber());
@@ -751,9 +750,9 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm
#if ENABLE(XHTMLMP)
if (!m_sawFirstElement && isXHTMLMPDocument()) {
- // As per the section 7.1 of OMA-WAP-XHTMLMP-V1_1-20061020-A.pdf,
- // we should make sure that the root element MUST be 'html' and
- // ensure the name of the default namespace on the root elment 'html'
+ // As per the section 7.1 of OMA-WAP-XHTMLMP-V1_1-20061020-A.pdf,
+ // we should make sure that the root element MUST be 'html' and
+ // ensure the name of the default namespace on the root elment 'html'
// MUST be 'http://www.w3.org/1999/xhtml'
if (localName != HTMLNames::htmlTag.localName()) {
handleError(fatal, "XHTMLMP document expects 'html' as root element.", lineNumber(), columnNumber());
@@ -761,7 +760,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm
}
if (uri.isNull()) {
- m_defaultNamespaceURI = HTMLNames::xhtmlNamespaceURI;
+ m_defaultNamespaceURI = HTMLNames::xhtmlNamespaceURI;
uri = m_defaultNamespaceURI;
}
}
@@ -776,7 +775,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm
stopParsing();
return;
}
-
+
ExceptionCode ec = 0;
handleElementNamespaces(newElement.get(), libxmlNamespaces, nb_namespaces, ec, m_scriptingPermission);
if (ec) {
@@ -816,7 +815,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm
m_doc->frame()->loader()->dispatchDocumentElementAvailable();
}
-void XMLTokenizer::endElementNs()
+void XMLDocumentParser::endElementNs()
{
if (m_parserStopped)
return;
@@ -825,7 +824,7 @@ void XMLTokenizer::endElementNs()
m_pendingCallbacks->appendEndElementNSCallback();
return;
}
-
+
exitText();
Node* n = m_currentNode;
@@ -833,11 +832,11 @@ void XMLTokenizer::endElementNs()
if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) {
popCurrentNode();
- ExceptionCode ec;
+ ExceptionCode ec;
n->remove(ec);
return;
}
-
+
if (!n->isElementNode() || !m_view) {
popCurrentNode();
return;
@@ -865,12 +864,12 @@ void XMLTokenizer::endElementNs()
#if ENABLE(XHTMLMP)
if (!scriptElement->shouldExecuteAsJavaScript())
m_doc->setShouldProcessNoscriptElement(true);
- else
+ else
#endif
{
String scriptHref = scriptElement->sourceAttributeValue();
if (!scriptHref.isEmpty()) {
- // we have a src attribute
+ // we have a src attribute
String scriptCharset = scriptElement->scriptCharset();
if (element->dispatchBeforeLoadEvent(scriptHref) &&
(m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) {
@@ -880,7 +879,7 @@ void XMLTokenizer::endElementNs()
// m_pendingScript will be 0 if script was already loaded and ref() executed it
if (m_pendingScript)
pauseParsing();
- } else
+ } else
m_scriptElement = 0;
} else
m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine));
@@ -889,21 +888,21 @@ void XMLTokenizer::endElementNs()
popCurrentNode();
}
-void XMLTokenizer::characters(const xmlChar* s, int len)
+void XMLDocumentParser::characters(const xmlChar* s, int len)
{
if (m_parserStopped)
return;
-
+
if (m_parserPaused) {
m_pendingCallbacks->appendCharactersCallback(s, len);
return;
}
-
+
if (m_currentNode->isTextNode() || enterText())
m_bufferedText.append(s, len);
}
-void XMLTokenizer::error(ErrorType type, const char* message, va_list args)
+void XMLDocumentParser::error(ErrorType type, const char* message, va_list args)
{
if (m_parserStopped)
return;
@@ -916,7 +915,7 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args)
if (vasprintf(&m, message, args) == -1)
return;
#endif
-
+
if (m_parserPaused)
m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(m), lineNumber(), columnNumber());
else
@@ -927,7 +926,7 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args)
#endif
}
-void XMLTokenizer::processingInstruction(const xmlChar* target, const xmlChar* data)
+void XMLDocumentParser::processingInstruction(const xmlChar* target, const xmlChar* data)
{
if (m_parserStopped)
return;
@@ -936,7 +935,7 @@ void XMLTokenizer::processingInstruction(const xmlChar* target, const xmlChar* d
m_pendingCallbacks->appendProcessingInstructionCallback(target, data);
return;
}
-
+
exitText();
// ### handle exceptions
@@ -947,7 +946,7 @@ void XMLTokenizer::processingInstruction(const xmlChar* target, const xmlChar* d
return;
pi->setCreatedByParser(true);
-
+
if (!m_currentNode->addChild(pi.get()))
return;
if (m_view && !pi->attached())
@@ -962,7 +961,7 @@ void XMLTokenizer::processingInstruction(const xmlChar* target, const xmlChar* d
#endif
}
-void XMLTokenizer::cdataBlock(const xmlChar* s, int len)
+void XMLDocumentParser::cdataBlock(const xmlChar* s, int len)
{
if (m_parserStopped)
return;
@@ -971,7 +970,7 @@ void XMLTokenizer::cdataBlock(const xmlChar* s, int len)
m_pendingCallbacks->appendCDATABlockCallback(s, len);
return;
}
-
+
exitText();
RefPtr<Node> newNode = CDATASection::create(m_doc, toString(s, len));
@@ -981,7 +980,7 @@ void XMLTokenizer::cdataBlock(const xmlChar* s, int len)
newNode->attach();
}
-void XMLTokenizer::comment(const xmlChar* s)
+void XMLDocumentParser::comment(const xmlChar* s)
{
if (m_parserStopped)
return;
@@ -990,7 +989,7 @@ void XMLTokenizer::comment(const xmlChar* s)
m_pendingCallbacks->appendCommentCallback(s);
return;
}
-
+
exitText();
RefPtr<Node> newNode = Comment::create(m_doc, toString(s));
@@ -999,7 +998,7 @@ void XMLTokenizer::comment(const xmlChar* s)
newNode->attach();
}
-void XMLTokenizer::startDocument(const xmlChar* version, const xmlChar* encoding, int standalone)
+void XMLDocumentParser::startDocument(const xmlChar* version, const xmlChar* encoding, int standalone)
{
ExceptionCode ec = 0;
@@ -1010,7 +1009,7 @@ void XMLTokenizer::startDocument(const xmlChar* version, const xmlChar* encoding
m_doc->setXMLEncoding(toString(encoding));
}
-void XMLTokenizer::endDocument()
+void XMLDocumentParser::endDocument()
{
exitText();
#if ENABLE(XHTMLMP)
@@ -1018,7 +1017,7 @@ void XMLTokenizer::endDocument()
#endif
}
-void XMLTokenizer::internalSubset(const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
+void XMLDocumentParser::internalSubset(const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
{
if (m_parserStopped)
return;
@@ -1027,7 +1026,7 @@ void XMLTokenizer::internalSubset(const xmlChar* name, const xmlChar* externalID
m_pendingCallbacks->appendInternalSubsetCallback(name, externalID, systemID);
return;
}
-
+
if (m_doc) {
#if ENABLE(WML) || ENABLE(XHTMLMP)
String extId = toString(externalID);
@@ -1047,7 +1046,7 @@ void XMLTokenizer::internalSubset(const xmlChar* name, const xmlChar* externalID
if (dtdName != HTMLNames::htmlTag.localName()) {
handleError(fatal, "Invalid DOCTYPE declaration, expected 'html' as root element.", lineNumber(), columnNumber());
return;
- }
+ }
if (m_doc->isXHTMLMPDocument())
setIsXHTMLMPDocument(true);
@@ -1062,10 +1061,10 @@ void XMLTokenizer::internalSubset(const xmlChar* name, const xmlChar* externalID
}
}
-static inline XMLTokenizer* getTokenizer(void* closure)
+static inline XMLDocumentParser* getParser(void* closure)
{
xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(closure);
- return static_cast<XMLTokenizer*>(ctxt->_private);
+ return static_cast<XMLDocumentParser*>(ctxt->_private);
}
// This is a hack around http://bugzilla.gnome.org/show_bug.cgi?id=159219
@@ -1087,47 +1086,47 @@ static void startElementNsHandler(void* closure, const xmlChar* localname, const
if (hackAroundLibXMLEntityBug(closure))
return;
- getTokenizer(closure)->startElementNs(localname, prefix, uri, nb_namespaces, namespaces, nb_attributes, nb_defaulted, libxmlAttributes);
+ getParser(closure)->startElementNs(localname, prefix, uri, nb_namespaces, namespaces, nb_attributes, nb_defaulted, libxmlAttributes);
}
static void endElementNsHandler(void* closure, const xmlChar*, const xmlChar*, const xmlChar*)
{
if (hackAroundLibXMLEntityBug(closure))
return;
-
- getTokenizer(closure)->endElementNs();
+
+ getParser(closure)->endElementNs();
}
static void charactersHandler(void* closure, const xmlChar* s, int len)
{
if (hackAroundLibXMLEntityBug(closure))
return;
-
- getTokenizer(closure)->characters(s, len);
+
+ getParser(closure)->characters(s, len);
}
static void processingInstructionHandler(void* closure, const xmlChar* target, const xmlChar* data)
{
if (hackAroundLibXMLEntityBug(closure))
return;
-
- getTokenizer(closure)->processingInstruction(target, data);
+
+ getParser(closure)->processingInstruction(target, data);
}
static void cdataBlockHandler(void* closure, const xmlChar* s, int len)
{
if (hackAroundLibXMLEntityBug(closure))
return;
-
- getTokenizer(closure)->cdataBlock(s, len);
+
+ getParser(closure)->cdataBlock(s, len);
}
static void commentHandler(void* closure, const xmlChar* comment)
{
if (hackAroundLibXMLEntityBug(closure))
return;
-
- getTokenizer(closure)->comment(comment);
+
+ getParser(closure)->comment(comment);
}
WTF_ATTRIBUTE_PRINTF(2, 3)
@@ -1135,7 +1134,7 @@ static void warningHandler(void* closure, const char* message, ...)
{
va_list args;
va_start(args, message);
- getTokenizer(closure)->error(XMLTokenizer::warning, message, args);
+ getParser(closure)->error(XMLDocumentParser::warning, message, args);
va_end(args);
}
@@ -1144,7 +1143,7 @@ static void fatalErrorHandler(void* closure, const char* message, ...)
{
va_list args;
va_start(args, message);
- getTokenizer(closure)->error(XMLTokenizer::fatal, message, args);
+ getParser(closure)->error(XMLDocumentParser::fatal, message, args);
va_end(args);
}
@@ -1153,7 +1152,7 @@ static void normalErrorHandler(void* closure, const char* message, ...)
{
va_list args;
va_start(args, message);
- getTokenizer(closure)->error(XMLTokenizer::nonFatal, message, args);
+ getParser(closure)->error(XMLDocumentParser::nonFatal, message, args);
va_end(args);
}
@@ -1200,38 +1199,38 @@ static xmlEntityPtr getEntityHandler(void* closure, const xmlChar* name)
}
ent = xmlGetDocEntity(ctxt->myDoc, name);
- if (!ent && (getTokenizer(closure)->isXHTMLDocument()
+ if (!ent && (getParser(closure)->isXHTMLDocument()
#if ENABLE(XHTMLMP)
- || getTokenizer(closure)->isXHTMLMPDocument()
+ || getParser(closure)->isXHTMLMPDocument()
#endif
#if ENABLE(WML)
- || getTokenizer(closure)->isWMLDocument()
+ || getParser(closure)->isWMLDocument()
#endif
)) {
ent = getXHTMLEntity(name);
if (ent)
ent->etype = XML_INTERNAL_GENERAL_ENTITY;
}
-
+
return ent;
}
static void startDocumentHandler(void* closure)
{
xmlParserCtxt* ctxt = static_cast<xmlParserCtxt*>(closure);
- getTokenizer(closure)->startDocument(ctxt->version, ctxt->encoding, ctxt->standalone);
+ getParser(closure)->startDocument(ctxt->version, ctxt->encoding, ctxt->standalone);
xmlSAX2StartDocument(closure);
}
static void endDocumentHandler(void* closure)
{
- getTokenizer(closure)->endDocument();
+ getParser(closure)->endDocument();
xmlSAX2EndDocument(closure);
}
static void internalSubsetHandler(void* closure, const xmlChar* name, const xmlChar* externalID, const xmlChar* systemID)
{
- getTokenizer(closure)->internalSubset(name, externalID, systemID);
+ getParser(closure)->internalSubset(name, externalID, systemID);
xmlSAX2InternalSubset(closure, name, externalID, systemID);
}
@@ -1247,7 +1246,7 @@ static void externalSubsetHandler(void* closure, const xmlChar*, const xmlChar*
|| (extId == "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN")
|| (extId == "-//WAPFORUM//DTD XHTML Mobile 1.0//EN")
)
- getTokenizer(closure)->setIsXHTMLDocument(true); // controls if we replace entities or not.
+ getParser(closure)->setIsXHTMLDocument(true); // controls if we replace entities or not.
}
static void ignorableWhitespaceHandler(void*, const xmlChar*, int)
@@ -1257,7 +1256,7 @@ static void ignorableWhitespaceHandler(void*, const xmlChar*, int)
// http://bugs.webkit.org/show_bug.cgi?id=5792
}
-void XMLTokenizer::initializeParserContext(const char* chunk)
+void XMLDocumentParser::initializeParserContext(const char* chunk)
{
xmlSAXHandler sax;
memset(&sax, 0, sizeof(sax));
@@ -1284,20 +1283,20 @@ void XMLTokenizer::initializeParserContext(const char* chunk)
m_sawXSLTransform = false;
m_sawFirstElement = false;
- XMLTokenizerScope scope(m_doc->docLoader());
+ XMLDocumentParserScope scope(m_doc->docLoader());
if (m_parsingFragment)
m_context = XMLParserContext::createMemoryParser(&sax, this, chunk);
else
m_context = XMLParserContext::createStringParser(&sax, this);
}
-void XMLTokenizer::doEnd()
+void XMLDocumentParser::doEnd()
{
#if ENABLE(XSLT)
if (m_sawXSLTransform) {
void* doc = xmlDocPtrForString(m_doc->docLoader(), m_originalSourceForTransform, m_doc->url().string());
m_doc->setTransformSource(new TransformSource(doc));
-
+
m_doc->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
m_doc->updateStyleSelector();
m_doc->setParsing(true);
@@ -1311,7 +1310,7 @@ void XMLTokenizer::doEnd()
if (m_context) {
// Tell libxml we're done.
{
- XMLTokenizerScope scope(m_doc->docLoader());
+ XMLDocumentParserScope scope(m_doc->docLoader());
xmlParseChunk(context(), 0, 0, 1);
}
@@ -1331,43 +1330,43 @@ void* xmlDocPtrForString(DocLoader* docLoader, const String& source, const Strin
const UChar BOM = 0xFEFF;
const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
- XMLTokenizerScope scope(docLoader, errorFunc, 0);
+ XMLDocumentParserScope scope(docLoader, errorFunc, 0);
xmlDocPtr sourceDoc = xmlReadMemory(reinterpret_cast<const char*>(source.characters()),
source.length() * sizeof(UChar),
url.latin1().data(),
- BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
+ BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
XSLT_PARSE_OPTIONS);
return sourceDoc;
}
#endif
-int XMLTokenizer::lineNumber() const
+int XMLDocumentParser::lineNumber() const
{
return context() ? context()->input->line : 1;
}
-int XMLTokenizer::columnNumber() const
+int XMLDocumentParser::columnNumber() const
{
return context() ? context()->input->col : 1;
}
-void XMLTokenizer::stopParsing()
+void XMLDocumentParser::stopParsing()
{
- Tokenizer::stopParsing();
+ DocumentParser::stopParsing();
if (context())
xmlStopParser(context());
}
-void XMLTokenizer::resumeParsing()
+void XMLDocumentParser::resumeParsing()
{
ASSERT(m_parserPaused);
-
+
m_parserPaused = false;
// First, execute any pending callbacks
while (!m_pendingCallbacks->isEmpty()) {
m_pendingCallbacks->callAndRemoveFirstCallback(this);
-
+
// A callback paused the parser
if (m_parserPaused)
return;
@@ -1389,22 +1388,22 @@ bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, E
if (!chunk.length())
return true;
- XMLTokenizer tokenizer(fragment, parent, scriptingPermission);
-
+ XMLDocumentParser parser(fragment, parent, scriptingPermission);
+
CString chunkAsUtf8 = chunk.utf8();
- tokenizer.initializeParserContext(chunkAsUtf8.data());
+ parser.initializeParserContext(chunkAsUtf8.data());
- xmlParseContent(tokenizer.context());
+ xmlParseContent(parser.context());
- tokenizer.endDocument();
+ parser.endDocument();
// Check if all the chunk has been processed.
- long bytesProcessed = xmlByteConsumed(tokenizer.context());
+ long bytesProcessed = xmlByteConsumed(parser.context());
if (bytesProcessed == -1 || ((unsigned long)bytesProcessed) != chunkAsUtf8.length())
return false;
// No error if the chunk is well formed or it is not but we have no error.
- return tokenizer.context()->wellFormed || xmlCtxtGetLastError(tokenizer.context()) == 0;
+ return parser.context()->wellFormed || xmlCtxtGetLastError(parser.context()) == 0;
}
// --------------------------------
@@ -1420,12 +1419,12 @@ static void attributesStartElementNsHandler(void* closure, const xmlChar* xmlLoc
{
if (strcmp(reinterpret_cast<const char*>(xmlLocalName), "attrs") != 0)
return;
-
+
xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(closure);
AttributeParseState* state = static_cast<AttributeParseState*>(ctxt->_private);
-
+
state->gotAttributes = true;
-
+
xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlAttributes);
for (int i = 0; i < nb_attributes; i++) {
String attrLocalName = toString(attributes[i].localname);
@@ -1433,7 +1432,7 @@ static void attributesStartElementNsHandler(void* closure, const xmlChar* xmlLoc
String attrValue = toString(attributes[i].value, valueLength);
String attrPrefix = toString(attributes[i].prefix);
String attrQName = attrPrefix.isEmpty() ? attrLocalName : attrPrefix + ":" + attrLocalName;
-
+
state->attributes.set(attrQName, attrValue);
}
}
diff --git a/WebCore/dom/XMLTokenizerQt.cpp b/WebCore/dom/XMLDocumentParserQt.cpp
index 2f76b28..89f542f 100644
--- a/WebCore/dom/XMLTokenizerQt.cpp
+++ b/WebCore/dom/XMLDocumentParserQt.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "XMLTokenizer.h"
+#include "XMLDocumentParser.h"
#include "CDATASection.h"
#include "CachedScript.h"
@@ -38,7 +38,7 @@
#include "FrameView.h"
#include "HTMLLinkElement.h"
#include "HTMLStyleElement.h"
-#include "HTMLTokenizer.h"
+#include "HTMLDocumentParser.h"
#include "ProcessingInstruction.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
@@ -77,7 +77,7 @@ QString EntityResolver::resolveUndeclaredEntity(const QString &name)
// --------------------------------
-XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view)
+XMLDocumentParser::XMLDocumentParser(Document* _doc, FrameView* _view)
: m_doc(_doc)
, m_view(_view)
, m_wroteText(false)
@@ -104,7 +104,7 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view)
m_stream.setEntityResolver(new EntityResolver);
}
-XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission permission)
+XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission permission)
: m_doc(fragment->document())
, m_view(0)
, m_wroteText(false)
@@ -131,21 +131,21 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, F
fragment->ref();
if (m_doc)
m_doc->ref();
-
+
// Add namespaces based on the parent node
Vector<Element*> elemStack;
while (parentElement) {
elemStack.append(parentElement);
-
+
Node* n = parentElement->parentNode();
if (!n || !n->isElementNode())
break;
parentElement = static_cast<Element*>(n);
}
-
+
if (elemStack.isEmpty())
return;
-
+
QXmlStreamNamespaceDeclarations namespaces;
for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) {
if (NamedNodeMap* attrs = element->attributes()) {
@@ -166,7 +166,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, F
m_defaultNamespaceURI = parentElement->namespaceURI();
}
-XMLTokenizer::~XMLTokenizer()
+XMLDocumentParser::~XMLDocumentParser()
{
clearCurrentNodeStack();
if (m_parsingFragment && m_doc)
@@ -176,7 +176,7 @@ XMLTokenizer::~XMLTokenizer()
delete m_stream.entityResolver();
}
-void XMLTokenizer::doWrite(const String& parseString)
+void XMLDocumentParser::doWrite(const String& parseString)
{
m_wroteText = true;
@@ -195,7 +195,7 @@ void XMLTokenizer::doWrite(const String& parseString)
return;
}
-void XMLTokenizer::initializeParserContext(const char*)
+void XMLDocumentParser::initializeParserContext(const char*)
{
m_parserStopped = false;
m_sawError = false;
@@ -203,7 +203,7 @@ void XMLTokenizer::initializeParserContext(const char*)
m_sawFirstElement = false;
}
-void XMLTokenizer::doEnd()
+void XMLDocumentParser::doEnd()
{
#if ENABLE(XSLT)
if (m_sawXSLTransform) {
@@ -214,31 +214,31 @@ void XMLTokenizer::doEnd()
m_parserStopped = true;
}
#endif
-
+
if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError
|| (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform && !m_sawError))
handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(), columnNumber());
}
-int XMLTokenizer::lineNumber() const
+int XMLDocumentParser::lineNumber() const
{
return m_stream.lineNumber();
}
-int XMLTokenizer::columnNumber() const
+int XMLDocumentParser::columnNumber() const
{
return m_stream.columnNumber();
}
-void XMLTokenizer::stopParsing()
+void XMLDocumentParser::stopParsing()
{
- Tokenizer::stopParsing();
+ DocumentParser::stopParsing();
}
-void XMLTokenizer::resumeParsing()
+void XMLDocumentParser::resumeParsing()
{
ASSERT(m_parserPaused);
-
+
m_parserPaused = false;
// First, execute any pending callbacks
@@ -262,13 +262,13 @@ bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, E
if (!chunk.length())
return true;
- XMLTokenizer tokenizer(fragment, parent, scriptingPermission);
-
- tokenizer.write(String("<qxmlstreamdummyelement>"), false);
- tokenizer.write(chunk, false);
- tokenizer.write(String("</qxmlstreamdummyelement>"), false);
- tokenizer.finish();
- return !tokenizer.hasError();
+ XMLDocumentParser parser(fragment, parent, scriptingPermission);
+
+ parser.write(String("<qxmlstreamdummyelement>"), false);
+ parser.write(chunk, false);
+ parser.write(String("</qxmlstreamdummyelement>"), false);
+ parser.finish();
+ return !parser.hasError();
}
// --------------------------------
@@ -350,7 +350,7 @@ static inline void handleElementAttributes(Element* newElement, const QXmlStream
}
}
-void XMLTokenizer::parse()
+void XMLDocumentParser::parse()
{
while (!m_parserStopped && !m_parserPaused && !m_stream.atEnd()) {
m_stream.readNext();
@@ -369,7 +369,7 @@ void XMLTokenizer::parse()
handleError(fatal, "DOCTYPE declaration lost.", lineNumber(), columnNumber());
break;
}
-#endif
+#endif
parseStartElement();
}
break;
@@ -438,7 +438,7 @@ void XMLTokenizer::parse()
}
}
-void XMLTokenizer::startDocument()
+void XMLDocumentParser::startDocument()
{
initializeParserContext();
ExceptionCode ec = 0;
@@ -455,7 +455,7 @@ void XMLTokenizer::startDocument()
}
}
-void XMLTokenizer::parseStartElement()
+void XMLDocumentParser::parseStartElement()
{
if (!m_sawFirstElement && m_parsingFragment) {
// skip dummy element for fragments
@@ -483,17 +483,17 @@ void XMLTokenizer::parseStartElement()
#if ENABLE(XHTMLMP)
if (!m_sawFirstElement && isXHTMLMPDocument()) {
- // As per 7.1 section of OMA-WAP-XHTMLMP-V1_1-20061020-A.pdf,
- // we should make sure that the root element MUST be 'html' and
- // ensure the name of the default namespace on the root elment 'html'
+ // As per 7.1 section of OMA-WAP-XHTMLMP-V1_1-20061020-A.pdf,
+ // we should make sure that the root element MUST be 'html' and
+ // ensure the name of the default namespace on the root elment 'html'
// MUST be 'http://www.w3.org/1999/xhtml'
if (localName != HTMLNames::htmlTag.localName()) {
handleError(fatal, "XHTMLMP document expects 'html' as root element.", lineNumber(), columnNumber());
return;
- }
+ }
if (uri.isNull()) {
- m_defaultNamespaceURI = HTMLNames::xhtmlNamespaceURI;
+ m_defaultNamespaceURI = HTMLNames::xhtmlNamespaceURI;
uri = m_defaultNamespaceURI;
m_stream.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration(prefix, HTMLNames::xhtmlNamespaceURI));
}
@@ -533,7 +533,7 @@ void XMLTokenizer::parseStartElement()
m_doc->frame()->loader()->dispatchDocumentElementAvailable();
}
-void XMLTokenizer::parseEndElement()
+void XMLDocumentParser::parseEndElement()
{
exitText();
@@ -580,7 +580,7 @@ void XMLTokenizer::parseEndElement()
{
String scriptHref = scriptElement->sourceAttributeValue();
if (!scriptHref.isEmpty()) {
- // we have a src attribute
+ // we have a src attribute
String scriptCharset = scriptElement->scriptCharset();
if (element->dispatchBeforeLoadEvent(scriptHref) &&
(m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) {
@@ -590,7 +590,7 @@ void XMLTokenizer::parseEndElement()
// m_pendingScript will be 0 if script was already loaded and ref() executed it
if (m_pendingScript)
pauseParsing();
- } else
+ } else
m_scriptElement = 0;
} else
m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine));
@@ -599,7 +599,7 @@ void XMLTokenizer::parseEndElement()
popCurrentNode();
}
-void XMLTokenizer::parseCharacters()
+void XMLDocumentParser::parseCharacters()
{
if (m_currentNode->isTextNode() || enterText()) {
ExceptionCode ec = 0;
@@ -607,7 +607,7 @@ void XMLTokenizer::parseCharacters()
}
}
-void XMLTokenizer::parseProcessingInstruction()
+void XMLDocumentParser::parseProcessingInstruction()
{
exitText();
@@ -635,7 +635,7 @@ void XMLTokenizer::parseProcessingInstruction()
#endif
}
-void XMLTokenizer::parseCdata()
+void XMLDocumentParser::parseCdata()
{
exitText();
@@ -646,7 +646,7 @@ void XMLTokenizer::parseCdata()
newNode->attach();
}
-void XMLTokenizer::parseComment()
+void XMLDocumentParser::parseComment()
{
exitText();
@@ -656,19 +656,19 @@ void XMLTokenizer::parseComment()
newNode->attach();
}
-void XMLTokenizer::endDocument()
+void XMLDocumentParser::endDocument()
{
#if ENABLE(XHTMLMP)
m_hasDocTypeDeclaration = false;
#endif
}
-bool XMLTokenizer::hasError() const
+bool XMLDocumentParser::hasError() const
{
return m_stream.hasError();
}
-void XMLTokenizer::parseDtd()
+void XMLDocumentParser::parseDtd()
{
QStringRef name = m_stream.dtdName();
QStringRef publicId = m_stream.dtdPublicId();
@@ -693,7 +693,7 @@ void XMLTokenizer::parseDtd()
if (AtomicString(name) != HTMLNames::htmlTag.localName()) {
handleError(fatal, "Invalid DOCTYPE declaration, expected 'html' as root element.", lineNumber(), columnNumber());
return;
- }
+ }
if (m_doc->isXHTMLMPDocument()) // check if the MIME type is correct with this method
setIsXHTMLMPDocument(true);
@@ -711,7 +711,7 @@ void XMLTokenizer::parseDtd()
#endif
if (!m_parsingFragment)
m_doc->addChild(DocumentType::create(m_doc, name, publicId, systemId));
-
+
}
}
diff --git a/WebCore/dom/XMLTokenizerScope.cpp b/WebCore/dom/XMLDocumentParserScope.cpp
index 3769f59..8afe49d 100644
--- a/WebCore/dom/XMLTokenizerScope.cpp
+++ b/WebCore/dom/XMLDocumentParserScope.cpp
@@ -20,17 +20,17 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
-#include "XMLTokenizerScope.h"
+#include "XMLDocumentParserScope.h"
namespace WebCore {
-DocLoader* XMLTokenizerScope::currentDocLoader = 0;
+DocLoader* XMLDocumentParserScope::currentDocLoader = 0;
-XMLTokenizerScope::XMLTokenizerScope(DocLoader* docLoader)
+XMLDocumentParserScope::XMLDocumentParserScope(DocLoader* docLoader)
: m_oldDocLoader(currentDocLoader)
#if ENABLE(XSLT)
, m_oldGenericErrorFunc(xmlGenericError)
@@ -42,7 +42,7 @@ XMLTokenizerScope::XMLTokenizerScope(DocLoader* docLoader)
}
#if ENABLE(XSLT)
-XMLTokenizerScope::XMLTokenizerScope(DocLoader* docLoader, xmlGenericErrorFunc genericErrorFunc, xmlStructuredErrorFunc structuredErrorFunc, void* errorContext)
+XMLDocumentParserScope::XMLDocumentParserScope(DocLoader* docLoader, xmlGenericErrorFunc genericErrorFunc, xmlStructuredErrorFunc structuredErrorFunc, void* errorContext)
: m_oldDocLoader(currentDocLoader)
, m_oldGenericErrorFunc(xmlGenericError)
, m_oldStructuredErrorFunc(xmlStructuredError)
@@ -56,7 +56,7 @@ XMLTokenizerScope::XMLTokenizerScope(DocLoader* docLoader, xmlGenericErrorFunc g
}
#endif
-XMLTokenizerScope::~XMLTokenizerScope()
+XMLDocumentParserScope::~XMLDocumentParserScope()
{
currentDocLoader = m_oldDocLoader;
#if ENABLE(XSLT)
diff --git a/WebCore/dom/XMLTokenizerScope.h b/WebCore/dom/XMLDocumentParserScope.h
index c29b796..89740d2 100644
--- a/WebCore/dom/XMLTokenizerScope.h
+++ b/WebCore/dom/XMLDocumentParserScope.h
@@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef XMLTokenizerScope_h
@@ -36,15 +36,15 @@ namespace WebCore {
class DocLoader;
- class XMLTokenizerScope : public Noncopyable {
+ class XMLDocumentParserScope : public Noncopyable {
public:
- XMLTokenizerScope(DocLoader* docLoader);
- ~XMLTokenizerScope();
+ XMLDocumentParserScope(DocLoader* docLoader);
+ ~XMLDocumentParserScope();
static DocLoader* currentDocLoader;
#if ENABLE(XSLT)
- XMLTokenizerScope(DocLoader* docLoader, xmlGenericErrorFunc genericErrorFunc, xmlStructuredErrorFunc structuredErrorFunc = 0, void* errorContext = 0);
+ XMLDocumentParserScope(DocLoader* docLoader, xmlGenericErrorFunc genericErrorFunc, xmlStructuredErrorFunc structuredErrorFunc = 0, void* errorContext = 0);
#endif
private:
diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl
index 04a68bb..a675438 100755
--- a/WebCore/dom/make_names.pl
+++ b/WebCore/dom/make_names.pl
@@ -868,7 +868,7 @@ static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespa
{
Settings* settings = element->document()->settings();
if (!MediaPlayer::isAvailable() || (settings && !settings->isMediaEnabled()))
- return toV8(static_cast<$parameters{namespace}Element*>(element));
+ return V8$parameters{namespace}Element::wrap(element);
return toV8(static_cast<${JSInterfaceName}*>(element));
}