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

Opaque DOMString #8477

Merged
merged 10 commits into from Nov 13, 2015
Merged

Opaque DOMString #8477

merged 10 commits into from Nov 13, 2015

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented Nov 12, 2015

This patch makes DOMString an opaque wrapper round String (currently it's a transparent wrapper).

The changes are:

  • Replacing DOMString(foo) by DOMString::from(foo).
  • Replacing foo.0 by String::from(foo).
  • Adding functions clear, push_str and extend for in-place mutation of DOMStrings.
  • Replacing DOMString by String in other threads (devtools, storage and filereader).
  • Making DOMString implement !Send.
  • Removing the pub attribute from the contents of DOMString.

This enables experimenting with other string representations in the DOM.

Review on Reviewable

@highfive
Copy link

highfive commented Nov 12, 2015

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify layout code, but no reftests are modified. Please consider adding a reftest!
@pcwalton
Copy link
Contributor

pcwalton commented Nov 12, 2015

Neat!

@jdm
Copy link
Member

jdm commented Nov 12, 2015

Thanks for splitting the commits up this way!
-S-awaiting-review +S-needs-code-changes


Reviewed 1 of 1 files at r1, 4 of 4 files at r2, 2 of 2 files at r3, 1 of 1 files at r4, 3 of 3 files at r5, 1 of 1 files at r6, 1 of 1 files at r7, 63 of 63 files at r8, 1 of 1 files at r9, 5 of 5 files at r10, 1 of 1 files at r11.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


components/devtools/actors/inspector.rs, line 209 [r2] (raw file):
I don't think these String::from calls are necessary any more.


components/script/dom/create.rs, line 85 [r8] (raw file):
No need for {}.


components/script/dom/htmlinputelement.rs, line 579 [r10] (raw file):
We should probably be fetching the placeholder attribute on-demand in the layout code instead of storing a duplicate. File an issue?


components/script/dom/storage.rs, line 131 [r5] (raw file):
I don't have any better ideas.


components/script/script_task.rs, line 1705 [r3] (raw file):
I'd prefer to keep this as DOMString and perform the conversion explicitly inside this function.


components/util/mem.rs, line 106 [r7] (raw file):
What if we made it really obvious what we're doing by transmuting to &String and calling heap_size_of_children instead?


Comments from the review on Reviewable.io

@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 12, 2015

I'm getting better at rewriting my git history :)


Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/util/mem.rs, line 106 [r7] (raw file):
Well, this code is going to vanish pretty soon anyway, since the next task is to move str.rs out of util and into script/dom, at which point we can derive HeapSizeOf.


Comments from the review on Reviewable.io

@jdm
Copy link
Member

jdm commented Nov 12, 2015

@bors-servo: delegate+
-S-awaiting-review +S-needs-squash


Reviewed 1 of 1 files at r12, 1 of 1 files at r13, 1 of 1 files at r14.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2015

✌️ @asajeffrey can now approve this pull request

@asajeffrey asajeffrey force-pushed the asajeffrey:opaque-domstring branch from 1341a4b to 0816dda Nov 12, 2015
@asajeffrey asajeffrey force-pushed the asajeffrey:opaque-domstring branch from 0816dda to 99c8a37 Nov 12, 2015
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 12, 2015

Rebased, and updated the unit tests.

@jdm
Copy link
Member

jdm commented Nov 12, 2015

@bors-servo: r+


Reviewed 1 of 1 files at r15.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2015

📌 Commit 99c8a37 has been approved by jdm

@jdm
Copy link
Member

jdm commented Nov 12, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2015

Testing commit 99c8a37 with merge e592382...

bors-servo added a commit that referenced this pull request Nov 12, 2015
Opaque DOMString

This patch makes DOMString an opaque wrapper round String (currently it's a transparent wrapper).

The changes are:

* Replacing DOMString(foo) by DOMString::from(foo).
* Replacing foo.0 by String::from(foo).
* Adding functions clear, push_str and extend for in-place mutation of DOMStrings.
* Replacing DOMString by String in other threads (devtools, storage and filereader).
* Making DOMString implement !Send.
* Removing the pub attribute from the contents of DOMString.

This enables experimenting with other string representations in the DOM.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8477)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2015

💔 Test failed - gonk

@jdm
Copy link
Member

jdm commented Nov 12, 2015

@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 12, 2015

Ah the trying-to-land-a-patch dance, how I love it. Rebased again.

asajeffrey added 10 commits Nov 10, 2015
Implemented From<String> and From<&str> for DOMString,
and From<DOMString> for String.
This change makes DOMStrings only accessible from the main JS thread.
We have to do this by hand because DOMString is defined in util.
Replaced DOMString(...) by DOMString::from(...).
Replaced ....0 by String::from(...).
Removed any uses of .to_owner() in DOMString::from("...").
The methods which are currently implemented are the ones on String that are currently being used:
string.push_str(...), string.clear() and string.extend(...). We may want to revisit this API.
Removed the "pub" attribute from the String field of DOMString.
This enables experimenting with other string representations.
@asajeffrey asajeffrey force-pushed the asajeffrey:opaque-domstring branch from 2dadea7 to 0da1623 Nov 12, 2015
@asajeffrey
Copy link
Member Author

asajeffrey commented Nov 12, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2015

📌 Commit 0da1623 has been approved by asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2015

Testing commit 0da1623 with merge 1cb98c3...

bors-servo added a commit that referenced this pull request Nov 13, 2015
Opaque DOMString

This patch makes DOMString an opaque wrapper round String (currently it's a transparent wrapper).

The changes are:

* Replacing DOMString(foo) by DOMString::from(foo).
* Replacing foo.0 by String::from(foo).
* Adding functions clear, push_str and extend for in-place mutation of DOMStrings.
* Replacing DOMString by String in other threads (devtools, storage and filereader).
* Making DOMString implement !Send.
* Removing the pub attribute from the contents of DOMString.

This enables experimenting with other string representations in the DOM.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8477)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2015

💔 Test failed - linux-rel

@eefriedman
Copy link
Contributor

eefriedman commented Nov 13, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2015

Testing commit 0da1623 with merge 62acdd3...

bors-servo added a commit that referenced this pull request Nov 13, 2015
Opaque DOMString

This patch makes DOMString an opaque wrapper round String (currently it's a transparent wrapper).

The changes are:

* Replacing DOMString(foo) by DOMString::from(foo).
* Replacing foo.0 by String::from(foo).
* Adding functions clear, push_str and extend for in-place mutation of DOMStrings.
* Replacing DOMString by String in other threads (devtools, storage and filereader).
* Making DOMString implement !Send.
* Removing the pub attribute from the contents of DOMString.

This enables experimenting with other string representations in the DOM.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8477)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2015

@bors-servo bors-servo merged commit 0da1623 into servo:master Nov 13, 2015
2 of 3 checks passed
2 of 3 checks passed
code-review/reviewable Review in progress: 58 of 75 files reviewed, all discussions resolved
Details
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

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