Figure out a solution for XUL hidden persistence on XUL <treecol>
Categories
(Toolkit :: General, task, P2)
Tracking
()
People
(Reporter: ntim, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 obsolete file)
Comment hidden (obsolete) |
Reporter | ||
Comment 2•4 years ago
|
||
Updated•4 years ago
|
Updated•4 years ago
|
Comment hidden (obsolete) |
Updated•4 years ago
|
Reporter | ||
Comment 4•4 years ago
|
||
This turns out not being an issue in XUL boolean attribute land (un-hidden is persisted as hidden=""
, which is un-hidden for XUL), so the current code is ok. Though that still needs to be fixed for HTML bool attributes.
Attribute removals should be persisted differently (not as empty-strings).
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 5•4 years ago
•
|
||
TLDR, this is facing a problem where some places used to set hidden="false"
and the false
value would be persisted, but now the hidden
attribute would just be removed (and hidden=""
is persisted). This is problematic for treecols with hidden="true"
by default, where un-hiding treecols would not be persisted after the underlying change (current state would restore hidden=""
instead of hidden="false"
which would both be considered as hidden in HTML land).
All usages of persistence with hidden are on <treecols>: https://searchfox.org/mozilla-central/search?q=persist%3D%22.*hidden&path=&case=false®exp=true
Solutions include:
- setting another attribute to force-hide and persist that too (kinda ugly imo)
- switching to collapsed to hide columns (that would really just move the problem to the collapsed attribute though)
- persisting some internal value like
_moz_attribute_removed_
instead of persisting an empty string? and make the xul store code handle that keyword differently. There's the potential issue of.setAttribute("hidden", "_moz_attribute_removed_")
fooling this, but I guess that's unlikely... - wait for <treecols> to stop being used and stop caring about this issue.
Solution 3. seems best, since it gives room for migrating other boolean style attributes as well.
Comment 6•4 years ago
|
||
Not sure what #5 was?
Maybe it's worth special casing hidden and the few other known boolean attributes during xul store persist/restore, and let those persist true/false? When storing, if set and not "false" store true, else store false. When restoring, toggleAttribute based on the true/false string from storage.
Updated•4 years ago
|
Reporter | ||
Comment 7•4 years ago
|
||
(In reply to Magnus Melin [:mkmelin] from comment #6)
Not sure what #5 was?
Ah I started this line with 3.
, so bugzilla thought it was a list item.
Maybe it's worth special casing hidden and the few other known boolean attributes during xul store persist/restore, and let those persist true/false? When storing, if set and not "false" store true, else store false. When restoring, toggleAttribute based on the true/false string from storage.
Yeah, persisting the JS property instead would be a good idea here.
Reporter | ||
Comment 8•4 years ago
|
||
Persisting the JS property doesn't look too nasty to implement, essentially it consists of:
-
creating new methods called GetPersistedAttr() and SetPersistedAttr() which are essentially equivalents of Element::GetAttr()/SetAttr(), but special-casing attribute name
hidden
and usingHidden()
/SetHidden()
there instead. Potentially issues include:- XULPersist.cpp is mostly based on mozilla::dom::Element, whereas as we're dealing with XULElement, which suggests it might just be easier to do GetBoolAttr()/SetBoolAttr(), though at the same time as bug 1691321 (otherwise,
GetBoolAttr()/SetBoolAttr()
will return the wrong thing). Alternatively, it could be done independently, but then we'd need to duplicate the XUL versions of these methods. - Having to cast boolean to string in C++ and vice-versa, but that's probably not too hard
- XULPersist.cpp is mostly based on mozilla::dom::Element, whereas as we're dealing with XULElement, which suggests it might just be easier to do GetBoolAttr()/SetBoolAttr(), though at the same time as bug 1691321 (otherwise,
-
Replacing the usages of
GetAttr()/SetAttr()
in dom/xul/XULPersist.cpp with the new methods. -
Handling backwards compat well (either through XULStore migration in BrowserGlue, either through XULPersist.cpp logic)
Overall, it doesn't look too hard.
Reporter | ||
Updated•4 years ago
|
Description
•