Changeset 105280 in webkit


Ignore:
Timestamp:
Jan 18, 2012 8:57:16 AM (12 years ago)
Author:
mihnea@adobe.com
Message:

[CSSRegions]Fix region style code in CSSStyleSelector
https://bugs.webkit.org/show_bug.cgi?id=76453

Reviewed by Antti Koivisto.

Source/WebCore:

Follow up after comments in https://bugs.webkit.org/show_bug.cgi?id=76064.
With the new approach, the css rule specificity is correctly taken into account
when applying the region style rule.
No new tests, the region style tests are still disabled.

  • css/CSSStyleSelector.cpp:

(WebCore::RuleSet::RuleSetSelectorPair::RuleSetSelectorPair):
(WebCore::CSSStyleSelector::CSSStyleSelector):
(WebCore::CSSStyleSelector::addMatchedDeclaration):
(WebCore::CSSStyleSelector::collectMatchingRules):
(WebCore::CSSStyleSelector::collectMatchingRulesForRegion):
(WebCore::CSSStyleSelector::matchRules):
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
(WebCore::CSSStyleSelector::matchAllRules):
(WebCore::CSSStyleSelector::styleForElement):
(WebCore::CSSStyleSelector::pseudoStyleForElement):
(WebCore::CSSStyleSelector::checkRegionStyle):
(WebCore::CSSStyleSelector::checkRegionSelector):
(WebCore::RuleData::RuleData):
(WebCore::RuleSet::RuleSet):
(WebCore::RuleSet::addRule):
(WebCore::RuleSet::addRegionRule):
(WebCore::RuleSet::addRulesFromSheet):
(WebCore::isInsideRegionRule):
(WebCore::CSSStyleSelector::applyDeclaration):
(WebCore::CSSStyleSelector::applyDeclarations):
(WebCore::CSSStyleSelector::isValidRegionStyleProperty):
(WebCore::CSSStyleSelector::applyProperty):

  • css/CSSStyleSelector.h:

LayoutTests:

