Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/148: getOptimalPosition utility should consider limiter ancestors with CSS overflow. Closes #148. #149

Merged
merged 6 commits into from
Apr 19, 2017

Conversation

oleq
Copy link
Member

@oleq oleq commented Apr 18, 2017

Suggested merge commit message (convention)

Fix: The getOptimalPosition utility should consider limiter ancestors with CSS overflow. Closes ckeditor/ckeditor5#4948.

@oleq oleq requested a review from oskarwrobel April 18, 2017 13:27
src/dom/rect.js Outdated

// Check the ancestors all the way up to the <body>.
while ( parent && parent != global.document.body ) {
const parentOverflow = global.window.getComputedStyle( parent ).overflow;
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if checking each parent as below (const intersectionRect = visibleRect.getIntersection( parentRect );) wouldn't be actually faster than using this window.getComputedStyle. Will benchmark.

Copy link
Member Author

Choose a reason for hiding this comment

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

...and I was right. window.getComputedStyle is slow. Twice the performance after 24e1d14.

@oleq oleq changed the title T/148: Fix: The getOptimalPosition utility should consider limiter ancestors with CSS overflow. Closes #148. T/148: getOptimalPosition utility should consider limiter ancestors with CSS overflow. Closes #148. Apr 18, 2017
src/dom/rect.js Outdated
* @readonly
* @member {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} #_obj
*/
Object.defineProperty( this, '_obj', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why defineProperty ?
Maybe _context instead of _obj?

Copy link
Member Author

Choose a reason for hiding this comment

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

defineProperty to set enumerable false. Without it iterating over the Rect would also return _obj and make some pieces of code more complex.

As for _obj, maybe not _context because it makes people think about this and stuff but _from?


// https://github.com/ckeditor/ckeditor5-utils/issues/148
it( 'should return coordinates (#3)', () => {
const overflowedAncestor = getElement( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Webstorm says Local variable 'overflowedAncestor' is redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is odd. It's used.

Copy link
Contributor

Choose a reason for hiding this comment

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

This warning is about

const overflowedAncestor = getelement();

limiter.parentNode = overflowedAncestor;

vs

limiter.parentNode = getelement();

but it's a detail.

width: 10,
height: 10
}, {
overflow: 'scroll'
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like overflow: scroll is no longer needed by this test but OTOH it better explains this test case.

@oskarwrobel
Copy link
Contributor

I left few comments but works 👌

@oskarwrobel oskarwrobel merged commit 6bf1741 into master Apr 19, 2017
@oskarwrobel oskarwrobel deleted the t/148 branch April 19, 2017 09:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getOptimalPosition utility should consider limiter ancestors with overflow
2 participants