Bug 105797 - Web Inspector: refactor DefaultTextEditor's private methods
Summary: Web Inspector: refactor DefaultTextEditor's private methods
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andrey Lushnikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-27 04:45 PST by Andrey Lushnikov
Modified: 2012-12-28 01:09 PST (History)
9 users (show)

See Also:


Attachments
Patch (47.31 KB, patch)
2012-12-27 05:07 PST, Andrey Lushnikov
no flags Details | Formatted Diff | Diff
Patch (48.67 KB, patch)
2012-12-27 07:49 PST, Andrey Lushnikov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Lushnikov 2012-12-27 04:45:28 PST
A pre-work is needed for splitting classes from DefaultTextEditor.js into four files: DefaultTextEditor.js (DefaultTextEditor class), TextEditorMainPanel.js (TextEditorMainPanel and TextEditorMainChunk classes), TextEditorGutterPanel.js (TextEditorGutterPanel and TextEditorGutterChunk classes) and TextEditorChunkedPanel.js (TextEditorChunkedPanel class).

Refactor DefaultTextEditor so that different classes do not use each-others private methods and fields if they will reside in different files.
Comment 1 Andrey Lushnikov 2012-12-27 05:07:04 PST
Created attachment 180793 [details]
Patch
Comment 2 Pavel Feldman 2012-12-27 06:24:10 PST
Comment on attachment 180793 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=180793&action=review

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:414
> +        this._mainPanel.handleTextInput(e);

Just add this listener within the main panel.

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:450
>              this._delegate.populateTextAreaContextMenu(contextMenu, target && target.lineNumber);

You should instead pass event.target here (this._mainPanel.handleContextMenu(event);)

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:458
> +        var firstVisibleLineNumber = this._mainPanel.findFirstVisibleLineNumber(visibleFrom);

lineNumberAtOffset(visibleFrom)

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:491
> +        this._mainPanel.setLastSelection(textRange);

I'd rather introduce mainPanel.setSelection that would do this all. _restoreSelection does not need to be public then.

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:590
> +        this.freeCachedElements();

You already have willHide, free cached elements from there.

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:1030
> +    this.element.addEventListener("scroll", this.scroll.bind(this), false);

Just create this.element in TextEditorChunkedPanel, add listener there.

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:1307
> +        return this._textEditor.totalHeight(this._expandedLineRows[0], this._expandedLineRows[this._expandedLineRows.length - 1]);

rename textEditor to chunkedPanel
Comment 3 Andrey Lushnikov 2012-12-27 07:45:34 PST
Comment on attachment 180793 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=180793&action=review

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:414
>> +        this._mainPanel.handleTextInput(e);
> 
> Just add this listener within the main panel.

fixed

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:450
>>              this._delegate.populateTextAreaContextMenu(contextMenu, target && target.lineNumber);
> 
> You should instead pass event.target here (this._mainPanel.handleContextMenu(event);)

fixed

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:458
>> +        var firstVisibleLineNumber = this._mainPanel.findFirstVisibleLineNumber(visibleFrom);
> 
> lineNumberAtOffset(visibleFrom)

fixed

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:491
>> +        this._mainPanel.setLastSelection(textRange);
> 
> I'd rather introduce mainPanel.setSelection that would do this all. _restoreSelection does not need to be public then.

fixed

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:590
>> +        this.freeCachedElements();
> 
> You already have willHide, free cached elements from there.

fixed

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:1030
>> +    this.element.addEventListener("scroll", this.scroll.bind(this), false);
> 
> Just create this.element in TextEditorChunkedPanel, add listener there.

done

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:1307
>> +        return this._textEditor.totalHeight(this._expandedLineRows[0], this._expandedLineRows[this._expandedLineRows.length - 1]);
> 
> rename textEditor to chunkedPanel

renamed
Comment 4 Andrey Lushnikov 2012-12-27 07:49:19 PST
Created attachment 180802 [details]
Patch
Comment 5 Pavel Feldman 2012-12-28 01:05:19 PST
Comment on attachment 180802 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=180802&action=review

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:437
> +            this._mainPanel.contextMenu(event.target, contextMenu);

populateContextMenu

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:462
> +        return this._mainPanel.getSelection();

selection()

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:-484
> -        return this._mainPanel._lastSelection;

lastSelection

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:556
> +        this._boundSelectionChangeListener = this._mainPanel.handleSelectionChange.bind(this._mainPanel);

You should register this listener within mainPanel's wasShown instead.

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:806
> +        throw new Error("createNewChunk() is not implemented");

... should be implemented by descendants
Comment 6 WebKit Review Bot 2012-12-28 01:09:33 PST
Comment on attachment 180802 [details]
Patch

Clearing flags on attachment: 180802

Committed r138527: <http://trac.webkit.org/changeset/138527>
Comment 7 WebKit Review Bot 2012-12-28 01:09:38 PST
All reviewed patches have been landed.  Closing bug.