Bug 38488 - Spatial Navigation: create a getter for the "fudgeFactor"
Summary: Spatial Navigation: create a getter for the "fudgeFactor"
Status: CLOSED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Antonio Gomes
URL:
Keywords:
Depends on:
Blocks: 35784
  Show dependency treegraph
 
Reported: 2010-05-03 14:33 PDT by Antonio Gomes
Modified: 2010-05-11 03:21 PDT (History)
3 users (show)

See Also:


Attachments
patch v1 (4.57 KB, patch)
2010-05-03 14:46 PDT, Antonio Gomes
no flags Details | Formatted Diff | Diff
patch v2 (4.85 KB, patch)
2010-05-07 12:49 PDT, Antonio Gomes
no flags Details | Formatted Diff | Diff
(committed with r59045, reviewed by Kenneth) patch v2.1 - same as v2, but fixing a minor (4.84 KB, patch)
2010-05-07 17:48 PDT, Antonio Gomes
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Gomes 2010-05-03 14:33:21 PDT
A couple of places in the Spatial Navigation code make use of a "fudge factor" to improve precision by working around outline focus metrics and such.

Currently each function using that has its own fudgeFactor variable declared locally. It makes sense to provide a getter for this so when it is to be changed it needs changing in one place only.

patch coming ...
Comment 1 Antonio Gomes 2010-05-03 14:46:06 PDT
Created attachment 54961 [details]
patch v1

Adds a getter for the "fudgeFactor"
Comment 2 Kenneth Rohde Christiansen 2010-05-06 08:00:17 PDT
Comment on attachment 54961 [details]
patch v1

WebCore/page/SpatialNavigation.cpp:481
 +      bounds.inflate(-fudgeFactor());
