-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move owners implementation from resources to owners #23668
Conversation
549c466
to
1bcb889
Compare
src/service/owners-impl.js
Outdated
import {isArray} from '../types'; | ||
import {registerServiceBuilderForDoc} from '../service'; | ||
|
||
const TAG_ = 'Owners'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: TAG
I know we use them interchangeably, but TAG without underscore is dominant.
src/service/owners-impl.js
Outdated
* @param {!Element|!Array<!Element>} elements | ||
* @return {!Array<!Element>} | ||
*/ | ||
function elements_(elements) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, no underscore
src/service/owners-impl.js
Outdated
schedulePreload(parentElement, subElements) {} | ||
schedulePreload(parentElement, subElements) { | ||
this.scheduleLayoutOrPreloadForSubresources_( | ||
Resource.forElement(parentElement), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reduce unnecessary dependency, use this.resources_.getResourcexxx to access this.
1bcb889
to
e3f9de7
Compare
7db76a1
to
1a01b76
Compare
src/service/resources-impl.js
Outdated
/** | ||
* @param {!Resource} resource | ||
* @param {boolean} layout | ||
* @param {number} parentPriority |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this param optional.
also, try to refactor the param to priorityOverride
, which is a more generic and meaningful param for a public method.
src/service/resources-impl.js
Outdated
@@ -262,6 +260,13 @@ export class ResourcesDef extends MutatorsAndOwnersDef { | |||
*/ | |||
removeForChildWindow(childWin) {} | |||
|
|||
/** | |||
* @param {!Resource} resource | |||
* @param {boolean} layout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: layout
=> layoutNeeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, i think layoutNeeded
is mis-leading. This boolean only controls the priority of the task.
we should refactor this boolean to isPreload
(which is negate of the current boolean layout
)
src/service/resources-impl.js
Outdated
* @param {boolean} layout | ||
* @param {number} parentPriority | ||
*/ | ||
measureAndTrySchedule(resource, layout, parentPriority) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I meant measureAndTryScheduleLayout
1a01b76
to
d0e4a28
Compare
6788a7b
to
69d93e3
Compare
* @interface | ||
*/ | ||
export class Owners { | ||
export class OwnersDef { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to unify all the service interface names to XXXInterface
, and move it out to its own file owners-interface.js
/** | ||
* @implements {OwnersDef} | ||
*/ | ||
export class Owners { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@visibleForTesting
Owners
=> OwnersImpl
import {Signals} from '../../src/utils/signals'; | ||
import {layoutRectLtwh} from '../../src/layout-rect'; | ||
|
||
/*eslint "google-camelcase/google-camelcase": 0*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment what is this for
resource.getState() === ResourceState.READY_FOR_LAYOUT && | ||
resource.isDisplayed() | ||
) { | ||
this.scheduleLayoutOrPreload_(resource, !isPreload, opt_parentPriority); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you checked every call site to ensure that isPreload
is the opposite of what it was? Why are we flipping it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Affirm that. The only reason is that we are making this an interface, and it needs to be a bit more readable.
@powerivq any blockers to this PR? |
378b86d
to
748e3b8
Compare
748e3b8
to
25fb7ff
Compare
@jridgewell Looked into the binary. The primary cause of increase is because we made two new public interfaces, and therefore their method names are no longer obfuscated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trusting that the methods are copy-pasted with only the preload
change.
* Move owners implementation from resources to owners * Refactor discoverElements * Fix tests
TODO: Move unit tests.