Bug 32285 - REGRESSION: With 2 highlighted lines of text in gmail/hotmail selecting Bold selects other 2 edit buttons automatically
Summary: REGRESSION: With 2 highlighted lines of text in gmail/hotmail selecting Bold ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All OS X 10.5
: P2 Normal
Assignee: Enrica Casucci
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2009-12-08 13:48 PST by Enrica Casucci
Modified: 2009-12-10 15:00 PST (History)
5 users (show)

See Also:


Attachments
Repro case (1.22 KB, text/html)
2009-12-08 13:48 PST, Enrica Casucci
no flags Details
Patch (5.55 KB, patch)
2009-12-08 15:04 PST, Enrica Casucci
oliver: review+
Details | Formatted Diff | Diff
Patch3 (10.06 KB, patch)
2009-12-10 14:43 PST, Enrica Casucci
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrica Casucci 2009-12-08 13:48:27 PST
Created attachment 44483 [details]
Repro case

* STEPS TO REPRODUCE
1. login to gmail, create new mail msg
2. type any two lines of text (one [enter] two)
3. Select all  (Ctrl-A)
4. CLick Bold edit button

* RESULTS
All three buttons (Bold, Italic and Underline) get selected, text is modified according to 1 selection made by user.
Comment 1 Enrica Casucci 2009-12-08 15:04:42 PST
Created attachment 44489 [details]
Patch
Comment 2 WebKit Review Bot 2009-12-08 15:07:58 PST
style-queue ran check-webkit-style on attachment 44489 [details] without any errors.
Comment 3 Darin Adler 2009-12-09 09:43:24 PST
Comment on attachment 44489 [details]
Patch

Enrica,

Did you look at <http://trac.webkit.org/changeset/46920>, the changeset that introduced this feature? Could you explain why the change wasn't needed to fix the bug that was being fixed back then? That changeset says something about "platforms other than Mac". Will this change of yours break some regression test on non-Mac platforms?
Comment 4 Enrica Casucci 2009-12-09 09:54:39 PST
(In reply to comment #3)
> (From update of attachment 44489 [details])
> Enrica,
> 
> Did you look at <http://trac.webkit.org/changeset/46920>, the changeset that
> introduced this feature? Could you explain why the change wasn't needed to fix
> the bug that was being fixed back then? That changeset says something about
> "platforms other than Mac". Will this change of yours break some regression
> test on non-Mac platforms?

I did look at the changeset and I honestly do not understand why it was done that way.
The original code was ignoring a number of style attributes for non-text nodes during the comparison.
Can I run the tests on Windows to verify that I haven't broken anything?
Comment 5 Darin Adler 2009-12-09 10:09:05 PST
I suggest sending mail to webkit-dev to see if anyone can remember. I don't think Justin or Ryosuke are going to be reachable.

> The original code was ignoring a number of style attributes for non-text nodes
> during the comparison.

Yes, I saw that. There must have been some reason to do so.

> Can I run the tests on Windows to verify that I haven't broken anything?

My guess is that if tests pass on both Mac and Windows (the patch says "platforms other than Mac", so those two platform should be enough) that means either you didn't break anything, or the tests checked in with the original change were insufficient.
Comment 6 Ryosuke Niwa 2009-12-09 19:42:14 PST
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 44489 [details] [details])
> > Enrica,
> > 
> > Did you look at <http://trac.webkit.org/changeset/46920>, the changeset that
> > introduced this feature? Could you explain why the change wasn't needed to fix
> > the bug that was being fixed back then? That changeset says something about
> > "platforms other than Mac". Will this change of yours break some regression
> > test on non-Mac platforms?
> 
> I did look at the changeset and I honestly do not understand why it was done
> that way.
> The original code was ignoring a number of style attributes for non-text nodes
> during the comparison.
> Can I run the tests on Windows to verify that I haven't broken anything?

In platforms other than Mac, the entire selected text needs to have the specified style as supposed to just the beginning of selection in Mac.  And when the selection contains non-text-node such as div element that does not contain any text, WebKit used to detect that the style isn't present since elements without text nodes may lack the particular style.  The changeset 46920 was introduced to avoid this problem by ignoring non-text-nodes since those do not contribute to the style.
Comment 7 Ryosuke Niwa 2009-12-09 19:58:19 PST
To see this behavior, modify executeToggleStyle locally to use the default behavior:
http://trac.webkit.org/browser/trunk/WebCore/editing/EditorCommand.cpp#L157

To illustrate this behavioral change in Mac and other platforms, consider:
<b>hello</b>world

When this text is selected, query state for bold returns true for Mac but returns false for other platforms.
Comment 8 Enrica Casucci 2009-12-10 09:35:07 PST
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > (From update of attachment 44489 [details] [details] [details])
> > > Enrica,
> > > 
> > > Did you look at <http://trac.webkit.org/changeset/46920>, the changeset that
> > > introduced this feature? Could you explain why the change wasn't needed to fix
> > > the bug that was being fixed back then? That changeset says something about
> > > "platforms other than Mac". Will this change of yours break some regression
> > > test on non-Mac platforms?
> > 
> > I did look at the changeset and I honestly do not understand why it was done
> > that way.
> > The original code was ignoring a number of style attributes for non-text nodes
> > during the comparison.
> > Can I run the tests on Windows to verify that I haven't broken anything?
> 
> In platforms other than Mac, the entire selected text needs to have the
> specified style as supposed to just the beginning of selection in Mac.  And
> when the selection contains non-text-node such as div element that does not
> contain any text, WebKit used to detect that the style isn't present since
> elements without text nodes may lack the particular style.  The changeset 46920
> was introduced to avoid this problem by ignoring non-text-nodes since those do
> not contribute to the style.
Thanks for the explanation, now I understand and I've verified that the fix breaks the test you added on platforms other than Mac. The original code still has a problem when you have something like
<b>hello</b><div><b>world</b></div> and you call queryCommandState("italic").
When looking at the first node the answer is false, but as you move to the div node the answer becomes true.
Now that I fully understand the goal of your patch, I'll post a new fix that takes into that into account.
Comment 9 Ryosuke Niwa 2009-12-10 13:04:48 PST
(In reply to comment #8)
> > In platforms other than Mac, the entire selected text needs to have the
> > specified style as supposed to just the beginning of selection in Mac.  And
> > when the selection contains non-text-node such as div element that does not
> > contain any text, WebKit used to detect that the style isn't present since
> > elements without text nodes may lack the particular style.  The changeset 46920
> > was introduced to avoid this problem by ignoring non-text-nodes since those do
> > not contribute to the style.
> Thanks for the explanation, now I understand and I've verified that the fix
> breaks the test you added on platforms other than Mac. The original code still
> has a problem when you have something like
> <b>hello</b><div><b>world</b></div> and you call queryCommandState("italic").
> When looking at the first node the answer is false, but as you move to the div
> node the answer becomes true.
> Now that I fully understand the goal of your patch, I'll post a new fix that
> takes into that into account.

Sorry about the regression, I guess I wasn't considering the case where there was no text-node. It seems like we need an extra condition that at least one text node has the given style.
Comment 10 Enrica Casucci 2009-12-10 14:43:31 PST
Created attachment 44640 [details]
Patch3

This patch fixes the issue for all the platforms.
Comment 11 WebKit Review Bot 2009-12-10 14:48:46 PST
style-queue ran check-webkit-style on attachment 44640 [details] without any errors.
Comment 12 Enrica Casucci 2009-12-10 15:00:20 PST
Committed revision 51965.