Bug 119137 - [CSS Regions] Selecting text through different regions flow does not match with highlight
Summary: [CSS Regions] Selecting text through different regions flow does not match wi...
Status: RESOLVED DUPLICATE of bug 131511
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 118668
  Show dependency treegraph
 
Reported: 2013-07-26 01:39 PDT by Manuel Rego Casasnovas
Modified: 2014-04-23 04:45 PDT (History)
8 users (show)

See Also:


Attachments
HTML test to reproduce the issue (2.88 KB, text/html)
2013-07-26 01:42 PDT, Manuel Rego Casasnovas
no flags Details
Patch (12.70 KB, patch)
2013-07-29 03:27 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (12.70 KB, patch)
2013-07-29 03:30 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (12.71 KB, patch)
2013-07-29 04:17 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
additional test case (2.77 KB, text/html)
2013-07-31 13:09 PDT, Zoltan Horvath
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2013-07-26 01:39:47 PDT
When you select text through different regions flow the selection highlights only the text in the same flow. However, if you get the content of the selection it also includes text in other flow.

This issues seems to be related to the patch for bug #105641 (r139197) in which the selection is controlled in render side, but nothing is done in editing part so the selection actually contains more text.
Comment 1 Manuel Rego Casasnovas 2013-07-26 01:42:28 PDT
Created attachment 207515 [details]
HTML test to reproduce the issue
Comment 2 Manuel Rego Casasnovas 2013-07-29 03:27:08 PDT
Created attachment 207631 [details]
Patch
Comment 3 Manuel Rego Casasnovas 2013-07-29 03:30:57 PDT
Created attachment 207632 [details]
Patch
Comment 4 Manuel Rego Casasnovas 2013-07-29 04:17:17 PDT
Created attachment 207639 [details]
Patch
Comment 5 Zoltan Horvath 2013-07-30 10:40:08 PDT
Comment on attachment 207639 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review

> Source/WebCore/ChangeLog:1
> +2013-07-29  Javier Fernandez  <jfernandez@igalia.com>
> LayoutTests/ChangeLog:1
> +2013-07-29  Manuel Rego Casasnovas  <rego@igalia.com>

The author is different for the 2 changelogs. Is it intentional?

> Source/WebCore/rendering/RenderView.cpp:-728
> -    if ((start && end) && (start->flowThreadContainingBlock() != end->flowThreadContainingBlock()))

I think at the point we remove this condition we should be able to select content through different regions.

I have some questions.

