RESOLVED FIXED 239423
[macOS] Image controls are editable and prevent drops in editable web views
https://bugs.webkit.org/show_bug.cgi?id=239423
Summary [macOS] Image controls are editable and prevent drops in editable web views
Wenson Hsieh
Reported 2022-04-16 13:40:09 PDT
Attachments
For EWS (6.29 KB, patch)
2022-04-16 14:05 PDT, Wenson Hsieh
no flags
For landing (6.33 KB, patch)
2022-04-16 16:05 PDT, Wenson Hsieh
no flags
Wenson Hsieh
Comment 1 2022-04-16 14:05:03 PDT
Darin Adler
Comment 2 2022-04-16 15:14:31 PDT
Comment on attachment 457755 [details] For EWS View in context: https://bugs.webkit.org/attachment.cgi?id=457755&action=review > Source/WebCore/dom/mac/ImageControlsMac.cpp:93 > + controlLayer->setContentEditable("false"_s); Mildly sad that we allocate and then deallocate the String containing "false" here. There is, however, a clean way to fix that. We can change HTMLElement::setContentEditable to take a StringView. Will still work with the String&& that the JavaScript bindings will pass to it. Probably will have to edit DOMHTMLElement.mm to keep it compiling since an NSString * knows how to turn itself into a String but not a StringView. Not really necessary to do *any* of this as part of this patch, just something I am noticing in passing.
Chris Dumez
Comment 3 2022-04-16 15:42:33 PDT
Comment on attachment 457755 [details] For EWS View in context: https://bugs.webkit.org/attachment.cgi?id=457755&action=review >> Source/WebCore/dom/mac/ImageControlsMac.cpp:93 >> + controlLayer->setContentEditable("false"_s); > > Mildly sad that we allocate and then deallocate the String containing "false" here. There is, however, a clean way to fix that. We can change HTMLElement::setContentEditable to take a StringView. Will still work with the String&& that the JavaScript bindings will pass to it. Probably will have to edit DOMHTMLElement.mm to keep it compiling since an NSString * knows how to turn itself into a String but not a StringView. Not really necessary to do *any* of this as part of this patch, just something I am noticing in passing. I totally agree that setContentEditable() should take a StringView. I also think that the most efficient code may be: controlLayer->setAttributeWithoutSynchronization(contenteditableAttr, "false"_s); or even controlLayer->setAttributeWithoutSynchronization(contenteditableAttr, HTMLElement::falseName()); if we expose falseName() in the HTMLElement header (it is currently in the cpp only). To avoid the string comparisons inside setContentEditable().
Wenson Hsieh
Comment 4 2022-04-16 15:47:38 PDT
Thanks for the reviews, Chris and Darin! (In reply to Chris Dumez from comment #3) > Comment on attachment 457755 [details] > For EWS > > View in context: > https://bugs.webkit.org/attachment.cgi?id=457755&action=review > > >> Source/WebCore/dom/mac/ImageControlsMac.cpp:93 > >> + controlLayer->setContentEditable("false"_s); > > > > Mildly sad that we allocate and then deallocate the String containing "false" here. There is, however, a clean way to fix that. We can change HTMLElement::setContentEditable to take a StringView. Will still work with the String&& that the JavaScript bindings will pass to it. Probably will have to edit DOMHTMLElement.mm to keep it compiling since an NSString * knows how to turn itself into a String but not a StringView. Not really necessary to do *any* of this as part of this patch, just something I am noticing in passing. > > I totally agree that setContentEditable() should take a StringView. I also > think that the most efficient code may be: > controlLayer->setAttributeWithoutSynchronization(contenteditableAttr, > "false"_s); > or even > controlLayer->setAttributeWithoutSynchronization(contenteditableAttr, > HTMLElement::falseName()); > if we expose falseName() in the HTMLElement header (it is currently in the > cpp only). > > To avoid the string comparisons inside setContentEditable(). That's a great point — I filed <https://webkit.org/b/239424> to track refactoring setContentEditable to take a StringView; I'll also tweak this patch so that it does: ``` controlLayer->setAttributeWithoutSynchronization(contenteditableAttr, "false"_s); ``` ...instead of using `setContentEditable()`.
Wenson Hsieh
Comment 5 2022-04-16 16:05:17 PDT
Created attachment 457758 [details] For landing
EWS
Comment 6 2022-04-16 20:14:11 PDT
Committed r292944 (249709@main): <https://commits.webkit.org/249709@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 457758 [details].
Note You need to log in before you can comment on or make changes to this bug.