diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/dom')
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/Document.cpp | 19 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/Document.h | 13 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/EventListener.h | 7 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/EventListener.idl | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/EventTarget.cpp | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/Node.cpp | 25 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/Node.h | 3 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/TransformSource.h | 51 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/TransformSourceLibxslt.cpp | 43 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/TransformSourceQt.cpp | 34 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp | 4 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp | 49 |
12 files changed, 184 insertions, 68 deletions
diff --git a/src/3rdparty/webkit/WebCore/dom/Document.cpp b/src/3rdparty/webkit/WebCore/dom/Document.cpp index 174c0ee..6dba900 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Document.cpp @@ -116,8 +116,10 @@ #include "TextIterator.h" #include "TextResourceDecoder.h" #include "Timer.h" +#include "TransformSource.h" #include "TreeWalker.h" #include "UIEvent.h" +#include "UserContentURLPattern.h" #include "WebKitAnimationEvent.h" #include "WebKitTransitionEvent.h" #include "WheelEvent.h" @@ -321,9 +323,6 @@ Document::Document(Frame* frame, bool isXHTML) , m_titleSetExplicitly(false) , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired) , m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired) -#if ENABLE(XSLT) - , m_transformSource(0) -#endif , m_xmlVersion("1.0") , m_xmlStandalone(false) #if ENABLE(XBL) @@ -487,10 +486,6 @@ Document::~Document() m_renderArena = 0; } -#if ENABLE(XSLT) - xmlFreeDoc((xmlDocPtr)m_transformSource); -#endif - #if ENABLE(XBL) delete m_bindingManager; #endif @@ -1974,6 +1969,8 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const const UserStyleSheetVector* sheets = it->second; for (unsigned i = 0; i < sheets->size(); ++i) { const UserStyleSheet* sheet = sheets->at(i).get(); + if (!UserContentURLPattern::matchesPatterns(url(), sheet->patterns())) + continue; RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url()); parsedSheet->setIsUserStyleSheet(true); parsedSheet->parseString(sheet->source(), !inCompatMode()); @@ -3850,13 +3847,11 @@ void Document::applyXSLTransform(ProcessingInstruction* pi) processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, frame()); } -void Document::setTransformSource(void* doc) +void Document::setTransformSource(PassOwnPtr<TransformSource> source) { - if (doc == m_transformSource) + if (m_transformSource == source) return; - - xmlFreeDoc((xmlDocPtr)m_transformSource); - m_transformSource = doc; + m_transformSource = source; } #endif diff --git a/src/3rdparty/webkit/WebCore/dom/Document.h b/src/3rdparty/webkit/WebCore/dom/Document.h index 2805562..f05c9f9 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.h +++ b/src/3rdparty/webkit/WebCore/dom/Document.h @@ -37,6 +37,8 @@ #include "ScriptExecutionContext.h" #include "Timer.h" #include <wtf/HashCountedSet.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { @@ -103,6 +105,10 @@ namespace WebCore { class SVGDocumentExtensions; #endif +#if ENABLE(XSLT) + class TransformSource; +#endif + #if ENABLE(XBL) class XBLBindingManager; #endif @@ -746,10 +752,11 @@ public: #if ENABLE(XSLT) void applyXSLTransform(ProcessingInstruction* pi); - void setTransformSource(void* doc); - const void* transformSource() { return m_transformSource; } PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; } void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; } + + void setTransformSource(PassOwnPtr<TransformSource>); + TransformSource* transformSource() const { return m_transformSource.get(); } #endif #if ENABLE(XBL) @@ -1054,7 +1061,7 @@ private: Timer<Document> m_executeScriptSoonTimer; #if ENABLE(XSLT) - void* m_transformSource; + OwnPtr<TransformSource> m_transformSource; RefPtr<Document> m_transformSourceDocument; #endif diff --git a/src/3rdparty/webkit/WebCore/dom/EventListener.h b/src/3rdparty/webkit/WebCore/dom/EventListener.h index 6862f06..f834b31 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventListener.h +++ b/src/3rdparty/webkit/WebCore/dom/EventListener.h @@ -31,6 +31,7 @@ namespace JSC { namespace WebCore { + class ScriptExecutionContext; class Event; class EventListener : public RefCounted<EventListener> { @@ -44,13 +45,13 @@ namespace WebCore { virtual ~EventListener() { } virtual bool operator==(const EventListener&) = 0; - virtual void handleEvent(Event*) = 0; + virtual void handleEvent(ScriptExecutionContext*, Event*) = 0; // Return true to indicate that the error is handled. - virtual bool reportError(const String& /*message*/, const String& /*url*/, int /*lineNumber*/) { return false; } + virtual bool reportError(ScriptExecutionContext*, const String& /*message*/, const String& /*url*/, int /*lineNumber*/) { return false; } virtual bool wasCreatedFromMarkup() const { return false; } #if USE(JSC) - virtual JSC::JSObject* jsFunction() const { return 0; } + virtual JSC::JSObject* jsFunction(ScriptExecutionContext*) const { return 0; } virtual void markJSFunction(JSC::MarkStack&) { } #endif diff --git a/src/3rdparty/webkit/WebCore/dom/EventListener.idl b/src/3rdparty/webkit/WebCore/dom/EventListener.idl index 9dc2e0a..1edf52f 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventListener.idl +++ b/src/3rdparty/webkit/WebCore/dom/EventListener.idl @@ -24,8 +24,8 @@ module events { interface [ NoStaticTables, ObjCProtocol, + PureInterface, InterfaceUUID=B04F2AE3-71E2-4ebe-ABFE-EF4938354082, - ImplementationUUID=DDFDD342-A78B-4f19-8F32-A5DF51B56E08 ] EventListener { void handleEvent(in Event evt); }; diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp index d3b3f55..ceb5221 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp @@ -269,7 +269,7 @@ bool EventTarget::fireEventListeners(Event* event) continue; // To match Mozilla, the AT_TARGET phase fires both capturing and bubbling // event listeners, even though that violates some versions of the DOM spec. - registeredListener.listener->handleEvent(event); + registeredListener.listener->handleEvent(scriptExecutionContext(), event); } d->firingEventEndIterators.removeLast(); diff --git a/src/3rdparty/webkit/WebCore/dom/Node.cpp b/src/3rdparty/webkit/WebCore/dom/Node.cpp index c899f3d..612bf18 100644 --- a/src/3rdparty/webkit/WebCore/dom/Node.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Node.cpp @@ -2422,6 +2422,20 @@ static inline EventTarget* eventTargetRespectingSVGTargetRules(Node* referenceNo return referenceNode; } +void Node::eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors) +{ + if (inDocument()) { + for (ContainerNode* ancestor = eventParentNode(); ancestor; ancestor = ancestor->eventParentNode()) { +#if ENABLE(SVG) + // Skip <use> shadow tree elements. + if (ancestor->isSVGElement() && ancestor->isShadowNode()) + continue; +#endif + ancestors.append(ancestor); + } + } +} + bool Node::dispatchEvent(PassRefPtr<Event> prpEvent) { RefPtr<EventTarget> protect = this; @@ -2452,16 +2466,7 @@ bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent) // Be sure to ref all of nodes since event handlers could result in the last reference going away. RefPtr<Node> thisNode(this); Vector<RefPtr<ContainerNode> > ancestors; - if (inDocument()) { - for (ContainerNode* ancestor = eventParentNode(); ancestor; ancestor = ancestor->eventParentNode()) { -#if ENABLE(SVG) - // Skip <use> shadow tree elements. - if (ancestor->isSVGElement() && ancestor->isShadowNode()) - continue; -#endif - ancestors.append(ancestor); - } - } + eventAncestors(ancestors); // Set up a pointer to indicate whether / where to dispatch window events. // We don't dispatch load events to the window. That quirk was originally diff --git a/src/3rdparty/webkit/WebCore/dom/Node.h b/src/3rdparty/webkit/WebCore/dom/Node.h index f3bebc6..35be6d3 100644 --- a/src/3rdparty/webkit/WebCore/dom/Node.h +++ b/src/3rdparty/webkit/WebCore/dom/Node.h @@ -206,6 +206,9 @@ public: // The node's parent for the purpose of event capture and bubbling. virtual ContainerNode* eventParentNode(); + // Node ancestors when concerned about event flow + void eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors); + bool isBlockFlow() const; bool isBlockFlowOrBlockTable() const; diff --git a/src/3rdparty/webkit/WebCore/dom/TransformSource.h b/src/3rdparty/webkit/WebCore/dom/TransformSource.h new file mode 100644 index 0000000..f97afcf --- /dev/null +++ b/src/3rdparty/webkit/WebCore/dom/TransformSource.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com> + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef TransformSource_h +#define TransformSource_h + +#if ENABLE(XSLT) + +#include "PlatformString.h" +#include <wtf/Noncopyable.h> + +namespace WebCore { + +#if USE(QXMLQUERY) + typedef String PlatformTransformSource; +#else + typedef void* PlatformTransformSource; +#endif + + class TransformSource : public Noncopyable { + public: + TransformSource(const PlatformTransformSource& source); + ~TransformSource(); + + PlatformTransformSource platformSource() const { return m_source; } + + private: + PlatformTransformSource m_source; + }; + +} // namespace WebCore + +#endif + +#endif // TransformSource_h diff --git a/src/3rdparty/webkit/WebCore/dom/TransformSourceLibxslt.cpp b/src/3rdparty/webkit/WebCore/dom/TransformSourceLibxslt.cpp new file mode 100644 index 0000000..33a85e8 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/dom/TransformSourceLibxslt.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * 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. + */ + +#include "config.h" +#include "TransformSource.h" + +#include <libxml/tree.h> + +namespace WebCore { + +TransformSource::TransformSource(const PlatformTransformSource& source) + : m_source(source) +{ +} + +TransformSource::~TransformSource() +{ + xmlFreeDoc((xmlDocPtr)m_source); +} + +} diff --git a/src/3rdparty/webkit/WebCore/dom/TransformSourceQt.cpp b/src/3rdparty/webkit/WebCore/dom/TransformSourceQt.cpp new file mode 100644 index 0000000..074f2cb --- /dev/null +++ b/src/3rdparty/webkit/WebCore/dom/TransformSourceQt.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2009 Jakub Wieczorek <faw217@gmail.com> + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "TransformSource.h" + +namespace WebCore { + +TransformSource::TransformSource(const PlatformTransformSource& source) + : m_source(source) +{ +} + +TransformSource::~TransformSource() +{ +} + +} diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp index da2f9b6..d3c6546 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp @@ -50,6 +50,7 @@ #include "ScriptSourceCode.h" #include "ScriptValue.h" #include "TextResourceDecoder.h" +#include "TransformSource.h" #include "XMLTokenizerScope.h" #include <libxml/parser.h> #include <libxml/parserInternals.h> @@ -1280,7 +1281,8 @@ void XMLTokenizer::doEnd() { #if ENABLE(XSLT) if (m_sawXSLTransform) { - m_doc->setTransformSource(xmlDocPtrForString(m_doc->docLoader(), m_originalSourceForTransform, m_doc->url().string())); + 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(); diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp index 799eef3..f745830 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp @@ -50,6 +50,7 @@ #include "ScriptSourceCode.h" #include "ScriptValue.h" #include "TextResourceDecoder.h" +#include "TransformSource.h" #include <QDebug> #include <wtf/Platform.h> #include <wtf/StringExtras.h> @@ -248,45 +249,19 @@ void XMLTokenizer::initializeParserContext(const char* chunk) void XMLTokenizer::doEnd() { #if ENABLE(XSLT) - #warning Look at XMLTokenizerLibXml.cpp -#endif - - if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError || (m_wroteText && !m_sawFirstElement)) { - handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(), - columnNumber()); + if (m_sawXSLTransform) { + m_doc->setTransformSource(new TransformSource(m_originalSourceForTransform)); + m_doc->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets. + m_doc->updateStyleSelector(); + m_doc->setParsing(true); + m_parserStopped = true; } -} - -#if ENABLE(XSLT) -void* xmlDocPtrForString(DocLoader* docLoader, const String& source, const String& url) -{ - if (source.isEmpty()) - return 0; - - // Parse in a single chunk into an xmlDocPtr - // FIXME: Hook up error handlers so that a failure to parse the main document results in - // good error messages. - const UChar BOM = 0xFEFF; - const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); - - xmlGenericErrorFunc oldErrorFunc = xmlGenericError; - void* oldErrorContext = xmlGenericErrorContext; - - setLoaderForLibXMLCallbacks(docLoader); - xmlSetGenericErrorFunc(0, errorFunc); - - xmlDocPtr sourceDoc = xmlReadMemory(reinterpret_cast<const char*>(source.characters()), - source.length() * sizeof(UChar), - url.latin1().data(), - BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE", - XSLT_PARSE_OPTIONS); - - setLoaderForLibXMLCallbacks(0); - xmlSetGenericErrorFunc(oldErrorContext, oldErrorFunc); +#endif - return sourceDoc; + if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError + || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform)) + handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(), columnNumber()); } -#endif int XMLTokenizer::lineNumber() const { @@ -683,7 +658,7 @@ void XMLTokenizer::parseProcessingInstruction() #if ENABLE(XSLT) m_sawXSLTransform = !m_sawFirstElement && pi->isXSL(); - if (m_sawXSLTransform && !m_doc->transformSourceDocument())) + if (m_sawXSLTransform && !m_doc->transformSourceDocument()) stopParsing(); #endif } |