Skip to content
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

Use element.getBoundingClientRect() to convert units to pixels #5109

Merged
merged 6 commits into from
Mar 2, 2022

Conversation

Comandeer
Copy link
Member

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

Tests are already in the codebase.

Did you follow the CKEditor 4 code style guide?

Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.

  • PR is consistent with the code style guide

What is the proposed changelog entry for this pull request?

* [#5097](https://github.com/ckeditor/ckeditor4/issues/5097): [Chrome] Fixed: Incorrect conversion of points to pixels while using [`CKEDITOR.tools.convertToPx()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-convertToPx).

What changes did you make?

I've switched to using element.getBoundingClientRect() as it returns the current number of pixels. I've also added a fallback to element.clientWidth for IE.

Which issues does your PR resolve?

Closes #5097.

@Comandeer
Copy link
Member Author

I've removed the fallback as we have already CKEDITOR.dom.element#getClientRect() method that does the fallback already.

@jacekbogdanski jacekbogdanski self-requested a review March 2, 2022 13:22
@jacekbogdanski jacekbogdanski self-assigned this Mar 2, 2022
Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I've just added a manual test confirming that borders work properly (sanity check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect pixel calculation on Chrome 98
2 participants