RESOLVED FIXED Bug 150729
Web Inspector: Convert remaining ContentViews to View base class
https://bugs.webkit.org/show_bug.cgi?id=150729
Summary Web Inspector: Convert remaining ContentViews to View base class
Matt Baker
Reported 2015-10-30 13:05:17 PDT
* SUMMARY Convert remaining ContentViews to View base class.
Attachments
[Patch] Proposed Fix (37.10 KB, patch)
2015-11-04 16:34 PST, Matt Baker
no flags
[Patch] Proposed Fix (28.43 KB, patch)
2015-11-05 14:56 PST, Matt Baker
no flags
Radar WebKit Bug Importer
Comment 1 2015-10-30 13:06:46 PDT
Matt Baker
Comment 2 2015-11-04 16:34:53 PST
Created attachment 264825 [details] [Patch] Proposed Fix
Blaze Burg
Comment 3 2015-11-05 11:45:40 PST
Comment on attachment 264825 [details] [Patch] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=264825&action=review r- because you missed a few addSubview cases. It would have been nice to review the database / apache changes separately, since the rest was mechanical. > Source/WebInspectorUI/UserInterface/Views/DatabaseContentView.js:95 > + this.prompt.updateLayout(); ConsolePrompt should be a subview. > Source/WebInspectorUI/UserInterface/Views/DatabaseContentView.js:98 > + for (let resultElement of results) { What the heck is this old crap... :) we should be adding DataGrid as a subview and remove this whole function.
Matt Baker
Comment 4 2015-11-05 13:11:03 PST
(In reply to comment #3) > Comment on attachment 264825 [details] > [Patch] Proposed Fix > > View in context: > https://bugs.webkit.org/attachment.cgi?id=264825&action=review > > r- because you missed a few addSubview cases. > > It would have been nice to review the database / apache changes separately, > since the rest was mechanical. Noted. I suspected as much during refactoring, and will remove from the follow up. > > Source/WebInspectorUI/UserInterface/Views/DatabaseContentView.js:95 > > + this.prompt.updateLayout(); > > ConsolePrompt should be a subview. The only other view using ConsolePrompt is the QuickConsole, which adds it as a subview. In this case, the prompt element is wrapped in another DOM element, which is why it can't be added directly as a subview. A possible solution is to extend ConsolePrompt, creating DatabaseConsolePrompt. It would be slightly awkward swapping out View.prototype._element with the wrapper element from the derived class, but it would work: class DatabaseConsolePrompt extends ConsolePrompt { constructor(delegate, mimeType) { super(delegate, mimeType); let wrapperElement = document.createElement("div"); wrapperElement.__view = this; wrapperElement.classList.add("database-query-prompt"); wrapperElement.appendChild(this.element); delete this.element.__view; this._element = wrapperElement; } }; We could support wrapper elements directly in the View base class with the following protected method: class View { // Protected insertRootElement(element) { console.assert(!this._element.parentNode); let oldRootElement = this._element; oldRootElement.__view = undefined; element.appendChild(oldRootElement); element.__view = this. this._element = element; } }; Then: class DatabaseConsolePrompt extends ConsolePrompt { constructor(delegate, mimeType) { super(delegate, mimeType); let wrapperElement = document.createElement("div"); wrapperElement.classList.add("database-query-prompt"); this.insertRootElement(wrapperElement); } }; > > Source/WebInspectorUI/UserInterface/Views/DatabaseContentView.js:98 > > + for (let resultElement of results) { > > What the heck is this old crap... :) we should be adding DataGrid as a > subview and remove this whole function. I'll look into it. Not sure how this is used.
Matt Baker
Comment 5 2015-11-05 13:23:59 PST
Actually, wrapping the View's DOM element from a derived class will be problematic. Superclasses between View and the most derived class would be operating on a different DOM element than the one they expect.
Blaze Burg
Comment 6 2015-11-05 13:37:36 PST
(In reply to comment #4) > (In reply to comment #3) > > Comment on attachment 264825 [details] > > [Patch] Proposed Fix > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=264825&action=review > > > > r- because you missed a few addSubview cases. > > > > It would have been nice to review the database / apache changes separately, > > since the rest was mechanical. > > Noted. I suspected as much during refactoring, and will remove from the > follow up. > > > > Source/WebInspectorUI/UserInterface/Views/DatabaseContentView.js:95 > > > + this.prompt.updateLayout(); > > > > ConsolePrompt should be a subview. > > The only other view using ConsolePrompt is the QuickConsole, which adds it > as a subview. In this case, the prompt element is wrapped in another DOM > element, which is why it can't be added directly as a subview. > > A possible solution is to extend ConsolePrompt, creating > DatabaseConsolePrompt. It would be slightly awkward swapping out > View.prototype._element with the wrapper element from the derived class, but > it would work: > > class DatabaseConsolePrompt extends ConsolePrompt > { > constructor(delegate, mimeType) > { > super(delegate, mimeType); > > let wrapperElement = document.createElement("div"); > wrapperElement.__view = this; > wrapperElement.classList.add("database-query-prompt"); > wrapperElement.appendChild(this.element); > > delete this.element.__view; > this._element = wrapperElement; > } > }; > > We could support wrapper elements directly in the View base class with the > following protected method: > Uh, that sounds complicated. Can we just straighten out the Database DOM tree, possibly in a followup patch if it will delay this much longer?
Matt Baker
Comment 7 2015-11-05 14:56:44 PST
Created attachment 264890 [details] [Patch] Proposed Fix
Matt Baker
Comment 8 2015-11-05 15:11:23 PST
DatabaseContentView is being refactored under https://bugs.webkit.org/show_bug.cgi?id=150959.
Blaze Burg
Comment 9 2015-11-05 15:15:51 PST
Comment on attachment 264890 [details] [Patch] Proposed Fix r=me, nice work
WebKit Commit Bot
Comment 10 2015-11-05 16:04:54 PST
Comment on attachment 264890 [details] [Patch] Proposed Fix Clearing flags on attachment: 264890 Committed r192086: <http://trac.webkit.org/changeset/192086>
WebKit Commit Bot
Comment 11 2015-11-05 16:04:58 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.