Wouldn't be easier to fix the highlighting of the selection? Or do you already have a plan to achieve that based on the actual patch? (Is this change necessary beside with the work in bug #106817 ?)
Comment 6 Javier Fernandez 2013-07-30 11:37:21 PDT
(In reply to comment #5)
> (From update of attachment 207639 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review
> 
> > Source/WebCore/ChangeLog:1
> > +2013-07-29  Javier Fernandez  <jfernandez@igalia.com>
> > LayoutTests/ChangeLog:1
> > +2013-07-29  Manuel Rego Casasnovas  <rego@igalia.com>
> 
> The author is different for the 2 changelogs. Is it intentional?
> 

The WebCore patch was extracted, actually, from the patch posted at bug #106817, but, since it covers only a specific case, a new and simpler test was added. I guess that's the reason, but rego should tell. 

> > Source/WebCore/rendering/RenderView.cpp:-728
> > -    if ((start && end) && (start->flowThreadContainingBlock() != end->flowThreadContainingBlock()))
> 
> I think at the point we remove this condition we should be able to select content through different regions.

Actually, this patch makes the highlighting to behave exactly as yours, but it solved at editing side, which I think is more appropriated and solves also other issues related to the selected content. More on this below.

> 
> I have some questions.
> 
> Wouldn't be easier to fix the highlighting of the selection? Or do you already have a plan to achieve that based on the actual patch? (Is this change necessary beside with the work in bug #106817 ?)

As I said before, this patch solves the highlighting issue as well. The approach followed in the patch for bug #106817 is based on multi-range, which was strongly rejected by some reviewers. Actually, there is an ongoing thread about this matter in the mailing list, still without many contributions, though. 

With this patch, when user selects content starting outside the region and ending inside, not only the highlighting works, but also the content inside the region is skipped too, so we think is more coherent which what user would expect.

It's important to notice that both, this patch and the one you provided for bug #105641 assume we won't allow the user to select content from different Flow Threads, which we thought it was a good start.  However, given the negative feedback we have been getting from the multi-range approach, we are thinking on keeping the selection as DOM based, even when the user would get weird selected content when flow named nodes are inside the selection boundaries.
Comment 7 Zoltan Horvath 2013-07-31 13:09:49 PDT
Created attachment 207874 [details]
additional test case

(In reply to comment #6)
> (In reply to comment #5)
> > (From update of attachment 207639 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review
> > 
> > > Source/WebCore/ChangeLog:1
> > > +2013-07-29  Javier Fernandez  <jfernandez@igalia.com>
> > > LayoutTests/ChangeLog:1
> > > +2013-07-29  Manuel Rego Casasnovas  <rego@igalia.com>
> > 
> > The author is different for the 2 changelogs. Is it intentional?
> > 
> 
> The WebCore patch was extracted, actually, from the patch posted at bug #106817, but, since it covers only a specific case, a new and simpler test was added. I guess that's the reason, but rego should tell. 
> 
> > > Source/WebCore/rendering/RenderView.cpp:-728
> > > -    if ((start && end) && (start->flowThreadContainingBlock() != end->flowThreadContainingBlock()))
> > 
> > I think at the point we remove this condition we should be able to select content through different regions.
> 
> Actually, this patch makes the highlighting to behave exactly as yours, but it solved at editing side, which I think is more appropriated and solves also other issues related to the selected content. More on this below.

Yes, that's true!

> > I have some questions.
> > 
> > Wouldn't be easier to fix the highlighting of the selection? Or do you already have a plan to achieve that based on the actual patch? (Is this change necessary beside with the work in bug #106817 ?)
> 
> As I said before, this patch solves the highlighting issue as well. The approach followed in the patch for bug #106817 is based on multi-range, which was strongly rejected by some reviewers. Actually, there is an ongoing thread about this matter in the mailing list, still without many contributions, though. 
> 
> With this patch, when user selects content starting outside the region and ending inside, not only the highlighting works, but also the content inside the region is skipped too, so we think is more coherent which what user would expect.
> 
> It's important to notice that both, this patch and the one you provided for bug #105641 assume we won't allow the user to select content from different Flow Threads, which we thought it was a good start.  However, given the negative feedback we have been getting from the multi-range approach, we are thinking on keeping the selection as DOM based, even when the user would get weird selected content when flow named nodes are inside the selection boundaries.

Thanks for the clarification. I ramped up on the topic now. We should go along with this approach for now. I like the change, but I miss some other cases from the solution. 
I attached a test case which includes some bad smell. As you see the highlighted content and the actual selected content isn't going to be the same. Can you take a look at it? 
In the meantime I'm going to raise some questions in the previous bug to Ryosuke.
Comment 8 Manuel Rego Casasnovas 2013-07-31 13:44:21 PDT
(In reply to comment #7)
> Created an attachment (id=207874) [details]
> additional test case
> 
> (In reply to comment #6)
> > (In reply to comment #5)
> > > (From update of attachment 207639 [details] [details] [details])
> > > View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review
> > > 
> > > > Source/WebCore/ChangeLog:1
> > > > +2013-07-29  Javier Fernandez  <jfernandez@igalia.com>
> > > > LayoutTests/ChangeLog:1
> > > > +2013-07-29  Manuel Rego Casasnovas  <rego@igalia.com>
> > > 
> > > The author is different for the 2 changelogs. Is it intentional?
> > > 
> > 
> > The WebCore patch was extracted, actually, from the patch posted at bug #106817, but, since it covers only a specific case, a new and simpler test was added. I guess that's the reason, but rego should tell. 

About the author it was just basically because of Javi did the patch itself and I wrote the test. But we can change it if you think it's wrong.

> Thanks for the clarification. I ramped up on the topic now. We should go along with this approach for now. I like the change, but I miss some other cases from the solution. 
> I attached a test case which includes some bad smell. As you see the highlighted content and the actual selected content isn't going to be the same. Can you take a look at it? 
> In the meantime I'm going to raise some questions in the previous bug to Ryosuke.

The idea of this patch was just to fix the initial issue. As stopping the highlight at render side don't seem like the best option compared to doing the same at editing side.

We know that there're still more use cases pending to be fixed. Some of them (like the one you attached) are fixed with the patch for bug #106817 (and other more complex will appear under the meta bug #118668). However, we preferred to split this in order to make easier the review process.

So, this is a first simple patch to fix some concrete issues of doing this in the render side instead of editing side. Maybe we could get this initial patch landed and carry on fixing other stuff in later bugs.
Comment 9 Zoltan Horvath 2013-07-31 14:05:42 PDT
(In reply to comment #8)
> About the author it was just basically because of Javi did the patch itself and I wrote the test. But we can change it if you think it's wrong.

That's fine, but it was just odd. :)

> The idea of this patch was just to fix the initial issue. As stopping the highlight at render side don't seem like the best option compared to doing the same at editing side.

I agree, I support the solution!
 
> We know that there're still more use cases pending to be fixed. Some of them (like the one you attached) are fixed with the patch for bug #106817 (and other more complex will appear under the meta bug #118668). However, we preferred to split this in order to make easier the review process.
> 
> So, this is a first simple patch to fix some concrete issues of doing this in the render side instead of editing side. Maybe we could get this initial patch landed and carry on fixing other stuff in later bugs.

I would wait for response from Ryosuke on the previous bug, but since this change doesn't harm anything and fixes an issue, I'm saying let's do this.
Comment 10 Ryosuke Niwa 2013-07-31 15:59:32 PDT
Comment on attachment 207639 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review

> Source/WebCore/editing/FrameSelection.cpp:307
> +    if (atDifferentFlowThread(s.base(), s.extent()))
> +        return;
> +

This is not the right place to fix this. We need to do this inside VisibleSelection::validate probably right before or right after we call adjustSelectionToAvoidCrossingShadowBoundaries.
Comment 11 Javier Fernandez 2013-08-01 03:56:26 PDT
(In reply to comment #10)
> (From update of attachment 207639 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207639&action=review
> 
> > Source/WebCore/editing/FrameSelection.cpp:307
> > +    if (atDifferentFlowThread(s.base(), s.extent()))
> > +        return;
> > +
> 
> This is not the right place to fix this. We need to do this inside VisibleSelection::validate probably right before or right after we call adjustSelectionToAvoidCrossingShadowBoundaries.

The purpose of this patch is to avoid setting a new VisibleSelection instance to the FrameSelection if it's incompatible in terms of RenderFlow. For the shake of clarity, I've taken the assumption that only selections starting and ending in the same FlowThread, or both outside, are allowed. On the other hand, that's the current behaviour after the fix for the bug #105641. This patch keep that behaviour form the rendering point of view, but at the same time targeting also the issues related to the selected content.

Getting back to your suggestion of implementing this in the VisibleSelection::validate(), this method is intended for adjusting the new Selection to fit in some validation rules. It's not necessary to adjust the new selection, since the one already set before in the FrameSelection instance is correct.

If done at validation() we should move back the extent Position to the last one FlowThread compatible, which it would require to explore the DOM. This could have also an impact on performance, even more considering validate(9 is called a lot of times, overall, when selection is performed by user gestures. 

After all this, do you still think VisibleSelection::validate() is the right place to put this logic ?
Comment 12 Manuel Rego Casasnovas 2014-04-23 04:44:54 PDT
Comment on attachment 207639 [details]
Patch

Clearing flags.
Comment 13 Manuel Rego Casasnovas 2014-04-23 04:45:09 PDT

*** This bug has been marked as a duplicate of bug 131511 ***