Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Removes non-primitive types from UrlBar #9757

Merged
merged 1 commit into from
Jul 5, 2017

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Jun 28, 2017

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #9756

Auditors: @bridiver @bbondy

Test Plan:

  • general test of url bar
  • focus on suggestions

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@NejcZdovc NejcZdovc added this to the 0.19.x (Nightly Channel) milestone Jun 28, 2017
@NejcZdovc NejcZdovc self-assigned this Jun 28, 2017
@NejcZdovc NejcZdovc force-pushed the refactor/#9756-urlbar branch 2 times, most recently from d5beac9 to 486c202 Compare June 30, 2017 11:35
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments left; otherwise, looks great 😄

}
])

it('suggestion list is empty', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

(this.props.urlbarLocationSuffix && this.props.autocompleteEnabled))) {
// Hack to make alt enter open a new tab for url bar suggestions when hitting enter on them.
const isDarwin = process.platform === 'darwin'
if (e.altKey) {
if (isDarwin) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the isDarwin that is inside platformUtil is a little different than the one which was removed; it's actually a function that needs to be called (as opposed to the one that was removed above (which only checks process.platform). This is because platformUtil is safe to use in the renderer (which doesn't have access to node (ex: process.platform). Instead, it checks navigator.platform

Copy link
Contributor Author

@NejcZdovc NejcZdovc Jul 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDarwin = () => {
  return process.platform === 'darwin' ||
    navigator.platform === 'MacIntel'
}

it first checks process.platform === 'darwin' same as we did in the removed code. Isn't then this the same or can navigator.platform === 'MacIntel' lead into wrong determination of the OS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NejcZdovc the check in platformUtil has been tested well in both the browser and renderer process. Typically, if you're in the renderer, process.platform will return undefined- hence the need to also check navigator.platform (which IS set in the renderer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this utility method is encouraged over duplicating the code (especially since it has tests 😄 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -125,11 +118,10 @@ class UrlBar extends React.Component {
const isLocationUrl = isUrl(location)
if (!isLocationUrl && e.ctrlKey) {
appActions.loadURLRequested(this.props.activeTabId, `www.${location}.com`)
} else if (this.shouldRenderUrlBarSuggestions &&
((typeof this.activeIndex === 'number' && this.activeIndex >= 0) ||
} else if (this.props.showrUrlBarSuggestions &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misspelling here; s/showrUrlBarSuggestions/showUrlBarSuggestions/g

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -144,7 +139,8 @@ class NavigationBar extends React.Component {
props.showHomeButton = !props.titleMode && getSetting(settings.SHOW_HOME_BUTTON)

// used in other functions
props.navbar = navbar // TODO(nejc) remove, primitives only
props.isFocused = navbar.getIn(['urlbar', 'focused'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this have a default (in case null, etc)? ex:
props.isFocused = navbar.getIn(['urlbar', 'focused'], false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only use it in if statement, so we don't need it, but I added it anyway 😃

@NejcZdovc NejcZdovc requested a review from bsclifton July 4, 2017 09:14
@NejcZdovc NejcZdovc force-pushed the refactor/#9756-urlbar branch 2 times, most recently from e66733c to 47f4af6 Compare July 4, 2017 20:35
@NejcZdovc
Copy link
Contributor Author

@bsclifton can we merged this one?

@@ -428,6 +398,16 @@ class UrlBar extends React.Component {
contextMenus.onUrlBarContextMenu(e)
}

onStop () {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like duplicating this logic here. Can we create windowActions.onStop and have both methods call that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just move the whole content of this function into another window action?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, that will have the added benefit of calling one windowAction instead of 2. You can refactor WINDOW_SET_URL_BAR_SELECTED and WINDOW_SET_URL_BAR_ACTIVE handlers in urlBarReducer into methods so you can call them from WINDOW_ON_STOP. In a follow-up we can get rid of SHORTCUT_ACTIVE_FRAME_STOP and replace it with a WINDOW_ON_STOP handler in the browser process

Copy link
Collaborator

@bridiver bridiver Jul 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendToFocusedWindow also needs to die eventually :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -83,17 +83,7 @@ class NavigationBar extends React.Component {

onStop () {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_STOP)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put this ipc message in there as well. When we get rid of it, we'll just switch over to the browser process handling WINDOW_ON_STOP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem is that ipc.emit is not working in urlBarReducer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as pre our discussion, I added TODO's, so that we remove this shortcut.

@NejcZdovc NejcZdovc merged commit 0562bf4 into brave:master Jul 5, 2017
@bsclifton
Copy link
Member

++

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants