<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>42653</bug_id>
          
          <creation_ts>2010-07-20 10:59:01 -0700</creation_ts>
          <short_desc>IntSize / FloatSize: add invalid() and isValid() helper methods</short_desc>
          <delta_ts>2010-08-06 13:21:53 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Antonio Gomes">tonikitoo</reporter>
          <assigned_to name="Antonio Gomes">tonikitoo</assigned_to>
          <cc>darin</cc>
    
    <cc>kenneth</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>253818</commentid>
    <comment_count>0</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 10:59:01 -0700</bug_when>
    <thetext>In comment https://bugs.webkit.org/show_bug.cgi?id=40197#c41 , it was suggested a helper / getter for invalid IntSize&apos;s. 
Maybe something simple like this:

static IntSize invalid() { return IntSize(-1, -1); }

similarly to the static IntPoint zero() { return IntPoint(0, 0); } added in bug 37220.

Thoughts?

ps: If I hear it is ok, upload a patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253821</commentid>
    <comment_count>1</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 11:08:44 -0700</bug_when>
    <thetext>isValid() would work similarly to Qt&apos;s version: &quot;Returns true if both the width and height is equal to or greater than 0; otherwise returns false.&quot; [1]

[1] http://doc.trolltech.com/4.7-snapshot/qsize.html#isValid</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253823</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-20 11:12:03 -0700</bug_when>
    <thetext>This use of -1,-1 as a magic value seems questionable to me, even though Qt uses it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253829</commentid>
    <comment_count>3</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 11:21:56 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; This use of -1,-1 as a magic value seems questionable to me, even though Qt uses it.

In fact qt does not use it as there is not static invalid method in QSize.

If we decide to not go for adding invalid() since -1,-1 is in fact &quot;magic&quot;, I can keep using IntSize(-1, -1) where appropriated.

However, least isValid() seems useful. It does have a different meaning from isEmpty and isZero.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253840</commentid>
    <comment_count>4</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 11:48:10 -0700</bug_when>
    <thetext>Other possible users of isValid() and maybe IntSize::invalid() 

static void constructDeletedValue(IntSize&amp; slot)
{
  new (&amp;slot) IntSize(-1, -1);
}

