[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:25:45 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 4cea6fee6d3aff173e67a3607f538e5d4394f54e
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jul 21 02:48:12 2002 +0000

    Fixing the FOUC problem.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1609 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index e8e595e..067b580 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,50 @@
+2002-07-20  David Hyatt  <hyatt at apple.com>
+
+	This patch fixes the FOUC (flash of unstyled content) problem.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+	If stylesheets are still loading, the styleForElement method
+	will return a default "display: none" style that prevents
+	the rendering tree from being built for that element.  
+	
+        * khtml/html/html_headimpl.cpp:
+        (HTMLLinkElementImpl::process):
+        (HTMLLinkElementImpl::setStyleSheet):
+        (HTMLStyleElementImpl::sheetLoaded):
+	The link element has been patched to notify the document
+	when stylesheet loads start and finish.
+	
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::startBody):
+	This function has been hacked to unblock the layout of
+	inlines within a block.  This can be done the moment the
+	stylesheet loads have been kicked off (you don't have to
+	wait for them to finish).
+	
+        * khtml/rendering/render_object.h:
+	Contains a new method for recursively descending into the
+	render tree to unblock the layout of inlines.  This is done
+	as soon as the <body> is encountered, so the render tree is
+	small at the time the unblocking occurs.
+	
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::stylesheetLoaded):
+        (DocumentImpl::updateStyleSelector):
+	The new function, stylesheetLoaded, is invoked by link elements
+	when a stylesheet loads.  It simply decrements the loading sheet
+	count and calls updateStyleSelector.  updateStyleSelector has
+	been patched to avoid the recalculation of style until all 
+	stylesheets have loaded.
+	
+        * khtml/xml/dom_docimpl.h:
+	Two new methods.  The first, stylesheetLoaded, is described
+	above.  The second is haveStylesheetsLoaded, which indicates
+	whether or not all the sheets have completed loading.  A single
+	new member variable, m_pendingStylesheets, tracks the number
+	of sheets currently pending.
+	
 2002-07-20  Darin Adler  <darin at apple.com>
 
         * khtml/css/css_ruleimpl.cpp: (CSSImportRuleImpl::~CSSImportRuleImpl):
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index e8e595e..067b580 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,50 @@
+2002-07-20  David Hyatt  <hyatt at apple.com>
+
+	This patch fixes the FOUC (flash of unstyled content) problem.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+	If stylesheets are still loading, the styleForElement method
+	will return a default "display: none" style that prevents
+	the rendering tree from being built for that element.  
+	
+        * khtml/html/html_headimpl.cpp:
+        (HTMLLinkElementImpl::process):
+        (HTMLLinkElementImpl::setStyleSheet):
+        (HTMLStyleElementImpl::sheetLoaded):
+	The link element has been patched to notify the document
+	when stylesheet loads start and finish.
+	
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::startBody):
+	This function has been hacked to unblock the layout of
+	inlines within a block.  This can be done the moment the
+	stylesheet loads have been kicked off (you don't have to
+	wait for them to finish).
+	
+        * khtml/rendering/render_object.h:
+	Contains a new method for recursively descending into the
+	render tree to unblock the layout of inlines.  This is done
+	as soon as the <body> is encountered, so the render tree is
+	small at the time the unblocking occurs.
+	
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::stylesheetLoaded):
+        (DocumentImpl::updateStyleSelector):
+	The new function, stylesheetLoaded, is invoked by link elements
+	when a stylesheet loads.  It simply decrements the loading sheet
+	count and calls updateStyleSelector.  updateStyleSelector has
+	been patched to avoid the recalculation of style until all 
+	stylesheets have loaded.
+	
+        * khtml/xml/dom_docimpl.h:
+	Two new methods.  The first, stylesheetLoaded, is described
+	above.  The second is haveStylesheetsLoaded, which indicates
+	whether or not all the sheets have completed loading.  A single
+	new member variable, m_pendingStylesheets, tracks the number
+	of sheets currently pending.
+	
 2002-07-20  Darin Adler  <darin at apple.com>
 
         * khtml/css/css_ruleimpl.cpp: (CSSImportRuleImpl::~CSSImportRuleImpl):
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index e8e595e..067b580 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,50 @@
+2002-07-20  David Hyatt  <hyatt at apple.com>
+
+	This patch fixes the FOUC (flash of unstyled content) problem.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+	If stylesheets are still loading, the styleForElement method
+	will return a default "display: none" style that prevents
+	the rendering tree from being built for that element.  
+	
+        * khtml/html/html_headimpl.cpp:
+        (HTMLLinkElementImpl::process):
+        (HTMLLinkElementImpl::setStyleSheet):
+        (HTMLStyleElementImpl::sheetLoaded):
+	The link element has been patched to notify the document
+	when stylesheet loads start and finish.
+	
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::startBody):
+	This function has been hacked to unblock the layout of
+	inlines within a block.  This can be done the moment the
+	stylesheet loads have been kicked off (you don't have to
+	wait for them to finish).
+	
+        * khtml/rendering/render_object.h:
+	Contains a new method for recursively descending into the
+	render tree to unblock the layout of inlines.  This is done
+	as soon as the <body> is encountered, so the render tree is
+	small at the time the unblocking occurs.
+	
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::stylesheetLoaded):
+        (DocumentImpl::updateStyleSelector):
+	The new function, stylesheetLoaded, is invoked by link elements
+	when a stylesheet loads.  It simply decrements the loading sheet
+	count and calls updateStyleSelector.  updateStyleSelector has
+	been patched to avoid the recalculation of style until all 
+	stylesheets have loaded.
+	
+        * khtml/xml/dom_docimpl.h:
+	Two new methods.  The first, stylesheetLoaded, is described
+	above.  The second is haveStylesheetsLoaded, which indicates
+	whether or not all the sheets have completed loading.  A single
+	new member variable, m_pendingStylesheets, tracks the number
+	of sheets currently pending.
+	
 2002-07-20  Darin Adler  <darin at apple.com>
 
         * khtml/css/css_ruleimpl.cpp: (CSSImportRuleImpl::~CSSImportRuleImpl):
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index dd00723..2706b4b 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -72,6 +72,7 @@ namespace khtml {
 CSSStyleSelectorList *CSSStyleSelector::defaultStyle = 0;
 CSSStyleSelectorList *CSSStyleSelector::defaultPrintStyle = 0;
 CSSStyleSheetImpl *CSSStyleSelector::defaultSheet = 0;
+RenderStyle* CSSStyleSelector::displayNoneStyle = 0;
 
 static CSSStyleSelector::Encodedurl *encodedurl = 0;
 
@@ -225,9 +226,11 @@ void CSSStyleSelector::clear()
     delete defaultStyle;
     delete defaultPrintStyle;
     delete defaultSheet;
+    delete displayNoneStyle;
     defaultStyle = 0;
     defaultPrintStyle = 0;
     defaultSheet = 0;
+    displayNoneStyle = 0;
 }
 
 #define MAXFONTSIZES 15
