Commit 8f5c7f00 authored by hyatt's avatar hyatt

Fix for the 2.5% perf regression from the descendant rules

	changes.  This patch does 3 things:
	(1) Fix the descendant rule check in the CSS parser. It
	was incorrect.
	(2) Fix DOM insertion/removal from setting the parent as needing
	a style re-resolve.
	(3) Fix whitespace inside <html> so that it doesn't make a premature
	<body>.

        Reviewed by mjs

        * khtml/css/cssparser.cpp:
        (StyleBaseImpl::parseSelector):
        * khtml/html/htmlparser.cpp:
        (KHTMLParser::insertNode):
        * khtml/xml/dom_elementimpl.cpp:
        (ElementImpl::recalcStyle):
        * khtml/xml/dom_nodeimpl.cpp:
        (NodeBaseImpl::insertBefore):
        (NodeBaseImpl::replaceChild):
        (NodeBaseImpl::removeChild):
        (NodeBaseImpl::appendChild):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 338cd0d7
2003-01-21 David Hyatt <hyatt@apple.com>
Fix for the 2.5% perf regression from the descendant rules
changes. This patch does 3 things:
(1) Fix the descendant rule check in the CSS parser. It
was incorrect.
(2) Fix DOM insertion/removal from setting the parent as needing
a style re-resolve.
(3) Fix whitespace inside <html> so that it doesn't make a premature
<body>.
Reviewed by mjs
* khtml/css/cssparser.cpp:
(StyleBaseImpl::parseSelector):
* khtml/html/htmlparser.cpp:
(KHTMLParser::insertNode):
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::recalcStyle):
* khtml/xml/dom_nodeimpl.cpp:
(NodeBaseImpl::insertBefore):
(NodeBaseImpl::replaceChild):
(NodeBaseImpl::removeChild):
(NodeBaseImpl::appendChild):
2003-01-21 Darin Adler <darin@apple.com>
Reviewed by Richard.
......
2003-01-21 David Hyatt <hyatt@apple.com>
Fix for the 2.5% perf regression from the descendant rules
changes. This patch does 3 things:
(1) Fix the descendant rule check in the CSS parser. It
was incorrect.
(2) Fix DOM insertion/removal from setting the parent as needing
a style re-resolve.
(3) Fix whitespace inside <html> so that it doesn't make a premature
<body>.
Reviewed by mjs
* khtml/css/cssparser.cpp:
(StyleBaseImpl::parseSelector):
* khtml/html/htmlparser.cpp:
(KHTMLParser::insertNode):
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::recalcStyle):
* khtml/xml/dom_nodeimpl.cpp:
(NodeBaseImpl::insertBefore):
(NodeBaseImpl::replaceChild):
(NodeBaseImpl::removeChild):
(NodeBaseImpl::appendChild):
2003-01-21 Darin Adler <darin@apple.com>
Reviewed by Richard.
......
......@@ -689,25 +689,33 @@ StyleBaseImpl::parseSelector(const QChar *curP, const QChar *endP)
slist->setAutoDelete(true);
}
slist->append(selector);
if (!sawDescendantRule &&
(selector->relation == CSSSelector::Descendant ||
selector->relation == CSSSelector::Child)) {
// We encountered a descendant rule. Get our document and set its
// descendant rule flag to true.
sawDescendantRule = true;
StyleBaseImpl *b = this;
StyleBaseImpl *root = this;
while (b) {
root = b;
b = b->m_parent;
}
if (root && root->isStyleSheet()) {
StyleSheetImpl *sheet = static_cast<StyleSheetImpl *>(root);
if (sheet->ownerNode()) {
DocumentImpl *doc = sheet->ownerNode()->getDocument();
doc->setUsesDescendantRules(true);
if (!sawDescendantRule) {
CSSSelector* sel = selector;
CSSSelector::Relation relation = sel->relation;
while ((sel = sel->tagHistory)) {
if (relation == CSSSelector::Descendant ||
relation == CSSSelector::Child) {
// We encountered a descendant rule. Get our document and set its
// descendant rule flag to true.
sawDescendantRule = true;
StyleBaseImpl *b = this;
StyleBaseImpl *root = this;
while (b) {
root = b;
b = b->m_parent;
}
if (root && root->isStyleSheet()) {
StyleSheetImpl *sheet = static_cast<StyleSheetImpl *>(root);
if (sheet->ownerNode()) {
DocumentImpl *doc = sheet->ownerNode()->getDocument();
if (!doc->usesDescendantRules())
doc->setUsesDescendantRules(true);
}
}
break;
}
relation = sel->relation;
}
}
}
......
......@@ -566,6 +566,12 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
handled = true;
}
break;
case ID_TEXT: {
TextImpl *t = static_cast<TextImpl *>(n);
if (t->containsOnlyWhitespace())
return false;
/* Fall through to default */
}
default:
if ( haveFrameSet ) break;
e = new HTMLBodyElementImpl(document);
......
......@@ -329,6 +329,8 @@ void ElementImpl::recalcStyle( StyleChange change )
{
// ### should go away and be done in renderobject
RenderStyle* _style = m_render ? m_render->style() : 0;
bool hasParentRenderer = parent() ? parent()->renderer() : false;
#if 0
const char* debug;
switch(change) {
......@@ -343,7 +345,7 @@ void ElementImpl::recalcStyle( StyleChange change )
}
qDebug("recalcStyle(%d: %s)[%p: %s]", change, debug, this, tagName().string().latin1());
#endif
if ( change >= Inherit || changed() ) {
if ( hasParentRenderer && (change >= Inherit || changed()) ) {
EDisplay oldDisplay = _style ? _style->display() : NONE;
RenderStyle *newStyle = getDocument()->styleSelector()->styleForElement(this);
......
......@@ -1164,8 +1164,7 @@ NodeImpl *NodeBaseImpl::insertBefore ( NodeImpl *newChild, NodeImpl *refChild, i
child = nextChild;
}
// ### set style in case it's attached
setChanged(true);
getDocument()->setDocumentChanged(true);
dispatchSubtreeModifiedEvent();
return newChild;
}
......@@ -1240,7 +1239,7 @@ NodeImpl *NodeBaseImpl::replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, i
}
// ### set style in case it's attached
setChanged(true);
getDocument()->setDocumentChanged(true);
dispatchSubtreeModifiedEvent();
return oldChild;
}
......@@ -1292,7 +1291,7 @@ NodeImpl *NodeBaseImpl::removeChild ( NodeImpl *oldChild, int &exceptioncode )
oldChild->setNextSibling(0);
oldChild->setParent(0);
setChanged(true);
getDocument()->setDocumentChanged(true);
// Dispatch post-removal mutation events
dispatchSubtreeModifiedEvent();
......@@ -1391,7 +1390,7 @@ NodeImpl *NodeBaseImpl::appendChild ( NodeImpl *newChild, int &exceptioncode )
child = nextChild;
}
setChanged(true);
getDocument()->setDocumentChanged(true);
// ### set style in case it's attached
dispatchSubtreeModifiedEvent();
return newChild;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment