diff options
Diffstat (limited to 'WebCore/dom/Document.cpp')
-rw-r--r-- | WebCore/dom/Document.cpp | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 2ad8b50..1e7c213 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -32,7 +32,6 @@ #include "Attr.h" #include "Attribute.h" #include "CDATASection.h" -#include "CSSHelper.h" #include "CSSStyleSelector.h" #include "CSSStyleSheet.h" #include "CSSValueKeywords.h" @@ -81,6 +80,7 @@ #include "HTMLMapElement.h" #include "HTMLNameCollection.h" #include "HTMLNames.h" +#include "HTMLParserIdioms.h" #include "HTMLStyleElement.h" #include "HTMLTitleElement.h" #include "HTTPParsers.h" @@ -88,7 +88,7 @@ #include "HitTestResult.h" #include "ImageLoader.h" #include "InspectorController.h" -#include "InspectorTimelineAgent.h" +#include "InspectorInstrumentation.h" #include "KeyboardEvent.h" #include "Logging.h" #include "MessageEvent.h" @@ -425,6 +425,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con , m_areKeysEnabledInFullScreen(0) #endif , m_loadEventDelayCount(0) + , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) { m_document = this; @@ -1013,8 +1014,10 @@ String Document::readyState() const void Document::setReadyState(ReadyState readyState) { - // FIXME: Fire the readystatechange event on this Document. + if (readyState == m_readyState) + return; m_readyState = readyState; + dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false)); } String Document::encoding() const @@ -1098,7 +1101,7 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned // When ignoreClipping is false, this method returns null for coordinates outside of the viewport. if (ignoreClipping) type |= HitTestRequest::IgnoreClipping; - else if (!frameView->visibleContentRect().intersects(HitTestResult::rectFromPoint(point, topPadding, rightPadding, bottomPadding, leftPadding))) + else if (!frameView->visibleContentRect().intersects(HitTestResult::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding))) return 0; HitTestRequest request(type); @@ -1189,7 +1192,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y) Node* shadowAncestorNode = node->shadowAncestorNode(); if (shadowAncestorNode != node) { unsigned offset = shadowAncestorNode->nodeIndex(); - Node* container = shadowAncestorNode->parentNode(); + ContainerNode* container = shadowAncestorNode->parentNode(); return Range::create(this, container, offset, container, offset); } @@ -1489,10 +1492,7 @@ void Document::recalcStyle(StyleChange change) if (m_inStyleRecalc) return; // Guard against re-entrancy. -dwh -#if ENABLE(INSPECTOR) - if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent()) - timelineAgent->willRecalculateStyle(); -#endif + InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(this); m_inStyleRecalc = true; suspendPostAttachCallbacks(); @@ -1555,10 +1555,7 @@ bail_out: implicitClose(); } -#if ENABLE(INSPECTOR) - if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent()) - timelineAgent->didRecalculateStyle(); -#endif + InspectorInstrumentation::didRecalculateStyle(cookie); } void Document::updateStyleIfNeeded() @@ -1916,6 +1913,7 @@ void Document::open(Document* ownerDocument) m_frame->loader()->stopAllLoaders(); } + removeAllEventListeners(); implicitOpen(); if (DOMWindow* domWindow = this->domWindow()) @@ -2036,7 +2034,7 @@ void Document::implicitClose() return; } - bool wasLocationChangePending = frame() && frame()->redirectScheduler()->locationChangePending(); + bool wasLocationChangePending = frame() && frame()->navigationScheduler()->locationChangePending(); bool doload = !parsing() && m_parser && !m_processingLoadEvent && !wasLocationChangePending; if (!doload) @@ -2091,7 +2089,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()->redirectScheduler()->locationChangePending() && elapsedTime() < cLayoutScheduleThreshold) { + if (frame()->navigationScheduler()->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(); @@ -2290,7 +2288,7 @@ void Document::processBaseElement() // FIXME: Since this doesn't share code with completeURL it may not handle encodings correctly. KURL baseElementURL; if (href) { - String strippedHref = deprecatedParseURL(*href); + String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href); if (!strippedHref.isEmpty() && (!frame() || frame()->script()->xssAuditor()->canSetBaseElementURL(*href))) baseElementURL = KURL(url(), strippedHref); } @@ -2571,7 +2569,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content) url = frame->loader()->url().string(); else url = completeURL(url).string(); - frame->redirectScheduler()->scheduleRedirect(delay, url); + frame->navigationScheduler()->scheduleRedirect(delay, url); } } else if (equalIgnoringCase(equiv, "set-cookie")) { // FIXME: make setCookie work on XML documents too; e.g. in case of <html:meta .....> @@ -2588,7 +2586,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content) FrameLoader* frameLoader = frame->loader(); if (frameLoader->shouldInterruptLoadForXFrameOptions(content, url())) { frameLoader->stopAllLoaders(); - frame->redirectScheduler()->scheduleLocationChange(blankURL(), String()); + frame->navigationScheduler()->scheduleLocationChange(blankURL(), String()); DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to display document because display forbidden by X-Frame-Options.\n")); frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String()); @@ -2670,7 +2668,7 @@ void Document::processViewport(const String& features) if (!frame || !frame->page()) return; - frame->page()->chrome()->client()->didReceiveViewportArguments(frame, m_viewportArguments); + frame->page()->updateViewportArguments(); } MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& request, const IntPoint& documentPoint, const PlatformMouseEvent& event) @@ -3168,6 +3166,9 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) } oldFocusedNode->dispatchUIEvent(eventNames().focusoutEvent, 0, 0); // DOM level 3 name for the bubbling blur event. + // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends + // on it, probably when <rdar://problem/8503958> is resolved. + oldFocusedNode->dispatchUIEvent(eventNames().DOMFocusOutEvent, 0, 0); // DOM level 2 name for compatibility. if (m_focusedNode) { // handler shifted focus @@ -3208,6 +3209,9 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) } m_focusedNode->dispatchUIEvent(eventNames().focusinEvent, 0, 0); // DOM level 3 bubbling focus event. + // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends + // on it, probably when <rdar://problem/8503958> is resolved. + m_focusedNode->dispatchUIEvent(eventNames().DOMFocusInEvent, 0, 0); // DOM level 2 for compatibility. if (m_focusedNode != newFocusedNode) { // handler shifted focus @@ -3522,6 +3526,10 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& else if (eventType == "DeviceOrientationEvent") event = DeviceOrientationEvent::create(); #endif +#if ENABLE(ORIENTATION_EVENTS) + else if (eventType == "OrientationEvent") + event = Event::create(); +#endif if (event) return event.release(); @@ -3888,7 +3896,7 @@ void Document::setInPageCache(bool flag) m_savedRenderer = 0; if (frame() && frame()->page()) - frame()->page()->chrome()->client()->didReceiveViewportArguments(frame(), m_viewportArguments); + frame()->page()->updateViewportArguments(); if (childNeedsStyleRecalc()) scheduleStyleRecalc(); @@ -4490,11 +4498,12 @@ void Document::updateURLForPushOrReplaceState(const KURL& url) void Document::statePopped(SerializedScriptValue* stateObject) { - Frame* f = frame(); - if (!f) + if (!frame()) return; - if (f->loader()->isComplete()) + // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we + // defer firing of popstate until we're in the complete state. + if (m_readyState == Complete) enqueuePopstateEvent(stateObject); else m_pendingStateObject = stateObject; @@ -4742,17 +4751,12 @@ bool Document::isXHTMLMPDocument() const #endif #if ENABLE(INSPECTOR) -InspectorTimelineAgent* Document::inspectorTimelineAgent() const -{ - return page() ? page()->inspectorTimelineAgent() : 0; -} - -InspectorController* Document::inspectorController() const +InspectorController* Document::inspectorController() const { return page() ? page()->inspectorController() : 0; } #endif - + #if ENABLE(FULLSCREEN_API) void Document::webkitRequestFullScreenForElement(Element* element, unsigned short flags) { @@ -4822,7 +4826,13 @@ void Document::decrementLoadEventDelayCount() ASSERT(m_loadEventDelayCount); --m_loadEventDelayCount; - if (frame() && !m_loadEventDelayCount) + if (frame() && !m_loadEventDelayCount && !m_loadEventDelayTimer.isActive()) + m_loadEventDelayTimer.startOneShot(0); +} + +void Document::loadEventDelayTimerFired(Timer<Document>*) +{ + if (frame()) frame()->loader()->checkCompleted(); } |