Closed
Bug 1407858
Opened 7 years ago
Closed 7 years ago
Add first-class literal support to DOMString
Categories
(Core :: DOM: Core & HTML, enhancement, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla59
People
(Reporter: n.nethercote, Assigned: bzbarsky)
References
Details
Attachments
(3 files, 1 obsolete file)
15.84 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
11.12 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
13.08 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
This is a follow-up to bug 1407117, which adds code that assigns static atom literals to DOMStrings via nsString.
It would be better to allow the literals to be assigned directly, without consructing/destructing an nsString.
Flags: needinfo?(bzbarsky)
Updated•7 years ago
|
Priority: -- → P3
Assignee | ||
Comment 1•7 years ago
|
||
The renaming here is like this:
SetStringBuffer -> SetKnownLiveStringBuffer
SetEphemeralStringBuffer -> SetStringBuffer
SetOwnedString -> SetKnownLiveString
SetOwnedAtom -> SetKnownLiveAtom
This should make it clearer what the lifetime expectations are on the caller side.
MozReview-Commit-ID: ERHbB3r6paN
Attachment #8938595 -
Flags: review?(bugs)
Assignee | ||
Comment 2•7 years ago
|
||
MozReview-Commit-ID: AaTeI1e7Qnk
Attachment #8938596 -
Flags: review?(bugs)
Assignee | ||
Comment 3•7 years ago
|
||
MozReview-Commit-ID: EsgAAcfDFKt
Attachment #8938597 -
Flags: review?(bugs)
Assignee | ||
Comment 4•7 years ago
|
||
Flags: needinfo?(bzbarsky)
Assignee | ||
Comment 5•7 years ago
|
||
Attachment #8938603 -
Flags: review?(bugs)
Assignee | ||
Updated•7 years ago
|
Attachment #8938595 -
Attachment is obsolete: true
Attachment #8938595 -
Flags: review?(bugs)
Updated•7 years ago
|
Attachment #8938603 -
Flags: review?(bugs) → review+
Comment 6•7 years ago
|
||
Comment on attachment 8938596 [details] [diff] [review]
part 2. Make DOMString's data model clearer and update various documentation
> * The proper way to extract a value is to check IsNull(). If not null, then
>- * check HasStringBuffer(). If that's true, check for a zero length, and if the
>- * length is nonzero call StringBuffer(). If the length is zero this is the
>- * empty string. If HasStringBuffer() returns false, call AsAString() and get
>- * the value from that.
>+ * check IsEmpty(). If neither of those is true, check HasStringBuffer(). If
>+ * that's true, call StringBuffer(). If HasStringBuffer() returns false, call
>+ * AsAString() and get the value from that.
This all doesn't seem to quite capture the case that AsString() can be called when IsEmpty() returns true.
>+
>+ enum class State : uint8_t {
Nit, { should be on its own line
Attachment #8938596 -
Flags: review?(bugs) → review+
Comment 7•7 years ago
|
||
Comment on attachment 8938597 [details] [diff] [review]
part 3. Add a literal string state to DOMString
>+ // Get the literal string. This can only be called if HasLiteral()
>+ // returned true. If that's true, it will never return null.
>+ const char16_t* Literal() const
>+ {
>+ MOZ_ASSERT(HasLiteral(),
>+ "Don't ask for the literal if we don't have it");
>+ MOZ_ASSERT(mStringBuffer,
>+ "We better have a literal if we claim to");
mStringBuffer? Shouldn't you use mLiteral here.
Both point to the same value, but would make reading easier.
>- // The nsStringBuffer in the OwnedStringBuffer/UnownedStringBuffer cases.
>- nsStringBuffer* MOZ_UNSAFE_REF("The ways in which this can be safe are "
>+ union {
I think { should be on its own line.
Attachment #8938597 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 8•7 years ago
|
||
> This all doesn't seem to quite capture the case that AsString() can be called when IsEmpty() returns true.
Well, for _extracting_ a value that's not really relevant, since if IsEmpty() is true then the value is empty.
> Nit, { should be on its own line
Done.
> mStringBuffer? Shouldn't you use mLiteral here.
Yes, good catch.
> I think { should be on its own line.
Done.
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a229bf234505
part 1. Give DOMString setter APIs clearer names. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/282695389a27
part 2. Make DOMString's data model clearer and update various documentation. r=smaug
https://hg.mozilla.org/integration/mozilla-inbound/rev/45fe585acac1
part 3. Add a literal string state to DOMString. r=smaug
Comment 10•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a229bf234505
https://hg.mozilla.org/mozilla-central/rev/282695389a27
https://hg.mozilla.org/mozilla-central/rev/45fe585acac1
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox59:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Comment 11•7 years ago
|
||
Too late for FF58. Mark 58 won't fix.
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•