safari patch splitup: close renderer
Alexander Kellett
lypanov at kde.org
Thu Jan 9 13:17:10 GMT 2003
this patch is a splitup of the closeRenderer() changes
untested (compile is taking aaaggggesssss)
Alex
--
"[...] Konqueror open source project. Weighing in at less than
one tenth the size of another open source renderer"
Apple, Jan 2003 (http://www.apple.com/safari/)
-------------- next part --------------
Index: html/htmlparser.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/htmlparser.cpp,v
retrieving revision 1.315
diff -u -p -B -w -r1.315 htmlparser.cpp
--- html/htmlparser.cpp 6 Jan 2003 12:52:53 -0000 1.315
+++ html/htmlparser.cpp 9 Jan 2003 13:20:15 -0000
@@ -331,8 +331,7 @@ bool KHTMLParser::insertNode(NodeImpl *n
QString state(document->document()->nextState());
if (!state.isNull()) n->restoreState(state);
}
- if(n->renderer())
- n->renderer()->close();
+ n->closeRenderer();
#endif
if(n->isInline()) m_inline = true;
}
@@ -1187,8 +1186,7 @@ void KHTMLParser::popOneBlock()
QString state(document->document()->nextState());
if (!state.isNull()) current->restoreState(state);
}
- if (current->renderer())
- current->renderer()->close();
+ current->closeRenderer();
}
#endif
Index: xml/dom_nodeimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_nodeimpl.cpp,v
retrieving revision 1.199
diff -u -p -B -w -r1.199 dom_nodeimpl.cpp
--- xml/dom_nodeimpl.cpp 8 Jan 2003 19:23:01 -0000 1.199
+++ xml/dom_nodeimpl.cpp 9 Jan 2003 13:20:15 -0000
@@ -62,6 +62,7 @@ NodeImpl::NodeImpl(DocumentPtr *doc)
m_focused( false ),
m_active( false ),
m_styleElement( false ),
+ m_rendererNeedsClose( false ),
m_implicit( false )
{
if (document)
@@ -888,10 +889,28 @@ void NodeImpl::dump(QTextStream *stream,
}
#endif
+void NodeImpl::closeRenderer()
+{
+ // It's important that we close the renderer, even if it hasn't been
+ // created yet. This happens even more because of the FOUC fixes we did
+ // at Apple, which prevent renderers from being created until the stylesheets
+ // are all loaded. If the renderer is not here to be closed, we set a flag,
+ // then close it later when it's attached.
+ assert(!m_rendererNeedsClose);
+ if (m_render)
+ m_render->close();
+ else
+ m_rendererNeedsClose = true;
+}
+
void NodeImpl::attach()
{
assert(!attached());
assert(!m_render || (m_render->style() && m_render->parent()));
+ if (m_render && m_rendererNeedsClose) {
+ m_render->close();
+ m_rendererNeedsClose = false;
+ }
m_attached = true;
}
Index: xml/dom_nodeimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_nodeimpl.h,v
retrieving revision 1.140
diff -u -p -B -w -r1.140 dom_nodeimpl.h
--- xml/dom_nodeimpl.h 8 Jan 2003 19:24:00 -0000 1.140
+++ xml/dom_nodeimpl.h 9 Jan 2003 13:20:15 -0000
@@ -290,6 +290,8 @@ public:
*/
virtual void detach();
+ void closeRenderer();
+
// -----------------------------------------------------------------------------
// Methods for maintaining the state of the element between history navigation
@@ -371,8 +373,9 @@ protected:
bool m_active : 1;
bool m_styleElement : 1; // contains stylesheet text
bool m_implicit : 1; // implicitely generated by the parser
+ bool m_rendererNeedsClose : 1;
- // 2 bits unused
+ // 1 bits unused
};
// this is the full Node Implementation with parents and children.
Index: xml/xml_tokenizer.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/xml_tokenizer.cpp,v
retrieving revision 1.40
diff -u -p -B -w -r1.40 xml_tokenizer.cpp
--- xml/xml_tokenizer.cpp 11 Dec 2002 21:11:53 -0000 1.40
+++ xml/xml_tokenizer.cpp 9 Jan 2003 13:20:15 -0000
@@ -113,8 +113,7 @@ bool XMLHandler::endElement( const QStri
if (m_currentNode->nodeType() == Node::TEXT_NODE)
exitText();
if (m_currentNode->parentNode() != 0) {
- if (m_currentNode->renderer())
- m_currentNode->renderer()->close();
+ m_currentNode->closeRenderer();
m_currentNode = m_currentNode->parentNode();
}
// ### else error
@@ -385,9 +384,9 @@ void XMLTokenizer::finish()
// Close the renderers so that they update their display correctly
// ### this should not be necessary, but requires changes in the rendering code...
- h1->renderer()->close();
- pre->renderer()->close();
- body->renderer()->close();
+ h1->closeRenderer();
+ pre->closeRenderer();
+ body->closeRenderer();
m_doc->document()->recalcStyle( NodeImpl::Inherit );
m_doc->document()->updateRendering();
More information about the kfm-devel
mailing list