Fix the test as it was not taking into account the selector specificity.

  • fast/regions/region-style-block-background-color.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105278 r105280  
     12012-01-18  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSSRegions]Fix region style code in CSSStyleSelector
     4        https://bugs.webkit.org/show_bug.cgi?id=76453
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Fix the test as it was not taking into account the selector specificity.
     9        * fast/regions/region-style-block-background-color.html:
     10
    1112012-01-18  Csaba Osztrogonác  <ossy@webkit.org>
    212
  • trunk/LayoutTests/fast/regions/region-style-block-background-color.html

    r102234 r105280  
    4545            #region72  { -webkit-flow-from: flow7; }
    4646            #p7 { background-color: green; }
    47             @-webkit-region #region71 { p { background-color: transparent; } }
     47            @-webkit-region #region71 { #p7 { background-color: transparent; } }
    4848        </style>
    4949   </head>
  • trunk/Source/WebCore/ChangeLog

    r105279 r105280  
     12012-01-18  Mihnea Ovidenie  <mihnea@adobe.com>
     2
     3        [CSSRegions]Fix region style code in CSSStyleSelector
     4        https://bugs.webkit.org/show_bug.cgi?id=76453
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Follow up after comments in https://bugs.webkit.org/show_bug.cgi?id=76064.
     9        With the new approach, the css rule specificity is correctly taken into account
     10        when applying the region style rule.
     11        No new tests, the region style tests are still disabled.
     12
     13        * css/CSSStyleSelector.cpp:
     14        (WebCore::RuleSet::RuleSetSelectorPair::RuleSetSelectorPair):
     15        (WebCore::CSSStyleSelector::CSSStyleSelector):
     16        (WebCore::CSSStyleSelector::addMatchedDeclaration):
     17        (WebCore::CSSStyleSelector::collectMatchingRules):
     18        (WebCore::CSSStyleSelector::collectMatchingRulesForRegion):
     19        (WebCore::CSSStyleSelector::matchRules):
     20        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
     21        (WebCore::CSSStyleSelector::matchAllRules):
     22        (WebCore::CSSStyleSelector::styleForElement):
     23        (WebCore::CSSStyleSelector::pseudoStyleForElement):
     24        (WebCore::CSSStyleSelector::checkRegionStyle):
     25        (WebCore::CSSStyleSelector::checkRegionSelector):
     26        (WebCore::RuleData::RuleData):
     27        (WebCore::RuleSet::RuleSet):
     28        (WebCore::RuleSet::addRule):
     29        (WebCore::RuleSet::addRegionRule):
     30        (WebCore::RuleSet::addRulesFromSheet):
     31        (WebCore::isInsideRegionRule):
     32        (WebCore::CSSStyleSelector::applyDeclaration):
     33        (WebCore::CSSStyleSelector::applyDeclarations):
     34        (WebCore::CSSStyleSelector::isValidRegionStyleProperty):
     35        (WebCore::CSSStyleSelector::applyProperty):
     36        * css/CSSStyleSelector.h:
     37
    1382012-01-17  Jer Noble  <jer.noble@apple.com>
    239
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r105276 r105280  
    173173class RuleData {
    174174public:
    175     RuleData(CSSStyleRule*, CSSSelector*, unsigned position, ERegionStyleEnabled useInRegionStyle = DoNotUseInRegionStyle);
     175    RuleData(CSSStyleRule*, CSSSelector*, unsigned position);
    176176
    177177    unsigned position() const { return m_position; }
     
    185185    unsigned specificity() const { return m_specificity; }
    186186    unsigned linkMatchType() const { return m_linkMatchType; }
    187     ERegionStyleEnabled useInRegionStyle() const { return static_cast<ERegionStyleEnabled>(m_useInRegionStyle); }
    188187
    189188    // Try to balance between memory usage (there can be lots of RuleData objects) and good filtering performance.
     
    197196    // This number was picked fairly arbitrarily. We can probably lower it if we need to.
    198197    // Some simple testing showed <100,000 RuleData's on large sites.
    199     unsigned m_position : 25;
     198    unsigned m_position : 26;
    200199    unsigned m_hasFastCheckableSelector : 1;
    201200    unsigned m_hasMultipartSelector : 1;
     
    203202    unsigned m_containsUncommonAttributeSelector : 1;
    204203    unsigned m_linkMatchType : 2; //  SelectorChecker::LinkMatchMask
    205     unsigned m_useInRegionStyle : 1; // ERegionStyleEnabled
    206204    // Use plain array instead of a Vector to minimize memory overhead.
    207205    unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
     
    221219    WTF_MAKE_NONCOPYABLE(RuleSet);
    222220public:
    223     RuleSet(ERegionStyleEnabled useInRegionStyle = DoNotUseInRegionStyle);
     221    RuleSet();
    224222
    225223    typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
     
    231229    void addPageRule(CSSPageRule*);
    232230    void addToRuleSet(AtomicStringImpl* key, AtomRuleMap&, const RuleData&);
     231    void addRegionRule(WebKitCSSRegionRule*);
    233232    void shrinkToFit();
    234233    void disableAutoShrinkToFit() { m_autoShrinkToFitEnabled = false; }
     
    256255    unsigned m_ruleCount;
    257256    bool m_autoShrinkToFitEnabled;
    258     ERegionStyleEnabled m_useInRegionStyle;
    259 
    260257    CSSStyleSelector::Features m_features;
     258
     259    struct RuleSetSelectorPair {
     260        RuleSetSelectorPair(CSSSelector* selector, RuleSet* ruleSet) : selector(selector), ruleSet(adoptPtr(ruleSet)) { }
     261        RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { }
     262        CSSSelector* selector;
     263        OwnPtr<RuleSet> ruleSet;
     264    };
     265
     266    Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets;
    261267};
    262268
     
    328334    , m_applyPropertyToRegularStyle(true)
    329335    , m_applyPropertyToVisitedLinkStyle(false)
    330     , m_applyPropertyToRegionStyle(false)
    331336    , m_applyProperty(CSSStyleApplyProperty::sharedCSSStyleApplyProperty())
    332337#if ENABLE(CSS_SHADERS)
     
    441446    if (document()->renderer() && document()->renderer()->style())
    442447        document()->renderer()->style()->font().update(fontSelector());
    443 }
    444 
    445 void CSSStyleSelector::addRegionRule(PassRefPtr<WebKitCSSRegionRule> regionStyleRule)
    446 {
    447     m_regionStyleRules.append(regionStyleRule);
    448448}
    449449
     
    635635}
    636636
    637 void CSSStyleSelector::addMatchedDeclaration(CSSMutableStyleDeclaration* styleDeclaration, unsigned linkMatchType, ERegionStyleEnabled useInRegionStyle)
     637void CSSStyleSelector::addMatchedDeclaration(CSSMutableStyleDeclaration* styleDeclaration, unsigned linkMatchType)
    638638{
    639639    m_matchedDecls.grow(m_matchedDecls.size() + 1);
     
    641641    newDeclaration.styleDeclaration = styleDeclaration;
    642642    newDeclaration.linkMatchType = linkMatchType;
    643     newDeclaration.useInRegionStyle = useInRegionStyle;
    644 }
    645 
    646 void CSSStyleSelector::matchRules(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
    647 {
    648     m_matchedRules.clear();
    649 
    650     if (!rules || !m_element)
    651         return;
     643}
     644
     645void CSSStyleSelector::collectMatchingRules(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
     646{
     647    ASSERT(rules);
     648    ASSERT(m_element);
    652649
    653650    // We need to collect the rules for id, class, tag, and everything else into a buffer and
    654651    // then sort the buffer.
    655652    if (m_element->hasID())
    656         matchRulesForList(rules->idRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     653        collectMatchingRulesForList(rules->idRules(m_element->idForStyleResolution().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    657654    if (m_element->hasClass()) {
    658655        ASSERT(m_styledElement);
     
    660657        size_t size = classNames.size();
    661658        for (size_t i = 0; i < size; ++i)
    662             matchRulesForList(rules->classRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     659            collectMatchingRulesForList(rules->classRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    663660    }
    664661    const AtomicString& pseudoId = m_element->shadowPseudoId();
    665662    if (!pseudoId.isEmpty()) {
    666663        ASSERT(m_styledElement);
    667         matchRulesForList(rules->shadowPseudoElementRules(pseudoId.impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     664        collectMatchingRulesForList(rules->shadowPseudoElementRules(pseudoId.impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    668665    }
    669666    if (m_element->isLink())
    670         matchRulesForList(rules->linkPseudoClassRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     667        collectMatchingRulesForList(rules->linkPseudoClassRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    671668    if (m_checker.matchesFocusPseudoClass(m_element))
    672         matchRulesForList(rules->focusPseudoClassRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    673     matchRulesForList(rules->tagRules(m_element->localName().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
    674     matchRulesForList(rules->universalRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     669        collectMatchingRulesForList(rules->focusPseudoClassRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     670    collectMatchingRulesForList(rules->tagRules(m_element->localName().impl()), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     671    collectMatchingRulesForList(rules->universalRules(), firstRuleIndex, lastRuleIndex, includeEmptyRules);
     672}
     673
     674void CSSStyleSelector::collectMatchingRulesForRegion(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
     675{
     676    if (!m_regionForStyling)
     677        return;
     678
     679    unsigned size = rules->m_regionSelectorsAndRuleSets.size();
     680    for (unsigned i = 0; i < size; ++i) {
     681        CSSSelector* regionSelector = rules->m_regionSelectorsAndRuleSets.at(i).selector;
     682        if (checkRegionSelector(regionSelector, static_cast<Element*>(m_regionForStyling->node()))) {
     683            RuleSet* regionRules = rules->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
     684            ASSERT(regionRules);
     685            collectMatchingRules(regionRules, firstRuleIndex, lastRuleIndex, includeEmptyRules);
     686        }
     687    }
     688}
     689
     690void CSSStyleSelector::matchRules(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
     691{
     692    m_matchedRules.clear();
     693
     694    if (!rules || !m_element)
     695        return;
     696
     697    collectMatchingRules(rules, firstRuleIndex, lastRuleIndex, includeEmptyRules);
     698    collectMatchingRulesForRegion(rules, firstRuleIndex, lastRuleIndex, includeEmptyRules);
    675699
    676700    if (m_matchedRules.isEmpty())
     
    696720        if (swapVisitedUnvisited && linkMatchType && linkMatchType != SelectorChecker::MatchAll)
    697721            linkMatchType = (linkMatchType == SelectorChecker::MatchVisited) ? SelectorChecker::MatchLink : SelectorChecker::MatchVisited;
    698         addMatchedDeclaration(m_matchedRules[i]->rule()->declaration(), linkMatchType, m_matchedRules[i]->useInRegionStyle());
     722        addMatchedDeclaration(m_matchedRules[i]->rule()->declaration(), linkMatchType);
    699723    }
    700724}
     
    734758}
    735759
    736 void CSSStyleSelector::matchRulesForList(const Vector<RuleData>* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
     760void CSSStyleSelector::collectMatchingRulesForList(const Vector<RuleData>* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
    737761{
    738762    if (!rules)
     
    854878        matchRules(m_authorStyle.get(), result.firstAuthorRule, result.lastAuthorRule, false);
    855879
    856     if (m_regionForStyling)
    857         matchRules(m_regionRules.get(), result.firstAuthorRule, result.lastAuthorRule, false);
    858 
    859880    // Now check our inline style attribute.
    860881    if (m_matchAuthorAndUserStyles && m_styledElement) {
     
    907928
    908929    m_fontDirty = false;
    909 }
    910 
    911 inline void CSSStyleSelector::initForRegionStyling(RenderRegion* region)
    912 {
    913     setRegionForStyling(region);
    914 
    915     if (region)
    916         initRegionRules(region);
    917 }
    918 
    919 void CSSStyleSelector::initRegionRules(RenderRegion* region)
    920 {
    921     ASSERT(region);
    922     // Mark that the set of rules comes from region styling since we need to filter
    923     // the properties that can be applied.
    924     m_regionRules = adoptPtr(new RuleSet(UseInRegionStyle));
    925 
    926     // From all the region style rules, select those that apply to the specified region.
    927     for (Vector<RefPtr<WebKitCSSRegionRule> >::iterator it = m_regionStyleRules.begin(); it != m_regionStyleRules.end(); ++it) {
    928         const CSSSelectorList& regionSelectorList = (*it)->selectorList();
    929         for (CSSSelector* s = regionSelectorList.first(); s; s = regionSelectorList.next(s)) {
    930             if (!m_checker.checkSelector(s, static_cast<Element*>(region->node())))
    931                 continue;
    932             CSSRuleList* regionStylingRules = (*it)->cssRules();
    933             for (unsigned index = 0; index < regionStylingRules->length(); ++index) {
    934                 CSSRule* regionStylingRule = regionStylingRules->item(index);
    935                 if (regionStylingRule->isStyleRule())
    936                     m_regionRules->addStyleRule(static_cast<CSSStyleRule*>(regionStylingRule));
    937             }
    938         }
    939     }
    940930}
    941931
     
    13231313    initElement(element);
    13241314    initForStyleResolve(element, defaultParent);
    1325     initForRegionStyling(regionForStyling);
     1315    m_regionForStyling = regionForStyling;
    13261316    if (allowSharing) {
    13271317        RenderStyle* sharedStyle = locateSharedStyle();
     
    14801470}
    14811471
    1482 PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle, RenderRegion* regionForStyling)
     1472PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle)
    14831473{
    14841474    if (!e)
     
    14881478
    14891479    initForStyleResolve(e, parentStyle, pseudo);
    1490     initForRegionStyling(regionForStyling);
    14911480    m_style = RenderStyle::create();
    14921481
     
    17811770}
    17821771
    1783 bool CSSStyleSelector::checkRegionStyle(Element* e)
    1784 {
    1785     m_checker.clearHasUnknownPseudoElements();
    1786     m_checker.setPseudoStyle(NOPSEUDO);
    1787 
    1788     for (Vector<RefPtr<WebKitCSSRegionRule> >::iterator it = m_regionStyleRules.begin(); it != m_regionStyleRules.end(); ++it) {
    1789         const CSSSelectorList& regionSelectorList = (*it)->selectorList();
    1790         for (CSSSelector* s = regionSelectorList.first(); s; s = regionSelectorList.next(s)) {
    1791             if (m_checker.checkSelector(s, e))
     1772bool CSSStyleSelector::checkRegionStyle(Element* regionElement)
     1773{
     1774    unsigned rulesSize = m_authorStyle->m_regionSelectorsAndRuleSets.size();
     1775    for (unsigned i = 0; i < rulesSize; ++i) {
     1776        ASSERT(m_authorStyle->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
     1777        if (checkRegionSelector(m_authorStyle->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
     1778            return true;
     1779    }
     1780
     1781    if (m_userStyle) {
     1782        rulesSize = m_userStyle->m_regionSelectorsAndRuleSets.size();
     1783        for (unsigned i = 0; i < rulesSize; ++i) {
     1784            ASSERT(m_userStyle->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
     1785            if (checkRegionSelector(m_userStyle->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
    17921786                return true;
    17931787        }
     
    18871881        return false;
    18881882    return true;
     1883}
     1884
     1885bool CSSStyleSelector::checkRegionSelector(CSSSelector* regionSelector, Element* regionElement)
     1886{
     1887    if (!regionSelector || !regionElement)
     1888        return false;
     1889
     1890    m_checker.clearHasUnknownPseudoElements();
     1891    m_checker.setPseudoStyle(NOPSEUDO);
     1892
     1893    for (CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
     1894        if (m_checker.checkSelector(s, regionElement))
     1895            return true;
     1896
     1897    return false;
    18891898}
    18901899   
     
    19721981}
    19731982
    1974 RuleData::RuleData(CSSStyleRule* rule, CSSSelector* selector, unsigned position, ERegionStyleEnabled useInRegionStyle)
     1983RuleData::RuleData(CSSStyleRule* rule, CSSSelector* selector, unsigned position)
    19751984    : m_rule(rule)
    19761985    , m_selector(selector)
     
    19821991    , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSelector(selector))
    19831992    , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector))
    1984     , m_useInRegionStyle(useInRegionStyle)
    19851993{
    19861994    SelectorChecker::collectIdentifierHashes(m_selector, m_descendantSelectorIdentifierHashes, maximumIdentifierCount);
    19871995}
    19881996
    1989 RuleSet::RuleSet(ERegionStyleEnabled useInRegionStyle)
     1997RuleSet::RuleSet()
    19901998    : m_ruleCount(0)
    19911999    , m_autoShrinkToFitEnabled(true)
    1992     , m_useInRegionStyle(useInRegionStyle)
    19932000{
    19942001}
     
    20502057void RuleSet::addRule(CSSStyleRule* rule, CSSSelector* selector)
    20512058{
    2052     RuleData ruleData(rule, selector, m_ruleCount++, m_useInRegionStyle);
     2059    RuleData ruleData(rule, selector, m_ruleCount++);
    20532060    collectFeaturesFromRuleData(m_features, ruleData);
    20542061
     
    20912098{
    20922099    m_pageRules.append(RuleData(rule, rule->selectorList().first(), m_pageRules.size()));
     2100}
     2101
     2102void RuleSet::addRegionRule(WebKitCSSRegionRule* rule)
     2103{
     2104    RuleSet* regionRuleSet = new RuleSet;
     2105    // The region rule set should take into account the position inside the parent rule set.
     2106    // Otherwise, the rules inside region block might be incorrectly positioned before other similar rules from
     2107    // the stylesheet that contains the region block.
     2108    regionRuleSet->m_ruleCount = m_ruleCount;
     2109
     2110    // Collect the region rules into a rule set
     2111    CSSRuleList* regionStylingRules = rule->cssRules();
     2112    unsigned rulesSize = regionStylingRules->length();
     2113    for (unsigned i = 0; i < rulesSize; ++i) {
     2114        CSSRule* regionStylingRule = regionStylingRules->item(i);
     2115        if (regionStylingRule->isStyleRule())
     2116            regionRuleSet->addStyleRule(static_cast<CSSStyleRule*>(regionStylingRule));
     2117    }
     2118
     2119    m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(rule->selectorList().first(), regionRuleSet));
    20932120}
    20942121
     
    21462173            styleSelector->addKeyframeStyle(static_cast<WebKitCSSKeyframesRule*>(rule));
    21472174        else if (rule->isRegionRule() && styleSelector)
    2148             styleSelector->addRegionRule(static_cast<WebKitCSSRegionRule*>(rule));
     2175            addRegionRule(static_cast<WebKitCSSRegionRule*>(rule));
    21492176    }
    21502177    if (m_autoShrinkToFitEnabled)
     
    22182245}
    22192246
     2247static inline bool isInsideRegionRule(CSSMutableStyleDeclaration* styleDeclaration)
     2248{
     2249    ASSERT(styleDeclaration);
     2250
     2251    CSSRule* parentRule = styleDeclaration->parentRule();
     2252    while (parentRule) {
     2253        if (parentRule->isRegionRule())
     2254            return true;
     2255        parentRule = parentRule->parentRule();
     2256    }
     2257    return false;
     2258}
     2259
    22202260template <bool applyFirst>
    22212261void CSSStyleSelector::applyDeclaration(CSSMutableStyleDeclaration* styleDeclaration, bool isImportant, bool inheritedOnly)
     
    22232263    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(document(), styleDeclaration->parentRule());
    22242264    CSSMutableStyleDeclaration::const_iterator end = styleDeclaration->end();
     2265
     2266    bool styleDeclarationInsideRegionRule = m_regionForStyling ? isInsideRegionRule(styleDeclaration) : false;
     2267
    22252268    for (CSSMutableStyleDeclaration::const_iterator it = styleDeclaration->begin(); it != end; ++it) {
    22262269        const CSSProperty& current = *it;
     
    22352278        }
    22362279        int property = current.id();
     2280
     2281        // Filter the properties that can be applied using region styling.
     2282        if (styleDeclarationInsideRegionRule && !CSSStyleSelector::isValidRegionStyleProperty(property))
     2283            continue;
     2284
    22372285        if (applyFirst) {
    22382286            COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
     
    22762324        return;
    22772325    }
    2278     for (int i = startIndex; i <= endIndex; ++i) {
    2279         m_applyPropertyToRegionStyle = m_matchedDecls[i].useInRegionStyle;
     2326    for (int i = startIndex; i <= endIndex; ++i)
    22802327        applyDeclaration<applyFirst>(m_matchedDecls[i].styleDeclaration.get(), isImportant, inheritedOnly);
    2281         m_applyPropertyToRegionStyle = false;
    2282     }
    22832328}
    22842329
     
    25682613// http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule
    25692614// FIXME: add incremental support for other region styling properties.
    2570 inline bool isValidRegionStyleProperty(int id)
     2615inline bool CSSStyleSelector::isValidRegionStyleProperty(int id)
    25712616{
    25722617    switch (static_cast<CSSPropertyID>(id)) {
     
    26582703        return;
    26592704    }
    2660 
    2661     // Filter region style property
    2662     if (applyPropertyToRegionStyle() && !isValidRegionStyleProperty(id))
    2663         return;
    26642705
    26652706    CSSPropertyID property = static_cast<CSSPropertyID>(id);
  • trunk/Source/WebCore/css/CSSStyleSelector.h

    r105276 r105280  
    3737
    3838enum ESmartMinimumForFontSize { DoNotUseSmartMinimumForFontSize, UseSmartMinimumForFontFize };
    39 enum ERegionStyleEnabled { DoNotUseInRegionStyle, UseInRegionStyle };
    4039
    4140class CSSFontSelector;
     
    116115    void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&);
    117116
    118     PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
     117    PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0);
    119118
    120119    PassRefPtr<RenderStyle> styleForPage(int pageIndex);
     
    143142    void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
    144143    void initElement(Element*);
    145     void initForRegionStyling(RenderRegion*);
    146     void initRegionRules(RenderRegion*);
    147144    void collectFeatures();
    148145    RenderStyle* locateSharedStyle();
     
    153150
    154151    PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const WebKitCSSKeyframeRule*, KeyframeValue&);
    155     void setRegionForStyling(RenderRegion* region) { m_regionForStyling = region; }
    156     RenderRegion* regionForStyling() const { return m_regionForStyling; }
    157152
    158153public:
     
    210205    void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule>);
    211206    void addPageStyle(PassRefPtr<CSSPageRule>);
    212     void addRegionRule(PassRefPtr<WebKitCSSRegionRule>);
    213 
    214     bool checkRegionStyle(Element*);
     207
     208    bool checkRegionStyle(Element* regionElement);
    215209
    216210    bool usesSiblingRules() const { return !m_features.siblingRules.isEmpty(); }
     
    263257
    264258    void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); }
    265     void addMatchedDeclaration(CSSMutableStyleDeclaration*, unsigned linkMatchType = SelectorChecker::MatchAll, ERegionStyleEnabled useInRegionStyle = DoNotUseInRegionStyle);
     259    void addMatchedDeclaration(CSSMutableStyleDeclaration*, unsigned linkMatchType = SelectorChecker::MatchAll);
    266260
    267261    struct MatchResult {
     
    278272    void matchUARules(MatchResult&);
    279273    void matchRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
    280     void matchRulesForList(const Vector<RuleData>*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
     274    void collectMatchingRules(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
     275    void collectMatchingRulesForRegion(RuleSet*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
     276    void collectMatchingRulesForList(const Vector<RuleData>*, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules);
    281277    bool fastRejectSelector(const RuleData&) const;
    282278    void sortMatchedRules();
    283279
    284280    bool checkSelector(const RuleData&);
    285 
     281    bool checkRegionSelector(CSSSelector* regionSelector, Element* regionElement);
    286282    void applyMatchedDeclarations(const MatchResult&);
    287283    template <bool firstPass>
     
    289285    template <bool firstPass>
    290286    void applyDeclaration(CSSMutableStyleDeclaration*, bool isImportant, bool inheritedOnly);
     287
     288    static bool isValidRegionStyleProperty(int id);
    291289
    292290    void matchPageRules(RuleSet*, bool isLeftPage, bool isFirstPage, const String& pageName);
     
    299297    OwnPtr<RuleSet> m_authorStyle;
    300298    OwnPtr<RuleSet> m_userStyle;
    301     OwnPtr<RuleSet> m_regionRules;
    302299
    303300    Features m_features;
     
    313310    KeyframesRuleMap m_keyframesRuleMap;
    314311
    315     typedef Vector<RefPtr<WebKitCSSRegionRule> > RegionStyleRules;
    316     RegionStyleRules m_regionStyleRules;
    317 
    318312public:
    319313    static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable; }
     
    325319    bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
    326320    bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
    327     bool applyPropertyToRegionStyle() const { return m_applyPropertyToRegionStyle; }
    328321
    329322private:
     
    374367        RefPtr<CSSMutableStyleDeclaration> styleDeclaration;
    375368        union {
    376             struct {
    377                 unsigned linkMatchType : 31;
    378                 unsigned useInRegionStyle : 1; // ERegionStyleEnabled
    379             };
     369            unsigned linkMatchType;
    380370            // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object.
    381371            void* possiblyPaddedMember;
     
    439429    bool m_applyPropertyToRegularStyle;
    440430    bool m_applyPropertyToVisitedLinkStyle;
    441     bool m_applyPropertyToRegionStyle;
    442431    const CSSStyleApplyProperty& m_applyProperty;
    443432   
Note: See TracChangeset for help on using the changeset viewer.