Bug 61562 - Switch paintCustomHighlight to use IntPoint
Summary: Switch paintCustomHighlight to use IntPoint
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Levi Weintraub
URL:
Keywords:
Depends on:
Blocks: 60318 61891
  Show dependency treegraph
 
Reported: 2011-05-26 14:29 PDT by Levi Weintraub
Modified: 2011-06-01 17:46 PDT (History)
6 users (show)

See Also:


Attachments
Patch (10.55 KB, patch)
2011-05-26 16:09 PDT, Levi Weintraub
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Levi Weintraub 2011-05-26 14:29:03 PDT
Removing tx/ty.
Comment 1 Levi Weintraub 2011-05-26 14:43:35 PDT
The paint code *mostly* treats tx/ty like a size, but Darin's comment https://bugs.webkit.org/show_bug.cgi?id=60783#c6 is still echoing in my mind before I convert all the paint code to one or the other...
Comment 2 Darin Adler 2011-05-26 14:57:57 PDT
It’s hard to tell points and sizes apart when we have nested coordinate systems. The distance from the top left to a rect is a “size”, yet it’s expressed as an origin point. I think that whenever we can’t decide, we should use IntPoint, and we should use IntSize only when it’s clearly the size of something, not just a distance (a point described relative to another point).
Comment 3 Levi Weintraub 2011-05-26 15:15:04 PDT
Thanks Darin. I like that idea a lot.
Comment 4 Emil A Eklund 2011-05-26 15:23:52 PDT
One of the drawbacks of using IntPoint for this is lack of an easy way to adjust one point by another. Adding IntPoint, IntPoint versions of the + and += operators would alleviate this concern even though strictly speaking adding two points doesn't make a whole lot of sense.
Comment 5 Levi Weintraub 2011-05-26 15:50:07 PDT
Plus currently adding two points yields a size, which conceptually makes sense, but can be quite unfortunate in practice...
Comment 6 Eric Seidel (no email) 2011-05-26 15:56:46 PDT
I can't tell if our problem is that the Size/Point division is broken, or if that the Rendering tree is just not designed in a way to use Size/Point elegantly.  Probably a combination of both.
Comment 7 Eric Seidel (no email) 2011-05-26 15:58:41 PDT
(In reply to comment #6)
> I can't tell if our problem is that the Size/Point division is broken, or if that the Rendering tree is just not designed in a way to use Size/Point elegantly.  Probably a combination of both.

"broken" is a stronger word than I mean.  I suspect that one could re-design the rendering tree to work nicely with Points and Sizes.  But as written, the division is very cumbersome to work with.
Comment 8 Levi Weintraub 2011-05-26 16:09:52 PDT
Created attachment 95065 [details]
Patch
Comment 9 Darin Adler 2011-05-26 16:44:26 PDT
(In reply to comment #4)
> One of the drawbacks of using IntPoint for this is lack of an easy way to adjust one point by another. Adding IntPoint, IntPoint versions of the + and += operators would alleviate this concern even though strictly speaking adding two points doesn't make a whole lot of sense.

Yes, we should add those. There is almost no downside.
Comment 10 Darin Adler 2011-05-26 16:44:36 PDT
(In reply to comment #5)
> Plus currently adding two points yields a size, which conceptually makes sense, but can be quite unfortunate in practice...

You mean subtracting, right?
Comment 11 Darin Adler 2011-05-26 16:45:38 PDT
(In reply to comment #7)
> (In reply to comment #6)
> > I can't tell if our problem is that the Size/Point division is broken, or if that the Rendering tree is just not designed in a way to use Size/Point elegantly.  Probably a combination of both.
> 
> "broken" is a stronger word than I mean.  I suspect that one could re-design the rendering tree to work nicely with Points and Sizes.  But as written, the division is very cumbersome to work with.

I don’t agree that you could do that. The fundamental question is whether an origin point is a point or a size. Making it a size sounds logical but it’s no good, because there is a thing called a coordinate system, where a point is an origin and another point is relative to that point.
Comment 12 Eric Seidel (no email) 2011-05-26 17:38:14 PDT
(In reply to comment #11)
> (In reply to comment #7)
> > (In reply to comment #6)
> > > I can't tell if our problem is that the Size/Point division is broken, or if that the Rendering tree is just not designed in a way to use Size/Point elegantly.  Probably a combination of both.
> > 
> > "broken" is a stronger word than I mean.  I suspect that one could re-design the rendering tree to work nicely with Points and Sizes.  But as written, the division is very cumbersome to work with.
> 
> I don’t agree that you could do that. The fundamental question is whether an origin point is a point or a size. Making it a size sounds logical but it’s no good, because there is a thing called a coordinate system, where a point is an origin and another point is relative to that point.

We could use a system more like SVG where instead of passing in the origin relative to the containing block, we instead transform the points/CTM as we go up the call stack (also seen as transforming the resulting rects/points as we come back down the call stack).

This would mean changing hit testing to translate the passed in hit point into the child's coordinate system before passing it in, instead of building up a tx, ty (which we can't decide if it's a point vs. size).
http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp#L165

Similarly, we could have all methods on objects return things in local coordinates with the responsibility of the calling parent to translate as necessary.
http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp#L61
http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp#L168

But my thinking may be too tied to the SVG world and not fitting what is actually needed for CSS.
Comment 13 Levi Weintraub 2011-06-01 16:37:30 PDT
*Ping* for review. This is starting to get in the way.
Comment 14 Eric Seidel (no email) 2011-06-01 16:41:15 PDT
Comment on attachment 95065 [details]
Patch

Sorry, I just didn't see it go by.
Comment 15 Levi Weintraub 2011-06-01 16:43:28 PDT
(In reply to comment #14)
> (From update of attachment 95065 [details])
> Sorry, I just didn't see it go by.

Thanks! I tried to ping ya on IRC but you weren't there :)
Comment 16 Eric Seidel (no email) 2011-06-01 16:44:10 PDT
Sorry, been doing an OS re-installs and forget to log back on.
Comment 17 Levi Weintraub 2011-06-01 17:46:51 PDT
Committed r87866: <http://trac.webkit.org/changeset/87866>