diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/dom')
38 files changed, 534 insertions, 210 deletions
diff --git a/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.h b/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.h new file mode 100644 index 0000000000..fc5814a987 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.h @@ -0,0 +1,67 @@ +/* + * 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 COMPUTER, 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. + * + */ + +#ifndef BeforeLoadEvent_h +#define BeforeLoadEvent_h + +#include "Event.h" +#include "EventNames.h" + +namespace WebCore { + +class BeforeLoadEvent : public Event { +public: + virtual bool isBeforeLoadEvent() const { return true; } + + static PassRefPtr<BeforeLoadEvent> create(const String& url) + { + return adoptRef(new BeforeLoadEvent(url)); + } + + void initBeforeLoadEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& url) + { + if (dispatched()) + return; + + initEvent(type, canBubble, cancelable); + + m_url = url; + } + + const String& url() const { return m_url; } + +private: + BeforeLoadEvent(const String& url) + : Event(eventNames().beforeloadEvent, false, true) + , m_url(url) + {} + + String m_url; +}; + +} // namespace WebCore + +#endif // BeforeLoadEvent_h diff --git a/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.idl b/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.idl new file mode 100644 index 0000000000..d06a39d291 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.idl @@ -0,0 +1,39 @@ +/* + * 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 COMPUTER, 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. + * + */ + +module events { + + interface [ + GenerateConstructor + ] BeforeLoadEvent : Event { + void initBeforeLoadEvent(in DOMString type, + in boolean canBubble, + in boolean cancelable, + in DOMString url); + readonly attribute DOMString url; + }; + +} diff --git a/src/3rdparty/webkit/WebCore/dom/ContainerNode.cpp b/src/3rdparty/webkit/WebCore/dom/ContainerNode.cpp index 7274b5dc3c..5cd07819d9 100644 --- a/src/3rdparty/webkit/WebCore/dom/ContainerNode.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ContainerNode.cpp @@ -23,6 +23,7 @@ #include "config.h" #include "ContainerNode.h" +#include "BeforeLoadEvent.h" #include "Cache.h" #include "ContainerNodeAlgorithms.h" #include "DeleteButtonController.h" @@ -909,4 +910,15 @@ static void dispatchChildRemovalEvents(Node* child) } } +bool ContainerNode::dispatchBeforeLoadEvent(const String& sourceURL) +{ + if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) + return true; + + RefPtr<ContainerNode> protector(this); + RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL); + dispatchEvent(beforeLoadEvent.get()); + return !beforeLoadEvent->defaultPrevented(); +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/ContainerNode.h b/src/3rdparty/webkit/WebCore/dom/ContainerNode.h index aa480a7e5d..9789f1f22f 100644 --- a/src/3rdparty/webkit/WebCore/dom/ContainerNode.h +++ b/src/3rdparty/webkit/WebCore/dom/ContainerNode.h @@ -71,6 +71,8 @@ public: void removeAllChildren(); void cloneChildNodes(ContainerNode* clone); + + bool dispatchBeforeLoadEvent(const String& sourceURL); protected: ContainerNode(Document*, ConstructionType = CreateContainer); diff --git a/src/3rdparty/webkit/WebCore/dom/Document.cpp b/src/3rdparty/webkit/WebCore/dom/Document.cpp index 6dba900646..4eb44f71ed 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Document.cpp @@ -58,6 +58,7 @@ #include "FrameLoader.h" #include "FrameTree.h" #include "FrameView.h" +#include "HTMLAllCollection.h" #include "HTMLAnchorElement.h" #include "HTMLBodyElement.h" #include "HTMLCanvasElement.h" @@ -511,6 +512,16 @@ Document::~Document() m_styleSheets->documentDestroyed(); } +Document::JSWrapperCache* Document::createWrapperCache(DOMWrapperWorld* world) +{ + JSWrapperCache* wrapperCache = new JSWrapperCache(); + m_wrapperCacheMap.set(world, wrapperCache); +#if USE(JSC) + world->rememberDocument(this); +#endif + return wrapperCache; +} + void Document::resetLinkColor() { m_linkColor = Color(0, 0, 238); @@ -943,7 +954,7 @@ Element* Document::elementFromPoint(int x, int y) const return 0; float zoomFactor = frame->pageZoomFactor(); - IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor, y * zoomFactor)) + view()->scrollOffset(); + IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY())); if (!frameView->visibleContentRect().contains(point)) return 0; @@ -973,7 +984,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y) return 0; float zoomFactor = frame->pageZoomFactor(); - IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor, y * zoomFactor)) + view()->scrollOffset(); + IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY())); if (!frameView->visibleContentRect().contains(point)) return 0; @@ -1561,6 +1572,9 @@ void Document::open(Document* ownerDocument) implicitOpen(); + if (DOMWindow* domWindow = this->domWindow()) + domWindow->removeAllEventListeners(); + if (m_frame) m_frame->loader()->didExplicitOpen(); } @@ -1582,7 +1596,11 @@ void Document::implicitOpen() { cancelParsing(); - clear(); + delete m_tokenizer; + m_tokenizer = 0; + + removeChildren(); + m_tokenizer = createTokenizer(); setParsing(true); @@ -1664,7 +1682,7 @@ void Document::implicitClose() return; } - bool wasLocationChangePending = frame() && frame()->loader()->isScheduledLocationChangePending(); + bool wasLocationChangePending = frame() && frame()->redirectScheduler()->locationChangePending(); bool doload = !parsing() && m_tokenizer && !m_processingLoadEvent && !wasLocationChangePending; if (!doload) @@ -1711,7 +1729,7 @@ void Document::implicitClose() if (f) f->animation()->resumeAnimations(this); - ImageLoader::dispatchPendingLoadEvents(); + ImageLoader::dispatchPendingEvents(); dispatchWindowLoadEvent(); dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, false), this); if (f) @@ -1731,7 +1749,7 @@ void Document::implicitClose() // fires. This will improve onload scores, and other browsers do it. // If they wanna cheat, we can too. -dwh - if (frame()->loader()->isScheduledLocationChangePending() && elapsedTime() < cLayoutScheduleThreshold) { + if (frame()->redirectScheduler()->locationChangePending() && elapsedTime() < cLayoutScheduleThreshold) { // Just bail out. Before or during the onload we were shifted to another page. // The old i-Bench suite does this. When this happens don't bother painting or laying out. view()->unscheduleRelayout(); @@ -1860,16 +1878,6 @@ void Document::finishParsing() m_tokenizer->finish(); } -void Document::clear() -{ - delete m_tokenizer; - m_tokenizer = 0; - - removeChildren(); - if (DOMWindow* domWindow = this->domWindow()) - domWindow->removeAllEventListeners(); -} - const KURL& Document::virtualURL() const { return m_url; @@ -1969,7 +1977,7 @@ 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())) + if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist())) continue; RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url()); parsedSheet->setIsUserStyleSheet(true); @@ -2160,7 +2168,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content) url = frame->loader()->url().string(); else url = completeURL(url).string(); - frame->loader()->scheduleHTTPRedirection(delay, url); + frame->redirectScheduler()->scheduleRedirect(delay, url); } } else if (equalIgnoringCase(equiv, "set-cookie")) { // FIXME: make setCookie work on XML documents too; e.g. in case of <html:meta .....> @@ -2174,7 +2182,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content) FrameLoader* frameLoader = frame->loader(); if (frameLoader->shouldInterruptLoadForXFrameOptions(content, url())) { frameLoader->stopAllLoaders(); - frameLoader->scheduleLocationChange(blankURL(), String()); + frame->redirectScheduler()->scheduleLocationChange(blankURL(), String()); } } } @@ -2357,8 +2365,8 @@ void Document::removePendingSheet() if (!m_pendingStylesheets && m_tokenizer) m_tokenizer->executeScriptsWaitingForStylesheets(); - if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && m_frame) - m_frame->loader()->gotoAnchor(); + if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view()) + view()->scrollToFragment(m_frame->loader()->url()); } void Document::updateStyleSelector() @@ -2894,42 +2902,47 @@ void Document::dispatchWindowLoadEvent() PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& ec) { + RefPtr<Event> event; if (eventType == "Event" || eventType == "Events" || eventType == "HTMLEvents") - return Event::create(); - if (eventType == "KeyboardEvent" || eventType == "KeyboardEvents") - return KeyboardEvent::create(); - if (eventType == "MessageEvent") - return MessageEvent::create(); - if (eventType == "MouseEvent" || eventType == "MouseEvents") - return MouseEvent::create(); - if (eventType == "MutationEvent" || eventType == "MutationEvents") - return MutationEvent::create(); - if (eventType == "OverflowEvent") - return OverflowEvent::create(); - if (eventType == "PageTransitionEvent") - return PageTransitionEvent::create(); - if (eventType == "ProgressEvent") - return ProgressEvent::create(); + event = Event::create(); + else if (eventType == "KeyboardEvent" || eventType == "KeyboardEvents") + event = KeyboardEvent::create(); + else if (eventType == "MessageEvent") + event = MessageEvent::create(); + else if (eventType == "MouseEvent" || eventType == "MouseEvents") + event = MouseEvent::create(); + else if (eventType == "MutationEvent" || eventType == "MutationEvents") + event = MutationEvent::create(); + else if (eventType == "OverflowEvent") + event = OverflowEvent::create(); + else if (eventType == "PageTransitionEvent") + event = PageTransitionEvent::create(); + else if (eventType == "ProgressEvent") + event = ProgressEvent::create(); #if ENABLE(DOM_STORAGE) - if (eventType == "StorageEvent") - return StorageEvent::create(); + else if (eventType == "StorageEvent") + event = StorageEvent::create(); #endif - if (eventType == "TextEvent") - return TextEvent::create(); - if (eventType == "UIEvent" || eventType == "UIEvents") - return UIEvent::create(); - if (eventType == "WebKitAnimationEvent") - return WebKitAnimationEvent::create(); - if (eventType == "WebKitTransitionEvent") - return WebKitTransitionEvent::create(); - if (eventType == "WheelEvent") - return WheelEvent::create(); + else if (eventType == "TextEvent") + event = TextEvent::create(); + else if (eventType == "UIEvent" || eventType == "UIEvents") + event = UIEvent::create(); + else if (eventType == "WebKitAnimationEvent") + event = WebKitAnimationEvent::create(); + else if (eventType == "WebKitTransitionEvent") + event = WebKitTransitionEvent::create(); + else if (eventType == "WheelEvent") + event = WheelEvent::create(); #if ENABLE(SVG) - if (eventType == "SVGEvents") - return Event::create(); - if (eventType == "SVGZoomEvents") - return SVGZoomEvent::create(); + else if (eventType == "SVGEvents") + event = Event::create(); + else if (eventType == "SVGZoomEvents") + event = SVGZoomEvent::create(); #endif + if (event) { + event->setCreatedByDOM(true); + return event.release(); + } ec = NOT_SUPPORTED_ERR; return 0; } @@ -2960,6 +2973,8 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType) addListenerType(ANIMATIONITERATION_LISTENER); else if (eventType == eventNames().webkitTransitionEndEvent) addListenerType(TRANSITIONEND_LISTENER); + else if (eventType == eventNames().beforeloadEvent) + addListenerType(BEFORELOAD_LISTENER); } CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&) @@ -3984,9 +3999,9 @@ PassRefPtr<HTMLCollection> Document::anchors() return HTMLCollection::create(this, DocAnchors); } -PassRefPtr<HTMLCollection> Document::all() +PassRefPtr<HTMLAllCollection> Document::all() { - return HTMLCollection::create(this, DocAll); + return HTMLAllCollection::create(this); } PassRefPtr<HTMLCollection> Document::windowNamedItems(const String &name) @@ -4016,8 +4031,17 @@ void Document::finishedParsing() { setParsing(false); dispatchEvent(Event::create(eventNames().DOMContentLoadedEvent, true, false)); - if (Frame* f = frame()) + if (Frame* f = frame()) { f->loader()->finishedParsing(); + +#if ENABLE(INSPECTOR) + if (!page()) + return; + + if (InspectorController* controller = page()->inspectorController()) + controller->mainResourceFiredDOMContentEvent(f->loader()->documentLoader(), url()); +#endif + } } Vector<String> Document::formElementsState() const @@ -4230,7 +4254,7 @@ void Document::initSecurityContext() m_cookieURL = url; ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(url)); - if (FrameLoader::allowSubstituteDataAccessToLocal()) { + if (SecurityOrigin::allowSubstituteDataAccessToLocal()) { // If this document was loaded with substituteData, then the document can // load local resources. See https://bugs.webkit.org/show_bug.cgi?id=16756 // and https://bugs.webkit.org/show_bug.cgi?id=19760 for further @@ -4494,7 +4518,7 @@ void Document::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const Frame* frame = this->frame(); if (frame) { FrameLoader* frameLoader = frame->loader(); - frameLoader->didLoadResourceByXMLHttpRequest(identifier, sourceString); + frameLoader->notifier()->didLoadResourceByXMLHttpRequest(identifier, sourceString); } } diff --git a/src/3rdparty/webkit/WebCore/dom/Document.h b/src/3rdparty/webkit/WebCore/dom/Document.h index f05c9f9702..0632be1033 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.h +++ b/src/3rdparty/webkit/WebCore/dom/Document.h @@ -71,6 +71,7 @@ namespace WebCore { class HitTestRequest; class HTMLCanvasElement; class HTMLCollection; + class HTMLAllCollection; class HTMLDocument; class HTMLElement; class HTMLFormElement; @@ -79,6 +80,7 @@ namespace WebCore { class HTMLMapElement; class InspectorTimelineAgent; class IntPoint; + class DOMWrapperWorld; class JSNode; class MouseEventWithHitTestResults; class NodeFilter; @@ -315,12 +317,13 @@ public: PassRefPtr<HTMLCollection> links(); PassRefPtr<HTMLCollection> forms(); PassRefPtr<HTMLCollection> anchors(); - PassRefPtr<HTMLCollection> all(); PassRefPtr<HTMLCollection> objects(); PassRefPtr<HTMLCollection> scripts(); PassRefPtr<HTMLCollection> windowNamedItems(const String& name); PassRefPtr<HTMLCollection> documentNamedItems(const String& name); + PassRefPtr<HTMLAllCollection> all(); + // Find first anchor with the given name. // First searches for an element with the given ID, but if that fails, then looks // for an anchor with the given name. ID matching is always case sensitive, but @@ -473,7 +476,6 @@ public: void write(const String& text, Document* ownerDocument = 0); void writeln(const String& text, Document* ownerDocument = 0); void finishParsing(); - void clear(); bool wellFormed() const { return m_wellFormed; } @@ -615,7 +617,8 @@ public: ANIMATIONEND_LISTENER = 0x100, ANIMATIONSTART_LISTENER = 0x200, ANIMATIONITERATION_LISTENER = 0x400, - TRANSITIONEND_LISTENER = 0x800 + TRANSITIONEND_LISTENER = 0x800, + BEFORELOAD_LISTENER = 0x1000 }; bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); } @@ -819,7 +822,15 @@ public: virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously. typedef HashMap<WebCore::Node*, JSNode*> JSWrapperCache; - JSWrapperCache& wrapperCache() { return m_wrapperCache; } + typedef HashMap<DOMWrapperWorld*, JSWrapperCache*> JSWrapperCacheMap; + JSWrapperCacheMap& wrapperCacheMap() { return m_wrapperCacheMap; } + JSWrapperCache* getWrapperCache(DOMWrapperWorld* world) + { + if (JSWrapperCache* wrapperCache = m_wrapperCacheMap.get(world)) + return wrapperCache; + return createWrapperCache(world); + } + JSWrapperCache* createWrapperCache(DOMWrapperWorld*); virtual void finishedParsing(); @@ -1137,7 +1148,7 @@ private: unsigned m_numNodeListCaches; - JSWrapperCache m_wrapperCache; + JSWrapperCacheMap m_wrapperCacheMap; #if ENABLE(DATABASE) RefPtr<DatabaseThread> m_databaseThread; diff --git a/src/3rdparty/webkit/WebCore/dom/Document.idl b/src/3rdparty/webkit/WebCore/dom/Document.idl index 822f860330..e9b5480571 100644 --- a/src/3rdparty/webkit/WebCore/dom/Document.idl +++ b/src/3rdparty/webkit/WebCore/dom/Document.idl @@ -172,6 +172,9 @@ module core { attribute HTMLElement body setter raises (DOMException); +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute HTMLHeadElement head; +#endif readonly attribute HTMLCollection images; readonly attribute HTMLCollection applets; readonly attribute HTMLCollection links; diff --git a/src/3rdparty/webkit/WebCore/dom/Element.cpp b/src/3rdparty/webkit/WebCore/dom/Element.cpp index 50ff033b7e..6924773765 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Element.cpp @@ -123,6 +123,7 @@ PassRefPtr<Element> Element::cloneElementWithoutChildren() void Element::removeAttribute(const QualifiedName& name, ExceptionCode& ec) { if (namedAttrMap) { + ec = 0; namedAttrMap->removeNamedItem(name, ec); if (ec == NOT_FOUND_ERR) ec = 0; @@ -515,7 +516,7 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value, return; } - const AtomicString& localName = (shouldIgnoreAttributeCase(this) && !name.string().impl()->isLower()) ? AtomicString(name.string().lower()) : name; + const AtomicString& localName = shouldIgnoreAttributeCase(this) ? name.lower() : name; // allocate attributemap if necessary Attribute* old = attributes(false)->getAttributeItem(localName, false); @@ -751,7 +752,7 @@ void Element::detach() bool Element::pseudoStyleCacheIsInvalid(const RenderStyle* currentStyle, RenderStyle* newStyle) { - ASSERT(currentStyle = renderStyle()); + ASSERT(currentStyle == renderStyle()); if (!renderer() || !currentStyle) return false; @@ -1413,7 +1414,7 @@ KURL Element::getURLAttribute(const QualifiedName& name) const ASSERT(isURLAttribute(attribute)); } #endif - return document()->completeURL(getAttribute(name)); + return document()->completeURL(deprecatedParseURL(getAttribute(name))); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/Event.cpp b/src/3rdparty/webkit/WebCore/dom/Event.cpp index 4088e2c45b..ba310ef609 100644 --- a/src/3rdparty/webkit/WebCore/dom/Event.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Event.cpp @@ -35,6 +35,7 @@ Event::Event() , m_defaultPrevented(false) , m_defaultHandled(false) , m_cancelBubble(false) + , m_createdByDOM(false) , m_eventPhase(0) , m_currentTarget(0) , m_createTime(static_cast<DOMTimeStamp>(currentTime() * 1000.0)) @@ -49,6 +50,7 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr , m_defaultPrevented(false) , m_defaultHandled(false) , m_cancelBubble(false) + , m_createdByDOM(false) , m_eventPhase(0) , m_currentTarget(0) , m_createTime(static_cast<DOMTimeStamp>(currentTime() * 1000.0)) @@ -149,6 +151,11 @@ bool Event::isXMLHttpRequestProgressEvent() const return false; } +bool Event::isBeforeLoadEvent() const +{ + return false; +} + #if ENABLE(SVG) bool Event::isSVGZoomEvent() const { diff --git a/src/3rdparty/webkit/WebCore/dom/Event.h b/src/3rdparty/webkit/WebCore/dom/Event.h index 7d06378bd6..74a2f10a8e 100644 --- a/src/3rdparty/webkit/WebCore/dom/Event.h +++ b/src/3rdparty/webkit/WebCore/dom/Event.h @@ -114,6 +114,7 @@ namespace WebCore { virtual bool isXMLHttpRequestProgressEvent() const; virtual bool isWebKitAnimationEvent() const; virtual bool isWebKitTransitionEvent() const; + virtual bool isBeforeLoadEvent() const; #if ENABLE(SVG) virtual bool isSVGZoomEvent() const; #endif @@ -144,6 +145,9 @@ namespace WebCore { virtual Clipboard* clipboard() const { return 0; } + bool createdByDOM() const { return m_createdByDOM; } + void setCreatedByDOM(bool createdByDOM) { m_createdByDOM = createdByDOM; } + protected: Event(); Event(const AtomicString& type, bool canBubble, bool cancelable); @@ -161,6 +165,9 @@ namespace WebCore { bool m_defaultHandled; bool m_cancelBubble; + // Whether this event was created by document.createEvent(). + bool m_createdByDOM; + unsigned short m_eventPhase; EventTarget* m_currentTarget; RefPtr<EventTarget> m_target; diff --git a/src/3rdparty/webkit/WebCore/dom/EventNames.h b/src/3rdparty/webkit/WebCore/dom/EventNames.h index 0eb98ec4e9..2c4cd32dbe 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventNames.h +++ b/src/3rdparty/webkit/WebCore/dom/EventNames.h @@ -32,6 +32,7 @@ namespace WebCore { macro(abort) \ macro(beforecopy) \ macro(beforecut) \ + macro(beforeload) \ macro(beforepaste) \ macro(beforeunload) \ macro(blur) \ @@ -63,7 +64,6 @@ namespace WebCore { macro(keypress) \ macro(keyup) \ macro(load) \ - macro(loadend) \ macro(loadstart) \ macro(message) \ macro(mousedown) \ diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp index ceb5221a3e..694e78a618 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.cpp @@ -192,9 +192,16 @@ bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen // Notify firing events planning to invoke the listener at 'index' that // they have one less listener to invoke. - for (size_t i = 0; i < d->firingEventEndIterators.size(); ++i) { - if (eventType == *d->firingEventEndIterators[i].eventType && index < *d->firingEventEndIterators[i].value) - --*d->firingEventEndIterators[i].value; + for (size_t i = 0; i < d->firingEventIterators.size(); ++i) { + if (eventType != d->firingEventIterators[i].eventType) + continue; + + if (index >= d->firingEventIterators[i].end) + continue; + + --d->firingEventIterators[i].end; + if (index <= d->firingEventIterators[i].iterator) + --d->firingEventIterators[i].iterator; } return true; @@ -232,6 +239,10 @@ bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR; return false; } + + if (!scriptExecutionContext()) + return false; + return dispatchEvent(event); } @@ -259,9 +270,15 @@ bool EventTarget::fireEventListeners(Event* event) RefPtr<EventTarget> protect = this; + // Fire all listeners registered for this event. Don't fire listeners removed + // during event dispatch. Also, don't fire event listeners added during event + // dispatch. Conveniently, all new event listeners will be added after 'end', + // so iterating to 'end' naturally excludes new event listeners. + + size_t i = 0; size_t end = entry.size(); - d->firingEventEndIterators.append(FiringEventEndIterator(&event->type(), &end)); - for (size_t i = 0; i < end; ++i) { + d->firingEventIterators.append(FiringEventIterator(event->type(), i, end)); + for ( ; i < end; ++i) { RegisteredEventListener& registeredListener = entry[i]; if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener.useCapture) continue; @@ -271,7 +288,7 @@ bool EventTarget::fireEventListeners(Event* event) // event listeners, even though that violates some versions of the DOM spec. registeredListener.listener->handleEvent(scriptExecutionContext(), event); } - d->firingEventEndIterators.removeLast(); + d->firingEventIterators.removeLast(); return !event->defaultPrevented(); } @@ -298,8 +315,10 @@ void EventTarget::removeAllEventListeners() // Notify firing events planning to invoke the listener at 'index' that // they have one less listener to invoke. - for (size_t i = 0; i < d->firingEventEndIterators.size(); ++i) - *d->firingEventEndIterators[i].value = 0; + for (size_t i = 0; i < d->firingEventIterators.size(); ++i) { + d->firingEventIterators[i].iterator = 0; + d->firingEventIterators[i].end = 0; + } } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/EventTarget.h b/src/3rdparty/webkit/WebCore/dom/EventTarget.h index 2d612e164d..9a1975c490 100644 --- a/src/3rdparty/webkit/WebCore/dom/EventTarget.h +++ b/src/3rdparty/webkit/WebCore/dom/EventTarget.h @@ -61,24 +61,26 @@ namespace WebCore { typedef int ExceptionCode; - struct FiringEventEndIterator { - FiringEventEndIterator(const AtomicString* eventType, size_t* value) + struct FiringEventIterator { + FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end) : eventType(eventType) - , value(value) + , iterator(iterator) + , end(end) { } - - const AtomicString* eventType; - size_t* value; + + const AtomicString& eventType; + size_t& iterator; + size_t& end; }; - typedef Vector<FiringEventEndIterator, 1> FiringEventEndIteratorVector; + typedef Vector<FiringEventIterator, 1> FiringEventIteratorVector; typedef Vector<RegisteredEventListener, 1> EventListenerVector; typedef HashMap<AtomicString, EventListenerVector> EventListenerMap; struct EventTargetData { EventListenerMap eventListenerMap; - FiringEventEndIteratorVector firingEventEndIterators; + FiringEventIteratorVector firingEventIterators; }; class EventTarget { @@ -209,7 +211,7 @@ namespace WebCore { EventTargetData* d = eventTargetData(); if (!d) return false; - return d->firingEventEndIterators.size() != 0; + return d->firingEventIterators.size() != 0; } inline bool EventTarget::hasEventListeners() diff --git a/src/3rdparty/webkit/WebCore/dom/ExceptionBase.cpp b/src/3rdparty/webkit/WebCore/dom/ExceptionBase.cpp index c73d5142ae..d175d8b1fb 100644 --- a/src/3rdparty/webkit/WebCore/dom/ExceptionBase.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ExceptionBase.cpp @@ -34,6 +34,7 @@ namespace WebCore { ExceptionBase::ExceptionBase(const ExceptionCodeDescription& description) : m_code(description.code) , m_name(description.name) + , m_description(description.description) { if (description.name) m_message = String::format("%s: %s Exception %d", description.name, description.typeName, description.code); diff --git a/src/3rdparty/webkit/WebCore/dom/ExceptionBase.h b/src/3rdparty/webkit/WebCore/dom/ExceptionBase.h index 44fad7e205..81e2d7f9b9 100644 --- a/src/3rdparty/webkit/WebCore/dom/ExceptionBase.h +++ b/src/3rdparty/webkit/WebCore/dom/ExceptionBase.h @@ -40,6 +40,7 @@ namespace WebCore { unsigned short code() const { return m_code; } String name() const { return m_name; } String message() const { return m_message; } + String description() const { return m_description; } String toString() const; @@ -50,6 +51,7 @@ namespace WebCore { unsigned short m_code; String m_name; String m_message; + String m_description; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.cpp b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.cpp index 0291a211ff..7bb8a50a06 100644 --- a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.cpp @@ -65,25 +65,70 @@ static const char* const exceptionNames[] = { "QUOTA_EXCEEDED_ERR" }; +static const char* const exceptionDescriptions[] = { + "Index or size was negative, or greater than the allowed value.", + "The specified range of text did not fit into a DOMString.", + "A Node was inserted somewhere it doesn't belong.", + "A Node was used in a different document than the one that created it (that doesn't support it).", + "An invalid or illegal character was specified, such as in an XML name.", + "Data was specified for a Node which does not support data.", + "An attempt was made to modify an object where modifications are not allowed.", + "An attempt was made to reference a Node in a context where it does not exist.", + "The implementation did not support the requested type of object or operation.", + "An attempt was made to add an attribute that is already in use elsewhere.", + "An attempt was made to use an object that is not, or is no longer, usable.", + "An invalid or illegal string was specified.", + "An attempt was made to modify the type of the underlying object.", + "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces.", + "A parameter or an operation was not supported by the underlying object.", + "A call to a method such as insertBefore or removeChild would make the Node invalid with respect to \"partial validity\", this exception would be raised and the operation would not be done.", + "The type of an object was incompatible with the expected type of the parameter associated to the object.", + "An attempt was made to break through the security policy of the user agent.", + // FIXME: Couldn't find a description in the HTML/DOM specifications for NETWORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, and QUOTA_EXCEEDED_ERR + "A network error occured.", + "The user aborted a request.", + "A worker global scope represented an absolute URL that is not equal to the resulting absolute URL.", + "An attempt was made to add something to storage that exceeded the quota." +}; + static const char* const rangeExceptionNames[] = { "BAD_BOUNDARYPOINTS_ERR", "INVALID_NODE_TYPE_ERR" }; +static const char* const rangeExceptionDescriptions[] = { + "The boundary-points of a Range did not meet specific requirements.", + "The container of an boundary-point of a Range was being set to either a node of an invalid type or a node with an ancestor of an invalid type." +}; + static const char* const eventExceptionNames[] = { "UNSPECIFIED_EVENT_TYPE_ERR" }; +static const char* const eventExceptionDescriptions[] = { + "The Event's type was not specified by initializing the event before the method was called." +}; + static const char* const xmlHttpRequestExceptionNames[] = { "NETWORK_ERR", "ABORT_ERR" }; +static const char* const xmlHttpRequestExceptionDescriptions[] = { + "A network error occured in synchronous requests.", + "The user aborted a request in synchronous requests." +}; + #if ENABLE(XPATH) static const char* const xpathExceptionNames[] = { "INVALID_EXPRESSION_ERR", "TYPE_ERR" }; + +static const char* const xpathExceptionDescriptions[] = { + "The expression had a syntax error or otherwise is not a legal expression according to the rules of the specific XPathEvaluator.", + "The expression could not be converted to return the specified type." +}; #endif #if ENABLE(SVG) @@ -92,6 +137,12 @@ static const char* const svgExceptionNames[] = { "SVG_INVALID_VALUE_ERR", "SVG_MATRIX_NOT_INVERTABLE" }; + +static const char* const svgExceptionDescriptions[] = { + "An object of the wrong type was passed to an operation.", + "An invalid value was passed to an operation or assigned to an attribute.", + "An attempt was made to invert a matrix that is not invertible." +}; #endif void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& description) @@ -101,6 +152,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des const char* typeName; int code = ec; const char* const* nameTable; + const char* const* descriptionTable; int nameTableSize; int nameTableOffset; ExceptionType type; @@ -110,6 +162,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des typeName = "DOM Range"; code -= RangeException::RangeExceptionOffset; nameTable = rangeExceptionNames; + descriptionTable = rangeExceptionDescriptions; nameTableSize = sizeof(rangeExceptionNames) / sizeof(rangeExceptionNames[0]); nameTableOffset = RangeException::BAD_BOUNDARYPOINTS_ERR; } else if (code >= EventException::EventExceptionOffset && code <= EventException::EventExceptionMax) { @@ -117,6 +170,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des typeName = "DOM Events"; code -= EventException::EventExceptionOffset; nameTable = eventExceptionNames; + descriptionTable = eventExceptionDescriptions; nameTableSize = sizeof(eventExceptionNames) / sizeof(eventExceptionNames[0]); nameTableOffset = EventException::UNSPECIFIED_EVENT_TYPE_ERR; } else if (code >= XMLHttpRequestException::XMLHttpRequestExceptionOffset && code <= XMLHttpRequestException::XMLHttpRequestExceptionMax) { @@ -124,6 +178,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des typeName = "XMLHttpRequest"; code -= XMLHttpRequestException::XMLHttpRequestExceptionOffset; nameTable = xmlHttpRequestExceptionNames; + descriptionTable = xmlHttpRequestExceptionDescriptions; nameTableSize = sizeof(xmlHttpRequestExceptionNames) / sizeof(xmlHttpRequestExceptionNames[0]); // XMLHttpRequest exception codes start with 101 and we don't want 100 empty elements in the name array nameTableOffset = XMLHttpRequestException::NETWORK_ERR; @@ -133,6 +188,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des typeName = "DOM XPath"; code -= XPathException::XPathExceptionOffset; nameTable = xpathExceptionNames; + descriptionTable = xpathExceptionDescriptions; nameTableSize = sizeof(xpathExceptionNames) / sizeof(xpathExceptionNames[0]); // XPath exception codes start with 51 and we don't want 51 empty elements in the name array nameTableOffset = XPathException::INVALID_EXPRESSION_ERR; @@ -143,6 +199,7 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des typeName = "DOM SVG"; code -= SVGException::SVGExceptionOffset; nameTable = svgExceptionNames; + descriptionTable = svgExceptionDescriptions; nameTableSize = sizeof(svgExceptionNames) / sizeof(svgExceptionNames[0]); nameTableOffset = SVGException::SVG_WRONG_TYPE_ERR; #endif @@ -150,17 +207,20 @@ void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des type = DOMExceptionType; typeName = "DOM"; nameTable = exceptionNames; + descriptionTable = exceptionDescriptions; nameTableSize = sizeof(exceptionNames) / sizeof(exceptionNames[0]); nameTableOffset = INDEX_SIZE_ERR; } description.typeName = typeName; description.name = (ec >= nameTableOffset && ec - nameTableOffset < nameTableSize) ? nameTable[ec - nameTableOffset] : 0; + description.description = (ec >= nameTableOffset && ec - nameTableOffset < nameTableSize) ? descriptionTable[ec - nameTableOffset] : 0; description.code = code; description.type = type; // All exceptions used in the DOM code should have names. ASSERT(description.name); + ASSERT(description.description); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h index 58b18e2303..573fb365dc 100644 --- a/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h +++ b/src/3rdparty/webkit/WebCore/dom/ExceptionCode.h @@ -77,6 +77,7 @@ namespace WebCore { struct ExceptionCodeDescription { const char* typeName; // has spaces and is suitable for use in exception description strings; maximum length is 10 characters const char* name; // exception name, also intended for use in exception description strings; 0 if name not known; maximum length is 27 characters + const char* description; // exception description, intended for use in exception strings; more readable explanation of error int code; // numeric value of the exception within a particular type ExceptionType type; }; diff --git a/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl b/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl deleted file mode 100644 index dee365f01f..0000000000 --- a/src/3rdparty/webkit/WebCore/dom/HTMLAllCollection.idl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2008, 2009 Google 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: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE COPYRIGHT - * OWNER 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. - */ - -module html { - - // This interface is used for undetectable HTMLCollections. - // An undetectable HTMLCollection behaves like an HTMLCollection - // when used, but the 'typeof' operator returns undefined and - // ToBoolean returns false. - interface HTMLAllCollection : HTMLCollection { - }; - -} diff --git a/src/3rdparty/webkit/WebCore/dom/MessageEvent.cpp b/src/3rdparty/webkit/WebCore/dom/MessageEvent.cpp index 2ef8bc29c0..3c8464281d 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessageEvent.cpp +++ b/src/3rdparty/webkit/WebCore/dom/MessageEvent.cpp @@ -34,10 +34,11 @@ namespace WebCore { MessageEvent::MessageEvent() + : m_data(SerializedScriptValue::create()) { } -MessageEvent::MessageEvent(const String& data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports) +MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports) : Event(eventNames().messageEvent, false, false) , m_data(data) , m_origin(origin) @@ -51,7 +52,7 @@ MessageEvent::~MessageEvent() { } -void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports) +void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports) { if (dispatched()) return; @@ -74,7 +75,7 @@ MessagePort* MessageEvent::messagePort() return (*m_ports)[0].get(); } -void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort* port) +void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort* port) { MessagePortArray* ports = 0; if (port) { diff --git a/src/3rdparty/webkit/WebCore/dom/MessageEvent.h b/src/3rdparty/webkit/WebCore/dom/MessageEvent.h index 555ed471c0..b7f9b0292e 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessageEvent.h +++ b/src/3rdparty/webkit/WebCore/dom/MessageEvent.h @@ -31,6 +31,7 @@ #include "DOMWindow.h" #include "Event.h" #include "MessagePort.h" +#include "SerializedScriptValue.h" namespace WebCore { @@ -42,15 +43,15 @@ namespace WebCore { { return adoptRef(new MessageEvent); } - static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, const String& data = "", const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) + static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data = 0, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) { return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports)); } virtual ~MessageEvent(); - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>); + void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>); - const String& data() const { return m_data; } + SerializedScriptValue* data() const { return m_data.get(); } const String& origin() const { return m_origin; } const String& lastEventId() const { return m_lastEventId; } DOMWindow* source() const { return m_source.get(); } @@ -59,15 +60,15 @@ namespace WebCore { // FIXME: remove this when we update the ObjC bindings (bug #28774). MessagePort* messagePort(); // FIXME: remove this when we update the ObjC bindings (bug #28774). - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*); + void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*); virtual bool isMessageEvent() const; private: MessageEvent(); - MessageEvent(const String& data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>); + MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>); - String m_data; + RefPtr<SerializedScriptValue> m_data; String m_origin; String m_lastEventId; RefPtr<DOMWindow> m_source; diff --git a/src/3rdparty/webkit/WebCore/dom/MessageEvent.idl b/src/3rdparty/webkit/WebCore/dom/MessageEvent.idl index a32cc93ab0..7e497fcd05 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessageEvent.idl +++ b/src/3rdparty/webkit/WebCore/dom/MessageEvent.idl @@ -30,20 +30,20 @@ module events { GenerateConstructor, NoStaticTables ] MessageEvent : Event { + readonly attribute SerializedScriptValue data; - readonly attribute DOMString data; readonly attribute DOMString origin; readonly attribute DOMString lastEventId; readonly attribute DOMWindow source; #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT readonly attribute [CustomGetter] Array ports; - [Custom] void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString dataArg, in DOMString originArg, in DOMString lastEventIdArg, in DOMWindow sourceArg, in Array messagePorts); + [Custom] void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in SerializedScriptValue dataArg, in DOMString originArg, in DOMString lastEventIdArg, in DOMWindow sourceArg, in Array messagePorts); #else // There's no good way to expose an array via the ObjC bindings, so for now just expose a single port. readonly attribute MessagePort messagePort; - void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString dataArg, in DOMString originArg, in DOMString lastEventIdArg, in DOMWindow sourceArg, in MessagePort messagePort); + void initMessageEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in SerializedScriptValue dataArg, in DOMString originArg, in DOMString lastEventIdArg, in DOMWindow sourceArg, in MessagePort messagePort); #endif }; diff --git a/src/3rdparty/webkit/WebCore/dom/MessagePort.cpp b/src/3rdparty/webkit/WebCore/dom/MessagePort.cpp index 50a0106536..9f6e6499cc 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessagePort.cpp +++ b/src/3rdparty/webkit/WebCore/dom/MessagePort.cpp @@ -56,7 +56,7 @@ MessagePort::~MessagePort() } // FIXME: remove this when we update the ObjC bindings (bug #28774). -void MessagePort::postMessage(const String& message, MessagePort* port, ExceptionCode& ec) +void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, ExceptionCode& ec) { MessagePortArray ports; if (port) @@ -64,12 +64,12 @@ void MessagePort::postMessage(const String& message, MessagePort* port, Exceptio postMessage(message, &ports, ec); } -void MessagePort::postMessage(const String& message, ExceptionCode& ec) +void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, ExceptionCode& ec) { postMessage(message, static_cast<MessagePortArray*>(0), ec); } -void MessagePort::postMessage(const String& message, const MessagePortArray* ports, ExceptionCode& ec) +void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec) { if (!m_entangledChannel) return; diff --git a/src/3rdparty/webkit/WebCore/dom/MessagePort.h b/src/3rdparty/webkit/WebCore/dom/MessagePort.h index e649d5d901..0ab0f505a4 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessagePort.h +++ b/src/3rdparty/webkit/WebCore/dom/MessagePort.h @@ -56,10 +56,10 @@ namespace WebCore { static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(new MessagePort(scriptExecutionContext)); } ~MessagePort(); - void postMessage(const String& message, ExceptionCode&); - void postMessage(const String& message, const MessagePortArray*, ExceptionCode&); + void postMessage(PassRefPtr<SerializedScriptValue> message, ExceptionCode&); + void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&); // FIXME: remove this when we update the ObjC bindings (bug #28774). - void postMessage(const String& message, MessagePort*, ExceptionCode&); + void postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*, ExceptionCode&); void start(); void close(); diff --git a/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.cpp b/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.cpp index 34b2ce7c8f..e1a3ac6f31 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.cpp +++ b/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.cpp @@ -33,13 +33,13 @@ namespace WebCore { -PassOwnPtr<MessagePortChannel::EventData> MessagePortChannel::EventData::create(const String& message, PassOwnPtr<MessagePortChannelArray> channels) +PassOwnPtr<MessagePortChannel::EventData> MessagePortChannel::EventData::create(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) { return new EventData(message, channels); } -MessagePortChannel::EventData::EventData(const String& message, PassOwnPtr<MessagePortChannelArray> channels) - : m_message(message.copy()) +MessagePortChannel::EventData::EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) + : m_message(message->release()) , m_channels(channels) { } diff --git a/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.h b/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.h index 4acfe7feae..2321b1f50e 100644 --- a/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.h +++ b/src/3rdparty/webkit/WebCore/dom/MessagePortChannel.h @@ -33,6 +33,8 @@ #include "PlatformString.h" +#include "SerializedScriptValue.h" + #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> @@ -45,6 +47,7 @@ namespace WebCore { class MessagePortChannel; class PlatformMessagePortChannel; class ScriptExecutionContext; + class SerializedScriptValue; class String; // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1. @@ -77,14 +80,14 @@ namespace WebCore { class EventData { public: - static PassOwnPtr<EventData> create(const String&, PassOwnPtr<MessagePortChannelArray>); + static PassOwnPtr<EventData> create(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>); - const String& message() { return m_message; } + SerializedScriptValue* message() { return m_message.get(); } PassOwnPtr<MessagePortChannelArray> channels() { return m_channels.release(); } private: - EventData(const String& message, PassOwnPtr<MessagePortChannelArray>); - String m_message; + EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray>); + RefPtr<SerializedScriptValue> m_message; OwnPtr<MessagePortChannelArray> m_channels; }; diff --git a/src/3rdparty/webkit/WebCore/dom/MouseRelatedEvent.cpp b/src/3rdparty/webkit/WebCore/dom/MouseRelatedEvent.cpp index 4ed85ce8bc..87815b1bad 100644 --- a/src/3rdparty/webkit/WebCore/dom/MouseRelatedEvent.cpp +++ b/src/3rdparty/webkit/WebCore/dom/MouseRelatedEvent.cpp @@ -57,7 +57,7 @@ static int contentsX(AbstractView* abstractView) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollX(); + return frameView->scrollX() / frame->pageZoomFactor(); } static int contentsY(AbstractView* abstractView) @@ -70,7 +70,7 @@ static int contentsY(AbstractView* abstractView) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollY(); + return frameView->scrollY() / frame->pageZoomFactor(); } MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> viewArg, diff --git a/src/3rdparty/webkit/WebCore/dom/ProcessingInstruction.cpp b/src/3rdparty/webkit/WebCore/dom/ProcessingInstruction.cpp index 84044810ac..72993dd271 100644 --- a/src/3rdparty/webkit/WebCore/dom/ProcessingInstruction.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ProcessingInstruction.cpp @@ -64,6 +64,7 @@ void ProcessingInstruction::setData(const String& data, ExceptionCode&) int oldLength = m_data.length(); m_data = data; document()->textRemoved(this, 0, oldLength); + checkStyleSheet(); } String ProcessingInstruction::nodeName() const @@ -142,13 +143,21 @@ void ProcessingInstruction::checkStyleSheet() } #endif } else { + if (m_cachedSheet) { + m_cachedSheet->removeClient(this); + m_cachedSheet = 0; + } + + String url = document()->completeURL(href).string(); + if (!dispatchBeforeLoadEvent(url)) + return; + m_loading = true; document()->addPendingSheet(); - if (m_cachedSheet) - m_cachedSheet->removeClient(this); + #if ENABLE(XSLT) if (m_isXSL) - m_cachedSheet = document()->docLoader()->requestXSLStyleSheet(document()->completeURL(href).string()); + m_cachedSheet = document()->docLoader()->requestXSLStyleSheet(url); else #endif { @@ -156,10 +165,15 @@ void ProcessingInstruction::checkStyleSheet() if (charset.isEmpty()) charset = document()->frame()->loader()->encoding(); - m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(document()->completeURL(href).string(), charset); + m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(url, charset); } if (m_cachedSheet) m_cachedSheet->addClient(this); + else { + // The request may have been denied if (for example) the stylesheet is local and the document is remote. + m_loading = false; + document()->removePendingSheet(); + } } } } diff --git a/src/3rdparty/webkit/WebCore/dom/QualifiedName.cpp b/src/3rdparty/webkit/WebCore/dom/QualifiedName.cpp index 607c846afc..2c5f39ae57 100644 --- a/src/3rdparty/webkit/WebCore/dom/QualifiedName.cpp +++ b/src/3rdparty/webkit/WebCore/dom/QualifiedName.cpp @@ -97,4 +97,11 @@ void QualifiedName::init() } } +const AtomicString& QualifiedName::localNameUpper() const +{ + if (!m_impl->m_localNameUpper) + m_impl->m_localNameUpper = m_impl->m_localName.upper(); + return m_impl->m_localNameUpper; +} + } diff --git a/src/3rdparty/webkit/WebCore/dom/QualifiedName.h b/src/3rdparty/webkit/WebCore/dom/QualifiedName.h index 939927bf11..3b9f5c44be 100644 --- a/src/3rdparty/webkit/WebCore/dom/QualifiedName.h +++ b/src/3rdparty/webkit/WebCore/dom/QualifiedName.h @@ -41,9 +41,10 @@ public: return adoptRef(new QualifiedNameImpl(prefix, localName, namespaceURI)); } - AtomicString m_prefix; - AtomicString m_localName; - AtomicString m_namespace; + const AtomicString m_prefix; + const AtomicString m_localName; + const AtomicString m_namespace; + mutable AtomicString m_localNameUpper; private: QualifiedNameImpl(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI) @@ -76,6 +77,9 @@ public: const AtomicString& localName() const { return m_impl->m_localName; } const AtomicString& namespaceURI() const { return m_impl->m_namespace; } + // Uppercased localName, cached for efficiency + const AtomicString& localNameUpper() const; + String toString() const; QualifiedNameImpl* impl() const { return m_impl; } diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptElement.cpp b/src/3rdparty/webkit/WebCore/dom/ScriptElement.cpp index fe38b46a3d..827aff390e 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptElement.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ScriptElement.cpp @@ -151,6 +151,9 @@ void ScriptElementData::requestScript(const String& sourceUrl) if (!document->frame()) return; + if (!m_element->dispatchBeforeLoadEvent(sourceUrl)) + return; + ASSERT(!m_cachedScript); m_cachedScript = document->docLoader()->requestScript(sourceUrl, scriptCharset()); m_requested = true; diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp index 45d4e23342..f7046e3a4d 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp +++ b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.cpp @@ -36,6 +36,10 @@ #include <wtf/MainThread.h> #include <wtf/PassRefPtr.h> +#if USE(JSC) +#include "JSDOMWindow.h" +#endif + namespace WebCore { class ProcessMessagesSoonTask : public ScriptExecutionContext::Task { @@ -195,4 +199,20 @@ ScriptExecutionContext::Task::~Task() { } +#if USE(JSC) +JSC::JSGlobalData* ScriptExecutionContext::globalData() +{ + if (isDocument()) + return JSDOMWindow::commonJSGlobalData(); + +#if ENABLE(WORKERS) + if (isWorkerContext()) + return static_cast<WorkerContext*>(this)->script()->globalData(); +#endif + + ASSERT_NOT_REACHED(); + return 0; +} +#endif + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h index bb78b6fe4e..398afecb51 100644 --- a/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h +++ b/src/3rdparty/webkit/WebCore/dom/ScriptExecutionContext.h @@ -104,6 +104,10 @@ namespace WebCore { void removeTimeout(int timeoutId); DOMTimer* findTimeout(int timeoutId); +#if USE(JSC) + JSC::JSGlobalData* globalData(); +#endif + protected: // Explicitly override the security origin for this script context. // Note: It is dangerous to change the security origin of a script context diff --git a/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp b/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp index 49713ba428..3d2a549cca 100644 --- a/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp +++ b/src/3rdparty/webkit/WebCore/dom/SelectElement.cpp @@ -479,12 +479,14 @@ bool SelectElement::appendFormData(SelectElementData& data, Element* element, Fo // We return the first one if it was a combobox select if (!successful && !data.multiple() && data.size() <= 1 && items.size()) { OptionElement* optionElement = toOptionElement(items[0]); - const AtomicString& value = optionElement->value(); - if (value.isNull()) - list.appendData(name, optionElement->text().stripWhiteSpace()); - else - list.appendData(name, value); - successful = true; + if (optionElement) { + const AtomicString& value = optionElement->value(); + if (value.isNull()) + list.appendData(name, optionElement->text().stripWhiteSpace()); + else + list.appendData(name, value); + successful = true; + } } return successful; @@ -874,13 +876,19 @@ void SelectElement::typeAheadFind(SelectElementData& data, Element* element, Key int index = (optionToListIndex(data, element, selected >= 0 ? selected : 0) + searchStartOffset) % itemCount; ASSERT(index >= 0); + // Compute a case-folded copy of the prefix string before beginning the search for + // a matching element. This code uses foldCase to work around the fact that + // String::startWith does not fold non-ASCII characters. This code can be changed + // to use startWith once that is fixed. + String prefixWithCaseFolded(prefix.foldCase()); for (int i = 0; i < itemCount; ++i, index = (index + 1) % itemCount) { OptionElement* optionElement = toOptionElement(items[index]); if (!optionElement || items[index]->disabled()) continue; + // Fold the option string and check if its prefix is equal to the folded prefix. String text = optionElement->textIndentedToRespectGroupLabel(); - if (stripLeadingWhiteSpace(text).startsWith(prefix, false)) { + if (stripLeadingWhiteSpace(text).foldCase().startsWith(prefixWithCaseFolded)) { setSelectedIndex(data, element, listToOptionIndex(data, element, index)); if (!data.usesMenuList()) listBoxOnChange(data, element); diff --git a/src/3rdparty/webkit/WebCore/dom/StyledElement.cpp b/src/3rdparty/webkit/WebCore/dom/StyledElement.cpp index 5212380b93..46ce13780c 100644 --- a/src/3rdparty/webkit/WebCore/dom/StyledElement.cpp +++ b/src/3rdparty/webkit/WebCore/dom/StyledElement.cpp @@ -240,8 +240,8 @@ void StyledElement::parseMappedAttribute(MappedAttribute *attr) if (namedAttrMap) { if (attr->isNull()) namedAttrMap->setID(nullAtom); - else if (document()->inCompatMode() && !attr->value().impl()->isLower()) - namedAttrMap->setID(AtomicString(attr->value().string().lower())); + else if (document()->inCompatMode()) + namedAttrMap->setID(attr->value().lower()); else namedAttrMap->setID(attr->value()); } diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp index 4d06343948..30d39e0170 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp @@ -40,6 +40,7 @@ #include "HTMLLinkElement.h" #include "HTMLNames.h" #include "HTMLStyleElement.h" +#include "ImageLoader.h" #include "ProcessingInstruction.h" #include "ResourceError.h" #include "ResourceHandle.h" @@ -78,15 +79,41 @@ bool XMLTokenizer::isWMLDocument() const } #endif -void XMLTokenizer::setCurrentNode(Node* n) +void XMLTokenizer::pushCurrentNode(Node* n) { - bool nodeNeedsReference = n && n != m_doc; - if (nodeNeedsReference) - n->ref(); - if (m_currentNodeIsReferenced) - m_currentNode->deref(); + ASSERT(n); + ASSERT(m_currentNode); + if (n != m_doc) + n->ref(); + m_currentNodeStack.append(m_currentNode); m_currentNode = n; - m_currentNodeIsReferenced = nodeNeedsReference; +} + +void XMLTokenizer::popCurrentNode() +{ + ASSERT(m_currentNode); + ASSERT(m_currentNodeStack.size()); + + if (m_currentNode != m_doc) + m_currentNode->deref(); + + m_currentNode = m_currentNodeStack.last(); + m_currentNodeStack.removeLast(); +} + +void XMLTokenizer::clearCurrentNodeStack() +{ + if (m_currentNode && m_currentNode != m_doc) + m_currentNode->deref(); + m_currentNode = 0; + + if (m_currentNodeStack.size()) { // Aborted parsing. + for (size_t i = m_currentNodeStack.size() - 1; i != 0; --i) + m_currentNodeStack[i]->deref(); + if (m_currentNodeStack[0] && m_currentNodeStack[0] != m_doc) + m_currentNodeStack[0]->deref(); + m_currentNodeStack.clear(); + } } void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/) @@ -105,6 +132,9 @@ void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/) } doWrite(s.toString()); + + // After parsing, go ahead and dispatch image beforeload/load events. + ImageLoader::dispatchPendingEvents(); } void XMLTokenizer::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber) @@ -139,7 +169,7 @@ bool XMLTokenizer::enterText() RefPtr<Node> newNode = Text::create(m_doc, ""); if (!m_currentNode->addChild(newNode.get())) return false; - setCurrentNode(newNode.get()); + pushCurrentNode(newNode.get()); return true; } @@ -169,10 +199,7 @@ void XMLTokenizer::exitText() if (m_view && m_currentNode && !m_currentNode->attached()) m_currentNode->attach(); - // FIXME: What's the right thing to do if the parent is really 0? - // Just leaving the current node set to the text node doesn't make much sense. - if (Node* par = m_currentNode->parentNode()) - setCurrentNode(par); + popCurrentNode(); } void XMLTokenizer::end() @@ -186,7 +213,7 @@ void XMLTokenizer::end() m_doc->updateStyleSelector(); } - setCurrentNode(0); + clearCurrentNodeStack(); if (!m_parsingFragment) m_doc->finishedParsing(); } @@ -296,7 +323,7 @@ void XMLTokenizer::notifyFinished(CachedResource* unusedResource) if (errorOccurred) scriptElement->dispatchErrorEvent(); else { - m_view->frame()->loader()->executeScript(sourceCode); + m_view->frame()->script()->executeScript(sourceCode); scriptElement->dispatchLoadEvent(); } diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h index 019a831f17..e1ee09f047 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h @@ -124,7 +124,10 @@ public: friend bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent); void initializeParserContext(const char* chunk = 0); - void setCurrentNode(Node*); + + void pushCurrentNode(Node*); + void popCurrentNode(); + void clearCurrentNodeStack(); void insertErrorMessageBlock(); @@ -148,7 +151,7 @@ public: Vector<xmlChar> m_bufferedText; #endif Node* m_currentNode; - bool m_currentNodeIsReferenced; + Vector<Node*> m_currentNodeStack; bool m_sawError; bool m_sawXSLTransform; diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp index d3c6546793..9aa0961a5e 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerLibxml2.cpp @@ -530,7 +530,6 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_context(0) , m_pendingCallbacks(new PendingCallbacks) , m_currentNode(_doc) - , m_currentNodeIsReferenced(false) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -557,7 +556,6 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_context(0) , m_pendingCallbacks(new PendingCallbacks) , m_currentNode(fragment) - , m_currentNodeIsReferenced(fragment) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -576,8 +574,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_scriptStartLine(0) , m_parsingFragment(true) { - if (fragment) - fragment->ref(); + fragment->ref(); if (m_doc) m_doc->ref(); @@ -614,7 +611,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) XMLTokenizer::~XMLTokenizer() { - setCurrentNode(0); + clearCurrentNodeStack(); if (m_parsingFragment && m_doc) m_doc->deref(); if (m_pendingScript) @@ -801,7 +798,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm return; } - setCurrentNode(newElement.get()); + pushCurrentNode(newElement.get()); if (m_view && !newElement->attached()) newElement->attach(); @@ -822,22 +819,29 @@ void XMLTokenizer::endElementNs() exitText(); Node* n = m_currentNode; - RefPtr<Node> parent = n->parentNode(); n->finishParsingChildren(); if (!n->isElementNode() || !m_view) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } Element* element = static_cast<Element*>(n); + + // The element's parent may have already been removed from document. + // Parsing continues in this case, but scripts aren't executed. + if (!element->inDocument()) { + popCurrentNode(); + return; + } + ScriptElement* scriptElement = toScriptElement(element); if (!scriptElement) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } - // don't load external scripts for standalone documents (for now) + // Don't load external scripts for standalone documents (for now). ASSERT(!m_pendingScript); m_requestingScript = true; @@ -851,7 +855,8 @@ void XMLTokenizer::endElementNs() if (!scriptHref.isEmpty()) { // we have a src attribute String scriptCharset = scriptElement->scriptCharset(); - if ((m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { + if (element->dispatchBeforeLoadEvent(scriptHref) && + (m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { m_scriptElement = element; m_pendingScript->addClient(this); @@ -861,10 +866,10 @@ void XMLTokenizer::endElementNs() } else m_scriptElement = 0; } else - m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); + m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); } m_requestingScript = false; - setCurrentNode(parent.get()); + popCurrentNode(); } void XMLTokenizer::characters(const xmlChar* s, int len) @@ -886,7 +891,7 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args) if (m_parserStopped) return; -#if PLATFORM(WIN_OS) +#if COMPILER(MSVC) char m[1024]; vsnprintf(m, sizeof(m) - 1, message, args); #else @@ -900,7 +905,7 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args) else handleError(type, m, lineNumber(), columnNumber()); -#if !PLATFORM(WIN_OS) +#if !COMPILER(MSVC) free(m); #endif } diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp index 04405d605c..79fc51ebaa 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp @@ -85,7 +85,6 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_view(_view) , m_wroteText(false) , m_currentNode(_doc) - , m_currentNodeIsReferenced(false) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -114,7 +113,6 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_view(0) , m_wroteText(false) , m_currentNode(fragment) - , m_currentNodeIsReferenced(fragment) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) @@ -133,8 +131,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_scriptStartLine(0) , m_parsingFragment(true) { - if (fragment) - fragment->ref(); + fragment->ref(); if (m_doc) m_doc->ref(); @@ -188,7 +185,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) XMLTokenizer::~XMLTokenizer() { - setCurrentNode(0); + clearCurrentNodeStack(); if (m_parsingFragment && m_doc) m_doc->deref(); if (m_pendingScript) @@ -259,7 +256,7 @@ void XMLTokenizer::doEnd() #endif if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError - || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform)) + || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform && !m_sawError)) handleError(fatal, qPrintable(m_stream.errorString()), lineNumber(), columnNumber()); } @@ -569,7 +566,7 @@ void XMLTokenizer::parseStartElement() return; } - setCurrentNode(newElement.get()); + pushCurrentNode(newElement.get()); if (m_view && !newElement->attached()) newElement->attach(); @@ -582,18 +579,26 @@ void XMLTokenizer::parseEndElement() exitText(); Node* n = m_currentNode; - RefPtr<Node> parent = n->parentNode(); n->finishParsingChildren(); if (!n->isElementNode() || !m_view) { - setCurrentNode(parent.get()); + if (!m_currentNodeStack.isEmpty()) + popCurrentNode(); return; } Element* element = static_cast<Element*>(n); + + // The element's parent may have already been removed from document. + // Parsing continues in this case, but scripts aren't executed. + if (!element->inDocument()) { + popCurrentNode(); + return; + } + ScriptElement* scriptElement = toScriptElement(element); if (!scriptElement) { - setCurrentNode(parent.get()); + popCurrentNode(); return; } @@ -611,7 +616,8 @@ void XMLTokenizer::parseEndElement() if (!scriptHref.isEmpty()) { // we have a src attribute String scriptCharset = scriptElement->scriptCharset(); - if ((m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { + if (element->dispatchBeforeLoadEvent(scriptHref) && + (m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) { m_scriptElement = element; m_pendingScript->addClient(this); @@ -621,10 +627,10 @@ void XMLTokenizer::parseEndElement() } else m_scriptElement = 0; } else - m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); + m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); } m_requestingScript = false; - setCurrentNode(parent.get()); + popCurrentNode(); } void XMLTokenizer::parseCharacters() |