static bool isDeletedValue(const IntSize&amp; value)
{
  return value.width() == -1 &amp;&amp; value.height() == -1;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253841</commentid>
    <comment_count>5</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 11:49:32 -0700</bug_when>
    <thetext>... and:

void FrameView::init()
{
    reset();
    m_margins = IntSize(-1, -1); // undefined

sorry for bug-spamming.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253843</commentid>
    <comment_count>6</comment_count>
      <attachid>62096</attachid>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 11:57:31 -0700</bug_when>
    <thetext>Created attachment 62096
patch1 - v1 - isValid addition.

Lets go with isValid for now. Darin?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253869</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-20 12:42:45 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; However, least isValid() seems useful. It does have a different meaning from isEmpty and isZero.

Sure, but is this a useful distinction? Again, I know Qt has it, but my starting point would be assuming we should not use invalid points.

The distinction between null and empty string is an eternal headache and it would be nice to not have more things like that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253879</commentid>
    <comment_count>8</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 12:59:42 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #3)
&gt; &gt; However, least isValid() seems useful. It does have a different meaning from isEmpty and isZero.
&gt; 
&gt; Sure, but is this a useful distinction? Again, I know Qt has it, but my starting point would be assuming we should not use invalid points.
&gt; 
&gt; The distinction between null and empty string is an eternal headache and it would be nice to not have more things like that.

Imho, it is an useful distiction in the context of the rect-based hit test, for example. The situation there is the following: if one calls nodesFromRect(x, y, 0, 0), a valid rect is still built up.

It means the caller of this method still wants a rect-based hit test but he (the caller) is saying to not expand the original point.

In fact, that is what he will get since the formula we are using the build up the rect from the point + padding still accepts the previous method input. Here is it:

inline IntRect HitTestResult::rectFromPoint(const IntPoint&amp; p) const
{
  return IntRect(p.x() - m_padding.width(),   // x
                 p.y() - m_padding.height(),  // y
                 2 * m_padding.width() + 1,   // weigth
                 2 * m_padding.height() + 1); // height
}


So in this context, non-negative IntSize&apos;s are valid.

If user explicitly passes an invalid/undefined/negative IntSize(-anyValue, -anyValue) the current is{Empty,Zero} methods are not what we need to perform the check.

Of course I can still make isValid internally in my class, but would be useful to have this int IntSize class.

Hope I could had made it clear about my of use for adding this simple helper. Let me know if you still thing it is bad thing to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>253880</commentid>
    <comment_count>9</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 13:01:16 -0700</bug_when>
    <thetext>s/weigth/width</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>254052</commentid>
    <comment_count>10</comment_count>
      <attachid>62096</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-20 16:19:23 -0700</bug_when>
    <thetext>Comment on attachment 62096
patch1 - v1 - isValid addition.

Core Graphics has this concept for rectangles, but not for sizes. And it calls the concept “is null” rather than “is (in)valid”.

I’m not sure our functions that manipulate sizes all respect this notion. It doesn’t do a lot of harm to add these functions, but I have to say the concept seems a bit unclear to me.

Where are some of the call sites where we want to use this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>254135</commentid>
    <comment_count>11</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 23:27:47 -0700</bug_when>
    <thetext>(In reply to comment #10)

I see your conceptual concerns. If we go for not adding this method, I can make it an inliner in my class, no problem.

&gt; Where are some of the call sites where we want to use this?

See some possible users of this in comment #4 and comment #5, and again, the validation check of m_padding (IntSize) in HitTestResult - see bug 40197.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>254138</commentid>
    <comment_count>12</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-20 23:30:27 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; See some possible users of this in comment #4 and comment #5

I would prefer not to use it in either of those places.

&gt; the validation check of m_padding (IntSize) in HitTestResult - see bug 40197.

I don’t know exactly what a validation check is. Do we really need a separate &quot;invalid&quot; value for padding? This seems unnecessarily tricky. Typically it&apos;s best to avoid special values and instead use explicit signaling. A separate boolean or some other way of saying there is no padding value, rather than a special &quot;null&quot; value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>254139</commentid>
    <comment_count>13</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2010-07-20 23:34:17 -0700</bug_when>
    <thetext>
&gt; &gt; the validation check of m_padding (IntSize) in HitTestResult - see bug 40197.
&gt; 
&gt; I don’t know exactly what a validation check is. Do we really need a separate &quot;invalid&quot; value for padding? This seems unnecessarily tricky. Typically it&apos;s best to avoid special values and instead use explicit signaling. A separate boolean or some other way of saying there is no padding value, rather than a special &quot;null&quot; value.

Sure. A boolean works for me, and I am already using one. I was think it&apos;d be more elegant to not use, though, but the change proved itself rather unneeded, so closing the bug as INVALID.

Thank you for your time on this, Darin.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>62096</attachid>
            <date>2010-07-20 11:57:31 -0700</date>
            <delta_ts>2010-08-06 13:21:53 -0700</delta_ts>
            <desc>patch1 - v1 - isValid addition.</desc>
            <filename>0001-2010-07-20-Antonio-Gomes-tonikitoo-webkit.org.patch</filename>
            <type>text/plain</type>
            <size>2930</size>
            <attacher name="Antonio Gomes">tonikitoo</attacher>
            
              <data encoding="base64">RnJvbSA4MzNkYWFiZTQxYWE5NWRjYzQ5MWY4MzI0YTdkOThjYTc2MGQ1YzQ5IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBBbnRvbmlvIEdvbWVzIDx0b25pa2l0b29Ad2Via2l0Lm9yZz4K
RGF0ZTogVHVlLCAyMCBKdWwgMjAxMCAxNDo1MTozOCAtMDQwMApTdWJqZWN0OiBbUEFUQ0hdIDIw
MTAtMDctMjAgIEFudG9uaW8gR29tZXMgIDx0b25pa2l0b29Ad2Via2l0Lm9yZz4KCiAgICAgICAg
UmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCgogICAgICAgIEludFNpemV8RmxvYXRTaXplOiBh
ZGQgaXNWYWxpZCgpIGhlbHBlciBtZXRob2QuCiAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5v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