Repository navigation
Implement the MozMap type. - #13332
Conversation
|
Heads up! This PR modifies the following files:
|
| /// # Panics | ||
| /// | ||
| /// Panics if `id` is not string-valued. | ||
| pub fn string_jsid_to_string(cx: *mut JSContext, id: HandleId) -> DOMString { |
There was a problem hiding this comment.
Could you make it unsafe while at it?
jdm
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
"relevant option"? Is this a copy-paste error?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(): |
| /// 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. |
|
|
||
| let property = match try!(T::from_jsval(cx, property.handle(), config.clone())) { | ||
| ConversionResult::Success(property) => property, | ||
| ConversionResult::Failure(message) => return Ok(ConversionResult::Failure(message)), |
There was a problem hiding this comment.
|
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(); |
There was a problem hiding this comment.
Couldn't this panic on an unpaired surrogate?
|
@bors-servo: r+ |
|
📌 Commit 2d83e5a has been approved by |
Implement the MozMap type. Fixes #13144. <!-- 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/13332) <!-- Reviewable:end -->
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
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 -->
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 -->
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 -->
Fixes #13144.
This change is