Summary: | [Cocoa] NSAttributedString representation of text copied from -webkit-nbsp-mode:space element contains non-breaking space characters, but shouldn’t | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | mitz | ||||||||
Component: | HTML Editing | Assignee: | mitz | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | ap, darin | ||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||
Version: | WebKit Nightly Build | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | Unspecified | ||||||||||
Attachments: |
|
Description
mitz
2016-12-06 21:55:12 PST
Created attachment 296374 [details]
Possible fix (no tests and no change log)
Comment on attachment 296374 [details] Possible fix (no tests and no change log) View in context: https://bugs.webkit.org/attachment.cgi?id=296374&action=review > Source/WebCore/editing/cocoa/HTMLConverter.mm:2252 > + nbspMode = characterData.parentElement() ? static_cast<ENBSPMode>(downcast<CSSPrimitiveValue>(*_caches->computedStylePropertyForElement(*characterData.parentElement(), CSSPropertyWebkitNbspMode).get())) : NBNORMAL; Perhaps the chance of encountering an non-breaking space is low enough that we can use afford to use propertyValueForNode() and do a string compare instead of using computedStylePropertyForElement(). Comment on attachment 296374 [details] Possible fix (no tests and no change log) View in context: https://bugs.webkit.org/attachment.cgi?id=296374&action=review >> Source/WebCore/editing/cocoa/HTMLConverter.mm:2252 >> + nbspMode = characterData.parentElement() ? static_cast<ENBSPMode>(downcast<CSSPrimitiveValue>(*_caches->computedStylePropertyForElement(*characterData.parentElement(), CSSPropertyWebkitNbspMode).get())) : NBNORMAL; > > Perhaps the chance of encountering an non-breaking space is low enough that we can use afford to use propertyValueForNode() and do a string compare instead of using computedStylePropertyForElement(). Seems clear we *could* do that even if non-breaking spaces are relatively common, because the textTransform logic below calls propertyValueForNode once per string already. So calling it a second time couldn’t make things more than twice as slow. I have to admit, I am not really an expert on the philosophy behind how the HTMLConverter works, but I see no harm in making this change. Change looks fine to me. Created attachment 296837 [details]
Replace non-breaking spaces with spaces as needed
Comment on attachment 296837 [details]
Replace non-breaking spaces with spaces as needed
Pleased to see that there’s a layout test that can tell the difference!
Created attachment 296839 [details]
Replace non-breaking spaces with spaces as needed
Fixed in <https://trac.webkit.org/r209682>. |