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.cpp75
1 files changed, 66 insertions, 9 deletions
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index c41b87e..c9a2182 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -76,10 +76,10 @@
#include "HTMLMapElement.h"
#include "HTMLNameCollection.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeConstructor.h"
+#include "LegacyHTMLTreeBuilder.h"
#include "HTMLStyleElement.h"
#include "HTMLTitleElement.h"
-#include "HTMLDocumentParser.h"
+#include "LegacyHTMLDocumentParser.h"
#include "HTTPParsers.h"
#include "HistoryItem.h"
#include "HitTestRequest.h"
@@ -372,7 +372,7 @@ private:
Document* m_document;
};
-Document::Document(Frame* frame, bool isXHTML, bool isHTML)
+Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
: ContainerNode(0)
, m_domtree_version(0)
, m_styleSheets(StyleSheetList::create(this))
@@ -431,7 +431,13 @@ Document::Document(Frame* frame, bool isXHTML, bool isHTML)
m_frame = frame;
+<<<<<<< HEAD
#if !PLATFORM(ANDROID)
+=======
+ if (frame || !url.isEmpty())
+ setURL(url);
+
+>>>>>>> webkit.org at r61871
m_axObjectCache = 0;
#endif
@@ -1534,6 +1540,43 @@ PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
return style.release();
}
+PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex)
+{
+ RefPtr<RenderStyle> style = styleSelector()->styleForPage(pageIndex);
+ return style.release();
+}
+
+bool Document::isPageBoxVisible(int pageIndex)
+{
+ RefPtr<RenderStyle> style = styleForPage(pageIndex);
+ return style->visibility() != HIDDEN; // display property doesn't apply to @page.
+}
+
+IntRect Document::pageAreaRectInPixels(int pageIndex)
+{
+ RefPtr<RenderStyle> style = styleForPage(pageIndex);
+ IntSize pageSize = preferredPageSizeInPixels(pageIndex);
+ // 100% value for margin-{left,right,top,bottom}. This is used also for top and bottom. http://www.w3.org/TR/CSS2/box.html#value-def-margin-width
+ int maxValue = pageSize.width();
+ int surroundLeft = style->marginLeft().calcValue(maxValue) + style->borderLeft().width() + style->paddingLeft().calcValue(maxValue);
+ int surroundRight = style->marginRight().calcValue(maxValue) + style->borderRight().width() + style->paddingRight().calcValue(maxValue);
+ int surroundTop = style->marginTop().calcValue(maxValue) + style->borderTop().width() + style->paddingTop().calcValue(maxValue);
+ int surroundBottom = style->marginBottom().calcValue(maxValue) + style->borderBottom().width() + style->paddingBottom().calcValue(maxValue);
+ int width = pageSize.width() - surroundLeft - surroundRight;
+ int height = pageSize.height() - surroundTop - surroundBottom;
+
+ return IntRect(surroundLeft, surroundTop, width, height);
+}
+
+IntSize Document::preferredPageSizeInPixels(int pageIndex)
+{
+ RefPtr<RenderStyle> style = styleForPage(pageIndex);
+ LengthSize size = style->pageSize();
+ ASSERT(size.width().isFixed());
+ ASSERT(size.height().isFixed());
+ return IntSize(size.width().calcValue(0), size.height().calcValue(0));
+}
+
void Document::createStyleSelector()
{
bool matchAuthorAndUserStyles = true;
@@ -1723,7 +1766,7 @@ void Document::open(Document* ownerDocument)
}
if (m_frame) {
- if (m_frame->loader()->isLoadingMainResource() || (parser() && parser()->executingScript()))
+ if (m_frame->loader()->isLoadingMainResource() || (parser() && parser()->isExecutingScript()))
return;
if (m_frame->loader()->state() == FrameStateProvisional)
@@ -2000,12 +2043,16 @@ void Document::write(const SegmentedString& text, Document* ownerDocument)
printf("Beginning a document.write at %d\n", elapsedTime());
#endif
- if (!m_parser)
+ if (!m_parser || m_parser->finishWasCalled())
open(ownerDocument);
ASSERT(m_parser);
+ // FIXME: forceSynchronous should always be the same as the bool passed to
+ // write(). However LegacyHTMLDocumentParser uses write("", false) to pump
+ // the parser (after running external scripts, etc.) thus necessitating a
+ // separate state for forceSynchronous.
bool wasForcedSynchronous = false;
- HTMLDocumentParser* parser = m_parser->asHTMLDocumentParser();
+ LegacyHTMLDocumentParser* parser = m_parser->asHTMLDocumentParser();
if (parser) {
wasForcedSynchronous = parser->forceSynchronous();
parser->setForceSynchronous(true);
@@ -4630,9 +4677,8 @@ void Document::initSecurityContext()
// In the common case, create the security context from the currently
// loading URL.
- const KURL& url = m_frame->loader()->url();
- m_cookieURL = url;
- ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(url, m_frame->loader()->sandboxFlags()));
+ m_cookieURL = m_url;
+ ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(m_url, m_frame->loader()->sandboxFlags()));
if (SecurityOrigin::allowSubstituteDataAccessToLocal()) {
// If this document was loaded with substituteData, then the document can
@@ -4790,6 +4836,17 @@ void Document::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<C
m_executeScriptSoonTimer.startOneShot(0);
}
+void Document::suspendExecuteScriptSoonTimer()
+{
+ m_executeScriptSoonTimer.stop();
+}
+
+void Document::resumeExecuteScriptSoonTimer()
+{
+ if (!m_scriptsToExecuteSoon.isEmpty())
+ m_executeScriptSoonTimer.startOneShot(0);
+}
+
// FF method for accessing the selection added for compatibility.
DOMSelection* Document::getSelection() const
{