safari patch splitup: stylesheetpending counter
Alexander Kellett
lypanov at kde.org
Thu Jan 9 15:45:37 GMT 2003
(patch six)
style sheet pending counter
needed for last patch
mvg,
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: dom_docimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_docimpl.h,v
retrieving revision 1.102
diff -u -p -B -w -r1.102 dom_docimpl.h
--- dom_docimpl.h 8 Jan 2003 18:17:25 -0000 1.102
+++ dom_docimpl.h 9 Jan 2003 15:49:16 -0000
@@ -162,6 +162,24 @@ public:
khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; }
/**
+ * Updates the pending sheet count and then calls updateStyleSelector.
+ */
+ void stylesheetLoaded();
+
+ /**
+ * This method returns true if all top-level stylesheets have loaded (including
+ * any @imports that they may be loading).
+ */
+ bool haveStylesheetsLoaded() { return m_pendingStylesheets <= 0; }
+
+ /**
+ * Increments the number of pending sheets. The <link> elements
+ * invoke this to add themselves to the loading list.
+ */
+ void addPendingSheet() { m_pendingStylesheets++; }
+
+
+ /**
* Called when one or more stylesheets in the document may have been added, removed or changed.
*
* Creates a new style selector and assign it to this document. This is done by iterating through all nodes in
@@ -392,6 +410,12 @@ protected:
QString m_usersheet;
QString m_printSheet;
QStringList m_availableSheets;
+
+ // Track the number of currently loading top-level stylesheets. Sheets
+ // loaded using the @import directive are not included in this count.
+ // We use this count of pending sheets to detect when we can begin attaching
+ // elements.
+ int m_pendingStylesheets;
CSSStyleSheetImpl *m_elemSheet;
Index: dom_docimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.210
diff -u -p -B -w -r1.210 dom_docimpl.cpp
--- dom_docimpl.cpp 8 Jan 2003 19:29:56 -0000 1.210
+++ dom_docimpl.cpp 9 Jan 2003 15:49:16 -0000
@@ -287,6 +287,7 @@ DocumentImpl::DocumentImpl(DOMImplementa
m_windowEventListeners.setAutoDelete(true);
m_inStyleRecalc = false;
+ m_pendingStylesheets = 0;
}
DocumentImpl::~DocumentImpl()
@@ -1744,8 +1745,22 @@ StyleSheetListImpl* DocumentImpl::styleS
return m_styleSheets;
}
+// This method is called whenever a top-level stylesheet has finished loading.
+void DocumentImpl::stylesheetLoaded()
+{
+ // Make sure we knew this sheet was pending, and that our count isn't out of sync.
+ assert(m_pendingStylesheets > 0);
+
+ m_pendingStylesheets--;
+ updateStyleSelector();
+}
+
void DocumentImpl::updateStyleSelector()
{
+ // Don't bother updating, since we haven't loaded all our style info yet.
+ if (m_pendingStylesheets > 0)
+ return;
+
recalcStyleSelector();
recalcStyle(Force);
#if 0
More information about the kfm-devel
mailing list