RESOLVED FIXED 30784
WebKit cannot remove nested bold tags
https://bugs.webkit.org/show_bug.cgi?id=30784
Summary WebKit cannot remove nested bold tags
Ryosuke Niwa
Reported 2009-10-26 12:47:48 PDT
WebKit fails to remove bold tags from "<b><b>hello</b></b>". Unbold it, and it produces "<b>hello</b>". Similarly, unbolding "<b><b>hello</b> world</b>" results in "<b>hello world</b>". We expect to get "hello" and "hello world" in respective cases. This bug is due to the fact executeToggleStyle compares the font weight with "bold" but triStateOfStyleInComputedStyle returns the value 700. Since "bold" != "700", triState is false and causes executeToogleStyle to bold the text instead of removing the bold.
Attachments
fixes the bug by making getPropertiesNotInComputedStyle more flexible (5.81 KB, patch)
2009-10-26 19:34 PDT, Ryosuke Niwa
no flags
fixes the bug by making getPropertiesNotInComputedStyle more flexible (fixed expected result) (5.92 KB, patch)
2009-10-26 19:37 PDT, Ryosuke Niwa
darin: review-
fixed per Darin's comment (5.97 KB, patch)
2009-10-27 12:21 PDT, Ryosuke Niwa
eric: review+
Ryosuke Niwa
Comment 1 2009-10-26 19:34:32 PDT
Created attachment 41926 [details] fixes the bug by making getPropertiesNotInComputedStyle more flexible
Ryosuke Niwa
Comment 2 2009-10-26 19:37:14 PDT
Created attachment 41927 [details] fixes the bug by making getPropertiesNotInComputedStyle more flexible (fixed expected result)
Ryosuke Niwa
Comment 3 2009-10-26 19:47:22 PDT
Since triStateOfStyleInComputedStyle calls getPropertiesNotInComputedStyle, I added new function getFontWeightValue in ApplyStyleCommand. getPropertiesNotInComputedStyle removes font-weight property from the style whenever the return value of getFontWeightValue match with that of the computed style. Because getFontWeightValue always converts the value of font-weight property to either 500 or 700, CSSValueBold and CSSValue700...900 will always match to each other.
Darin Adler
Comment 4 2009-10-27 11:26:54 PDT
Comment on attachment 41927 [details] fixes the bug by making getPropertiesNotInComputedStyle more flexible (fixed expected result) > +int getFontWeightValue(CSSStyleDeclaration* style) { Naming here does not match the WebKit coding style. We use nouns to name functions with return values, not "get". I also think the word "value" is not so good here in the name. There is already a font weight value, and it's a CSSValue object. The name of the function needs to describe what it does. It seems to me that this function actually just returns a boolean stating whether or not the font weight is a "bold" weight. So it would probably be better to make a function named fontWeightIsBold that returns a boolean. Or perhaps you have plans for the future that involve multiple font weights and therefore want to use the font weight numbers. Formatting here does not match the WebKit coding style. The brace goes on the beginning of the next line. I think the code needs a comment explaining exactly why "there are only two font-weights for rich text editing purposes". A concrete explanation of this. > + case CSSValue100 : > + case CSSValue200 : > + case CSSValue300 : > + case CSSValue400 : > + case CSSValue500 : > + case CSSValueNormal : > + return 500; > + case CSSValueBold : > + case CSSValue600 : > + case CSSValue700 : > + case CSSValue800 : > + case CSSValue900 : > + return 700; Formatting here does not match the WebKit coding style. We don't line up the colons like this. Patch otherwise looks pretty good to me. review- because of the issues mentioned above
Ryosuke Niwa
Comment 5 2009-10-27 12:21:57 PDT
Created attachment 41975 [details] fixed per Darin's comment
Eric Seidel (no email)
Comment 6 2009-10-27 12:36:33 PDT
Comment on attachment 41975 [details] fixed per Darin's comment LGTM.
Eric Seidel (no email)
Comment 7 2009-10-27 14:52:32 PDT
Yeah, the queue is kinda backed up at the moment. It may be faster for you to land by hand. Mostly it's backed up because the buildbots are so red. :(
Ryosuke Niwa
Comment 8 2009-10-27 16:34:17 PDT
Note You need to log in before you can comment on or make changes to this bug.