Maybe the minus here needs a comment, and you use it positively elsewhere.
Comment 3 Antonio Gomes 2010-05-07 11:46:24 PDT
(In reply to comment #2)
> (From update of attachment 54961 [details])
> WebCore/page/SpatialNavigation.cpp:481
>  +      bounds.inflate(-fudgeFactor());
> Maybe the minus here needs a comment, and you use it positively elsewhere.

In fact, the fudgetFactor is a negative value. See 

+inline int fudgeFactor()
+{
+    return -2;
+}

so in this case, I am really inflating the rect by doing inflate(-1*(-2)) , while in the case of

static void deflateIfOverlapped(IntRect& a, IntRect& b)
{
(..)
-  static const int fudgeFactor = -2;
-
   // Avoid negative width or height values.
-  if ((a.width() + 2 * fudgeFactor > 0) && (a.height() + 2 * fudgeFactor > 0))
-    a.inflate(fudgeFactor);
+  if ((a.width() + 2 * fudgeFactor() > 0) && (a.height() + 2 * fudgeFactor() > 0))
+    a.inflate(fudgeFactor());

... I am deflating the rects. Since IntRect has no deflate() method, I do inflate(negative_value).
Comment 4 Kenneth Rohde Christiansen 2010-05-07 12:27:05 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 54961 [details] [details])
> > WebCore/page/SpatialNavigation.cpp:481
> >  +      bounds.inflate(-fudgeFactor());
> > Maybe the minus here needs a comment, and you use it positively elsewhere.
> 
> In fact, the fudgetFactor is a negative value. See 
> 
> +inline int fudgeFactor()
> +{
> +    return -2;
> +}
> 
> so in this case, I am really inflating the rect by doing inflate(-1*(-2)) ,
> while in the case of
> 
> static void deflateIfOverlapped(IntRect& a, IntRect& b)
> {
> (..)
> -  static const int fudgeFactor = -2;
> -
>    // Avoid negative width or height values.
> -  if ((a.width() + 2 * fudgeFactor > 0) && (a.height() + 2 * fudgeFactor > 0))
> -    a.inflate(fudgeFactor);
> +  if ((a.width() + 2 * fudgeFactor() > 0) && (a.height() + 2 * fudgeFactor() >
> 0))
> +    a.inflate(fudgeFactor());
> 
> ... I am deflating the rects. Since IntRect has no deflate() method, I do
> inflate(negative_value).

I would prefer you using a positive fudgeFactor (btw that is not really a factor, but a constant) and add the minuses in the code itself. You could even make fudgeFactor return a unsigned int.
Comment 5 Antonio Gomes 2010-05-07 12:49:40 PDT
Created attachment 55409 [details]
patch v2


> I would prefer you using a positive fudgeFactor (btw that is not really a
> factor, but a constant) and add the minuses in the code itself. You could even
> make fudgeFactor return a unsigned int.

done
Comment 6 Antonio Gomes 2010-05-07 17:48:54 PDT
Created attachment 55443 [details]
(committed with r59045, reviewed by Kenneth) patch v2.1 - same as v2, but fixing a minor

Patch 55409 (v2) was doing a assignment of a negative value to a unsigned int variable. patch 2.1 fixes that. Other than that it is the same.
Comment 7 Kenneth Rohde Christiansen 2010-05-07 17:58:00 PDT
Comment on attachment 55443 [details]
(committed with r59045, reviewed by Kenneth) patch v2.1 - same as v2, but fixing a minor

r=me, though I would still prefer another name, it is not a factor as you are not really multiplying with it, but just doing inflate/deflate. Maybe fudgeThickness?
Comment 8 Antonio Gomes 2010-05-07 20:32:21 PDT
(In reply to comment #7)
> (From update of attachment 55443 [details])
> r=me, though I would still prefer another name, it is not a factor as you are
> not really multiplying with it, but just doing inflate/deflate. Maybe
> fudgeThickness?

Hi Kenne, thank you for looking at the patch. 

fudgeThickness works for me here , but the expression/term "fudge factor" is being used in many other parts of WebCore with the same meaning. I'd rather like to keep it, unless you really think it needs change.

$ grep -nHRi fudge WebCore/ --exclude=*ChangeLog*
- WebCore/rendering/RenderLayer.cpp:3085:        result.inflate(view->maximalOutlineSize()); // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
- WebCore/rendering/RenderView.h:190:    int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables.
- WebCore/rendering/RenderBlock.cpp:56:// Number of pixels to allow as a fudge factor when clicking above or below a line.
- WebCore/rendering/RenderBlock.cpp:57:// clicking up to verticalLineClickFudgeFactor pixels above a line will correspond to the closest point on the line.   
- WebCore/rendering/RenderBlock.cpp:58:static const int verticalLineClickFudgeFactor = 3;


$ grep -nHRi fudge WebKit --exclude=*ChangeLog*
- WebKit/mac/WebView/WebView.mm:5073:    // As a fudge factor, use 1000 instead of 1024, in case the reported byte
Comment 9 Kenneth Rohde Christiansen 2010-05-08 08:32:26 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > (From update of attachment 55443 [details] [details])
> > r=me, though I would still prefer another name, it is not a factor as you are
> > not really multiplying with it, but just doing inflate/deflate. Maybe
> > fudgeThickness?
> 
> Hi Kenne, thank you for looking at the patch. 
> 
> fudgeThickness works for me here , but the expression/term "fudge factor" is
> being used in many other parts of WebCore with the same meaning. I'd rather
> like to keep it, unless you really think it needs change.

OK fine, it is already r+ :-)
Comment 10 Antonio Gomes 2010-05-08 20:32:18 PDT
Comment on attachment 55443 [details]
(committed with r59045, reviewed by Kenneth) patch v2.1 - same as v2, but fixing a minor

Clearing flags on attachment: 55443

Committed r59045: <http://trac.webkit.org/changeset/r59045>
Comment 11 Simon Hausmann 2010-05-11 03:21:08 PDT
Revision r59045 cherry-picked into qtwebkit-2.0 with commit 836023e07365d07b7ab58a161939184e46375368