<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>89240</bug_id>
          
          <creation_ts>2012-06-15 12:23:04 -0700</creation_ts>
          <short_desc>REGRESSION (r112923): getMatchedCSSRules always returning null for parentStyleSheet</short_desc>
          <delta_ts>2022-07-13 10:12:41 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=79653</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Regression</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>jmayhew</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>joethomas</cc>
    
    <cc>kling</cc>
    
    <cc>koivisto</cc>
    
    <cc>shanestephens</cc>
    
    <cc>tonistiigi</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>650395</commentid>
    <comment_count>0</comment_count>
      <attachid>147873</attachid>
    <who name="">jmayhew</who>
    <bug_when>2012-06-15 12:23:04 -0700</bug_when>
    <thetext>Created attachment 147873
Test html file that shows the bug when pressing the html button.

This happens in the webkit nightly and the webkit versions for Chromium 20. The problem does not occur in Safari 5.1.7 for Chrome 19.

window.getMatchedCSSRules() should return rule object(s) that have a valid parentStyleSheet property. Recent webkit versions make this api always return a null parentStyleSheet property.

Attached is a simple test file. Pressing the button will force a call to window.getMatchedCSSRules() and will display the parentStyleSheet properties value. In Chrome 19 and Safari 5.1.7, the property is non-null. In the webkit nightly it is null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>651758</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2012-06-18 14:51:24 -0700</bug_when>
    <thetext>Does this affect any live web sites?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>651786</commentid>
    <comment_count>2</comment_count>
    <who name="">jmayhew</who>
    <bug_when>2012-06-18 15:14:26 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; Does this affect any live web sites?

Per this bug: https://bugs.webkit.org/show_bug.cgi?id=79653 I would say yes. It does affect us, but we aren&apos;t live yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>652985</commentid>
    <comment_count>3</comment_count>
    <who name="">jmayhew</who>
    <bug_when>2012-06-19 16:51:04 -0700</bug_when>
    <thetext>After a brief investigation it looks like changeset 112923 has quite a bit of refactoring in this area of CSS in webcore. I think this bug is just an artifact of that effort. 

In short, StyleResolver::sortAndTransferMatchedRules() calls 

    m_ruleList-&gt;rules().append(m_matchedRules[i]-&gt;rule()-&gt;createCSSOMWrapper()); 

and is not passing in the parent stylesheet. I think this call to createCSSOMWrapper should pass in the parent but I don&apos;t think it is available to the StyleResolver class. Fixing this will require making the parent sheet pointer available to the StyleResolver. This change should probably be done by the people heading the refactoring effort as it will depend on their new class design.

Also, StyleRule.h includes the following lines
    // FIXME: There shouldn&apos;t be any need for the null parent version.
    PassRefPtr&lt;CSSRule&gt; createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const;
    PassRefPtr&lt;CSSRule&gt; createCSSOMWrapper(CSSRule* parentRule) const;

I agree with the FIXME comment that there should be no default value for the parentSheet parameter. Is there ever a case where a rule should have a null parentSheet/parentRule? If this default value is removed, the resulting errors will indicate the areas that need to be addressed.

I hope that helps.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>667187</commentid>
    <comment_count>4</comment_count>
    <who name="">jmayhew</who>
    <bug_when>2012-07-11 16:11:35 -0700</bug_when>
    <thetext>Okay, our project is no longer under NDA, we are open source and our alpha release is out so I can share it as an example of a web site/chrome extension that relies heavily on getMatchedCSSRules(...)

Our extension is available on the chrome web store here https://chrome.google.com/webstore/detail/jjdndclgmfdgpiccmlamlicfjmkognne

We had to add a workaround for this bug. When we detect a null parent we have to manually search through the rules to find the matching parent style sheet. This workaround is not 100% reliable so getting this bug fixed is very important to us as is the continued support of the getMatchedCSSRules() api.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1883135</commentid>
    <comment_count>5</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-07-13 10:09:52 -0700</bug_when>
    <thetext>Chrome and Firefox don&apos;t seem to support &apos;window.getMatchedCSSRules()&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1883136</commentid>
    <comment_count>6</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-07-13 10:12:41 -0700</bug_when>
    <thetext>WebKit intends to remove this non-standard function in Bug 79653. We are not likely to take action on this bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>147873</attachid>
            <date>2012-06-15 12:23:04 -0700</date>
            <delta_ts>2012-06-15 12:23:04 -0700</delta_ts>
            <desc>Test html file that shows the bug when pressing the html button.</desc>
            <filename>parentStyleSheetTest.html</filename>
            <type>text/html</type>
            <size>850</size>
            <attacher>jmayhew</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KICAgIDx0aXRsZT5UZXN0IGZvciBwYXJlbnQg
c3R5bGUgc2hlZXQ8L3RpdGxlPgogICAgCiAgICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgogICAg
ICAgIGJv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