@@ -289,6 +292,15 @@ static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
 
 RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
 {
+    if (!e->getDocument()->haveStylesheetsLoaded()) {
+        if (!displayNoneStyle) {
+            displayNoneStyle = new RenderStyle();
+	    displayNoneStyle->setDisplay(NONE);
+	    displayNoneStyle->ref();
+	}
+	return displayNoneStyle;
+    }
+  
     // set some variables we will need
     dynamicState = state;
     usedDynamicStates = StyleSelector::None;
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index e62c306..3c4cd13 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -157,6 +157,8 @@ namespace khtml
         CSSStyleSelectorList *userStyle;
         DOM::CSSStyleSheetImpl *userSheet;
 
+	static RenderStyle* displayNoneStyle;
+ 
     private:
         void init();
 
diff --git a/WebCore/khtml/html/html_headimpl.cpp b/WebCore/khtml/html/html_headimpl.cpp
index e026899..455d3f7 100644
--- a/WebCore/khtml/html/html_headimpl.cpp
+++ b/WebCore/khtml/html/html_headimpl.cpp
@@ -156,6 +156,8 @@ void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr)
     }
 }
 
+static bool inProcessFunction = false;
+
 void HTMLLinkElementImpl::process()
 {
     if (!inDocument())
@@ -186,13 +188,21 @@ void HTMLLinkElementImpl::process()
         // ### there may be in some situations e.g. for an editor or script to manipulate
         if( m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print") ) {
             m_loading = true;
-
+            inProcessFunction = true;
+            
             QString chset = getAttribute( ATTR_CHARSET ).string();
             if (m_cachedSheet)
 		m_cachedSheet->deref(this);
             m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(m_url, chset);
             if (m_cachedSheet)
 		m_cachedSheet->ref(this);
+
+            // If the stylesheet was synchronously available, then our m_loading variable will have
+            // been set to false when the cached sheet above gets a ref.  In this case, we don't
+            // need to add the sheet to our list of pending sheets, because it has already loaded.
+            if (m_loading)
+                getDocument()->addPendingSheet(); // Let the document know that we're pending.
+            inProcessFunction = false;
         }
     }
     else if (m_sheet) {
@@ -232,7 +242,11 @@ void HTMLLinkElementImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DO
 
     m_loading = false;
 
-    getDocument()->updateStyleSelector();
+    // Just tell the doc about the sheet.
+    if (!inProcessFunction)
+        getDocument()->stylesheetLoaded();
+    else
+        getDocument()->updateStyleSelector();
 }
 
 bool HTMLLinkElementImpl::isLoading() const
