- change Document to hold onto Frame* instead of FrameView*
This is an architectural cleanup and a prerequisite to fixing citibank login
in an architecturally sound way.
Some fixups for the page cache:
* history/CachedPage.cpp:
(WebCore::CachedPage::restore): Add an assert that the document's view
matches the cached page's view - this needs to be true by the time this
function is called.
(WebCore::CachedPage::clear): Change assert to require frame matching, not
view matching.
* history/CachedPage.h:
(WebCore::CachedPage::view): Add a way to get the view out.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::begin): pass Frame, not FrameView, when creating document
(WebCore::FrameLoader::open): restore view based on CachedPage, not Document.
Remaining changes are just straightforward updates based on which
pointer is held or passed:
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
(WebCore::DOMImplementation::createHTMLDocument):
* dom/DOMImplementation.h:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::view):
(WebCore::Document::frame):
(WebCore::Document::recalcStyle):
(WebCore::Document::updateLayout):
(WebCore::Document::attach):
(WebCore::Document::detach):
(WebCore::Document::createTokenizer):
(WebCore::Document::recalcStyleSelector):
(WebCore::Document::setInPageCache):
(WebCore::Document::applyXSLTransform):
* dom/Document.h:
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::HTMLDocument):
* html/HTMLDocument.h:
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::HTMLViewSourceDocument):
* html/HTMLViewSourceDocument.h:
* ksvg2/svg/SVGDocument.cpp:
(WebCore::SVGDocument::SVGDocument):
* ksvg2/svg/SVGDocument.h:
* loader/ImageDocument.cpp:
(WebCore::ImageDocument::ImageDocument):
* loader/ImageDocument.h:
* loader/PluginDocument.cpp:
(WebCore::PluginDocument::PluginDocument):
* loader/PluginDocument.h:
* loader/TextDocument.cpp:
(WebCore::TextDocument::TextDocument):
* loader/TextDocument.h:
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource):
(WebCore::XSLTProcessor::transformToDocument):
* xml/XSLTProcessor.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@21179
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-04-28 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin and Oliver.
+
+ - change Document to hold onto Frame* instead of FrameView*
+
+ This is an architectural cleanup and a prerequisite to fixing citibank login
+ in an architecturally sound way.
+
+ Some fixups for the page cache:
+
+ * history/CachedPage.cpp:
+ (WebCore::CachedPage::restore): Add an assert that the document's view
+ matches the cached page's view - this needs to be true by the time this
+ function is called.
+ (WebCore::CachedPage::clear): Change assert to require frame matching, not
+ view matching.
+ * history/CachedPage.h:
+ (WebCore::CachedPage::view): Add a way to get the view out.
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::begin): pass Frame, not FrameView, when creating document
+ (WebCore::FrameLoader::open): restore view based on CachedPage, not Document.
+
+ Remaining changes are just straightforward updates based on which
+ pointer is held or passed:
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocument):
+ (WebCore::DOMImplementation::createHTMLDocument):
+ * dom/DOMImplementation.h:
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::view):
+ (WebCore::Document::frame):
+ (WebCore::Document::recalcStyle):
+ (WebCore::Document::updateLayout):
+ (WebCore::Document::attach):
+ (WebCore::Document::detach):
+ (WebCore::Document::createTokenizer):
+ (WebCore::Document::recalcStyleSelector):
+ (WebCore::Document::setInPageCache):
+ (WebCore::Document::applyXSLTransform):
+ * dom/Document.h:
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::HTMLDocument):
+ * html/HTMLDocument.h:
+ * html/HTMLViewSourceDocument.cpp:
+ (WebCore::HTMLViewSourceDocument::HTMLViewSourceDocument):
+ * html/HTMLViewSourceDocument.h:
+ * ksvg2/svg/SVGDocument.cpp:
+ (WebCore::SVGDocument::SVGDocument):
+ * ksvg2/svg/SVGDocument.h:
+ * loader/ImageDocument.cpp:
+ (WebCore::ImageDocument::ImageDocument):
+ * loader/ImageDocument.h:
+ * loader/PluginDocument.cpp:
+ (WebCore::PluginDocument::PluginDocument):
+ * loader/PluginDocument.h:
+ * loader/TextDocument.cpp:
+ (WebCore::TextDocument::TextDocument):
+ * loader/TextDocument.h:
+ * xml/XSLTProcessor.cpp:
+ (WebCore::XSLTProcessor::createDocumentFromSource):
+ (WebCore::XSLTProcessor::transformToDocument):
+ * xml/XSLTProcessor.h:
+
2007-04-28 Adele Peterson <adele@apple.com>
RS by Darin.
return sheet.release();
}
-PassRefPtr<Document> DOMImplementation::createDocument(FrameView* view)
+PassRefPtr<Document> DOMImplementation::createDocument(Frame* frame)
{
- return new Document(this, view);
+ return new Document(this, frame);
}
-PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(FrameView* view)
+PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(Frame* frame)
{
- return new HTMLDocument(this, view);
+ return new HTMLDocument(this, frame);
}
DOMImplementation* DOMImplementation::instance()
return d.release();
}
-PassRefPtr<Document> DOMImplementation::createDocument(const String& type, FrameView* view, bool inViewSourceMode)
+PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, bool inViewSourceMode)
{
if (inViewSourceMode)
- return new HTMLViewSourceDocument(this, view);
+ return new HTMLViewSourceDocument(this, frame);
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
- return new HTMLDocument(this, view);
+ return new HTMLDocument(this, frame);
if (type == "application/xhtml+xml")
- return new Document(this, view);
+ return new Document(this, frame);
// PDF is one image type for which a plugin can override built-in support.
// We do not want QuickTime to take over all image types, obviously.
if ((type == "application/pdf" || type == "text/pdf") && PlugInInfoStore::supportsMIMEType(type))
- return new PluginDocument(this, view);
+ return new PluginDocument(this, frame);
if (Image::supportsType(type))
- return new ImageDocument(this, view);
+ return new ImageDocument(this, frame);
// Everything else can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
if (PlugInInfoStore::supportsMIMEType(type))
- return new PluginDocument(this, view);
+ return new PluginDocument(this, frame);
#if ENABLE(SVG)
if (type == "image/svg+xml")
- return new SVGDocument(this, view);
+ return new SVGDocument(this, frame);
#endif
if (isXMLMIMEType(type))
- return new Document(this, view);
+ return new Document(this, frame);
if (isTextMIMEType(type))
- return new TextDocument(this, view);
+ return new TextDocument(this, frame);
- return new HTMLDocument(this, view);
+ return new HTMLDocument(this, frame);
}
}
class CSSStyleSheet;
class Document;
class DocumentType;
-class FrameView;
+class Frame;
class HTMLDocument;
class String;
PassRefPtr<HTMLDocument> createHTMLDocument(const String& title);
// Other methods (not part of DOM)
- PassRefPtr<Document> createDocument(const String& MIMEType, FrameView*, bool inViewSourceMode);
- PassRefPtr<Document> createDocument(FrameView*);
- PassRefPtr<HTMLDocument> createHTMLDocument(FrameView*);
+ PassRefPtr<Document> createDocument(const String& MIMEType, Frame*, bool inViewSourceMode);
+ PassRefPtr<Document> createDocument(Frame*);
+ PassRefPtr<HTMLDocument> createHTMLDocument(Frame*);
// Returns the static instance of this class - only one instance of this class should
// ever be present, and is used as a factory method for creating Document objects
DeprecatedPtrList<Document>* Document::changedDocuments = 0;
// FrameView might be 0
-Document::Document(DOMImplementation* impl, FrameView *v)
+Document::Document(DOMImplementation* impl, Frame* frame)
: ContainerNode(0)
, m_implementation(impl)
, m_domtree_version(0)
m_printing = false;
- m_view = v;
+ m_frame = frame;
m_renderArena = 0;
m_axObjectCache = 0;
- m_docLoader = new DocLoader(v ? v->frame() : 0, this);
+ // FIXME: DocLoader probably no longer needs the frame argument
+ m_docLoader = new DocLoader(frame, this);
visuallyOrdered = false;
m_bParsing = false;
FrameView* Document::view() const
{
- return m_view;
+ return m_frame ? m_frame->view() : 0;
}
Frame* Document::frame() const
{
- return m_view ? m_view->frame() : 0;
+ return m_frame;
}
Page* Document::page() const
FontDescription fontDescription;
fontDescription.setUsePrinterFont(printing());
- if (m_view) {
- const Settings *settings = m_view->frame()->settings();
+ if (Frame* f = frame()) {
+ const Settings *settings = f->settings();
if (printing() && !settings->shouldPrintBackgrounds())
_style->setForceBackgroundsToWhite(true);
const AtomicString& stdfont = settings->standardFontFamily();
if (change >= Inherit || n->hasChangedChild() || n->changed())
n->recalcStyle(change);
- if (changed() && m_view)
- m_view->layout();
+ if (changed() && view())
+ view()->layout();
bail_out:
setChanged(false);
updateRendering();
// Only do a layout if changes have occurred that make it necessary.
- if (m_view && renderer() && (m_view->layoutPending() || renderer()->needsLayout()))
- m_view->layout();
+ FrameView* v = view();
+ if (v && renderer() && (v->layoutPending() || renderer()->needsLayout()))
+ v->layout();
}
// FIXME: This is a bad idea and needs to be removed eventually.
m_renderArena = new RenderArena();
// Create the rendering tree
- setRenderer(new (m_renderArena) RenderView(this, m_view));
+ setRenderer(new (m_renderArena) RenderView(this, view()));
recalcStyle(Force);
if (render)
render->destroy();
- m_view = 0;
+ // FIXME: is this needed or desirable?
+ m_frame = 0;
if (m_renderArena) {
delete m_renderArena;
Tokenizer* Document::createTokenizer()
{
- return new XMLTokenizer(this, m_view);
+ // FIXME: this should probably pass the frame instead
+ return new XMLTokenizer(this, view());
}
void Document::open()
// Create a new style selector
delete m_styleSelector;
String usersheet = m_usersheet;
- if (m_view && m_view->mediaType() == "print")
+ if (view() && view()->mediaType() == "print")
usersheet += m_printSheet;
m_styleSelector = new CSSStyleSelector(this, usersheet, m_styleSheets.get(), !inCompatMode());
m_styleSelector->setEncodedURL(m_url);
if (flag) {
ASSERT(m_savedRenderer == 0);
m_savedRenderer = renderer();
- if (m_view)
- m_view->resetScrollbars();
+ if (FrameView* v = view())
+ v->resetScrollbars();
} else {
ASSERT(renderer() == 0 || renderer() == m_savedRenderer);
ASSERT(m_renderArena);
if (!processor->transformToString(this, resultMIMEType, newSource, resultEncoding))
return;
// FIXME: If the transform failed we should probably report an error (like Mozilla does).
- processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, view());
+ processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, frame());
}
#endif
class Document : public ContainerNode {
public:
- Document(DOMImplementation*, FrameView*);
+ Document(DOMImplementation*, Frame*);
~Document();
virtual void removedLastRef();
protected:
CSSStyleSelector* m_styleSelector;
- FrameView* m_view;
+ Frame* m_frame;
DocLoader* m_docLoader;
Tokenizer* m_tokenizer;
void CachedPage::restore(Page* page)
{
+ ASSERT(m_document->view() == m_view);
+
Frame* mainFrame = page->mainFrame();
KJSProxy* proxy = mainFrame->scriptProxy();
Window* window = Window::retrieveWindow(mainFrame);
return;
ASSERT(m_view);
- ASSERT(m_document->view() == m_view);
+ ASSERT(m_document->frame() == m_view->frame());
if (m_document->inPageCache()) {
Frame::clearTimers(m_view.get());
void clear();
Document* document() const { return m_document.get(); }
+ FrameView* view() const { return m_view.get(); }
Node* mousePressNode() const { return m_mousePressNode.get(); }
const KURL& URL() const { return m_URL; }
void restore(Page*);
using namespace HTMLNames;
-HTMLDocument::HTMLDocument(DOMImplementation* implementation, FrameView* view)
- : Document(implementation, view)
+HTMLDocument::HTMLDocument(DOMImplementation* implementation, Frame* frame)
+ : Document(implementation, frame)
{
m_xmlVersion = String();
}
class HTMLDocument : public Document, public CachedResourceClient {
public:
- HTMLDocument(DOMImplementation*, FrameView* = 0);
+ HTMLDocument(DOMImplementation*, Frame*);
virtual ~HTMLDocument();
virtual bool isHTMLDocument() const { return true; }
using namespace HTMLNames;
-HTMLViewSourceDocument::HTMLViewSourceDocument(DOMImplementation* implementation, FrameView* v)
- : HTMLDocument(implementation, v), m_current(0)
+HTMLViewSourceDocument::HTMLViewSourceDocument(DOMImplementation* implementation, Frame* frame)
+ : HTMLDocument(implementation, frame)
+ , m_current(0)
{
}
namespace WebCore {
-class DOMImplementation;
-class FrameView;
class Token;
-class Attribute;
class HTMLViewSourceDocument : public HTMLDocument
{
public:
- HTMLViewSourceDocument(DOMImplementation*, FrameView* = 0);
+ HTMLViewSourceDocument(DOMImplementation*, Frame*);
virtual Tokenizer* createTokenizer();
namespace WebCore {
-SVGDocument::SVGDocument(DOMImplementation* i, FrameView* view)
- : Document(i, view)
+SVGDocument::SVGDocument(DOMImplementation* i, Frame* frame)
+ : Document(i, frame)
{
}
class SVGDocument : public Document {
public:
- SVGDocument(DOMImplementation*, FrameView*);
+ SVGDocument(DOMImplementation*, Frame*);
virtual ~SVGDocument();
virtual bool isSVGDocument() const { return true; }
if (!m_URL.isEmpty())
baseurl = m_URL;
- RefPtr<Document> document = DOMImplementation::instance()->
- createDocument(m_responseMIMEType, m_frame->view(), m_frame->inViewSourceMode());
+ RefPtr<Document> document = DOMImplementation::instance()->createDocument(m_responseMIMEType, m_frame, m_frame->inViewSourceMode());
m_frame->setDocument(document.get());
document->setURL(m_URL.url());
m_wasLoadEventEmitted = false;
m_outgoingReferrer = URL.url();
- m_frame->setView(document->view());
+ m_frame->setView(cachedPage.view());
m_frame->setDocument(document);
m_decoder = document->decoder();
return false;
}
-ImageDocument::ImageDocument(DOMImplementation *_implementation, FrameView *v)
- : HTMLDocument(_implementation, v)
+ImageDocument::ImageDocument(DOMImplementation* implementation, Frame* frame)
+ : HTMLDocument(implementation, frame)
{
}
class ImageDocument : public HTMLDocument
{
public:
- ImageDocument(DOMImplementation*, FrameView* = 0);
+ ImageDocument(DOMImplementation*, Frame*);
virtual bool isImageDocument() const { return true; }
return false;
}
-PluginDocument::PluginDocument(DOMImplementation* _implementation, FrameView* v)
- : HTMLDocument(_implementation, v)
+PluginDocument::PluginDocument(DOMImplementation* implementation, Frame* frame)
+ : HTMLDocument(implementation, frame)
{
setParseMode(Compat);
}
class PluginDocument : public HTMLDocument
{
public:
- PluginDocument(DOMImplementation*, FrameView* = 0);
+ PluginDocument(DOMImplementation*, Frame*);
virtual bool isPluginDocument() const { return true; }
return false;
}
-TextDocument::TextDocument(DOMImplementation* implementation, FrameView* v)
- : HTMLDocument(implementation, v)
+TextDocument::TextDocument(DOMImplementation* implementation, Frame* frame)
+ : HTMLDocument(implementation, frame)
{
}
class TextDocument : public HTMLDocument
{
public:
- TextDocument(DOMImplementation*, FrameView* = 0);
+ TextDocument(DOMImplementation*, Frame*);
virtual Tokenizer* createTokenizer();
};
RefPtr<Document> XSLTProcessor::createDocumentFromSource(const DeprecatedString& sourceString,
- const DeprecatedString& sourceEncoding, const DeprecatedString& sourceMIMEType, Node* sourceNode, FrameView* view)
+ const DeprecatedString& sourceEncoding, const DeprecatedString& sourceMIMEType, Node* sourceNode, Frame* frame)
{
RefPtr<Document> ownerDocument = sourceNode->document();
bool sourceIsDocument = (sourceNode == ownerDocument.get());
String documentSource = sourceString;
RefPtr<Document> result;
- if (sourceMIMEType == "text/html")
- result = ownerDocument->implementation()->createHTMLDocument(view);
- else {
- result = ownerDocument->implementation()->createDocument(view);
- if (sourceMIMEType == "text/plain")
- transformTextStringToXHTMLDocumentString(documentSource);
- }
+ if (sourceMIMEType == "text/plain") {
+ result = ownerDocument->implementation()->createDocument(frame);
+ transformTextStringToXHTMLDocumentString(documentSource);
+ } else
+ result = ownerDocument->implementation()->createDocument(sourceMIMEType, frame, false);
// Before parsing, we need to save & detach the old document and get the new document
// in place. We have to do this only if we're rendering the result document.
- if (view) {
- view->clear();
- result->setTransformSourceDocument(view->frame()->document());
- view->frame()->setDocument(result.get());
+ if (frame) {
+ if (FrameView* view = frame->view())
+ view->clear();
+ result->setTransformSourceDocument(frame->document());
+ frame->setDocument(result.get());
}
result->open();
result->write(documentSource);
result->finishParsing();
- if (view)
- view->frame()->loader()->checkCompleted();
+ if (frame)
+ frame->loader()->checkCompleted();
else
result->close(); // FIXME: Even viewless docs can load subresources. onload will fire too early.
// This is probably a bug in XMLHttpRequestObjects as well.
DeprecatedString resultEncoding;
if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncoding))
return 0;
- return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode);
+ return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode, 0);
}
RefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
namespace WebCore {
-class FrameView;
+class Frame;
class Node;
class Document;
class DocumentFragment;
public:
void setXSLStylesheet(XSLStyleSheet *styleSheet) { m_stylesheet = styleSheet; }
bool transformToString(Node *source, DeprecatedString &resultMIMEType, DeprecatedString &resultString, DeprecatedString &resultEncoding);
- RefPtr<Document> createDocumentFromSource(const DeprecatedString &source, const DeprecatedString &sourceEncoding, const DeprecatedString &sourceMIMEType, Node *sourceNode, FrameView *view = 0);
+ RefPtr<Document> createDocumentFromSource(const DeprecatedString& source, const DeprecatedString& sourceEncoding, const DeprecatedString& sourceMIMEType, Node* sourceNode, Frame* frame);
// DOM methods
void importStylesheet(Node *style) { m_stylesheetRootNode = style; }