Commit ba46b5b3 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[directory tree] Make FakeItem derive from TreeItem

TreeItem handles the item content creation, label, tree parent_ etc so
remove local FakeItem code related to that.

Bug: 992819
Change-Id: Ice70bf57e9e739a4dc806c5e3973f893be5e7bd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868212Reviewed-by: default avatarAustin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707299}
parent 2c68f41e
......@@ -1709,40 +1709,32 @@ class AndroidAppItem extends TreeItem {
/**
* FakeItem is used by Recent and Linux files.
*/
class FakeItem extends cr.ui.TreeItem {
class FakeItem extends TreeItem {
/**
* @param {!VolumeManagerCommon.RootType} rootType root type.
* @param {!NavigationModelFakeItem} modelItem
* @param {!DirectoryTree} tree Current tree, which contains this item.
*/
constructor(rootType, modelItem, tree) {
super();
// Get the original label id defined by TreeItem, before overwriting
// prototype.
const labelId = this.labelElement.id;
super(modelItem.label, tree);
this.__proto__ = FakeItem.prototype;
if (window.IN_TEST) {
this.setAttribute('dir-type', 'FakeItem');
this.setAttribute('entry-label', modelItem.label);
}
this.rootType_ = rootType;
this.parentTree_ = tree;
this.modelItem_ = modelItem;
this.dirEntry_ = modelItem.entry;
this.innerHTML = TREE_ITEM_INNER_HTML;
this.labelElement.id = labelId;
this.label = modelItem.label;
this.directoryModel_ = tree.directoryModel;
this.dirEntry_ = modelItem.entry;
this.modelItem_ = modelItem;
this.rootType_ = rootType;
const icon = this.querySelector('.icon');
icon.classList.add('item-icon');
icon.setAttribute('root-type-icon', rootType);
if (tree.disabledContextMenu) {
cr.ui.contextMenuHandler.setContextMenu(this, tree.disabledContextMenu);
}
const icon = queryRequiredElement('.icon', this);
icon.classList.add('item-icon');
icon.setAttribute('root-type-icon', rootType);
}
/**
......@@ -1788,19 +1780,23 @@ class FakeItem extends cr.ui.TreeItem {
}
/**
* FakeItem doesn't really have shared status/icon so we define here as no-op.
* FakeItem's do not have shared status/icon.
*/
updateDriveSpecificIcons() {}
/**
* The DirectoryEntry corresponding to this DirectoryItem.
*/
get entry() {
return this.dirEntry_;
}
/**
* @type {!NavigationModelVolumeItem}
*/
get modelItem() {
return this.modelItem_;
}
get labelElement() {
return this.firstElementChild.querySelector('.label');
}
}
////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment