Bug 226810

Summary: Parse attributes' HTML length values by HTMLDimension
Product: WebKit Reporter: cathiechen <cathiechen>
Component: DOMAssignee: cathiechen <cathiechen>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, darin, esprehn+autocc, ews-watchlist, gyuyoung.kim, koivisto, rbuis, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=226469
Attachments:
Description Flags
Patch
none
Patch none

cathiechen
Reported 2021-06-09 02:52:52 PDT
`addHTMLLengthToStyle()` is using CSS parser to get the values. We should reuse `parseHTMLDimension()` here.
Attachments
Patch (67.92 KB, patch)
2021-06-10 04:08 PDT, cathiechen
no flags
Patch (68.24 KB, patch)
2021-06-11 08:37 PDT, cathiechen
no flags
cathiechen
Comment 1 2021-06-10 04:08:23 PDT
cathiechen
Comment 2 2021-06-10 07:25:21 PDT
Comment on attachment 431060 [details] Patch Hi, I think this patch is ready for review now:) It applies HTMLDimension to other length parsing scenarios. Please take a look, thanks!
Darin Adler
Comment 3 2021-06-10 14:07:24 PDT
Comment on attachment 431060 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431060&action=review > Source/WebCore/html/HTMLElement.cpp:1019 > +void HTMLElement::addHTMLLengthToStyleWithConfigs(MutableStyleProperties& style, CSSPropertyID propertyID, const String& value, AllowPercentage allowPercentage, UseCSSPXAsUnitType useCSSPX, IsMultiLength isMultiLengh) Typo here in isMultiLengh Not thrilled with the word "configs" here. I think the function name doesn’t have to change just because we have three more arguments; it can just be an overload. Think of the arguments as having default values. > Source/WebCore/html/HTMLElement.h:155 > + enum class AllowPercentage : bool { No, Yes }; > + enum class UseCSSPXAsUnitType : bool { No, Yes }; > + enum class IsMultiLength : bool { No, Yes }; > + void addHTMLLengthToStyleWithConfigs(MutableStyleProperties&, CSSPropertyID, const String& value, AllowPercentage, UseCSSPXAsUnitType, IsMultiLength); These all can and should be private instead of protected. Also not sure that these options are best represented as three separate booleans, but if we make that private it’s easy to change it later. This function should take a StringView, not a const String&. > Source/WebCore/html/HTMLElement.h:159 > void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, const String& value); > + void addHTMLMultiLengthToStyle(MutableStyleProperties&, CSSPropertyID, const String& value); > + void addHTMLPixelsToStyle(MutableStyleProperties&, CSSPropertyID, const String& value); > + void addHTMLNumberToStyle(MutableStyleProperties&, CSSPropertyID, const String& value); These functions should take StringView, not const String&.
cathiechen
Comment 4 2021-06-11 08:23:35 PDT
Comment on attachment 431060 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431060&action=review Hi Darin, Thanks for the review! >> Source/WebCore/html/HTMLElement.cpp:1019 >> +void HTMLElement::addHTMLLengthToStyleWithConfigs(MutableStyleProperties& style, CSSPropertyID propertyID, const String& value, AllowPercentage allowPercentage, UseCSSPXAsUnitType useCSSPX, IsMultiLength isMultiLengh) > > Typo here in isMultiLengh > > Not thrilled with the word "configs" here. I think the function name doesn’t have to change just because we have three more arguments; it can just be an overload. Think of the arguments as having default values. Got it! Done, thanks! >> Source/WebCore/html/HTMLElement.h:155 >> + void addHTMLLengthToStyleWithConfigs(MutableStyleProperties&, CSSPropertyID, const String& value, AllowPercentage, UseCSSPXAsUnitType, IsMultiLength); > > These all can and should be private instead of protected. Also not sure that these options are best represented as three separate booleans, but if we make that private it’s easy to change it later. > > This function should take a StringView, not a const String&. Done! >> Source/WebCore/html/HTMLElement.h:159 >> + void addHTMLNumberToStyle(MutableStyleProperties&, CSSPropertyID, const String& value); > > These functions should take StringView, not const String&. Ah, done, thanks!
cathiechen
Comment 5 2021-06-11 08:37:33 PDT
EWS
Comment 6 2021-06-11 10:41:25 PDT
Committed r278765 (238725@main): <https://commits.webkit.org/238725@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431198 [details].
Radar WebKit Bug Importer
Comment 7 2021-06-11 10:42:20 PDT
Note You need to log in before you can comment on or make changes to this bug.