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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CKEditor 4 Changelog

## CKEditor 4.17.3 [IN DEVELOPMENT]

Fixed issues:

* [#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).

Other changes:

* [#5087](/~https://github.com/ckeditor/ckeditor4/issues/5087): Deprecated jQuery API calls in jQuery adapter were replaced by undeprecated ones. Thanks to [Fran Boon](/~https://github.com/flavour)!
Expand Down
7 changes: 5 additions & 2 deletions core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,8 @@
* @returns {Number/String} A number representing the length in pixels or a string with a percentage value.
*/
convertToPx: ( function() {
var calculator;
var calculator,
boundingClientRect;

return function( cssLength ) {
if ( !calculator ) {
Expand All @@ -990,7 +991,9 @@
}

calculator.setStyle( 'width', cssLength );
ret = calculator.$.clientWidth;
boundingClientRect = calculator.getClientRect();

ret = Math.round( boundingClientRect.width );

if ( isNegative ) {
return -ret;
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/plugins/pastefromword/manual/tableborders.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div id="editor"></div>

<script>
if ( !CKEDITOR.env.chrome ) {
bender.ignore();
}

CKEDITOR.replace( 'editor' );
</script>
12 changes: 12 additions & 0 deletions tests/plugins/pastefromword/manual/tableborders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@bender-tags: bug, 5097
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, pastefromword, sourcearea, elementspath, table

1. Paste a table from the [linked MS Word document](_assets/table_border.docx).
2. Open source area to verify table borders style.

## Expected
Table borders have 1px width.

## Unexpected
Table borders have 2px width.