Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Issue 139293004: Teach the IDL compiler about TreatNullAs=EmptyString (Closed)

Created:
6 years, 11 months ago by philipj_slow
Modified:
6 years, 11 months ago
CC:
blink-reviews, Nils Barth (inactive), kojih, arv+blink, jsbell+bindings_chromium.org, sof, abarth-chromium, marja+watch_chromium.org, adamk+blink_chromium.org, Nate Chapin, watchdog-blink-watchlist_google.com, Inactive
Visibility:
Public.

Description

Teach the IDL compiler about TreatNullAs=EmptyString http://heycam.github.io/webidl/#TreatNullAs We already have TreatNullAs=NullString, but this is not equivalent, as the C++ code can differentiate between null and empty strings. The extent to which this is actually done has not been surveyed, but it's likely that some such checks can be removed in the process of converting (non-reflected) attributes from TreatNullAs=NullString to EmptyString. BUG=334519

Patch Set 1 #

Total comments: 5

Patch Set 2 : update test results #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+168 lines, -4 lines) Patch
M Source/bindings/scripts/code_generator_v8.pm View 1 1 chunk +5 lines, -4 lines 0 comments Download
M Source/bindings/tests/idls/TestObject.idl View 2 chunks +5 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestObject.cpp View 1 7 chunks +148 lines, -0 lines 0 comments Download
M Source/bindings/v8/V8StringResource.h View 2 chunks +10 lines, -0 lines 2 comments Download

Messages

Total messages: 12 (0 generated)
philipj_slow
https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h File Source/bindings/v8/V8StringResource.h (right): https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h#newcode169 Source/bindings/v8/V8StringResource.h:169: TreatNullAsEmptyString, The naming here isn't impressive, but I couldn't ...
6 years, 11 months ago (2014-01-15 10:04:00 UTC) #1
haraken
This CL looks OK, but I don't want to have both [TreatNullAs=NullString] and [TreatNullAs=EmptyString]. It's ...
6 years, 11 months ago (2014-01-15 11:57:36 UTC) #2
haraken
On 2014/01/15 11:57:36, haraken wrote: > This CL looks OK, but I don't want to ...
6 years, 11 months ago (2014-01-15 12:00:06 UTC) #3
arv (Not doing code reviews)
https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h File Source/bindings/v8/V8StringResource.h (right): https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h#newcode240 Source/bindings/v8/V8StringResource.h:240: if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { On 2014/01/15 10:04:01, philipj ...
6 years, 11 months ago (2014-01-15 15:44:58 UTC) #4
philipj_slow
https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h File Source/bindings/v8/V8StringResource.h (right): https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h#newcode240 Source/bindings/v8/V8StringResource.h:240: if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { On 2014/01/15 15:44:58, arv ...
6 years, 11 months ago (2014-01-15 15:49:14 UTC) #5
philipj_slow
On 2014/01/15 12:00:06, haraken wrote: > On 2014/01/15 11:57:36, haraken wrote: > > This CL ...
6 years, 11 months ago (2014-01-15 15:54:27 UTC) #6
arv (Not doing code reviews)
https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h File Source/bindings/v8/V8StringResource.h (right): https://codereview.chromium.org/139293004/diff/1/Source/bindings/v8/V8StringResource.h#newcode240 Source/bindings/v8/V8StringResource.h:240: if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { On 2014/01/15 15:49:14, philipj ...
6 years, 11 months ago (2014-01-15 15:59:00 UTC) #7
philipj_slow
I wrote a benchmark to test only this aspect: http://jsperf.com/setting-htmlbodyelement-alink Here are the results in ...
6 years, 11 months ago (2014-01-15 16:39:49 UTC) #8
philipj_slow
I should also mention that I was testing with a debug build, because building a ...
6 years, 11 months ago (2014-01-15 16:46:26 UTC) #9
philipj_slow
The numbers for release are 25,316,019±0.40% vs 1,357,553±0.45%, so my way is still 18 times ...
6 years, 11 months ago (2014-01-16 02:32:56 UTC) #10
haraken
On 2014/01/16 02:32:56, philipj wrote: > The numbers for release are 25,316,019±0.40% vs 1,357,553±0.45%, so ...
6 years, 11 months ago (2014-01-16 02:37:16 UTC) #11
philipj_slow
6 years, 11 months ago (2014-01-16 02:58:09 UTC) #12
Message was sent while issue was closed.
On 2014/01/16 02:37:16, haraken wrote:
> On 2014/01/16 02:32:56, philipj wrote:
> > The numbers for release are 25,316,019±0.40% vs 1,357,553±0.45%, so my way
is
> > still 18 times slower :/
> > 
> > Case closed.
> 
> Thanks for the investigation, philipj! The result is really helpful to
> understand our current code.
> 
> Just to clarify: Do you need [TreatNullAs=EmptyString] to fix some web-exposed
> behavior?

Not that I know of, but what originally prompted me to do this is the isNull()
check in HTMLSelectElement::setValue(). value used to have
[TreatNullAs=NullString] and when it did setting value to null and "" would not
have followed the same code path, and indeed have different Web-exposed
behavior. Fiddle with this in a Chromium older than Blink r163087 to verify:

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2750

The reason I didn't remove the null check together with [TreatNullAs=NullString]
is that the code is also reachable from WebSelectElement, and I couldn't
determine whether it could ever send in null in the twists and turns of form
autofill :/

My concern is that we might have more cases like this with subtly different
behavior for "" and null. It's not an issue for reflected attributes, so
hopefully after my war on [TreatNullAs=NullString] is reaching the end it'll be
possible to manually check the remaining cases and write test cases to verify.

Powered by Google App Engine
This is Rietveld 408576698