Skip to content

Implement the MozMap type. - #13332

Merged
bors-servo merged 7 commits into
masterfrom
mozmap
Sep 21, 2016
Merged

bors-servo merged 7 commits into
masterfrom
mozmap

Conversation

@Ms2ger

@Ms2ger Ms2ger commented Sep 20, 2016 •

Copy link
Copy Markdown
Contributor

Fixes #13144.

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/testbinding.rs, components/script/dom/bindings/mod.rs, components/script/dom/bindings/mozmap.rs, components/script/dom/bindings/conversions.rs, components/script/dom/webidls/TestBinding.webidl

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 20, 2016
/// # Panics
///
/// Panics if `id` is not string-valued.
pub fn string_jsid_to_string(cx: *mut JSContext, id: HandleId) -> DOMString {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it unsafe while at it?

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple small changes and clarifications. Great work!

pub fn jsid_to_str(cx: *mut JSContext, id: HandleId) -> DOMString {
/// Convert `id` to a `DOMString`, assuming it is string-valued.
///
/// Handling of invalid UTF-16 in strings depends on the relevant option.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"relevant option"? Is this a copy-paste error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refers to opts::get().replace_surrogates; not sure if it would be better to mention -Z replace-surrogates explicitly.


def innerMozMapType(type):
assert type.isMozMap()
return type.inner.inner if type.nullable() else type.inner

@jdm jdm Sep 20, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might as well merge this with the innerSequenceType function (innerMapOrSequenceType?), since they're identical except for the asserts.

if type.isSequence():
return getConversionConfigForType(type.unroll(), isEnforceRange, isClamp, treatNullAs)

if type.isMozMap():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this with the previous.

/// Convert `id` to a `DOMString`. Returns `None` if `id` is not a string or
/// integer.
///
/// Handling of invalid UTF-16 in strings depends on the relevant option.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant option?


let property = match try!(T::from_jsval(cx, property.handle(), config.clone())) {
ConversionResult::Success(property) => property,
ConversionResult::Failure(message) => return Ok(ConversionResult::Failure(message)),

@jdm jdm Sep 20, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failure => return Ok(failure),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   |
73 |                 failure => return Ok(failure),
   |                                      ^^^^^^^ expected struct `dom::bindings::mozmap::MozMap`, found type parameter
   |
   = note: expected type `js::conversions::ConversionResult<dom::bindings::mozmap::MozMap<T>>`
   = note:    found type `js::conversions::ConversionResult<T>`

ConversionResult::Failure(message) => return Ok(ConversionResult::Failure(message)),
};

let key = jsid_to_string(cx, id.handle()).unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this panic on an unpaired surrogate?

@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 Sep 20, 2016
@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 Sep 21, 2016
@jdm

jdm commented Sep 21, 2016

Copy link
Copy Markdown
Member

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 2d83e5a 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 Sep 21, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 2d83e5a with merge 7b98c8a...

bors-servo pushed a commit that referenced this pull request Sep 21, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev

@bors-servo
bors-servo merged commit 2d83e5a into master Sep 21, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 21, 2016
bors-servo pushed a commit that referenced this pull request Sep 22, 2016
Support OpenEndedDictionary (Mozmap) in the Headers

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

This PR will support OpenEndedDictionary (based on MozMap implementation from #13332) in the Headers API.

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

<!-- Either: -->
- [X] 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13356)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Sep 23, 2016
Support OpenEndedDictionary (Mozmap) in the Headers

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

This PR will support OpenEndedDictionary (based on MozMap implementation from #13332) in the Headers API.

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

<!-- Either: -->
- [X] 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13356)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Sep 23, 2016
Support OpenEndedDictionary (Mozmap) in the Headers

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

This PR will support OpenEndedDictionary (based on MozMap implementation from #13332) in the Headers API.

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

<!-- Either: -->
- [X] 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13356)
<!-- Reviewable:end -->
@Ms2ger
Ms2ger deleted the mozmap branch September 27, 2016 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants