if (!this.trustedUpdatePolicy) {Gustavo MartinCan you make sure to return an empty TrustedHTML object in case that `chrome.readingMode.isReadabilityEnabled` is false?
Done
return window.trustedTypes!.emptyHTML;Gustavo MartinCan you change this to
```suggestion
return window.trustedTypes ? window.trustedTypes.emptyHTML : '';
```
since `window.trustedTypes` could be `undefined.`
I don't think we can do that since this funcion needs to return TrustedHTML.
And for us to be able to return that, window.trustedTypes needs to exist
lmk your thoughts
source->OverrideContentSecurityPolicy(Gustavo MartinCan you try to delete all the `polymer` references? They are not needed as we are only using `lit`.
If I remove them I get these runtime errors:
https://paste.googleplex.com/5999382308716544
Will leave them as discussed offline.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
const wordCount = (this.$.container.textContent) ?
getWordCount(this.$.container.textContent) :Does this need to change in this CL?
// Readability Path: Build DOM from the HTML string.
const title = chrome.readingMode.htmlTitle;
const contentHtml = chrome.readingMode.htmlContent;
// TODO: crbug.com/459156155 - Default to screen2X distillation if no
// distilled content from Readability.
if (!contentHtml) {
this.setEmpty();
return null;
}
const contentFragment = document.createDocumentFragment();
if (title) {
const titleElement = document.createElement('h1');
titleElement.textContent = title;
contentFragment.appendChild(titleElement);
}
const contentContainer = document.createElement('div');
contentContainer.innerHTML = this.getTrustedHtml(contentHtml);
contentFragment.appendChild(contentContainer);
this.setState(ContentType.HAS_CONTENT);
this.initializeReadAloud(contentFragment);
return contentFragment;Lets move this into another helper e.g. updateContentForReadability or similar
initializeReadAloud(rootNode: Node): void {nit: lets call this something more like updateReadAloudState
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
return window.trustedTypes!.emptyHTML;Gustavo MartinCan you change this to
```suggestion
return window.trustedTypes ? window.trustedTypes.emptyHTML : '';
```
since `window.trustedTypes` could be `undefined.`
I don't think we can do that since this funcion needs to return TrustedHTML.
And for us to be able to return that, window.trustedTypes needs to exist
lmk your thoughts
Done
const wordCount = (this.$.container.textContent) ?
getWordCount(this.$.container.textContent) :Does this need to change in this CL?
It doesn't, I added it in this CL to avoid having to modify app.ts in a future CL.
I have flag guarded this change in case it causes issues.
// Readability Path: Build DOM from the HTML string.
const title = chrome.readingMode.htmlTitle;
const contentHtml = chrome.readingMode.htmlContent;
// TODO: crbug.com/459156155 - Default to screen2X distillation if no
// distilled content from Readability.
if (!contentHtml) {
this.setEmpty();
return null;
}
const contentFragment = document.createDocumentFragment();
if (title) {
const titleElement = document.createElement('h1');
titleElement.textContent = title;
contentFragment.appendChild(titleElement);
}
const contentContainer = document.createElement('div');
contentContainer.innerHTML = this.getTrustedHtml(contentHtml);
contentFragment.appendChild(contentContainer);
this.setState(ContentType.HAS_CONTENT);
this.initializeReadAloud(contentFragment);
return contentFragment;Lets move this into another helper e.g. updateContentForReadability or similar
Done
nit: lets call this something more like updateReadAloudState
Done
return window.trustedTypes!.emptyHTML;Gustavo MartinCan you change this to
```suggestion
return window.trustedTypes ? window.trustedTypes.emptyHTML : '';
```
since `window.trustedTypes` could be `undefined.`
I don't think we can do that since this funcion needs to return TrustedHTML.
And for us to be able to return that, window.trustedTypes needs to exist
lmk your thoughts
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
if (!this.willDrawAgainSoon_) {
const wordCount = chrome.readingMode.isReadabilityEnabled ?
(this.$.container.textContent ?
getWordCount(this.$.container.textContent) :
0) :
(newRoot && newRoot.textContent ? getWordCount(newRoot.textContent) :
0);Can you pull out the container to a separate variable? I think that might make this a bit more readable. (I'm sure the formatting of this suggestion is off)
```suggestion
const wordCountContainer = chrome.readingMode.isReadabilityEnabled ? this.$.container : newRoot;
if (!this.willDrawAgainSoon_) {
const wordCount =
(wordCountContainer && wordCountContainer.textContent ? getWordCount(wordCountContainer.textContent) :
0);
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (!this.willDrawAgainSoon_) {
const wordCount = chrome.readingMode.isReadabilityEnabled ?
(this.$.container.textContent ?
getWordCount(this.$.container.textContent) :
0) :
(newRoot && newRoot.textContent ? getWordCount(newRoot.textContent) :
0);Can you pull out the container to a separate variable? I think that might make this a bit more readable. (I'm sure the formatting of this suggestion is off)
```suggestion
const wordCountContainer = chrome.readingMode.isReadabilityEnabled ? this.$.container : newRoot;
if (!this.willDrawAgainSoon_) {
const wordCount =
(wordCountContainer && wordCountContainer.textContent ? getWordCount(wordCountContainer.textContent) :
0);
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (chrome.readingMode.isReadabilityEnabled) {Let's also add a check for Chrome.readingMode.htmlContent being empty here for this CL. We can refine that in the next CL once Readability is connected- but that way, we won't break anything with Screen2x in-between submissions.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Let's also add a check for Chrome.readingMode.htmlContent being empty here for this CL. We can refine that in the next CL once Readability is connected- but that way, we won't break anything with Screen2x in-between submissions.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// return window.trustedTypes ? window.trustedTypes.emptyHTML : '';Remove this comment.
console.warn(e);Apparently other instances in the codebase that create a trusted policy don't use a try/catch block.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// return window.trustedTypes ? window.trustedTypes.emptyHTML : '';Gustavo MartinRemove this comment.
Done
Apparently other instances in the codebase that create a trusted policy don't use a try/catch block.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Modify updateContent to support showing DOM Distiller content.
When isReadabilityEnabled is active, updateContent method now shows in
RM WebUI content from htmlTitle and htmlContent. These variables are
currently empty but in a future CL (crrev.com/c/7282479) they will hold
distilled content from DOM distiller.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |