getRelativeRuleLine yields wrong result after DOMUtils.parseStyleSheet

RESOLVED FIXED in Firefox 43

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: tromey, Assigned: tromey)

Tracking

unspecified
mozilla43
Points:
---

Firefox Tracking Flags

(firefox43 fixed)

Details

Attachments

(1 attachment, 4 obsolete attachments)

(Assignee)

Description

3 years ago
I noticed today that my fix for bug 1013814 causes a regression.
After the patch, if I call DOMUtils.parseStyleSheet on style
sheet coming from a <style> element, then future calls to
getRelativeRuleLine will yield wrong results (in particular they
underflow and are turned into very large numbers due to the use
of unsigned math).

I tracked this down to this line:

 https://dxr.mozilla.org/mozilla-central/source/layout/style/CSSStyleSheet.cpp#2316

which sets the line number to 1 -- but I think it should be the
line number of the <style> element.

I have a patch for this that I'll attach.  It works for my
case but I haven't run the full test suite.
(Assignee)

Comment 1

3 years ago
Created attachment 8649469 [details] [diff] [review]
set line number when re-parsing sheet

Here's the patch.
(Assignee)

Comment 2

3 years ago
Comment on attachment 8649469 [details] [diff] [review]
set line number when re-parsing sheet

I am wondering if this seems like a reasonable approach or if there
is some other way I should try.

If it looks ok I will write the test and try a full test run.
Attachment #8649469 - Flags: feedback?(cam)
(Assignee)

Updated

3 years ago
Blocks: 984880
Comment on attachment 8649469 [details] [diff] [review]
set line number when re-parsing sheet

Review of attachment 8649469 [details] [diff] [review]:
-----------------------------------------------------------------

Yeah I think this is OK.  We do preserve the line number when the sheet's text is modified through the DOM.
Attachment #8649469 - Flags: feedback?(cam) → feedback+
(Assignee)

Comment 4

3 years ago
Created attachment 8655680 [details] [diff] [review]
set line number when re-parsing sheet

Patch with test.
Attachment #8649469 - Attachment is obsolete: true
(Assignee)

Updated

3 years ago
Attachment #8655680 - Flags: review?(cam)
Comment on attachment 8655680 [details] [diff] [review]
set line number when re-parsing sheet

Review of attachment 8655680 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/inspector/tests/test_parseStyleSheet.html
@@ +8,5 @@
> +    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
> +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
> +    <style>
> +      body {
> +      color: red;

Indentation looks off here.
Attachment #8655680 - Flags: review?(cam) → review+
(Assignee)

Comment 6

3 years ago
Created attachment 8656025 [details] [diff] [review]
set line number when re-parsing sheet

Updated per review.
Attachment #8655680 - Attachment is obsolete: true
(Assignee)

Updated

3 years ago
Attachment #8656025 - Flags: review+
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
(Assignee)

Comment 8

3 years ago
Removing checkin-needed for now because the patch had a conflict during a rebase.
Keywords: checkin-needed
(Assignee)

Comment 9

3 years ago
Created attachment 8656556 [details] [diff] [review]
set line number when re-parsing sheet

Rebased.
Attachment #8656025 - Attachment is obsolete: true
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
(Assignee)

Updated

3 years ago
Attachment #8656556 - Flags: review+
Hi Tom, this patch failed to apply:

adding 1195978 to series file
renamed 1195978 -> Bug-1195978---set-line-number-when-re-parsing-shee.patch
applying Bug-1195978---set-line-number-when-re-parsing-shee.patch
patching file layout/style/CSSStyleSheet.cpp
Hunk #2 FAILED at 2309
1 out of 2 hunks FAILED -- saving rejects to file layout/style/CSSStyleSheet.cpp.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working directory
errors during apply, please fix and refresh Bug-1195978---set-line-number-when-re-parsing-shee.patch

could you take a look, thanks!
Flags: needinfo?(ttromey)
Keywords: checkin-needed
(Assignee)

Comment 11

3 years ago
(In reply to Carsten Book [:Tomcat] from comment #10)
> Hi Tom, this patch failed to apply:
> 
> adding 1195978 to series file
> renamed 1195978 -> Bug-1195978---set-line-number-when-re-parsing-shee.patch
> applying Bug-1195978---set-line-number-when-re-parsing-shee.patch
> patching file layout/style/CSSStyleSheet.cpp
> Hunk #2 FAILED at 2309
> 1 out of 2 hunks FAILED -- saving rejects to file
> layout/style/CSSStyleSheet.cpp.rej
> patch failed, unable to continue (try -v)
> patch failed, rejects left in working directory
> errors during apply, please fix and refresh
> Bug-1195978---set-line-number-when-re-parsing-shee.patch
> 
> could you take a look, thanks!

Hah, the patch that caused me to do a rebase (comment #9) was since reverted.
I'll attach the replacement patch shortly.
Flags: needinfo?(ttromey)
(Assignee)

Comment 12

3 years ago
Created attachment 8657128 [details] [diff] [review]
set line number when re-parsing sheet

Rebased for the revert.
Attachment #8656556 - Attachment is obsolete: true
(Assignee)

Updated

3 years ago
Attachment #8657128 - Flags: review+
(Assignee)

Updated

3 years ago
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/8e33c66fc2ca
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox43: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.