@@ -381,7 +395,7 @@ bool HTMLStyleElementImpl::isLoading() const
 
 void HTMLStyleElementImpl::sheetLoaded()
 {
-    getDocument()->updateStyleSelector();
+  getDocument()->updateStyleSelector();
 }
 
 // -------------------------------------------------------------------------
diff --git a/WebCore/khtml/html/htmlparser.cpp b/WebCore/khtml/html/htmlparser.cpp
index 0789fde..8da6d47 100644
--- a/WebCore/khtml/html/htmlparser.cpp
+++ b/WebCore/khtml/html/htmlparser.cpp
@@ -1276,6 +1276,13 @@ void KHTMLParser::startBody()
 
     inBody = true;
 
+    // This hack exists only to deal with unsetting the m_blockBidi
+    // bits in RenderFlows.  For more info, see render_object.h, and
+    // look at the closeEntireTree() method.
+    if (!document->document()->haveStylesheetsLoaded() && 
+	document->document()->renderer())
+        document->document()->renderer()->closeEntireTree();
+
     if( isindex ) {
         flat = true; // don't decend into this node
         insertNode( isindex );
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index f5c45b6..c4e2908 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -160,6 +160,22 @@ public:
     RenderObject *container() const;
 
     void setOverhangingContents(bool p=true);
+    
+    // This hack function is only required to clear the m_blockBidi variable
+    // in RenderFlows.  Unless this variable is cleared, inline children are
+    // prevented from laying out.  In the asynchronous stylesheet case, we
+    // don't go through the parser when attaching, so close() doesn't get called.
+    // Therefore blocks end up unwilling to lay out inline children when the
+    // stylesheets finally do come in. -- dwh
+    void closeEntireTree() {
+      RenderObject *child = firstChild();
+      while (child) {
+	child->closeEntireTree();
+	child = child->nextSibling();
+      }
+      close();
+    }
+
     void setLayouted(bool b=true) {
 	m_layouted = b;
 	if(!b) {
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 447f50d..b559bd7 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -279,6 +279,7 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_styleSelector = new CSSStyleSelector( this, m_usersheet, m_styleSheets, m_url,
                                             pMode == Strict );
     m_windowEventListeners.setAutoDelete(true);
+    m_pendingStylesheets = 0;
 }
 
 DocumentImpl::~DocumentImpl()
@@ -1667,8 +1668,22 @@ StyleSheetListImpl* DocumentImpl::styleSheets()
     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
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 14cb91c..c4faef5 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -157,6 +157,23 @@ 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
@@ -387,6 +404,12 @@ protected:
     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;
 
     QPaintDevice *m_paintDevice;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list