NEW 121415
The size of the background colour is not properly adjusted when the font size is being changed
https://bugs.webkit.org/show_bug.cgi?id=121415
Summary The size of the background colour is not properly adjusted when the font size...
Artur Moryc
Reported 2013-09-16 02:47:38 PDT
When the background colour is set to a specific colour but the font size is being changed it results in that the size of the background colour doesn't fit to any of the font sizes.
Attachments
Test to validate the background combined with the font sizes (1.26 KB, text/html)
2013-09-17 02:48 PDT, Artur Moryc
no flags
Expected result for the attached test (31.78 KB, image/png)
2013-09-17 02:55 PDT, Artur Moryc
no flags
Propesed solution for the font size change and backgroundcolor issue (12.95 KB, patch)
2013-10-17 09:52 PDT, Artur Moryc
rniwa: review-
Solution improvment for the font size change and backgroundcolor issue (14.94 KB, patch)
2013-11-08 06:35 PST, Artur Moryc
rniwa: review-
chart with redundant nodes (67.41 KB, image/png)
2013-11-08 06:37 PST, Artur Moryc
no flags
chart with optimzed nodes (85.34 KB, image/png)
2013-11-08 06:39 PST, Artur Moryc
no flags
Solution enhancement for the font size change and backgroundcolor issue (9.93 KB, patch)
2013-11-13 03:07 PST, Artur Moryc
darin: review-
The results of the provided fix (83.29 KB, image/png)
2013-11-13 03:08 PST, Artur Moryc
no flags
New solution for the font size change and backgroundcolor issue (19.71 KB, patch)
2013-12-01 07:53 PST, Artur Moryc
eflews.bot: commit-queue-
New solution for the font size change and backgroundcolor issue (19.21 KB, patch)
2013-12-02 03:11 PST, Artur Moryc
buildbot: commit-queue-
New solution for the font size change and backgroundcolor issue (18.94 KB, patch)
2013-12-02 04:33 PST, Artur Moryc
buildbot: commit-queue-
New solution for the font size change and backgroundcolor issue (18.90 KB, patch)
2013-12-04 01:24 PST, Artur Moryc
rniwa: review-
Updating solution for the font size and backgroundcolor changes (21.64 KB, patch)
2014-02-05 07:32 PST, Artur Moryc
no flags
Updating solution for the font size and backgroundcolor changes (21.62 KB, patch)
2014-02-05 08:04 PST, Artur Moryc
no flags
Updating solution for the font size and backgroundcolor changes (21.62 KB, patch)
2014-02-05 08:20 PST, Artur Moryc
rniwa: review-
Updating solution for backgroundcolor and fontsize issue (21.63 KB, patch)
2014-02-06 08:48 PST, Artur Moryc
rniwa: review-
Node distribution if there is no default fontsize. (73.50 KB, image/png)
2014-02-17 02:07 PST, Artur Moryc
no flags
Node distribution with default fontsize. (78.92 KB, image/png)
2014-02-17 02:13 PST, Artur Moryc
no flags
Node distribution for the default and small fontsize (81.00 KB, image/png)
2014-04-01 06:31 PDT, Artur Moryc
no flags
Solution update for the backgroundcolor while the fontsize varies (20.66 KB, patch)
2014-07-03 09:46 PDT, Artur Moryc
no flags
Solution update for the backgroundcolor while the fontsize varies (20.86 KB, patch)
2014-07-04 06:45 PDT, Artur Moryc
no flags
Solution update for the backgroundcolor while the fontsize varies (20.84 KB, patch)
2014-07-04 07:25 PDT, Artur Moryc
darin: review-
Solution update for the backgroundcolor while the fontsize varies (20.60 KB, patch)
2014-09-23 11:15 PDT, Artur Moryc
no flags
Node distribution for the latest patch (89.10 KB, image/png)
2014-09-23 11:17 PDT, Artur Moryc
no flags
Node distribution (99.45 KB, image/png)
2014-09-23 11:25 PDT, Artur Moryc
no flags
Safari 15.5 matches other browsers (818.32 KB, image/png)
2022-06-01 14:25 PDT, Ahmad Saleem
no flags
Alexey Proskuryakov
Comment 1 2013-09-16 09:57:14 PDT
Do you have an example web site, or better yet a test case that you could attach here?
Artur Moryc
Comment 2 2013-09-17 02:48:58 PDT
Created attachment 211876 [details] Test to validate the background combined with the font sizes Steps to reproduce the bug: In the attached file (FontBackgroundTest.html) perform the following actions: 1. Set the font size to Huge 2. Set the beckground color 3. Insert text 4. Change the font size ( different than the previous one) Observed result: The background color doesn't fit to any font sizes. Expected result: The background color can adjust respectively to the font sizes
Artur Moryc
Comment 3 2013-09-17 02:55:31 PDT
Created attachment 211877 [details] Expected result for the attached test
Alexey Proskuryakov
Comment 4 2013-09-17 09:27:53 PDT
Thank you, I can reproduce some clearly incorrect behaviors with this test case.
Radar WebKit Bug Importer
Comment 5 2013-09-17 13:45:31 PDT
Artur Moryc
Comment 6 2013-10-17 09:52:17 PDT
Created attachment 214466 [details] Propesed solution for the font size change and backgroundcolor issue The proposed fix should be looked closer for the default font size case. In this solution the default font size case is considered as a text node with a span backgroundcolor parent. The problem appears if the sibling of the default fontsize node has the font size smaller than default since its backgroundcolor is overwritten by the parent backgroundcolor. However, If the default fontsize node would be considered as a span node with backgroundcolor the problem seem to be solved.
Ryosuke Niwa
Comment 7 2013-10-18 01:31:59 PDT
Comment on attachment 214466 [details] Propesed solution for the font size change and backgroundcolor issue View in context: https://bugs.webkit.org/attachment.cgi?id=214466&action=review Thanks for the patch but I don't think the code change is sound. For one, it introduces a security bug. It appears to me that we just need to be more careful about where we add span/font elements to specify the font if there is already background color specified somewhere. We should be exposing the ability to compute the effective background color in EditingStyle intend of manually computing it here. > Source/WebCore/editing/ApplyStyleCommand.cpp:1478 > + if (node->hasTagName(fontTag) && node->previousSibling() && node->previousSibling()->hasTagName(fontTag)) > + nodeFromWhichBackgrounColorCoppied = node->previousSibling()->firstChild(); What are we trying to accomplish with this code? > Source/WebCore/editing/ApplyStyleCommand.cpp:1486 > + String backgroundColorValue = inlineStyle->getPropertyValue(CSSPropertyBackgroundColor); > + if (!backgroundColorValue.isEmpty() && !isBackgroundcolorSet) { r- because this code only checks inline style but background color may also been specified by a CSS rule. > Source/WebCore/editing/ApplyStyleCommand.cpp:1488 > + spamElement->setAttribute(styleAttr, newCSSStyle); r- because this breaks undo. We must use setNodeAttribute or alike that uses EditCommand to create an undo step. > Source/WebCore/editing/ApplyStyleCommand.cpp:1493 > + if (node->hasTagName(spanTag) && node->firstChild()->hasTagName(fontTag) && node->parentNode() && node->parentNode() != editableRoot) node is a raw pointer and it could have been removed by some script while calling surroundNodeRangeWithElement. r- because this code introduces a use-after-free bug. > Source/WebCore/editing/ApplyStyleCommand.cpp:1494 > + removeNodePreservingChildren(toHTMLElement(node)); r- because node can have other styles and removing this node could alter the style. e.g. decedent selectors such as "a b" will fail to match "b" if we removed "a".
Artur Moryc
Comment 8 2013-11-08 06:35:37 PST
Created attachment 216387 [details] Solution improvment for the font size change and backgroundcolor issue Thank you for valuable remarks which helped to brush up the code. Functionality of backgroundColorInEffect has been used to find a parent node with backgroundcolor. Two charts are attached that show redundant nodes and solution without them.
Artur Moryc
Comment 9 2013-11-08 06:37:54 PST
Created attachment 216388 [details] chart with redundant nodes Chart which shows redundant parent nodes.
Artur Moryc
Comment 10 2013-11-08 06:39:45 PST
Created attachment 216389 [details] chart with optimzed nodes In this case redundant nodes have been removed
Ryosuke Niwa
Comment 11 2013-11-08 09:57:23 PST
Comment on attachment 216387 [details] Solution improvment for the font size change and backgroundcolor issue View in context: https://bugs.webkit.org/attachment.cgi?id=216387&action=review Thanks for the updated patch but we need more detailed descriptions in the change log. > LayoutTests/editing/inserting/default-fontsize-inner-span-background-expected.txt:5 > +| size="7" > +| style="background-color: rgb(255, 0, 0);" > +| <span> > +| style="background-color: rgb(255, 0, 0);" I don't think we should have the inner span. r- because this markup is too verbose. > LayoutTests/editing/inserting/default-fontsize-inner-span-background.html:20 > + minFontSize = 1; > + maxFontSize = 7; > + digitsInBlock = 3; > + fontColor = '#F00'; Please declare these variables with either "var" or "const". > LayoutTests/editing/inserting/default-fontsize-inner-span-background.html:44 > +<p>This Layout Test checks whether the height of background combined with font tag is correct. The test successes when background color is red and it exactly matches the font size.</p> Please put this in Markup.description. You can do Markup.description(document.querySelector('p').textContent); > LayoutTests/editing/inserting/default-fontsize-inner-span-background.html:50 > +<script> > +var div = document.getElementById("test"); > +div.focus(); > +changeFontSizeForOneBackgroundcolorTest(); > +</script> Why is this script element inside #test? > LayoutTests/editing/inserting/default-fontsize-inner-span-background.html:55 > +<script> > +forceExpectedResult('#F00'); > +var div = document.getElementById("test"); > +Markup.dump(div); What are we testing here? > LayoutTests/editing/inserting/default-fontsize-outer-span-background-expected.txt:7 > +| <span> > +| style="background-color: rgb(255, 0, 0);" > +| <font> > +| size="7" > +| <span> > +| style="background-color: rgb(255, 0, 0);" > +| "777" Why do we have background-color in the outer span here? Also, why was not font modified to specify the background color? > Source/WebCore/ChangeLog:9 > + The bug is observed in the editing field while the font size is being changed for one background > + color then the size of the background is not properly adjusted to different font sizes Note that font size can be specified by font-size CSS property as well as font element. > Source/WebCore/ChangeLog:12 > + The proposed solution is to find background color of the parent node and apply > + such style inside of the font tag Please don't do that. That'll increase the size of markup very quickly, ending up setting background-color on virtually every single node. We used to have this problem, and we've worked hard to fix that. > Source/WebCore/editing/ApplyStyleCommand.cpp:1467 > + RefPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(toHTMLElement(spanElement.get())->inlineStyle()); We shouldn't always create a span. When there is an appropriate span or font element, we should simply add an inline style there. Also, we should be using EditingStyle instead of manually manipulating MutableStylePropertySet. r- because of these two problems. > Source/WebCore/editing/ApplyStyleCommand.cpp:1477 > + if (node->hasTagName(spanTag) && node->firstChild()->hasTagName(fontTag) && node->parentNode() && node->parentNode() != editableRoot) > + removeNodePreservingChildren(toHTMLElement(node)); I'm not sure if I wasn't clear with my previous comment but this function should NEVER remove an element. That'll cause crashes and infinite loops elsewhere. > Source/WebCore/editing/EditingStyle.cpp:1347 > +RefPtr<CSSValue> EditingStyle::obtainBackgroundcolorIfNeeded(const Node *node) What does IfNeeded in this context? > Source/WebCore/editing/EditingStyle.cpp:1351 > + if (node && isFontTagNode(node->parentNode())) > + value = backgroundColorInEffect(const_cast<Node*>(node)); Why is font element special? The intent/purpose of this function needs to clearly explained in the change log. r- because of this. > Source/WebCore/editing/htmlediting.cpp:162 > +bool isFontTagNode(const Node *node) > +{ > + return node && node->hasTagName(fontTag); > +} > + We already have isHTMLFontElement. r- because this function duplicates that functionality.
Artur Moryc
Comment 12 2013-11-13 03:07:32 PST
Created attachment 216786 [details] Solution enhancement for the font size change and backgroundcolor issue Thank you very much for very comprehensive comments and explanations to the previous patches. In this patch background color is added to the font tag inline. However, still there are two things that can be pointed out: 1) As it can be seen in the attach chart there is still no difference between the small and normal font size. It happens since the span tag with style background color may overwrite the background color for the font tag with small size font (please have a look at the attached chart) 2) After adding a text with default font size it results in that next nodes with different font sizes are added as child nodes. It also may influence on overwriting the beckgroundcolor for small font size.
Artur Moryc
Comment 13 2013-11-13 03:08:34 PST
Created attachment 216787 [details] The results of the provided fix
Darin Adler
Comment 14 2013-11-15 10:53:18 PST
Comment on attachment 216786 [details] Solution enhancement for the font size change and backgroundcolor issue View in context: https://bugs.webkit.org/attachment.cgi?id=216786&action=review > Source/WebCore/editing/ApplyStyleCommand.cpp:1467 > + newCSSStyle.append(styleChange.cssStyle()); Does something guarantee that cssStyle ends with a semicolon if it’s not empty? If not, don’t we need to add a semicolon? What if the style attribute string already has background-color in it? Will we just keep adding more? Could we add test cases that cover this? > Source/WebCore/editing/ApplyStyleCommand.cpp:1468 > + newCSSStyle.append("background-color:" + backgroundColorCSSValue->cssText()); This is wrong. If we already have a string builder we should append one string at a time. This way does unnecessary allocation. Something like this: newCSSStyle.appendLiteral(“background-color:”); newCSSStyle.append(backgroundColorCSSValue->cssText()); Not sure I have the syntax exactly right. > Source/WebCore/editing/ApplyStyleCommand.cpp:1469 > + setNodeAttribute(toHTMLElement(fontElement.get()), styleAttr, newCSSStyle.toString()); Code above is just calling fontElement->setAttribute. Why does this code call setNodeAttribute instead? > Source/WebCore/editing/EditingStyle.cpp:1346 > +PassRefPtr<CSSValue> EditingStyle::backgroundColorInEffect(Node* node) It’s ugly to have this return a CSSValue, although that’s not new to this patch. For internal use in WebKit we should not be using DOM types like this. The new caller wants only the serialized string form. The old caller wants only an RGBA value, which does not require allocation of a CSSValue object at all. The new caller wants the serialized color, and it also seems wasteful to allocate a CSSValue for this. > Source/WebCore/editing/EditingStyle.cpp:1350 > + if (RefPtr<CSSValue> value = ComputedStyleExtractor(ancestor).propertyValue(CSSPropertyBackgroundColor)) { > + if (!isTransparentColorValue(value.get())) This is an inefficient approach. I don’t think we want to involve computed style until we reach the item that has a background color. We should answer the “does this have a non-transparent background color” using the lower level, RenderStyle. It’s wasteful to construct a CSSValue for internal use. > Source/WebCore/editing/EditingStyle.cpp:1354 > + return 0; nullptr
Darin Adler
Comment 15 2013-11-15 10:54:04 PST
Comment on attachment 216786 [details] Solution enhancement for the font size change and backgroundcolor issue Oops, sorry, meant review-
Ryosuke Niwa
Comment 16 2013-11-17 05:05:01 PST
Comment on attachment 216786 [details] Solution enhancement for the font size change and backgroundcolor issue View in context: https://bugs.webkit.org/attachment.cgi?id=216786&action=review > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-expected.txt:7 > +| <span> > +| style="background-color: rgb(255, 0, 0);" > +| <font> > +| size="7" > +| style="background-color:rgb(255, 0, 0)" > +| "777" We shouldn't have all these nested spans with red background. > Source/WebCore/editing/ApplyStyleCommand.cpp:1464 > + RefPtr<CSSValue> backgroundColorCSSValue = m_style->EditingStyle::backgroundColorInEffect(startNode.get()); Why do we need EditingStyle::? >> Source/WebCore/editing/ApplyStyleCommand.cpp:1468 >> + newCSSStyle.append("background-color:" + backgroundColorCSSValue->cssText()); > > This is wrong. If we already have a string builder we should append one string at a time. This way does unnecessary allocation. Something like this: > > newCSSStyle.appendLiteral(“background-color:”); > newCSSStyle.append(backgroundColorCSSValue->cssText()); > > Not sure I have the syntax exactly right. We shouldn't be doing these kinds of string manipulations to modify style. That should be done in EditingStyle instead.
Artur Moryc
Comment 17 2013-12-01 07:53:34 PST
Created attachment 218111 [details] New solution for the font size change and backgroundcolor issue Hello, thank you for your previous valuable remarks and comprehensive explanations.
EFL EWS Bot
Comment 18 2013-12-01 07:58:26 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass efl-ews (efl): Output: http://webkit-queues.appspot.com/results/40248113
EFL EWS Bot
Comment 19 2013-12-01 07:59:21 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass efl-wk2-ews (efl-wk2): Output: http://webkit-queues.appspot.com/results/40158131
Build Bot
Comment 20 2013-12-01 08:22:32 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/40078155
kov's GTK+ EWS bot
Comment 21 2013-12-01 08:23:56 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass gtk-ews (gtk): Output: http://webkit-queues.appspot.com/results/40148148
Build Bot
Comment 22 2013-12-01 08:35:43 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass win-ews (win): Output: http://webkit-queues.appspot.com/results/40098146
Build Bot
Comment 23 2013-12-01 08:42:14 PST
Comment on attachment 218111 [details] New solution for the font size change and backgroundcolor issue Attachment 218111 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/40058141
Artur Moryc
Comment 24 2013-12-02 03:11:50 PST
Created attachment 218155 [details] New solution for the font size change and backgroundcolor issue Hi, thanks again for previous valuable remarks and comprehensive explanations.
WebKit Commit Bot
Comment 25 2013-12-02 03:14:16 PST
Attachment 218155 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-expected.txt', u'LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-if-continue-style-expected.txt', u'LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-if-continue-style.html', u'LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment.html', u'LayoutTests/editing/inserting/fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style-expected.txt', u'LayoutTests/editing/inserting/fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html', u'Source/WebCore/ChangeLog', u'Source/WebCore/editing/ApplyStyleCommand.cpp', u'Source/WebCore/editing/EditingStyle.cpp', u'Source/WebCore/editing/EditingStyle.h']" exit_code: 1 Source/WebCore/editing/EditingStyle.cpp:452: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 1 in 11 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 26 2013-12-02 03:41:56 PST
Comment on attachment 218155 [details] New solution for the font size change and backgroundcolor issue Attachment 218155 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/39978363
Build Bot
Comment 27 2013-12-02 04:03:24 PST
Comment on attachment 218155 [details] New solution for the font size change and backgroundcolor issue Attachment 218155 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/40428096
Artur Moryc
Comment 28 2013-12-02 04:33:13 PST
Created attachment 218161 [details] New solution for the font size change and backgroundcolor issue Thanks for previous valuable remarks and comprehensive explanations!
Build Bot
Comment 29 2013-12-02 05:03:42 PST
Comment on attachment 218161 [details] New solution for the font size change and backgroundcolor issue Attachment 218161 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/41658030
Build Bot
Comment 30 2013-12-02 05:32:18 PST
Comment on attachment 218161 [details] New solution for the font size change and backgroundcolor issue Attachment 218161 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/41508049
Artur Moryc
Comment 31 2013-12-04 01:24:56 PST
Created attachment 218389 [details] New solution for the font size change and backgroundcolor issue Hi, Thanks for previous valuable review remarks and very comprehensive explanations!
Artur Moryc
Comment 32 2013-12-09 22:29:05 PST
Hello, any comments from reviewers?
Ryosuke Niwa
Comment 33 2013-12-24 00:36:19 PST
Comment on attachment 218389 [details] New solution for the font size change and backgroundcolor issue View in context: https://bugs.webkit.org/attachment.cgi?id=218389&action=review > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-expected.txt:3 > +| <span> > +| style="background-color: rgb(255, 0, 0);" We shouldn't have this outer span with background color. > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-if-continue-style.html:12 > +<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script> Why does this script element have both language and type specified? Neither attribute is needed here. Also, we need to wrap the path in quotation marks. > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-if-continue-style.html:18 > + function changeFontSizeForOneBackgroundcolorTest() { Nit: the function shouldn't be indented. > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-if-continue-style.html:23 > + for(fontSize = maxFontSize-1; fontSize >= minFontSize; fontSize--) { Nit: Space around -. > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment.html:5 > +<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script> Ditto. > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment.html:11 > + function changeFontSizeForOneBackgroundcolorTest() { Ditto. > LayoutTests/editing/inserting/fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html:17 > +<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script> Ditto. > LayoutTests/editing/inserting/fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html:24 > + var minFontSize = 1; Nit: Wrong indentation. Each indentation must be done by 4 spaces. > Source/WebCore/ChangeLog:26 > + * editing/ApplyStyleCommand.cpp: > + (WebCore::ApplyStyleCommand::applyInlineStyleChange): > + * editing/EditingStyle.cpp: > + (WebCore::ColorValueToRGBA): > + (WebCore::rgbaBackgroundColorInEffect): > + (WebCore::EditingStyle::init): > + (WebCore::EditingStyle::styleAtSelectionStart): > + (WebCore::EditingStyle::backgroundColorInEffect): > + * editing/EditingStyle.h: You need to have per-function level comments. > Source/WebCore/editing/EditingStyle.cpp:390 > +static RGBA32 colorValueToRGBA(Color colorValue) > +{ > + if (!colorValue.isValid() || !colorValue.alpha()) > + return Color::transparent; Why is invalid color treated as transparent? It seems like this is specific to background color and better be delt with in rgbaBackgroundColorInEffect itself. > Source/WebCore/editing/EditingStyle.cpp:1494 > + color = style->visitedDependentColor(CSSPropertyBackgroundColor); We should definitely not use visitedDependentColor. r- because this leaks history information. > Source/WebCore/editing/EditingStyle.cpp:-1608 > -PassRefPtr<CSSValue> backgroundColorInEffect(Node* node) > -{ Why are you rewriting this function? This was a perfectly reasonable implementation.
Artur Moryc
Comment 34 2014-02-05 07:32:58 PST
Created attachment 223231 [details] Updating solution for the font size and backgroundcolor changes Response to previous comments: 1. > Source/WebCore/editing/EditingStyle.cpp:-1608 > -PassRefPtr<CSSValue> backgroundColorInEffect(Node* node) > -{ >Why are you rewriting this function? This was a perfectly reasonable implementation. Please have a look at Darin Adler's suggestions. 2. >We shouldn't have this outer span with background color. Yes. I agree, however you were not content if redundant spans were removed. Current solution leads to the following results: 1. in the fontsize-varying-backgroundcolor-adjustment.html test there is proper span and font tags distribution without outer span. 2. in the fontsize-varying-backgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node (why not a sibling node?) but the result is proper. <font> | <span> | style="background-color: rgb(0, 255, 0);" | "333" | <font> | size="2" | <span> | style="background-color: rgb(0, 255, 0);" | "222" 3. in the fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node and extra span tag with background is added which leads to shadowing the background size by the default fontsize. If there is no going over the default fontsize then backgroundcolor is being added by css style to all nodes and it works. <font> | class="backGround" | "333" | <font> | size="2" | <span> | style="background-color: rgb(0, 255, 0);" | "222" | <font> | size="1" | <span> | style="background-color: rgb(0, 255, 0);" | "111<#selection-caret>" Can you give any hints how to deal with that?
WebKit Commit Bot
Comment 35 2014-02-05 07:35:56 PST
Attachment 223231 [details] did not pass style-queue: ERROR: Source/WebCore/editing/EditingStyle.cpp:411: An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement. [readability/control_flow] [4] Total errors found: 1 in 11 files If any of these errors are false positives, please file a bug against check-webkit-style.
Artur Moryc
Comment 36 2014-02-05 08:04:29 PST
Created attachment 223238 [details] Updating solution for the font size and backgroundcolor changes Response to previous comments: 1. > Source/WebCore/editing/EditingStyle.cpp:-1608 > -PassRefPtr<CSSValue> backgroundColorInEffect(Node* node) > -{ >Why are you rewriting this function? This was a perfectly reasonable implementation. Please have a look at Darin Adler's suggestions. 2. >We shouldn't have this outer span with background color. Yes. I agree, however you were not content if redundant spans were removed. Current solution leads to the following results: 1. in the fontsize-varying-backgroundcolor-adjustment.html test there is proper span and font tags distribution without outer span. 2. in the fontsize-varying-backgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node (why not a sibling node?) but the result is proper. <font> | <span> | style="background-color: rgb(0, 255, 0);" | "333" | <font> | size="2" | <span> | style="background-color: rgb(0, 255, 0);" | "222" 3. in the fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node and extra span tag with background is added which leads to shadowing the background size by the default fontsize. If there is no going over the default fontsize then backgroundcolor is being added by css style to all nodes and it works. <font> | class="backGround" | "333" | <font> | size="2" | <span> | style="background-color: rgb(0, 255, 0);" | "222" | <font> | size="1" | <span> | style="background-color: rgb(0, 255, 0);" | "111<#selection-caret>" Can you give any hints how to deal with that?
Artur Moryc
Comment 37 2014-02-05 08:20:45 PST
Created attachment 223239 [details] Updating solution for the font size and backgroundcolor changes
Artur Moryc
Comment 38 2014-02-06 08:48:24 PST
Created attachment 223336 [details] Updating solution for backgroundcolor and fontsize issue
Ryosuke Niwa
Comment 39 2014-02-06 20:16:09 PST
Comment on attachment 223336 [details] Updating solution for backgroundcolor and fontsize issue View in context: https://bugs.webkit.org/attachment.cgi?id=223336&action=review Please review our contribution guide: http://www.webkit.org/coding/contributing.html and address my review comments. Keep posting patches wouldn't change my mind as long as they have the same problems I've pointed out thus far. > LayoutTests/editing/inserting/fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style-expected.txt:23 > +| <font> > +| size="2" > +| <span> > +| style="background-color: rgb(0, 255, 0);" > +| "222" We shouldn't be creating a nested font/span structure like that. "background-color" property should have been added on the font element. > Source/WebCore/editing/EditingStyle.cpp:1506 > + color = style->visitedDependentColor(CSSPropertyBackgroundColor); Calling visitedDependentColor here is WRONG as I have repeatedly pointed out. visited dependent color leaks history information so we can't do this. r-.
Ryosuke Niwa
Comment 40 2014-02-06 20:21:02 PST
(In reply to comment #34) > 2. > >We shouldn't have this outer span with background color. > Yes. I agree, however you were not content if redundant spans were removed. Yes. We should strive to generate the simplest markup possible. > Current solution leads to the following results: > 1. in the fontsize-varying-backgroundcolor-adjustment.html test there is proper span and font tags distribution without outer span. > 2. in the fontsize-varying-backgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node (why not a sibling node?) but the result is proper. > <font> > | <span> > | style="background-color: rgb(0, 255, 0);" > | "333" > | <font> > | size="2" > | <span> > | style="background-color: rgb(0, 255, 0);" > | "222" > > 3. in the fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html test when it comes to going from the default fontsize the next font tag is being created as a child node and extra span tag with background is added which > leads to shadowing the background size by the default fontsize. If there is no going over the default fontsize then backgroundcolor is being added by css style to all nodes and it works. > <font> > | class="backGround" > | "333" > | <font> > | size="2" > | <span> > | style="background-color: rgb(0, 255, 0);" > | "222" > | <font> > | size="1" > | <span> > | style="background-color: rgb(0, 255, 0);" > | "111<#selection-caret>" In both cases background color should be added to the font element themselves. In general, we should avoid generating superfluous spans as much as possible.
Artur Moryc
Comment 41 2014-02-17 02:07:42 PST
Created attachment 224343 [details] Node distribution if there is no default fontsize. Can you let me know if such node distribution is ok from your viewpoint?
Artur Moryc
Comment 42 2014-02-17 02:13:02 PST
Created attachment 224345 [details] Node distribution with default fontsize. For default fontsize node distribution changes: - extra font tag is added - for default fontsize nodes are the span nodes. Can you let me know if such distribution is acceptable from your view point?
Ryosuke Niwa
Comment 43 2014-03-05 00:58:13 PST
Comment on attachment 223239 [details] Updating solution for the font size and backgroundcolor changes View in context: https://bugs.webkit.org/attachment.cgi?id=223239&action=review > LayoutTests/editing/inserting/fontsize-varying-backgroundcolor-adjustment-expected.txt:6 > +| <font> > +| size="7" > +| <span> > +| style="background-color: rgb(255, 0, 0);" > +| "777" We shouldn't generate nested font/span pairs like these.
Artur Moryc
Comment 44 2014-04-01 06:31:27 PDT
Created attachment 228280 [details] Node distribution for the default and small fontsize
Artur Moryc
Comment 45 2014-07-03 09:46:08 PDT
Created attachment 234350 [details] Solution update for the backgroundcolor while the fontsize varies
Artur Moryc
Comment 46 2014-07-04 06:45:20 PDT
Created attachment 234406 [details] Solution update for the backgroundcolor while the fontsize varies
WebKit Commit Bot
Comment 47 2014-07-04 06:47:48 PDT
Attachment 234406 [details] did not pass style-queue: ERROR: Source/WebCore/editing/EditingStyle.h:38: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 11 files If any of these errors are false positives, please file a bug against check-webkit-style.
Artur Moryc
Comment 48 2014-07-04 07:25:00 PDT
Created attachment 234410 [details] Solution update for the backgroundcolor while the fontsize varies
Darin Adler
Comment 49 2014-07-04 12:33:07 PDT
Comment on attachment 234410 [details] Solution update for the backgroundcolor while the fontsize varies View in context: https://bugs.webkit.org/attachment.cgi?id=234410&action=review Quite a few mistakes here, and not sure if the basic approach is right. We need test cases demonstrating why it’s OK for this to work only on span and font elements. Why not work on <div> and <p> elements too? What about <b> elements? > Source/WebCore/editing/ApplyStyleCommand.cpp:556 > + if (!style) > + return; Seems strange to handle null here. I don’t believe the functions below handle null. I suggest that this function take EditingStyle& instead of EditingStyle&. > Source/WebCore/editing/ApplyStyleCommand.cpp:564 > + if (node->isTextNode() && node->parentNode()) > + node = node->parentNode(); > + if (node->hasTagName(spanTag) || node->hasTagName(fontTag)) { The behavior here is bizarre. This function works only on span elements, font elements, and text elements that are just inside one of those two. How could that possibly be correct? The text node part seems particularly peculiar. If the function doesn’t work on all nodes, why would it specifically do the parent thing for text nodes? > Source/WebCore/editing/ApplyStyleCommand.cpp:565 > + String backgroundColorString = mutableStyle ? mutableStyle->getPropertyValue(CSSPropertyBackgroundColor) : emptyString(); No need to re-check mutableStyle for null here since you are already doing it above. > Source/WebCore/editing/ApplyStyleCommand.cpp:568 > + if (backgroundColor.isValid() && backgroundColor.alpha()) { Don’t need to also check isValid if we are checking alpha for zero since all invalid colors have RGBA of 0. > Source/WebCore/editing/ApplyStyleCommand.cpp:572 > + if (backgroundColorString.length() && htmlElement) It doesn’t make sense to check htmlElement for null here. It will only be null if node was null, and we have already dereferenced null. Should be using isEmpty here rather than checking length. > Source/WebCore/editing/ApplyStyleCommand.cpp:576 > + } > + } > + } These braces are indented incorrectly. > Source/WebCore/editing/EditingStyle.cpp:392 > + if (!colorValue.isValid() || !colorValue.alpha()) > + return Color::transparent; This code is repeated twice, here and in colorValueToRGBA. We don’t need it twice. If we’re checking for alpha of zero, we don’t also have to check isValid; invalid colors have RGBA of 0. > Source/WebCore/editing/EditingStyle.cpp:439 > + if (value.isValid() && value.alpha()) If we’re checking for alpha of zero, we don’t also have to check isValid; invalid colors have RGBA of 0. > Source/WebCore/editing/EditingStyle.cpp:1291 > + if (value.isValid() && value.alpha()) If we’re checking for alpha of zero, we don’t also have to check isValid; invalid colors have RGBA of 0. > Source/WebCore/editing/EditingStyle.cpp:1647 > + if (!ancestor || !ancestor->renderStyle()) > + continue; There’s no need to check !ancestor here. That’s already in the loop condition. It doesn’t make much sense to check renderStyle for null, and then using computedStyle. The main point of computedStyle is that it can give us a color even when the render style is not available. If we require a renderStyle then we should just use it. What guarantees that style is updated? One of this things that ComputedStyleExtractor::propertyValue does is call the appropriate layout functions, such as updateLayoutIgnorePendingStylesheets and such. If you are removing it, then the new code has to handle that issue somehow. Style isn’t guaranteed to already be computed when this function is called. > Source/WebCore/editing/EditingStyle.cpp:1648 > + RenderStyle* style = ancestor->computedStyle(); I don’t think we should be using computedStyle at all. > Source/WebCore/editing/EditingStyle.cpp:1652 > + if (color.isValid() && color.alpha()) If we’re checking for alpha of zero, we don’t also have to check isValid; invalid colors have RGBA of 0. > Source/WebCore/editing/EditingStyle.h:37 > +#include "Color.h" A return value of Color does not require including the entire Color header. A forward class declaration will suffice.
Artur Moryc
Comment 50 2014-09-23 11:15:09 PDT
Created attachment 238550 [details] Solution update for the backgroundcolor while the fontsize varies Tank you for previous comments. Please, have a look also at the charts backgroundColorFontsizeItalic_setInlineStyleProperty.png and backgrounColorFonssizeItalic_No_setInlineStyle.png which show the node distribution for the case pointed out in the last review i.e. whether the proposed solution is still valid if backgroundcolor and ather style like italic are set with the font size varying. Also the charts show that the styles once set are being continued if a new paragraph is added. Regards, Artur M.
Artur Moryc
Comment 51 2014-09-23 11:17:56 PDT
Created attachment 238551 [details] Node distribution for the latest patch This chart shows the node distribution for the latest patch
Artur Moryc
Comment 52 2014-09-23 11:25:19 PDT
Created attachment 238553 [details] Node distribution This chart show the node distribution for the latest patch without setting setInlineStyleProperty(CSSPropertyBackgroundColor, backgroundColorString); in the setPropertyAndInlineStylePropertyWithBackgroundColorIfNeeded method. But then for one case in the fontsize-varying-cssBackgroundcolor-adjustment-if-continue-style.html test- as described in the change log, the bug still exists.
Artur Moryc
Comment 53 2014-11-25 07:58:11 PST
Dear reviewer can you comment?
Michael Catanzaro
Comment 54 2016-09-17 07:06:15 PDT
Comment on attachment 238550 [details] Solution update for the backgroundcolor while the fontsize varies Hi, Apologies that your patch was not reviewed in a timely manner. Since it's now quite old, I am removing it from the review request queue. Please consider rebasing it on trunk and resubmitting. To increase the chances of getting a review, consider using 'Tools/Scripts/webkit-patch upload --suggest-reviewers' to CC reviewers who might be interested in this bug.
Ahmad Saleem
Comment 55 2022-06-01 14:25:28 PDT
Created attachment 459934 [details] Safari 15.5 matches other browsers Based on screenshots and reproduction of test case, I think all browser matches each other and this might have been fixed. If the attached in screenshot is not intended behavior, appreciate if someone can provide an update. Else I think this can be marked as "RESOLVED CONFIGURATION CHANGED" or "RESOLVED INVALID". Thanks!
Alexey Proskuryakov
Comment 56 2022-06-01 14:42:44 PDT
I believe that the intention here is to improve on status quo. It's not obvious to me personally if the proposed behavior is better, but that's what people have been driving towards here.
Note You need to log in before you can comment on or make changes to this bug.