Ticket #656 (closed enhancement: fixed)
reduce repetitive usage of HTMLArea.is_ie test
| Reported by: | mokhet | Owned by: | mokhet |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Xinha Core | Version: | trunk |
| Severity: | normal | Keywords: | performance is_ie |
| Cc: |
Description
After i've submited the ticket #654, i've find a few places where the test should be done once while creating the object prototype and not everytime in the instance javascript at every call.
here is the list of the functions i've noticed that could be enhanced this way, i will submit a patch for them in a moment. I think this can improve a bit the performances since most of thoses functions are intensively used.
- function stripTag(el) in HTMLArea.prototype._wordClean
- HTMLArea.prototype.insertNodeAtSelection
- HTMLArea.prototype.getParentElement
- HTMLArea.prototype._activeElement
- HTMLArea.prototype._selectionEmpty
- HTMLArea.prototype.selectNodeContents
- HTMLArea.prototype.insertHTML
- HTMLArea.prototype.getSelectedHTML
- HTMLArea.prototype.dom_checkBackspace and HTMLArea.prototype.ie_checkBackspace
for those 2 functions, i have renamed them checkBackspace and instead of always creating both functions, i create only the one needed. In the dom_checkBackspace, i think it's weird to use a setTimeout to eventually cancel an event, it seems to work but still i think it's not a "solid" way to handle the case. Anyway, this is another topic :)
- HTMLArea.prototype._getSelection
- HTMLArea.prototype._createRange
- HTMLArea.getOuterHTML
there is also HTMLArea._postback, HTMLArea._getback and HTMLArea._geturlcontent but i'll open another ticket later since there is more to do with thoses 3 functions.
I dont understand well how is working the function autoWrap in HTMLArea.prototype._editorEvent but i think there is a bug or at least useless code in changeset 477.
if(HTMLArea.is_gecko)
{
var s = editor._getSelection()
var autoWrap = function (textNode, tag)
{
if(HTMLArea.is_ie) <-- HERE
{
How can (HTMLArea.is_ie) be ever TRUE when we are in a function define only when (HTMLArea.is_gecko) ? But as i said, i dont understand this part of the code.
Anyway, I really think this function (HTMLArea.prototype._editorEvent) needs also to be splitted in 2 functions between IE and other world (as in all the patches submited). Because we do 9 tests on (HTMLArea.is_ie) and 4 tests on (HTMLArea.is_gecko) in this function, this is too much specificity for a generic handler event imo, especially since it is used very often. This part of the code is really confuse for me, i'll try to make a patch but i cant promiss anything.
