Changeset 57299 in webkit


Ignore:
Timestamp:
Apr 8, 2010 3:37:37 PM (14 years ago)
Author:
hyatt@apple.com
Message:

Followup optimization to bug 24300, don't leak history info via CSS :visited. If a Web
site uses document colors that are the same for link and vlink in HTML and also doesn't
specify any :link or :visited rules, then don't waste time resolving visited styles.

Reviewed by Oliver Hunt.

There is a further optimization that could be done to detect when :link and :visited are
used together in the same rule to specify a color, and this is how most sites turn off
visited link colors, but this fix doesn't address that. It just restores the optimization
that existed prior to the patch in 24300 landing.

  • css/CSSGrammar.y:
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::styleForElement):

  • dom/Document.cpp:

(WebCore::Document::Document):

  • dom/Document.h:

(WebCore::Document::usesLinkRules):
(WebCore::Document::setUsesLinkRules):

Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57297 r57299  
     12010-04-08  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Followup optimization to bug 24300, don't leak history info via CSS :visited.  If a Web
     6        site uses document colors that are the same for link and vlink in HTML and also doesn't
     7        specify any :link or :visited rules, then don't waste time resolving visited styles.
     8
     9        There is a further optimization that could be done to detect when :link and :visited are
     10        used together in the same rule to specify a color, and this is how most sites turn off
     11        visited link colors, but this fix doesn't address that.  It just restores the optimization
     12        that existed prior to the patch in 24300 landing.
     13
     14        * css/CSSGrammar.y:
     15        * css/CSSStyleSelector.cpp:
     16        (WebCore::CSSStyleSelector::styleForElement):
     17        * dom/Document.cpp:
     18        (WebCore::Document::Document):
     19        * dom/Document.h:
     20        (WebCore::Document::usesLinkRules):
     21        (WebCore::Document::setUsesLinkRules):
     22
    1232010-04-08  David Hyatt  <hyatt@apple.com>
    224
  • trunk/WebCore/css/CSSGrammar.y

    r57161 r57299  
    10961096            if (Document* doc = p->document())
    10971097                doc->setUsesBeforeAfterRules(true);
     1098        } else if (type == CSSSelector::PseudoLink || type == CSSSelector::PseudoVisited) {
     1099            CSSParser* p = static_cast<CSSParser*>(parser);
     1100            if (Document* doc = p->document())
     1101                doc->setUsesLinkRules(true);
    10981102        }
    10991103    }
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r57292 r57299  
    13191319
    13201320    // Compute our style allowing :visited to match.
    1321     if (!matchVisitedRules && m_style->insideLink()) {
     1321    if (!matchVisitedRules && m_style->insideLink() && e->document()->usesLinkRules()) {
    13221322        // Fetch our parent style.
    13231323        RenderStyle* parentStyle = m_parentStyle;
  • trunk/WebCore/dom/Document.cpp

    r57210 r57299  
    429429    m_usesBeforeAfterRules = false;
    430430    m_usesRemUnits = false;
     431    m_usesLinkRules = false;
    431432
    432433    m_gotoAnchorNeededAfterStylesheetsLoad = false;
  • trunk/WebCore/dom/Document.h

    r57210 r57299  
    441441    bool usesRemUnits() const { return m_usesRemUnits; }
    442442    void setUsesRemUnits(bool b) { m_usesRemUnits = b; }
     443    bool usesLinkRules() const { return linkColor() != visitedLinkColor() || m_usesLinkRules; }
     444    void setUsesLinkRules(bool b) { m_usesLinkRules = b; }
    443445
    444446    // Machinery for saving and restoring state when you leave and then go back to a page.
     
    11021104    bool m_usesBeforeAfterRules;
    11031105    bool m_usesRemUnits;
     1106    bool m_usesLinkRules;
    11041107    bool m_gotoAnchorNeededAfterStylesheetsLoad;
    11051108    bool m_isDNSPrefetchEnabled;
Note: See TracChangeset for help on using the changeset viewer.