Commit aa59fcd9 authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-16 David Hyatt <hyatt@apple.com>

        Add a new flag (similar to first-line and first-letter) to Document to track whether any before/after rules
        are being used.  If not, don't waste time probing for those pseudo element styles.

        Reviewed by Sam Weinig

        * css/CSSGrammar.y:
        * dom/Document.cpp:
        (WebCore::Document::Document):
        * dom/Document.h:
        (WebCore::Document::usesBeforeAfterRules):
        (WebCore::Document::setUsesBeforeAfterRules):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::styleDidChange):
        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::updateBeforeAfterContentForContainer):
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::styleDidChange):
        (WebCore::RenderInline::addChildToFlow):
        (WebCore::RenderInline::splitInlines):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7d33ec57
2009-01-16 David Hyatt <hyatt@apple.com>
Add a new flag (similar to first-line and first-letter) to Document to track whether any before/after rules
are being used. If not, don't waste time probing for those pseudo element styles.
Reviewed by Sam Weinig
* css/CSSGrammar.y:
* dom/Document.cpp:
(WebCore::Document::Document):
* dom/Document.h:
(WebCore::Document::usesBeforeAfterRules):
(WebCore::Document::setUsesBeforeAfterRules):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange):
* rendering/RenderContainer.cpp:
(WebCore::RenderContainer::updateBeforeAfterContentForContainer):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::addChildToFlow):
(WebCore::RenderInline::splitInlines):
2009-01-16 Dmitry Titov <dimich@chromium.org>
Reviewed by Alp Toker.
......@@ -1097,6 +1097,11 @@ pseudo:
CSSParser* p = static_cast<CSSParser*>(parser);
if (Document* doc = p->document())
doc->setUsesFirstLineRules(true);
} else if (type == CSSSelector::PseudoBefore ||
type == CSSSelector::PseudoAfter) {
CSSParser* p = static_cast<CSSParser*>(parser);
if (Document* doc = p->document())
doc->setUsesBeforeAfterRules(true);
}
}
| ':' ':' IDENT {
......@@ -1111,6 +1116,11 @@ pseudo:
CSSParser* p = static_cast<CSSParser*>(parser);
if (Document* doc = p->document())
doc->setUsesFirstLineRules(true);
} else if (type == CSSSelector::PseudoBefore ||
type == CSSSelector::PseudoAfter) {
CSSParser* p = static_cast<CSSParser*>(parser);
if (Document* doc = p->document())
doc->setUsesBeforeAfterRules(true);
}
}
// used by :nth-*(ax+b)
......
......@@ -348,6 +348,7 @@ Document::Document(Frame* frame, bool isXHTML)
m_usesSiblingRules = false;
m_usesFirstLineRules = false;
m_usesFirstLetterRules = false;
m_usesBeforeAfterRules = false;
m_gotoAnchorNeededAfterStylesheetsLoad = false;
m_styleSelector = 0;
......
......@@ -361,6 +361,8 @@ public:
void setUsesFirstLineRules(bool b) { m_usesFirstLineRules = b; }
bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
void setUsesFirstLetterRules(bool b) { m_usesFirstLetterRules = b; }
bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
void setUsesBeforeAfterRules(bool b) { m_usesBeforeAfterRules = b; }
// Machinery for saving and restoring state when you leave and then go back to a page.
void registerFormElementWithState(HTMLFormControlElementWithState* e) { m_formElementsWithState.add(e); }
......@@ -895,6 +897,7 @@ private:
bool m_usesSiblingRules;
bool m_usesFirstLineRules;
bool m_usesFirstLetterRules;
bool m_usesBeforeAfterRules;
bool m_gotoAnchorNeededAfterStylesheetsLoad;
bool m_isDNSPrefetchEnabled;
bool m_haveExplicitlyDisabledDNSPrefetch;
......
......@@ -172,7 +172,7 @@ void RenderBlock::styleDidChange(RenderStyle::Diff diff, const RenderStyle* oldS
m_lineHeight = -1;
// Update pseudos for :before and :after now.
if (!isAnonymous() && canHaveChildren()) {
if (!isAnonymous() && document()->usesBeforeAfterRules() && canHaveChildren()) {
updateBeforeAfterContent(RenderStyle::BEFORE);
updateBeforeAfterContent(RenderStyle::AFTER);
}
......
......@@ -258,6 +258,9 @@ static RenderObject* findBeforeAfterParent(RenderObject* object)
void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId type, RenderContainer* styledObject)
{
// Double check that the document did in fact use generated content rules. Otherwise we should not have been called.
ASSERT(document()->usesBeforeAfterRules());
// In CSS2, before/after pseudo-content cannot nest. Check this first.
if (style()->styleType() == RenderStyle::BEFORE || style()->styleType() == RenderStyle::AFTER)
return;
......
......@@ -68,7 +68,7 @@ void RenderInline::styleDidChange(RenderStyle::Diff diff, const RenderStyle* old
m_lineHeight = -1;
// Update pseudos for :before and :after now.
if (!isAnonymous()) {
if (!isAnonymous() && document()->usesBeforeAfterRules()) {
updateBeforeAfterContent(RenderStyle::BEFORE);
updateBeforeAfterContent(RenderStyle::AFTER);
}
......@@ -115,7 +115,8 @@ void RenderInline::addChildToFlow(RenderObject* newChild, RenderObject* beforeCh
// has to move into the inline continuation. Call updateBeforeAfterContent to ensure that our :after
// content gets properly destroyed.
bool isLastChild = (beforeChild == lastChild());
updateBeforeAfterContent(RenderStyle::AFTER);
if (document()->usesBeforeAfterRules())
updateBeforeAfterContent(RenderStyle::AFTER);
if (isLastChild && beforeChild != lastChild())
beforeChild = 0; // We destroyed the last child, so now we need to update our insertion
// point to be 0. It's just a straight append now.
......@@ -187,7 +188,8 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
// Someone may have indirectly caused a <q> to split. When this happens, the :after content
// has to move into the inline continuation. Call updateBeforeAfterContent to ensure that the inline's :after
// content gets properly destroyed.
curr->updateBeforeAfterContent(RenderStyle::AFTER);
if (document()->usesBeforeAfterRules())
curr->updateBeforeAfterContent(RenderStyle::AFTER);
// Now we need to take all of the children starting from the first child
// *after* currChild and append them all to the clone.
......
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