XML Patch For FOUC
Alexander Kellett
lypanov@kde.org
Wed, 15 Jan 2003 10:27:24 +0100
--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
ach. caught by that famous MUA bug, the one
were it forgets to remind you to attach :)
Alex
On Wed, Jan 15, 2003 at 10:21:59AM +0100, Alexander Kellett wrote:
> hiya david!
>
> quick question to cvs khtml people, why is parentNode()->renderer()
> asserted in some attach() methods but not in others?, bugs?
>
> the attached patch merges in the below dom_xmlimpl.cpp
> changes (didn't have time to look into the <link> element logic)
> and does a s/_style/style/ in html/html_baseimpl.cpp to make the
> code slightly cleaner. adds some parentNode()->renderer() checks
> and removes some asserts, and a few other things that i noticed
> in the WebCore diffs. questions about those few things follow...
>
> david, one thing i wondered was why HTMLFrameSetElementImpl::attach
> uses isStyleAvailable rather than a parentNode()->renderer() like
> most of the other code. problem is that i'm really unsure of
> the "assert(parentNode()->renderer());" removal that i made.
> i'll have time on sunday to get a grasp on the entire attach/addChild
> situation in khtml, but before then i'm just looking through a
> magnifying glass at the WebCore diff code sections only :)
>
> one more thing, is the HTMLFrameElementImpl::contentDocument change
> purely to remove the use of renderer() and thus to stop possible
> crashes due to FOUC?
>
> btw, current version of stylesheet support does have
> alternate and disabled (not sure about title)
> well, assuming that the html/html_headimpl.h (isDisabled for example)
> changes that were merged by antti during the fouc merge?
> i'm reallyl unsure as to whether these are all the changes
> needed. for example i'm not sure that m_media and m_type
> are being set at all in fact. i'll do some more checks on this.
>
> thanks,
> Alex
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/)
--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fouc-all-v5-partial.patch"
Index: html/html_baseimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_baseimpl.cpp,v
retrieving revision 1.177
diff -u -p -B -w -r1.177 html_baseimpl.cpp
--- html/html_baseimpl.cpp 14 Jan 2003 09:42:03 -0000 1.177
+++ html/html_baseimpl.cpp 15 Jan 2003 10:01:57 -0000
@@ -296,7 +296,6 @@ void HTMLFrameElementImpl::attach()
{
assert(!attached());
assert(parentNode());
- assert(parentNode()->renderer());
// we should first look up via id, then via name.
// this shortterm hack fixes the ugly case. ### rewrite needed for next release
@@ -319,9 +318,7 @@ void HTMLFrameElementImpl::attach()
}
// ignore display: none for this element!
- KHTMLView* w = getDocument()->view();
-
- if (isURLAllowed(url.string())) {
+ if (parentNode()->renderer() && isURLAllowed(url.string())) {
m_render = new RenderFrame(this);
m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
parentNode()->renderer()->addChild(m_render, nextRenderer());
@@ -332,6 +329,8 @@ void HTMLFrameElementImpl::attach()
if (!m_render)
return;
+ KHTMLView* w = getDocument()->view();
+
// we need a unique name for every frame in the frameset. Hope that's unique enough.
if(name.isEmpty() || w->part()->frameExists( name.string() ) )
name = DOMString(w->part()->requestFrameName());
@@ -368,12 +367,14 @@ void HTMLFrameElementImpl::setFocus(bool
DocumentImpl* HTMLFrameElementImpl::contentDocument() const
{
- if ( !m_render ) return 0;
-
- RenderPart* render = static_cast<RenderPart*>( m_render );
+ KHTMLView* w = getDocument()->view();
- if(render->widget() && render->widget()->inherits("KHTMLView"))
- return static_cast<KHTMLView*>( render->widget() )->part()->xmlDocImpl();
+ if (w) {
+ KHTMLPart *part = w->part()->findFrame( name.string() );
+ if (part) {
+ return part->xmlDocImpl();
+ }
+ }
return 0;
}
@@ -459,7 +460,6 @@ void HTMLFrameSetElementImpl::attach()
{
assert(!m_render);
assert(parentNode());
- assert(parentNode()->renderer());
// inherit default settings from parent frameset
HTMLElementImpl* node = static_cast<HTMLElementImpl*>(parentNode());
@@ -475,10 +475,16 @@ void HTMLFrameSetElementImpl::attach()
node = static_cast<HTMLElementImpl*>(node->parentNode());
}
- // ignore display: none
+ // ignore display: none but do pay attention if a stylesheet has caused us to delay
+ // our loading.
+ RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+ style->ref();
+ if (style->isStyleAvailable()) {
m_render = new RenderFrameSet(this);
- m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
+ m_render->setStyle(style);
parentNode()->renderer()->addChild(m_render, nextRenderer());
+ }
+ style->deref();
NodeBaseImpl::attach();
}
@@ -523,17 +529,16 @@ void HTMLHtmlElementImpl::attach()
{
assert(!m_render);
assert(parentNode());
- assert(parentNode()->renderer());
- RenderStyle* _style = getDocument()->styleSelector()->styleForElement(this);
- _style->ref();
- if (_style->display() != NONE)
+ RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+ style->ref();
+ if (parentNode()->renderer() && style->display() != NONE)
{
m_render = new RenderHtml(this);
- m_render->setStyle(_style);
+ m_render->setStyle(style);
parentNode()->renderer()->addChild(m_render, nextRenderer());
}
- _style->deref();
+ style->deref();
NodeBaseImpl::attach();
}
@@ -589,15 +594,14 @@ void HTMLIFrameElementImpl::attach()
assert(!m_render);
assert(parentNode());
- RenderStyle* _style = getDocument()->styleSelector()->styleForElement(this);
- _style->ref();
- if (isURLAllowed(url.string()) &&
- parentNode()->renderer() && _style->display() != NONE) {
+ RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+ style->ref();
+ if (isURLAllowed(url.string()) && parentNode()->renderer() && style->display() != NONE) {
m_render = new RenderPartObject(this);
- m_render->setStyle(_style);
+ m_render->setStyle(style);
parentNode()->renderer()->addChild(m_render, nextRenderer());
}
- _style->deref();
+ style->deref();
NodeBaseImpl::attach();
Index: rendering/render_style.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_style.cpp,v
retrieving revision 1.56
diff -u -p -B -w -r1.56 render_style.cpp
--- rendering/render_style.cpp 12 Jan 2003 20:00:21 -0000 1.56
+++ rendering/render_style.cpp 15 Jan 2003 10:01:57 -0000
@@ -24,6 +24,7 @@
*/
#include "xml/dom_stringimpl.h"
+#include "css/cssstyleselector.h"
#include "render_style.h"
@@ -230,6 +231,11 @@ bool RenderStyle::operator==(const Rende
background == o.background &&
surround == o.surround &&
inherited == o.inherited);
+}
+
+bool RenderStyle::isStyleAvailable() const
+{
+ return this != CSSStyleSelector::styleNotYetAvailable;
}
RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid)
Index: rendering/render_style.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_style.h,v
retrieving revision 1.80
diff -u -p -B -w -r1.80 render_style.h
--- rendering/render_style.h 28 Dec 2002 14:05:05 -0000 1.80
+++ rendering/render_style.h 15 Jan 2003 10:01:57 -0000
@@ -640,6 +640,8 @@ public:
bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
+ bool isStyleAvailable() const;
+
// attribute getter methods
EDisplay display() const { return noninherited_flags._display; }
Index: xml/dom_xmlimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_xmlimpl.cpp,v
retrieving revision 1.23
diff -u -p -B -w -r1.23 dom_xmlimpl.cpp
--- xml/dom_xmlimpl.cpp 9 Dec 2002 07:21:45 -0000 1.23
+++ xml/dom_xmlimpl.cpp 15 Jan 2003 10:01:57 -0000
@@ -257,6 +257,7 @@ ProcessingInstructionImpl::ProcessingIns
m_localHref = 0;
m_sheet = 0;
m_cachedSheet = 0;
+ m_loading = false;
}
ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentPtr *doc, DOMString _target, DOMString _data) : NodeBaseImpl(doc)
@@ -373,6 +374,8 @@ void ProcessingInstructionImpl::checkSty
{
// ### some validation on the URL?
// ### FIXME charset
+ m_loading = true;
+ getDocument()->addPendingSheet();
if (m_cachedSheet) m_cachedSheet->deref(this);
m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(getDocument()->completeURL(href.string()), QString::null);
if (m_cachedSheet)
@@ -383,6 +386,20 @@ void ProcessingInstructionImpl::checkSty
}
}
+bool ProcessingInstructionImpl::isLoading() const
+{
+ if(m_loading) return true;
+ if(!m_sheet) return false;
+ return static_cast<CSSStyleSheetImpl *>(m_sheet)->isLoading();
+}
+
+void ProcessingInstructionImpl::sheetLoaded()
+{
+ if (!isLoading())
+ getDocument()->stylesheetLoaded();
+}
+
+
StyleSheetImpl *ProcessingInstructionImpl::sheet() const
{
return m_sheet;
@@ -399,7 +416,11 @@ void ProcessingInstructionImpl::setStyle
m_cachedSheet->deref(this);
m_cachedSheet = 0;
- getDocument()->updateStyleSelector();
+ m_loading = false;
+
+ // Tell the doc about the sheet.
+ if (!isLoading() && m_sheet)
+ getDocument()->stylesheetLoaded();
}
void ProcessingInstructionImpl::setStyleSheet(CSSStyleSheetImpl* sheet)
Index: xml/dom_xmlimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/xml/dom_xmlimpl.h,v
retrieving revision 1.21
diff -u -p -B -w -r1.21 dom_xmlimpl.h
--- xml/dom_xmlimpl.h 9 Dec 2002 07:21:45 -0000 1.21
+++ xml/dom_xmlimpl.h 15 Jan 2003 10:01:57 -0000
@@ -150,6 +150,8 @@ public:
void checkStyleSheet();
virtual void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet);
virtual void setStyleSheet(CSSStyleSheetImpl* sheet);
+ bool isLoading() const;
+ void sheetLoaded();
protected:
DOMStringImpl *m_target;
@@ -157,6 +159,7 @@ protected:
DOMStringImpl *m_localHref;
khtml::CachedCSSStyleSheet *m_cachedSheet;
CSSStyleSheetImpl *m_sheet;
+ bool m_loading;
};
class XMLAttributeReader : public QXmlDefaultHandler
--yrj/dFKFPuw6o+aM--