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

Issue 9623017: Refactor the event-generation code to locate it in systemhtml.py. (Closed)

Created:
8 years, 9 months ago by nweiz
Modified:
8 years, 9 months ago
Reviewers:
Jacob, sra1
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Refactor the event-generation code to locate it in systemhtml.py. This also adds some code to enforce the generation of an events class for DocumentFragment so that it can provide access to all the element events. Committed: https://code.google.com/p/dart/source/detail?r=5196

Patch Set 1 #

Total comments: 9

Patch Set 2 : Code review changes #

Total comments: 6

Patch Set 3 : Code review changes #

Total comments: 13

Patch Set 4 : Code review changes #

Patch Set 5 : Code review changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+448 lines, -386 lines) Patch
M client/dom/scripts/dartgenerator.py View 1 chunk +0 lines, -7 lines 0 comments Download
M client/dom/scripts/systemfrog.py View 1 chunk +0 lines, -3 lines 0 comments Download
M client/dom/scripts/systemhtml.py View 1 2 3 4 14 chunks +80 lines, -31 lines 0 comments Download
M client/dom/scripts/systeminterface.py View 1 chunk +0 lines, -3 lines 0 comments Download
M client/dom/scripts/systemwrapping.py View 1 chunk +0 lines, -3 lines 0 comments Download
M client/html/dartium/html_dartium.dart View 46 chunks +88 lines, -81 lines 0 comments Download
M client/html/frog/html_frog.dart View 1 2 46 chunks +65 lines, -60 lines 0 comments Download
M client/html/generated/html/dartium/BodyElement.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/DOMApplicationCache.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M client/html/generated/html/dartium/Document.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/DocumentFragment.dart View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M client/html/generated/html/dartium/Element.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/EventSource.dart View 1 chunk +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/FrameSetElement.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/InputElement.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/Notification.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/SVGElementInstance.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/WebSocket.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/Window.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/dartium/XMLHttpRequest.dart View 2 chunks +5 lines, -5 lines 0 comments Download
M client/html/generated/html/frog/BodyElement.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/DOMApplicationCache.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/Document.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/DocumentFragment.dart View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M client/html/generated/html/frog/Element.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/EventSource.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/FrameSetElement.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/InputElement.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/Notification.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/SVGElementInstance.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/WebSocket.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/Window.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/frog/XMLHttpRequest.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M client/html/generated/html/interface/BodyElement.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/DOMApplicationCache.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/Document.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/DocumentFragment.dart View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M client/html/generated/html/interface/Element.dart View 1 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/EventSource.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/FrameSetElement.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/InputElement.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/Notification.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/SVGElementInstance.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/WebSocket.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/Window.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/generated/html/interface/XMLHttpRequest.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M client/html/release/html.dart View 46 chunks +88 lines, -81 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
nweiz
8 years, 9 months ago (2012-03-07 22:02:24 UTC) #1
Jacob
https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py#newcode508 client/dom/scripts/systemhtml.py:508: # Hack to generate no-op Element events for DocumentFragment. ...
8 years, 9 months ago (2012-03-07 23:24:04 UTC) #2
nweiz
https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py#newcode508 client/dom/scripts/systemhtml.py:508: # Hack to generate no-op Element events for DocumentFragment. ...
8 years, 9 months ago (2012-03-08 01:03:50 UTC) #3
Jacob
https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/1/client/dom/scripts/systemhtml.py#newcode778 client/dom/scripts/systemhtml.py:778: if events != None: self.AddEventAttributes(events) On 2012/03/08 01:03:51, nweiz ...
8 years, 9 months ago (2012-03-08 18:38:09 UTC) #4
nweiz
https://chromiumcodereview.appspot.com/9623017/diff/4001/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/4001/client/dom/scripts/systemhtml.py#newcode644 client/dom/scripts/systemhtml.py:644: if events == set(): On 2012/03/08 18:38:09, Jacob wrote: ...
8 years, 9 months ago (2012-03-08 20:47:15 UTC) #5
Jacob
lgtm https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py#newcode501 client/dom/scripts/systemhtml.py:501: def GetOneParentEventsClass(self, interface): Nit: remove the word "One" ...
8 years, 9 months ago (2012-03-08 21:45:11 UTC) #6
sra1
I'll let Jacob comment on the generated code. I have a few comments on the ...
8 years, 9 months ago (2012-03-08 21:58:59 UTC) #7
nweiz
https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py#newcode501 client/dom/scripts/systemhtml.py:501: def GetOneParentEventsClass(self, interface): On 2012/03/08 21:45:11, Jacob wrote: > ...
8 years, 9 months ago (2012-03-08 22:14:45 UTC) #8
Jacob
https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py#newcode650 client/dom/scripts/systemhtml.py:650: if events == set(): I think the issue is ...
8 years, 9 months ago (2012-03-08 22:33:37 UTC) #9
nweiz
https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py File client/dom/scripts/systemhtml.py (right): https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/systemhtml.py#newcode650 client/dom/scripts/systemhtml.py:650: if events == set(): On 2012/03/08 22:33:38, Jacob wrote: ...
8 years, 9 months ago (2012-03-08 22:52:45 UTC) #10
Jacob
lgtm
8 years, 9 months ago (2012-03-08 22:54:18 UTC) #11
sra1
8 years, 9 months ago (2012-03-08 23:07:32 UTC) #12
https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/s...
File client/dom/scripts/systemhtml.py (right):

https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/s...
client/dom/scripts/systemhtml.py:650: if events == set():
On 2012/03/08 22:14:45, nweiz wrote:
> On 2012/03/08 21:58:59, sra1 wrote:
> > This is slightly confusing, since pythonic style is "if events:"
> > 
> > Perhaps:
> > 
> >   if events is not None:
> >     if events:
> >     else:
> 
> Why is explicitly comparing to None less confusing than explicitly comparing
to
> set()?

Idea 1:
Do we need to emit the no-added-methods on-getter at all?

Idea 2:
Push the login into AddEventAttributes.  It calls GetOneParentEventsClass
anyway.

events = self._shared...
if events is not None:
  self.AddEventAttributes(events)


If stay like this:

There are three actions here, one is to do nothing.  'do-nothing' is at a
coarser level of distinction, so it might be clearer when expressed as
if-without-{else,elif}.  Your code is:

detail1
detail2
[implicit !feature]

I'm suggesting:

feature
  detail1
  detail2

This is not a *huge* issue, but I stumbled when reading the original; it just
looked odd.  I thought 'huh?' and had to go and read GetEventAttributes to see
that the value is not always a set.
There is clearly something not quite 100% perfect because Jacob was confused
too.

Perhaps the answer is to make both falsy values explicit, so it is clear we are
dealing with a nullable possibly empty collection.

if events is not None:
  if events == set():
  else:

if events is not None:
  if events:
  else: # empty set of events means we can inherit the events.

https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/s...
client/dom/scripts/systemhtml.py:725: def _EmitEventGetter(self, interface):
can we call this events_interface for uniformity with above and to avoid
potential confusion that self._interface might be the same?

https://chromiumcodereview.appspot.com/9623017/diff/9002/client/dom/scripts/s...
client/dom/scripts/systemhtml.py:1051: def _EmitEventGetter(self, interface):
interface -> events_class ?

Powered by Google App Engine
This is Rietveld 408576698