Skip to content

Opaque DOMString - #8477

Merged
bors-servo merged 10 commits into
servo:masterfrom
asajeffrey:opaque-domstring
Nov 13, 2015
Merged

bors-servo merged 10 commits into
servo:masterfrom
asajeffrey:opaque-domstring

Conversation

@asajeffrey

Copy link
Copy Markdown
Contributor

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 highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 12, 2015
@highfive

Copy link
Copy Markdown

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
Copy Markdown
Contributor

Neat!

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 12, 2015
@jdm

jdm commented Nov 12, 2015

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 12, 2015
@jdm

jdm commented Nov 12, 2015

Copy link
Copy Markdown
Member

@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

@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 12, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

✌️ @asajeffrey can now approve this pull request

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 12, 2015
@asajeffrey asajeffrey removed the S-needs-squash Some (or all) of the commits in the PR should be combined. label Nov 12, 2015
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Rebased, and updated the unit tests.

@jdm

jdm commented Nov 12, 2015

Copy link
Copy Markdown
Member

@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
Copy Markdown
Contributor

📌 Commit 99c8a37 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 12, 2015
@jdm

jdm commented Nov 12, 2015

Copy link
Copy Markdown
Member

@bors-servo: p=1

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 99c8a37 with merge e592382...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - gonk

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 12, 2015
@jdm

jdm commented Nov 12, 2015

Copy link
Copy Markdown
Member

@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Nov 12, 2015
@asajeffrey

Copy link
Copy Markdown
Contributor Author

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

Alan Jeffrey added 10 commits November 12, 2015 17:51
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

Copy link
Copy Markdown
Contributor Author

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0da1623 has been approved by asajeffrey

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 12, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0da1623 with merge 1cb98c3...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 13, 2015
@eefriedman

Copy link
Copy Markdown
Contributor

@bors-servo retry #8487

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0da1623 with merge 62acdd3...

bors-servo pushed 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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 13, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit 0da1623 into servo:master Nov 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants