Changeset 175758 in webkit


Ignore:
Timestamp:
Nov 7, 2014 12:29:49 PM (9 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
https://bugs.webkit.org/show_bug.cgi?id=138438

Reviewed by Benjamin Poulain.

Source/WebCore:

Test: inspector/css/psuedo-element-matches.html

Element::matches is not the correct API to use to check selectors with pseudo-elements.
Instead we should use the CSS Selector checking machinary which understands them.

  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::getSupportedCSSProperties):
(WebCore::InspectorCSSAgent::buildArrayForRuleList):
(WebCore::InspectorCSSAgent::buildArrayForRegions):
(WebCore::InspectorCSSAgent::buildObjectForNamedFlow):
Some RefPtr release improvements.

(WebCore::InspectorCSSAgent::buildArrayForMatchedRuleList):
Use a SelectorChecker to check each Selector against the element.
This matches the SelectorChecker used when we collected the rules
for this element.

Source/WebInspectorUI:

  • UserInterface/Base/Test.js:

(WebInspector.loaded):
Include a global setting for shadow dom used by DOM model classes.
Give it a "test" specific name to not override non-test setting values.

LayoutTests:

  • inspector/css/pseudo-element-matches-expected.txt: Added.
  • inspector/css/pseudo-element-matches.html: Added.

Add a test to ensure we get correct selector matches for a pseudo element
inside of an <audio> element. The test is heavily coupled to our UserAgent
stylesheet and Shadow DOM layout, so check for possible failures if
WebCore changes things.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r175755 r175758  
     12014-11-07  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
     4        https://bugs.webkit.org/show_bug.cgi?id=138438
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        * inspector/css/pseudo-element-matches-expected.txt: Added.
     9        * inspector/css/pseudo-element-matches.html: Added.
     10        Add a test to ensure we get correct selector matches for a pseudo element
     11        inside of an <audio> element. The test is heavily coupled to our UserAgent
     12        stylesheet and Shadow DOM layout, so check for possible failures if
     13        WebCore changes things.
     14
    1152014-11-07  Bem Jones-Bey  <bjonesbe@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r175752 r175758  
     12014-11-07  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
     4        https://bugs.webkit.org/show_bug.cgi?id=138438
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Test: inspector/css/psuedo-element-matches.html
     9
     10        Element::matches is not the correct API to use to check selectors with pseudo-elements.
     11        Instead we should use the CSS Selector checking machinary which understands them.
     12
     13        * inspector/InspectorCSSAgent.cpp:
     14        (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
     15        (WebCore::InspectorCSSAgent::buildArrayForRuleList):
     16        (WebCore::InspectorCSSAgent::buildArrayForRegions):
     17        (WebCore::InspectorCSSAgent::buildObjectForNamedFlow):
     18        Some RefPtr release improvements.
     19
     20        (WebCore::InspectorCSSAgent::buildArrayForMatchedRuleList):
     21        Use a SelectorChecker to check each Selector against the element.
     22        This matches the SelectorChecker used when we collected the rules
     23        for this element.
     24
    1252014-11-07  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r175719 r175758  
    5050#include "RenderNamedFlowFragment.h"
    5151#include "SVGStyleElement.h"
     52#include "SelectorChecker.h"
    5253#include "StyleProperties.h"
    5354#include "StylePropertyShorthand.h"
     
    827828            longhands->addItem(getPropertyNameString(longhandID));
    828829        }
    829         property->setLonghands(longhands);
     830        property->setLonghands(longhands.release());
    830831        properties->addItem(property.release());
    831832    }
     
    10481049        if (!ruleObject)
    10491050            continue;
    1050         result->addItem(ruleObject);
     1051        result->addItem(ruleObject.release());
    10511052    }
    10521053    return result.release();
     
    10561057{
    10571058    RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::RuleMatch>> result = Inspector::Protocol::Array<Inspector::Protocol::CSS::RuleMatch>::create();
     1059
     1060    SelectorChecker::CheckingContext context(SelectorChecker::Mode::CollectingRules);
     1061    SelectorChecker selectorChecker(element->document());
    10581062
    10591063    for (unsigned i = 0; i < matchedRules.size(); ++i) {
    10601064        if (!matchedRules[i]->isStyleRule())
    10611065            continue;
     1066
    10621067        StyleRule* matchedStyleRule = static_cast<StyleRule*>(matchedRules[i].get());
    10631068        RefPtr<Inspector::Protocol::CSS::CSSRule> ruleObject = buildObjectForRule(matchedStyleRule, styleResolver);
    10641069        if (!ruleObject)
    10651070            continue;
     1071
    10661072        RefPtr<Inspector::Protocol::Array<int>> matchingSelectors = Inspector::Protocol::Array<int>::create();
    10671073        const CSSSelectorList& selectorList = matchedStyleRule->selectorList();
    10681074        long index = 0;
    10691075        for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) {
    1070             bool matched = element->matches(selector->selectorText(), IGNORE_EXCEPTION);
     1076            bool matched = selectorChecker.match(selector, element, context);
    10711077            if (matched)
    10721078                matchingSelectors->addItem(index);
    10731079            ++index;
    10741080        }
     1081
    10751082        RefPtr<Inspector::Protocol::CSS::RuleMatch> match = Inspector::Protocol::CSS::RuleMatch::create()
    1076             .setRule(ruleObject)
    1077             .setMatchingSelectors(matchingSelectors);
    1078         result->addItem(match);
     1083            .setRule(ruleObject.release())
     1084            .setMatchingSelectors(matchingSelectors.release());
     1085        result->addItem(match.release());
    10791086    }
    10801087
     
    11291136            .setNodeId(m_domAgent->pushNodeToFrontend(errorString, documentNodeId, regionList->item(i)));
    11301137
    1131         regions->addItem(region);
     1138        regions->addItem(region.release());
    11321139    }
    11331140
     
    11451152    }
    11461153
    1147     RefPtr<Inspector::Protocol::CSS::NamedFlow> namedFlow = Inspector::Protocol::CSS::NamedFlow::create()
     1154    return Inspector::Protocol::CSS::NamedFlow::create()
    11481155        .setDocumentNodeId(documentNodeId)
    11491156        .setName(webkitNamedFlow->name().string())
    11501157        .setOverset(webkitNamedFlow->overset())
    1151         .setContent(content)
    1152         .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegions(), documentNodeId));
    1153 
    1154     return namedFlow.release();
     1158        .setContent(content.release())
     1159        .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegions(), documentNodeId))
     1160        .release();
    11551161}
    11561162
  • trunk/Source/WebInspectorUI/ChangeLog

    r175658 r175758  
     12014-11-07  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
     4        https://bugs.webkit.org/show_bug.cgi?id=138438
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        * UserInterface/Base/Test.js:
     9        (WebInspector.loaded):
     10        Include a global setting for shadow dom used by DOM model classes.
     11        Give it a "test" specific name to not override non-test setting values.
     12
    1132014-11-05  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Base/Test.js

    r175478 r175758  
    6464    // Perform one-time tasks.
    6565    WebInspector.CSSCompletions.requestCSSNameCompletions();
     66
     67    this.showShadowDOMSetting = new WebInspector.Setting("test-show-shadow-dom", true);
    6668}
    6769
Note: See TracChangeset for help on using the changeset viewer.