-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support checking height in checkBoldBroken #582
Conversation
@tmyt what font are you seeing the issue on? |
@Tyriar my browser choose 'courier' from demo app default stylesheet. |
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.
Instead of this approach I think we should roll this into checkBoldBroken
in Renderer.ts. This function checks whether an element's width is the same with and without bold, if not it will disable bold in the terminal. Fundamentally this is an issue with the font and it shouldn't be used.
I also think we should add a console.error
when bold is broken to make it clear in the console why bold doesn't work.
This reverts commit 43cb4f4.
Thanks to your review, I agree with that. First, needs to fix |
scrollWidth does not work on Chrome with `display: inline` element.
function checkBoldBroken(document) { | ||
const body = document.getElementsByTagName('body')[0]; | ||
function checkBoldBroken(terminal) { | ||
const document = terminal.ownerDocument; |
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.
Based on this https://github.com/sourcelair/xterm.js/blob/ec91a6c7f4b8032e3483a8730e6ed66a672415d0/src/xterm.js#L589
Shouldn't terminal.document
be the same as terminal.ownerDocument
since terminal.parent should be owned by the same document?
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.
This is bad naming terminal
. The terminal
passed with terminal.element
. So I should change naming terminal
to terminalElement
.
terminal.element
is created by terminal.parent.ownerDocument.createElement
.
As a result terminal.document
same as terminalElement.ownerDocument
.
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.
If terminal.document is the same as terminalElement.ownerDocument why not leave it as it was? (<any>this._terminal).document
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.
I needed (this._terminal).element for apply monospace font.
I think, document could get from element, then I want to simplify function arguments.
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.
Ah makes sense, you add it to terminal instead of body which is much nicer.
body.appendChild(el); | ||
const w1 = el.scrollWidth; | ||
terminal.appendChild(el); | ||
const w1 = el.offsetWidth; |
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.
I believe we want scrollWidth
/scrollHeight
here as offset*
may not give the correct results if the element is off screen? https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements
Did doing this fix the issue for you?
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.
I seems to fix the issue on my environment (Chrome 59 & Firefox 54).
This changes for scroll*
does not work for display: inline
element (e.g. span
) on Chrome. Then I change scroll*
to offset*
.
Should I change offset*
to scroll*
and use div
instead of span
?
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.
Main just concerned about if this would break when the terminal is either detached from the DOM or is invisible (display:none
, visibility:hidden
).
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.
Both properties could not get the correct size from detached or invisible element. Anyway, currently or my PR both needs on visible DOM tree. Do you have you any great ideas?
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.
Thanks for checking if there's no regression this is all good 👍
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.
function checkBoldBroken(document) { | ||
const body = document.getElementsByTagName('body')[0]; | ||
function checkBoldBroken(terminal) { | ||
const document = terminal.ownerDocument; |
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.
Ah makes sense, you add it to terminal instead of body which is much nicer.
body.appendChild(el); | ||
const w1 = el.scrollWidth; | ||
terminal.appendChild(el); | ||
const w1 = el.offsetWidth; |
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.
Thanks for checking if there's no regression this is all good 👍
This PR resolve #581
After apply this patch, resolve issue and gets these results.
And each row DOM elements has styles.
Please consider to fix.