Ticket #2414 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

OpenLayers.Element.getDimensions method should not set style.display property to none

Reported by: bbinet Owned by: ahocevar
Priority: major Milestone: 2.9.1 Release
Component: BaseTypes.Element Version: 2.8
Keywords: Cc:
State: Complete

Description

The bug appears when an OpenLayers.Element has a computed style display value set to none, and when this value comes from a css class and not from its own style attribute.

In this case, a call to OpenLayers.Element.getDimensions leads to setting the own style attribute display to none for the element.

Attachments

patch_2414-r9943.diff Download (0.8 KB) - added by bbinet 3 years ago.
patch_2414-r10113.diff Download (2.3 KB) - added by bbinet 3 years ago.
patch_2414-r10113.2.diff Download (3.7 KB) - added by bbinet 3 years ago.
patch_2414-r10113.3.2.diff Download (3.2 KB) - added by bbinet 3 years ago.
patch_2414-r10113.3.diff Download (3.2 KB) - added by bbinet 3 years ago.
2414.patch Download (0.6 KB) - added by elemoine 3 years ago.
testcase.html Download (2.7 KB) - added by quietriver 3 years ago.
Correct minimal test case, the previous test case was invalid as it did not include a maxExtent. This includes getCurrentSize to show the inclusion of 2414.patch fixing the issue described

Change History

Changed 3 years ago by bbinet

  Changed 3 years ago by bbinet

  • state set to Review

patch_2414-r9943.diff Download fixes the bug.

  Changed 3 years ago by bbinet

  • state changed from Review to Needs More Work

This needs more work since els.display = ; does not enable the element because it does not change the computed style display value (still equals to none).

follow-up: ↓ 5   Changed 3 years ago by ahocevar

  • state changed from Needs More Work to Commit

@bbinet: the patch fixes the reported bug, but it does not help us find the dimensions of the element. If this came up because Map::updateSize failed, then this is fixed already (see #2461).

Please commit.

follow-up: ↓ 6   Changed 3 years ago by tschaub

  • owner changed from euzuro to ahocevar

Bruno is not listed on CLA.

in reply to: ↑ 3   Changed 3 years ago by bbinet

Replying to ahocevar:

@bbinet: the patch fixes the reported bug, but it does not help us find the dimensions of the element. If this came up because Map::updateSize failed, then this is fixed already (see #2461). Please commit.

I'll see if #2461 fix the problem, and I'll report back.

in reply to: ↑ 4   Changed 3 years ago by bbinet

Replying to tschaub:

Bruno is not listed on CLA.

My name is now listed on CLA.

follow-up: ↓ 9   Changed 3 years ago by bartvde

Bruno, any news on this one?

  Changed 3 years ago by bartvde

  • milestone changed from 2.10 Release to 2.9 Release

in reply to: ↑ 7   Changed 3 years ago by bbinet

Replying to bartvde:

Bruno, any news on this one?

Sorry, I haven't taken the time to check this one. I'll do it tonight and report back.

Changed 3 years ago by bbinet

  Changed 3 years ago by bbinet

  • state changed from Commit to Review

patch_2414-r10113.diff Download gives up the previous non completely working patch and remove the entire workaround which tries to guess the size of hidden elements (size of display:none elements is 0).

As explain in thread http://openlayers.org/pipermail/dev/2010-January/005612.html , this new patch makes the application responsible for manually calling updateSize when display:none is removed from the map div.

This new patch does not fix the reported bug, so I'm fine with creating a new ticket, if needed.

If you think we must stay with the current behavior and guess the size on display:none element, then I don't see any good solution. We could force display:block and then restore the original display property (but I don't like the idea of making temporary changes to the DOM only to get the size of an element).

Changed 3 years ago by bbinet

  Changed 3 years ago by bbinet

I forgot to remove the corresponding tests.

patch_2414-r10113.2.diff Download is the same as previous patch but remove also the tests.

  Changed 3 years ago by fredj

Since Element.getDimensions is an API function, could you mark it as deprecated and keep the code ? Removing the test is fine.

Changed 3 years ago by bbinet

Changed 3 years ago by bbinet

  Changed 3 years ago by bbinet

Yes, you're right Fred.

patch_2414-r10113.3.diff Download is same as previous but does not remove the getDimensions API function which is now marked as deprecated.

  Changed 3 years ago by fredj

  • state changed from Review to Commit

Thanks, please commit.

  Changed 3 years ago by bbinet

I don't have rights to commit in openlayers trunk, so please commit ;)

  Changed 3 years ago by fredj

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [10125]) mark Element.getDimensions as deprecated and remove the workaround in Map.getCurrentSize. p=bbinet, r=me (closes #2414)

  Changed 3 years ago by ahocevar

  • status changed from closed to reopened
  • resolution fixed deleted

  Changed 3 years ago by ahocevar

  • milestone changed from 2.9 Release to 2.9.1 Release

  Changed 3 years ago by ahocevar

  • state changed from Complete to Review

attachment: patch_2414-r9943.diff would have fixed the reported issue. I am in favor of reverting r10125 and committing the first patch instead. It may not fix the application issue of the ticket creator, but it fixes the issue described in the ticket summary.

  Changed 3 years ago by bartvde

Andreas, your proposal makes sense to me, but I want to hear back from one of the C2C people first before setting the state to commit.

Changed 3 years ago by elemoine

  Changed 3 years ago by elemoine

  • state changed from Review to Commit

2414.patch Download doesn't solve the issue. Andreas, we agree with your proposal. We'll open a new ticket for the remaining issues.

  Changed 3 years ago by ahocevar

  • keywords pullup added
  • state changed from Commit to Pullup

(In [10276]) reverted r10125, which does not fix the described issue, and store style.display instead (first patch attached to #2414). r=bartvde,elemoine (pullup #2414)

  Changed 3 years ago by ahocevar

  • state changed from Pullup to Needs More Work

  Changed 3 years ago by ahocevar

  • keywords pullup removed

maybe there was a misunderstanding. quietriver is running more tests right now.

Changed 3 years ago by quietriver

Correct minimal test case, the previous test case was invalid as it did not include a maxExtent. This includes getCurrentSize to show the inclusion of 2414.patch fixing the issue described

  Changed 3 years ago by bartvde

r10276 has already been pulled up to the 2.9 branch in r10277

  Changed 3 years ago by ahocevar

  • keywords pullup added
  • state changed from Needs More Work to Pullup

(In [10278]) now don't use getDimensions any more, but use offsetWidth and offsetHeight before like getDimension does if style.display is not none. r=elemoine,quietriver (pullup #2414)

  Changed 3 years ago by bartvde

  • keywords pullup removed
  • status changed from reopened to closed
  • state changed from Pullup to Complete
  • resolution set to fixed

(In [10279]) pullup r10278 to the 2.9 branch (closes #2414)

Note: See TracTickets for help on using tickets.