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
Legacy IE (7-9) Compatibility #1605
Conversation
Wow @austinhyde, this is absolutely fantastic! |
This is great work @austinhyde. I've made a couple of comments, but am +lots on this. I don't have access to Windows machine to test it, but the code looks very good. |
That makes sense, but I still need the typecast to make the Closure Compiler happy, because |
The compiler can infer types from |
Interesting... I tried with only the assertion and the compiler errored because " |
Are you sure you were asserting that It's possible that we need to give the compiler a couple more hints here. Currently /** @type {ol.renderer.dom.Layer} */
var layerRenderer; |
results in
|
Interesting. This approach works elsewhere (e.g. fd733ec) but obviously something else is going on here. So, please keep the typecast for the moment and we can debug this later. |
What do you mean? Impressive work @austinhyde! I think we'll discuss this work during our next hangout meeting on Thursday. And feel free to join the meeting if you're interested in attending. |
I don't want to promise anything, but we're experimenting with implementing an |
This is awesome, support for legacy IE will definitely make a big difference in uptake by the community and additional contributions by people that might not have considered ol3 if it lacked this. One minor comment, not intending to derail this, but is there some way to extract this such that it could be loaded as a shim in some conditional comments targeting older browsers? Although there is very little code in here for the value added, it does add some bulk and complexity to the code and css that isn't needed for people targeting only newer browsers. Also, I assume potential vector support for legacy IE will add more code? |
@@ -522,7 +522,7 @@ ol.Map.prototype.freezeRendering = function() { | |||
|
|||
/** | |||
* Returns the geographical coordinate for a browser event. | |||
* @param {Event} event Event. | |||
* @param {Event|goog.events.BrowserEvent} event Event. |
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.
getEventPixel and getEventCoordinate are user-API functions, and we do not expose goog types/objects to the user. We could add getEventPixelInternal and getEventCoordinateInternal functions to work around that.
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.
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.
As it turned out, #1588 did not need this changes (thanks @elemoine). So, @austinhyde it would be great if you could add getEventPixelInternal
and getEventCoordinateInternal
functions, thanks.
I can't think of anyway an additional shim could work well, because of how thoroughly the Closure Compiler optimizes and minifies the code. What you could do if this is accepted, is make a new branch on a local checkout, use
This PR only introduces a ~0.8% increase in minified code size (+3KB out of a total 263KB) - hardly anything to be worried about. Performance-wise, most of the JS changes only target the DOM render (and thus, only legacy browsers), and even then, there aren't any real performance hits.
Yes, but I have no idea how much yet. |
A good way to solve this is to add an |
Example: /**
* @define {boolean} Support old versions of IE.
*/
ol.OLD_IE_SUPPORT = true;
// ...
ol.someFunction = function() {
if (ol.OLD_IE_SUPPORT) {
// code in this block will only be included in the compiled output if ol.OLD_IE_SUPPORT is true
}
if (ol.OLD_IE_SUPPORT && goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9.0')) {
// this whole if statement will be removed if ol.OLD_IE_SUPPORT is false
}
}; |
I can add the |
If you're feeling really ambitious, you could make |
I don't see too much value in that, as there's very little difference between 7 and 8, at least as far as these changes go. |
OK, in that case I agree that it makes more sense to keep it as a |
@austinhyde, please say if we can help with this PR. I've just been working with IE (in issue #1639) and would love to see this rebased on the latest master and merged. |
This is all very stable, as far as I can tell, and hand-tested extensively on IE7 and 8, both native and emulated in IE11. When you say "rebased", do you mean a literal |
Please do a |
In IE7, handling some mouseup events are causing the native event underlying goog.events.BrowserEvent to be invalidated, and it would error out with a "Member not found" message. By passing the Closure event rather than the native event around, we avoid this case.
IE < 9 does not support RGBA transparency, so instead fall back to more readable alternatives where possible. Conflicts: css/ol.css
IE < 9 does not support CSS content properties, so the +/- does not get rendered. Instead, add the +/- as text nodes when creating the DOM nodes for the control.
Also adds the msTransform property for IE 9
Adds support for the IE-specific Matrix filter and adds fixes that enable IE 7-8 to render transformations without distortion
Changed ol.interaction.Draw.defaultStyleFunction to be a getter, so that it only calls Canvas APIs when needed, rather than on script load
When removing/inserting layers back-to-back, the layer elements can get out of order because createLayerRenderer always appends to the layer pane. This makes it always reattach the layer node at the correct index, ensuring correct layer ordering.
When the event object is reference outside the call stack of the original event handler (like in a setTimeout), accessing its properties results in a "member not found" error. The solution is to clone the event object and use the clone.
Alright, everything's rebased. Let me know if you need anything else! |
Thanks @austinhyde! It works great in IE7, but I'm getting just a blank map for the simple example in IE8, with no tiles displayed (I've set It looks like |
It looks like the issue with the examples is two-fold: first, Looking through some of the other examples, there are a number of them that ought to work, but won't because of things like |
Thanks for the fix - it looks good. I'm +1 on merging this now. As you suggest, we can fix the other examples in a separate PR. Any other reviews/comments before merging? |
Not from me - merge whenever you want. |
We discussed this at the Hangout last Thursday, and everybody was for merging this. I was hoping that they would also post a comment here in the PR, but obviously that is not to be. So, merging this. |
+1 from me too. Great work! |
👍 |
These changes add compatibility for Internet Explorer 7-9 for most existing features of the DOM renderer, as well as some small improvements to the DOM renderer.
Namely:
As a result, the following features work smoothly on Internet Explorer 7-9:
Things that do not work in IE 7-9, and are not considered in this PR:
Feel free to cherry-pick this or let me know if you think more needs done before accepting.