summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/Document.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/dom/Document.cpp')
-rw-r--r--WebCore/dom/Document.cpp112
1 files changed, 50 insertions, 62 deletions
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index a92c5ab..262dad2 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -43,6 +43,7 @@
#include "Console.h"
#include "CookieJar.h"
#include "CustomEvent.h"
+#include "DateComponents.h"
#include "DOMImplementation.h"
#include "DOMWindow.h"
#include "DeviceMotionEvent.h"
@@ -64,6 +65,7 @@
#include "FrameLoader.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "HashChangeEvent.h"
#include "HTMLAllCollection.h"
#include "HTMLAnchorElement.h"
#include "HTMLBodyElement.h"
@@ -369,7 +371,7 @@ private:
Document* m_document;
};
-Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
+Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, const KURL& baseURL)
: ContainerNode(0)
, m_compatibilityMode(NoQuirksMode)
, m_compatibilityModeLocked(false)
@@ -439,7 +441,15 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
if (frame || !url.isEmpty())
setURL(url);
+<<<<<<< HEAD
#if !PLATFORM(ANDROID)
+=======
+ // Setting of m_baseURL needs to happen after the setURL call, since that
+ // calls updateBaseURL, which would clobber the passed in value.
+ if (!baseURL.isNull())
+ m_baseURL = baseURL;
+
+>>>>>>> webkit.org at r67908
m_axObjectCache = 0;
#endif
@@ -623,6 +633,11 @@ void Document::setCompatibilityMode(CompatibilityMode mode)
}
}
+String Document::compatMode() const
+{
+ return inQuirksMode() ? "BackCompat" : "CSS1Compat";
+}
+
void Document::resetLinkColor()
{
m_linkColor = Color(0, 0, 238);
@@ -1079,7 +1094,7 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned
if (!frameView)
return 0;
- float zoomFactor = frameView->pageZoomFactor();
+ float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(centerX * zoomFactor + view()->scrollX(), centerY * zoomFactor + view()->scrollY()));
IntSize padding(hPadding, vPadding);
@@ -1132,7 +1147,7 @@ Element* Document::elementFromPoint(int x, int y) const
if (!frameView)
return 0;
- float zoomFactor = frameView->pageZoomFactor();
+ float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY()));
if (!frameView->visibleContentRect().contains(point))
@@ -1162,7 +1177,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
if (!frameView)
return 0;
- float zoomFactor = frameView->pageZoomFactor();
+ float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY()));
if (!frameView->visibleContentRect().contains(point))
@@ -2000,26 +2015,6 @@ void Document::close()
}
}
-// FIXME: These settings probably don't work anymore. We should either remove
-// them or make them work properly.
-#ifdef BUILDING_ON_LEOPARD
-static bool shouldCreateImplicitHead(Document* document)
-{
- ASSERT(document);
- Settings* settings = document->page() ? document->page()->settings() : 0;
- return settings ? !settings->needsLeopardMailQuirks() : true;
-}
-#elif defined(BUILDING_ON_TIGER)
-static bool shouldCreateImplicitHead(Document* document)
-{
- ASSERT(document);
- Settings* settings = document->page() ? document->page()->settings() : 0;
- return settings ? !settings->needsTigerMailQuirks() : true;
-}
-#else
-inline bool shouldCreateImplicitHead(Document*) { return true; }
-#endif
-
void Document::implicitClose()
{
// If we're in the middle of recalcStyle, we need to defer the close until the style information is accurate and all elements are re-attached.
@@ -2046,21 +2041,6 @@ void Document::implicitClose()
// Parser should have picked up all preloads by now
m_cachedResourceLoader->clearPreloads();
- // Create a head and a body if we don't have those yet (e.g. for about:blank).
- if (!this->body() && isHTMLDocument()) {
- if (Node* documentElement = this->documentElement()) {
- ExceptionCode ec = 0;
-
- // The implicit <head> isn't expected in older versions of Mail - <rdar://problem/6863795>
- if (!head() && shouldCreateImplicitHead(this)) {
- documentElement->appendChild(HTMLHeadElement::create(this), ec);
- ASSERT(!ec);
- }
- documentElement->appendChild(HTMLBodyElement::create(this), ec);
- ASSERT(!ec);
- }
- }
-
// FIXME: We kick off the icon loader when the Document is done parsing.
// There are earlier opportunities we could start it:
// -When the <head> finishes parsing
@@ -2591,13 +2571,15 @@ void Document::processHttpEquiv(const String& equiv, const String& content)
else if (equalIgnoringCase(equiv, "x-dns-prefetch-control"))
parseDNSPrefetchControlHeader(content);
else if (equalIgnoringCase(equiv, "x-frame-options")) {
- FrameLoader* frameLoader = frame->loader();
- if (frameLoader->shouldInterruptLoadForXFrameOptions(content, url())) {
- frameLoader->stopAllLoaders();
- frame->redirectScheduler()->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());
+ if (frame) {
+ FrameLoader* frameLoader = frame->loader();
+ if (frameLoader->shouldInterruptLoadForXFrameOptions(content, url())) {
+ frameLoader->stopAllLoaders();
+ frame->redirectScheduler()->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());
+ }
}
}
}
@@ -3321,7 +3303,7 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode* container)
if (Frame* frame = this->frame()) {
for (Node* n = container->firstChild(); n; n = n->nextSibling()) {
frame->selection()->nodeWillBeRemoved(n);
- frame->dragCaretController()->nodeWillBeRemoved(n);
+ frame->page()->dragCaretController()->nodeWillBeRemoved(n);
}
}
}
@@ -3340,7 +3322,7 @@ void Document::nodeWillBeRemoved(Node* n)
if (Frame* frame = this->frame()) {
frame->selection()->nodeWillBeRemoved(n);
- frame->dragCaretController()->nodeWillBeRemoved(n);
+ frame->page()->dragCaretController()->nodeWillBeRemoved(n);
}
#if ENABLE(FULLSCREEN_API)
@@ -3695,15 +3677,24 @@ void Document::setDomain(const String& newDomain, ExceptionCode& ec)
m_frame->script()->updateSecurityOrigin();
}
+// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
String Document::lastModified() const
{
- Frame* f = frame();
- if (!f)
- return String();
- DocumentLoader* loader = f->loader()->documentLoader();
- if (!loader)
- return String();
- return loader->response().httpHeaderField("Last-Modified");
+ DateComponents date;
+ bool foundDate = false;
+ if (m_frame) {
+ String httpLastModified = m_frame->loader()->documentLoader()->response().httpHeaderField("Last-Modified");
+ if (!httpLastModified.isEmpty()) {
+ date.setMillisecondsSinceEpochForDateTime(parseDate(httpLastModified));
+ foundDate = true;
+ }
+ }
+ // FIXME: If this document came from the file system, the HTML5
+ // specificiation tells us to read the last modification date from the file
+ // system.
+ if (!foundDate)
+ date.setMillisecondsSinceEpochForDateTime(currentTimeMS());
+ return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
}
static bool isValidNameNonASCII(const UChar* characters, unsigned length)
@@ -4037,10 +4028,9 @@ bool Document::inDesignMode() const
Document* Document::parentDocument() const
{
- Frame* childPart = frame();
- if (!childPart)
+ if (!m_frame)
return 0;
- Frame* parent = childPart->tree()->parent();
+ Frame* parent = m_frame->tree()->parent();
if (!parent)
return 0;
return parent->document();
@@ -4711,11 +4701,9 @@ void Document::enqueuePageshowEvent(PageshowEventPersistence persisted)
dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, persisted), this);
}
-void Document::enqueueHashchangeEvent(const String& /*oldURL*/, const String& /*newURL*/)
+void Document::enqueueHashchangeEvent(const String& oldURL, const String& newURL)
{
- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36335 Hashchange event is now its own interface and takes two
- // URL arguments which we need to pass in here.
- enqueueEvent(Event::create(eventNames().hashchangeEvent, false, false));
+ enqueueEvent(HashChangeEvent::create(oldURL, newURL));
}
void Document::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject)