Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop parsing style attributes during restyle in geckolib. #11787

Merged
merged 1 commit into from Jun 24, 2016

Conversation

@heycam
Copy link
Member

heycam commented Jun 18, 2016

This allows PropertyDeclarationBlocks parsed for style="" attributes to be stored on a Gecko node so that we don't have to re-parse it each time we compute style for an element. Works with Gecko bug 1280772.

r? @bholley
CC @emilio


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Jun 18, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@bors-servo
Copy link
Contributor

bors-servo commented Jun 21, 2016

The latest upstream changes (presumably #11784) made this pull request unmergeable. Please resolve the merge conflicts.

@heycam heycam force-pushed the heycam:style-attr branch from 2497893 to 401b627 Jun 22, 2016
@heycam
Copy link
Member Author

heycam commented Jun 22, 2016

A few questions on this updated patch:

  • Should the new GeckoDeclarationBlock struct live elsewhere?
  • Is it right to use RefCells for the two members that I need to be able to modify, and if so, should I combine them into a single RefCell?
  • Do you think it's important to have the Servo_ClearDeclarationBlockCachePointer function? (If not, we can make GeckoDeclarationBlock::cache not a RefCell.) If the nsHTMLCSSStyleSheet is going away, then we're in document shutdown, so we shouldn't need to look at the GeckoDeclarationBlock again.
  • In TElement::style_attribute for GeckoElement, I'm using transmute to get around lifetime issues when returning arc.declarations. Is there something better I should be doing?
@bholley
Copy link
Contributor

bholley commented Jun 22, 2016

Should the new GeckoDeclarationBlock struct live elsewhere?

Per the bug I think we should get rid of the pointer and the RefCell. And maybe just put the bool inside PropertyDeclarationBlock and conditionally compile it for geckolib?

Is it right to use RefCells for the two members that I need to be able to modify, and if so, should I combine them into a single RefCell?

N/A given the discussion in the bug.

Do you think it's important to have the Servo_ClearDeclarationBlockCachePointer function? (If not, we can make GeckoDeclarationBlock::cache not a RefCell.) If the nsHTMLCSSStyleSheet is going away, then we're in document shutdown, so we shouldn't need to look at the GeckoDeclarationBlock again.

Same.

In TElement::style_attribute for GeckoElement, I'm using transmute to get around lifetime issues when returning arc.declarations. Is there something better I should be doing?

I think you should be able to just use .as_ref() on the the *PropertyDeclarationBlock and the borrow checker should be satisfied.

@heycam heycam force-pushed the heycam:style-attr branch from 401b627 to b04061b Jun 23, 2016
@heycam
Copy link
Member Author

heycam commented Jun 23, 2016

Per the IRC discussion we had, I've left the nsHTMLCSSStyleSheet pointer and the immutable bool, and left them on the GeckoDeclarationBlock rather than move them up to PropertyDeclarationBlock and make them conditionally compiled.

#[no_mangle]
pub extern "C" fn Servo_GetDeclarationBlockCache(declarations: *mut ServoDeclarationBlock)
-> *mut nsHTMLCSSStyleSheet {
let declarations: &GeckoDeclarationBlock = unsafe { transmute(declarations) };

This comment has been minimized.

Copy link
@bholley

bholley Jun 23, 2016

Contributor

We should be able to remove these transmutes by mapping the types together and then using .as_ref(). We do this elsewhere IIRC.

if ptr.is_null() {
&NO_STYLE_ATTRIBUTE
} else {
let declarations: &GeckoDeclarationBlock = transmute(ptr);

This comment has been minimized.

Copy link
@bholley

bholley Jun 23, 2016

Contributor

We should be able to eliminate this as well.

This comment has been minimized.

Copy link
@bholley

bholley Jun 23, 2016

Contributor

And .as_ref() will map nicely to the NO_STYLE_ATTRIBUTE case.

In general transmute is a big hammer, and we should restrict our uses to the cases where we really need it.

@bholley
Copy link
Contributor

bholley commented Jun 23, 2016

@bors-servo delegate+ with the transmutes removed.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 23, 2016

✌️ @heycam can now approve this pull request

@heycam heycam force-pushed the heycam:style-attr branch from b04061b to 21e378b Jun 24, 2016
@heycam
Copy link
Member Author

heycam commented Jun 24, 2016

@bors-servo r=bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

📌 Commit 21e378b has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

Testing commit 21e378b with merge 62fad97...

bors-servo added a commit that referenced this pull request Jun 24, 2016
Stop parsing style attributes during restyle in geckolib.

<!-- Please describe your changes on the following line: -->

This allows `PropertyDeclarationBlock`s parsed for `style=""` attributes to be stored on a Gecko node so that we don't have to re-parse it each time we compute style for an element.  Works with [Gecko bug 1280772](https://bugzilla.mozilla.org/show_bug.cgi?id=1280772).

r? @bholley
CC @emilio

---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11787)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

💔 Test failed - linux-dev

@heycam heycam force-pushed the heycam:style-attr branch from 21e378b to 98a32a7 Jun 24, 2016
@heycam
Copy link
Member Author

heycam commented Jun 24, 2016

@bors-servo retry

@jdm
Copy link
Member

jdm commented Jun 24, 2016

@bors-servo: r=bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

📌 Commit 98a32a7 has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

Testing commit 98a32a7 with merge 581c8ba...

bors-servo added a commit that referenced this pull request Jun 24, 2016
Stop parsing style attributes during restyle in geckolib.

<!-- Please describe your changes on the following line: -->

This allows `PropertyDeclarationBlock`s parsed for `style=""` attributes to be stored on a Gecko node so that we don't have to re-parse it each time we compute style for an element.  Works with [Gecko bug 1280772](https://bugzilla.mozilla.org/show_bug.cgi?id=1280772).

r? @bholley
CC @emilio

---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11787)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

💔 Test failed - mac-rel-wpt

@heycam
Copy link
Member Author

heycam commented Jun 24, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

Previous build results for android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, windows are reusable. Rebuilding only mac-rel-wpt...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 24, 2016

@bors-servo bors-servo merged commit 98a32a7 into servo:master Jun 24, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.