WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
48316
Web Inspector: rewrite InspectorInstrumenation using macro
https://bugs.webkit.org/show_bug.cgi?id=48316
Summary
Web Inspector: rewrite InspectorInstrumenation using macro
Pavel Podivilov
Reported
2010-10-26 02:42:53 PDT
Web Inspector: rewrite InspectorInstrumenation using macro
Attachments
Patch.
(37.90 KB, patch)
2010-10-26 02:43 PDT
,
Pavel Podivilov
no flags
Details
Formatted Diff
Diff
Patch.
(37.75 KB, patch)
2010-10-26 02:46 PDT
,
Pavel Podivilov
no flags
Details
Formatted Diff
Diff
Build fix.
(37.76 KB, patch)
2010-10-26 06:57 PDT
,
Pavel Podivilov
no flags
Details
Formatted Diff
Diff
Patch.
(38.00 KB, patch)
2010-10-27 09:49 PDT
,
Pavel Podivilov
mjs
: review-
Details
Formatted Diff
Diff
InspectorInstrumentation.h
(9.30 KB, text/plain)
2010-10-27 09:49 PDT
,
Pavel Podivilov
no flags
Details
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Pavel Podivilov
Comment 1
2010-10-26 02:43:33 PDT
Created
attachment 71855
[details]
Patch.
Pavel Podivilov
Comment 2
2010-10-26 02:46:47 PDT
Created
attachment 71856
[details]
Patch.
Early Warning System Bot
Comment 3
2010-10-26 03:01:55 PDT
Attachment 71856
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/4755012
Eric Seidel (no email)
Comment 4
2010-10-26 03:31:46 PDT
Attachment 71856
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/4787009
Eric Seidel (no email)
Comment 5
2010-10-26 03:54:23 PDT
Attachment 71856
[details]
did not build on chromium: Build output:
http://queues.webkit.org/results/4816018
Pavel Podivilov
Comment 6
2010-10-26 06:57:56 PDT
Created
attachment 71872
[details]
Build fix.
Alexander Pavlov (apavlov)
Comment 7
2010-10-26 08:34:22 PDT
Comment on
attachment 71872
[details]
Build fix. View in context:
https://bugs.webkit.org/attachment.cgi?id=71872&action=review
> WebCore/ChangeLog:5 > + Web Inspector: rewrite InspectorInstrumenation using macro
Bad "InspectorInstrumenation" spelling (from the bug summary)
> WebCore/inspector/InspectorInstrumentation.cpp:462 > + if (page) {
Converted into a series of guards (if (...) return 0;), it would read better
> WebCore/inspector/InspectorInstrumentation.cpp:471 > +InspectorController* InspectorInstrumentation::retrieveInspectorController(ScriptExecutionContext* context)
we usually name getters without a leading verb (e.g. InspectorInstrumentation::inspectorController(..)). Ditto for the overloads.
Joseph Pecoraro
Comment 8
2010-10-26 09:47:22 PDT
I don't find this easier to read at all. There is too much magic going on, I don't think all of it is necessary. I would say its easier to read generated code than this. I don't think this makes it easier to understand and write inspector code for newcomers.
Joseph Pecoraro
Comment 9
2010-10-26 09:48:39 PDT
Thats a lot of "I don'ts". I am just worried about this change making it more difficult for people learn and work on the inspector.
Pavel Feldman
Comment 10
2010-10-26 09:58:08 PDT
(In reply to
comment #9
)
> Thats a lot of "I don'ts". I am just worried about this change making it more difficult > for people learn and work on the inspector.
I can see your concerns. We'd like to have a nice facade for the instrumentation calls in WebCore and this class serves the purpose. But we've learned that it is error-prone since api methods call corresponding impl methods and those delegate further. So one can easily confuse names and such. This change kills code and that's why I tend to like it. It makes things no so clear, but it definitely allows adding instrumentation with less pain. Like inspector.idl was a great thing to have instead of the InspectorFrontend class. What are your suggestions wrt killing code and making it less error-prone?
Joseph Pecoraro
Comment 11
2010-10-26 10:45:31 PDT
> It makes things not so clear, but it definitely allows adding instrumentation with less pain. > Like inspector.idl was a great thing to have instead of the InspectorFrontend class.
I think Inspector.idl was a nice improvement. It is much easier to follow how the idl function generates the .cpp, .h, and .js files. And, if there is any confusion you can see the actual generated file to see what it output. Here, there is no generated file. Maybe you can run the pre-processor to see what it produces, but it still feels more difficult. This looks like it is trying to provide a new special syntax whereas the idl approach has a cleaner, more standard syntax. It could just be that the macros are so spread out in the patch that I have to jump around a lot to follow what is happening. Would you mind putting up a patch of what InspectorInstrumentation.h looks like after your patch?
> What are your suggestions wrt killing code and making it less error-prone?
I'm a big fan of DRY (Don't Repeat Yourself) removing duplicated code.
Pavel Podivilov
Comment 12
2010-10-27 09:49:07 PDT
Created
attachment 72047
[details]
Patch.
Pavel Podivilov
Comment 13
2010-10-27 09:49:39 PDT
Created
attachment 72048
[details]
InspectorInstrumentation.h
Pavel Podivilov
Comment 14
2010-10-27 09:53:20 PDT
(In reply to
comment #7
)
> (From update of
attachment 71872
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=71872&action=review
> > > WebCore/ChangeLog:5 > > + Web Inspector: rewrite InspectorInstrumenation using macro > > Bad "InspectorInstrumenation" spelling (from the bug summary)
done
> > > WebCore/inspector/InspectorInstrumentation.cpp:462 > > + if (page) { > > Converted into a series of guards (if (...) return 0;), it would read better
done
> > > WebCore/inspector/InspectorInstrumentation.cpp:471 > > +InspectorController* InspectorInstrumentation::retrieveInspectorController(ScriptExecutionContext* context) > > we usually name getters without a leading verb (e.g. InspectorInstrumentation::inspectorController(..)). Ditto for the overloads.
Actually it's not a getter, since InspectorInstrumentation doesn't store pointers to InspectorController. I think retrieveInspectorController name better reflects what method does.
Maciej Stachowiak
Comment 15
2010-11-08 01:02:48 PST
Comment on
attachment 72047
[details]
Patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=72047&action=review
> WebCore/inspector/InspectorInstrumentation.h:106 > +#define ARGS0() > +#define ARGS1(Arg1) , Arg1 arg1 > +#define ARGS2(Arg1, Arg2) ARGS1(Arg1), Arg2 arg2 > +#define ARGS3(Arg1, Arg2, Arg3) ARGS2(Arg1, Arg2), Arg3 arg3 > +#define ARGS4(Arg1, Arg2, Arg3, Arg4) ARGS3(Arg1, Arg2, Arg3), Arg4 arg4 > + > +#define ARGNAMES0 > +#define ARGNAMES1 , arg1 > +#define ARGNAMES2 , arg1, arg2 > +#define ARGNAMES3 , arg1, arg2, arg3 > +#define ARGNAMES4 , arg1, arg2, arg3, arg4 > + > +#define EXPAND(macro, name, Origin, argc, args) macro(name, Origin, ARGS##argc args, ARGNAMES##argc) > +#define EXPAND1(macro, name, Origin, argc, args) macro(name, Origin, ARGS##argc args, ARGNAMES##argc, , ) > +#define EXPAND2(macro, name, Origin, argc1, args1, argc2, args2) macro(name, Origin, ARGS##argc1 args1, ARGNAMES##argc1, ARGS##argc2 args2, ARGNAMES##argc2) > + > +#define INSPECTOR_INSTRUMENTATION_METHODS(macro, pairedMacro) \ > + EXPAND(macro, willInsertDOMNode, Document*, 2, (Node*, Node*)) \ > + EXPAND(macro, didInsertDOMNode, Document*, 1, (Node*)) \ > + EXPAND(macro, willRemoveDOMNode, Document*, 1, (Node*)) \ > + EXPAND(macro, didRemoveDOMNode, Document*, 1, (Node*)) \ > + EXPAND(macro, willModifyDOMAttr, Document*, 1, (Element*)) \ > + EXPAND(macro, didModifyDOMAttr, Document*, 1, (Element*)) \ > + EXPAND(macro, characterDataModified, Document*, 1, (CharacterData*)) \ > + EXPAND(macro, willSendXMLHttpRequest, ScriptExecutionContext*, 1, (const String&)) \ > + EXPAND(macro, didScheduleResourceRequest, Document*, 1, (const String&)) \ > + EXPAND(macro, didInstallTimer, ScriptExecutionContext*, 3, (int, int, bool)) \ > + EXPAND(macro, didRemoveTimer, ScriptExecutionContext*, 1, (int)) \ > + EXPAND(macro, didCreateWebSocket, ScriptExecutionContext*, 3, (unsigned long, const KURL&, const KURL&)) \ > + EXPAND(macro, willSendWebSocketHandshakeRequest, ScriptExecutionContext*, 2, (unsigned long, const WebSocketHandshakeRequest&)) \ > + EXPAND(macro, didReceiveWebSocketHandshakeResponse, ScriptExecutionContext*, 2, (unsigned long, const WebSocketHandshakeResponse&)) \ > + EXPAND(macro, didCloseWebSocket, ScriptExecutionContext*, 1, (unsigned long)) \ > + EXPAND1(pairedMacro, CallFunction, Frame*, 2, (const String&, int)) \ > + EXPAND1(pairedMacro, ChangeXHRReadyState, ScriptExecutionContext*, 1, (XMLHttpRequest*)) \ > + EXPAND1(pairedMacro, DispatchEvent, Document*, 4, (const Event&, DOMWindow*, Node*, const Vector<RefPtr<ContainerNode> >&)) \ > + EXPAND1(pairedMacro, DispatchEventOnWindow, Frame*, 2, (const Event&, DOMWindow*)) \ > + EXPAND1(pairedMacro, EvaluateScript, Frame*, 2, (const String&, int)) \ > + EXPAND1(pairedMacro, FireTimer, ScriptExecutionContext*, 1, (int)) \ > + EXPAND1(pairedMacro, Layout, Frame*, 0, ()) \ > + EXPAND1(pairedMacro, LoadXHR, ScriptExecutionContext*, 1, (XMLHttpRequest*)) \ > + EXPAND1(pairedMacro, Paint, Frame*, 1, (const IntRect&)) \ > + EXPAND1(pairedMacro, RecalculateStyle, Document*, 0, ()) \ > + EXPAND1(pairedMacro, ReceiveResourceData, Frame*, 1, (unsigned long)) \ > + EXPAND1(pairedMacro, ReceiveResourceResponse, Frame*, 2, (unsigned long, const ResourceResponse&)) \ > + EXPAND2(pairedMacro, WriteHTML, Document*, 2, (unsigned int, unsigned int), 1, (unsigned int)) \ > +// end of INSPECTOR_INSTRUMENTATION_METHODS
This seems like a bad change. It makes it harder to see what inspector methods exist and what the method signatures are, and it's very hard to follow in general. It also makes for more difficult debugging. For nontrivial code generation we prefer to write code-generator scripts to excess use of macros. r- because this is a refactoring change but seems to make readability worse instead of better.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug