Skip to content

Commit

Permalink
WebUI Polymer 2 migration: Remove cr-lazy-render type extension.
Browse files Browse the repository at this point in the history
This CL upgrades cr-lazy-render for compatibility with Polymer 2. It
does this by using a slot for a <template> from the light DOM which
gets templatized since the cr-lazy-render element itself can no longer
be a <template>.

This means that all clients need to wrap their light DOM in <template>
tags.

Bug: 818279
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ieaed7cb2f9422557aed0c3a388939b17b5825245
Reviewed-on: https://chromium-review.googlesource.com/977203
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546012}
  • Loading branch information
nik3daz authored and Commit Bot committed Mar 27, 2018
1 parent 6827251 commit 44cb654
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 221 deletions.
81 changes: 43 additions & 38 deletions chrome/browser/resources/md_bookmarks/command_manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,49 @@
display: none;
}
</style>
<template is="cr-lazy-render" id="dropdown">
<cr-action-menu on-mousedown="onMenuMousedown_">
<template is="dom-repeat" items="[[menuCommands_]]" as="command">
<button slot="item" class="dropdown-item"
command$="[[command]]"
hidden$="[[!isCommandVisible_(command, menuIds_)]]"
disabled$="[[!isCommandEnabled_(command, menuIds_)]]"
on-click="onCommandClick_">
<span class="label">
[[getCommandLabel_(command, menuIds_)]]
</span>
<span class="sublabel">
[[getCommandSublabel_(command, menuIds_)]]
</span>
</button>
<hr hidden$="[[!showDividerAfter_(command, menuIds_)]]"
aria-hidden="true">
</hr>
</template>
</cr-action-menu>
</template>
<template is="cr-lazy-render" id="editDialog">
<bookmarks-edit-dialog></bookmarks-edit-dialog>
</template>
<template is="cr-lazy-render" id="openDialog">
<dialog is="cr-dialog">
<div slot="title">$i18n{openDialogTitle}</div>
<div slot="body"></div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onOpenCancelTap_">
$i18n{cancel}
</paper-button>
<paper-button class="action-button" on-click="onOpenConfirmTap_">
$i18n{openDialogConfirm}
</paper-button>
</div>
</dialog>
</template>
<cr-lazy-render id="dropdown">
<template>
<cr-action-menu on-mousedown="onMenuMousedown_">
<template is="dom-repeat" items="[[menuCommands_]]" as="command">
<button slot="item" class="dropdown-item"
command$="[[command]]"
hidden$="[[!isCommandVisible_(command, menuIds_)]]"
disabled$="[[!isCommandEnabled_(command, menuIds_)]]"
on-click="onCommandClick_">
<span class="label">
[[getCommandLabel_(command, menuIds_)]]
</span>
<span class="sublabel">
[[getCommandSublabel_(command, menuIds_)]]
</span>
</button>
<hr hidden$="[[!showDividerAfter_(command, menuIds_)]]"
aria-hidden="true">
</template>
</cr-action-menu>
</template>
</cr-lazy-render>
<cr-lazy-render id="editDialog">
<template>
<bookmarks-edit-dialog></bookmarks-edit-dialog>
</template>
</cr-lazy-render>
<cr-lazy-render id="openDialog">
<template>
<dialog is="cr-dialog">
<div slot="title">$i18n{openDialogTitle}</div>
<div slot="body"></div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onOpenCancelTap_">
$i18n{cancel}
</paper-button>
<paper-button class="action-button" on-click="onOpenConfirmTap_">
$i18n{openDialogConfirm}
</paper-button>
</div>
</dialog>
</template>
</cr-lazy-render>
</template>
<script src="chrome://bookmarks/command_manager.js"></script>
</dom-module>
40 changes: 23 additions & 17 deletions chrome/browser/resources/md_extensions/manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,29 @@
apps="[[apps_]]" extensions="[[extensions_]]"
on-show-install-warnings="onShowInstallWarnings_">
</extensions-item-list>
<template id="details-view" is="cr-lazy-render">
<extensions-detail-view delegate="[[delegate]]" slot="view"
in-dev-mode="[[inDevMode]]"
incognito-available="[[incognitoAvailable_]]"
data="[[detailViewItem_]]">
</extensions-detail-view>
</template>
<template id="keyboard-shortcuts" is="cr-lazy-render">
<extensions-keyboard-shortcuts delegate="[[delegate]]" slot="view"
items="[[extensions_]]">
</extensions-keyboard-shortcuts>
</template>
<template id="error-page" is="cr-lazy-render">
<extensions-error-page data="[[errorPageItem_]]" slot="view"
delegate="[[delegate]]" slot="view">
</extensions-error-page>
</template>
<cr-lazy-render id="details-view">
<template>
<extensions-detail-view delegate="[[delegate]]" slot="view"
in-dev-mode="[[inDevMode]]"
incognito-available="[[incognitoAvailable_]]"
data="[[detailViewItem_]]">
</extensions-detail-view>
</template>
</cr-lazy-render>
<cr-lazy-render id="keyboard-shortcuts">
<template>
<extensions-keyboard-shortcuts delegate="[[delegate]]" slot="view"
items="[[extensions_]]">
</extensions-keyboard-shortcuts>
</template>
</cr-lazy-render>
<cr-lazy-render id="error-page">
<template>
<extensions-error-page data="[[errorPageItem_]]" slot="view"
delegate="[[delegate]]" slot="view">
</extensions-error-page>
</template>
</cr-lazy-render>
</extensions-view-manager>
<template is="dom-if" if="[[showOptionsDialog_]]" restamp>
<extensions-options-dialog id="options-dialog"
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/resources/md_extensions/view_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ cr.define('extensions', function() {
const animationFunction = extensions.viewAnimations.get(animation);
assert(animationFunction);

let effectiveView =
view.matches('[is=cr-lazy-render]') ? view.get() : view;
let effectiveView = view.matches('cr-lazy-render') ? view.get() : view;

effectiveView.classList.add('active');
effectiveView.dispatchEvent(new CustomEvent('view-enter-start'));
Expand Down
20 changes: 11 additions & 9 deletions chrome/browser/resources/md_history/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@
</iron-pages>
</div>

<template is="cr-lazy-render" id="drawer">
<cr-drawer heading="$i18n{title}" align="$i18n{textdirection}"
swipe-open>
<history-side-bar id="drawer-side-bar" class="drawer-content"
selected-page="{{selectedPage_}}"
show-footer="[[showSidebarFooter]]">
</history-side-bar>
</cr-drawer>
</template>
<cr-lazy-render id="drawer">
<template>
<cr-drawer heading="$i18n{title}" align="$i18n{textdirection}"
swipe-open>
<history-side-bar id="drawer-side-bar" class="drawer-content"
selected-page="{{selectedPage_}}"
show-footer="[[showSidebarFooter]]">
</history-side-bar>
</cr-drawer>
</template>
</cr-lazy-render>

<iron-media-query query="(max-width: 1023px)"
query-matches="{{hasDrawer_}}">
Expand Down
62 changes: 33 additions & 29 deletions chrome/browser/resources/md_history/history_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,40 @@
lower-threshold="500" on-lower-threshold="onScrollToBottom_">
</iron-scroll-threshold>

<template is="cr-lazy-render" id="dialog">
<dialog is="cr-dialog">
<div slot="title">$i18n{removeSelected}</div>
<div slot="body">$i18n{deleteWarning}</div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onDialogCancelTap_">
$i18n{cancel}
</paper-button>
<paper-button class="action-button" on-click="onDialogConfirmTap_">
$i18n{deleteConfirm}
</paper-button>
</div>
</dialog>
</template>
<cr-lazy-render id="dialog">
<template>
<dialog is="cr-dialog">
<div slot="title">$i18n{removeSelected}</div>
<div slot="body">$i18n{deleteWarning}</div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onDialogCancelTap_">
$i18n{cancel}
</paper-button>
<paper-button class="action-button" on-click="onDialogConfirmTap_">
$i18n{deleteConfirm}
</paper-button>
</div>
</dialog>
</template>
</cr-lazy-render>

<template is="cr-lazy-render" id="sharedMenu">
<cr-action-menu>
<button id="menuMoreButton" slot="item" class="dropdown-item"
hidden="[[!canSearchMoreFromSite_(
searchedTerm, actionMenuModel_.item.domain)]]"
on-click="onMoreFromSiteTap_">
$i18n{moreFromSite}
</button>
<button id="menuRemoveButton" slot="item" class="dropdown-item"
hidden="[[!canDeleteHistory_]]"
on-click="onRemoveFromHistoryTap_">
$i18n{removeFromHistory}
</button>
</cr-action-menu>
</template>
<cr-lazy-render id="sharedMenu">
<template>
<cr-action-menu>
<button id="menuMoreButton" slot="item" class="dropdown-item"
hidden="[[!canSearchMoreFromSite_(
searchedTerm, actionMenuModel_.item.domain)]]"
on-click="onMoreFromSiteTap_">
$i18n{moreFromSite}
</button>
<button id="menuRemoveButton" slot="item" class="dropdown-item"
hidden="[[!canDeleteHistory_]]"
on-click="onRemoveFromHistoryTap_">
$i18n{removeFromHistory}
</button>
</cr-action-menu>
</template>
</cr-lazy-render>
</template>
<script src="chrome://history/history_list.js"></script>
</dom-module>
26 changes: 14 additions & 12 deletions chrome/browser/resources/md_history/synced_device_manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@
</paper-button>
</div>

<template is="cr-lazy-render" id="menu">
<cr-action-menu>
<button id="menuOpenButton" slot="item" class="dropdown-item"
on-click="onOpenAllTap_">
$i18n{openAll}
</button>
<button id="menuDeleteButton" slot="item" class="dropdown-item"
on-click="onDeleteSessionTap_">
$i18n{deleteSession}
</button>
</cr-action-menu>
</template>
<cr-lazy-render id="menu">
<template>
<cr-action-menu>
<button id="menuOpenButton" slot="item" class="dropdown-item"
on-click="onOpenAllTap_">
$i18n{openAll}
</button>
<button id="menuDeleteButton" slot="item" class="dropdown-item"
on-click="onDeleteSessionTap_">
$i18n{deleteSession}
</button>
</cr-action-menu>
</template>
</cr-lazy-render>
</template>
<script src="chrome://history/synced_device_manager.js"></script>
</dom-module>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
</button>
</div>
</print-preview-settings-section>
<template is="cr-lazy-render" id="advancedDialog">
<print-preview-advanced-dialog
settings="{{settings}}" destination="[[destination]]">
</print-preview-advanced-dialog>
</template>
<cr-lazy-render id="advancedDialog">
<template>
<print-preview-advanced-dialog
settings="{{settings}}" destination="[[destination]]">
</print-preview-advanced-dialog>
</template>
</cr-lazy-render>
</template>
<script src="advanced_options_settings.js"></script>
</dom-module>
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@
</button>
</div>
</print-preview-settings-section>
<template is="cr-lazy-render" id="destinationDialog">
<print-preview-destination-dialog
destination-store="[[destinationStore]]"
recent-destinations="[[recentDestinations]]"
user-info="{{userInfo}}"
show-cloud-print-promo="{{showCloudPrintPromo_}}">
</print-preview-destination-dialog>
</template>
<cr-lazy-render id="destinationDialog">
<template>
<print-preview-destination-dialog
destination-store="[[destinationStore]]"
recent-destinations="[[recentDestinations]]"
user-info="{{userInfo}}"
show-cloud-print-promo="{{showCloudPrintPromo_}}">
</print-preview-destination-dialog>
</template>
</cr-lazy-render>
</template>
<script src="destination_settings.js"></script>
</dom-module>
Loading

0 comments on commit 44cb654

Please sign in to comment.