Difference between revisions of "User:Minooz/OSD600/FF/patch565031"

From CDOT Wiki
< User:Minooz‎ | OSD600‎ | FF
Jump to: navigation, search
(Created page with ' <source lang="java"> diff -r ec44e31cc46b layout/generic/nsImageMap.cpp --- a/layout/generic/nsImageMap.cpp Wed Mar 30 20:48:32 2011 -0400 +++ b/layout/generic/nsImageMap.cpp …')
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<div id="Apr16">
 +
=== Apr16 ===
 +
: The review of the bug suggests to start over the function based on the HTML5 specs.
 +
: However, the spec is using an integer list to add the valid values dynamically. There are memory allocation problems with that in c++.
 +
: Seems the existing method is more reasonable for doing the same concept but not following exact same steps.
 +
: Also I'm not sure how using aSpec of type nsAString is doable instead of converting it using ''ToNewCString(aSpec)''
 +
: So, still working on these issues...
 +
<source lang="java">
 +
void Area::ParseCoords(const nsAString& aSpec)
 +
{
 +
  char* cp = ToNewCString(aSpec);
 +
  if (!cp) {
 +
    return;
 +
  }
 +
    char *tptr;
 +
    char *n_str;
 +
    PRInt32 i, cnt, pos, value;
 +
    PRInt32 *value_list;
 +
    PRBool negated = false;
 +
    PRBool started = false;
 +
    PRBool gotNumber = false;
 +
    PRBool finished = false;
 +
    PRBool bogus = false;
 +
 +
    /*
 +
    * Nothing in an empty list
 +
    */
 +
    mNumCoords = 0;
 +
    mCoords = nsnull;
 +
 +
    value_list = new int [5];
 +
 +
    /*
 +
    * Make a pass where any two numbers separated by just whitespace
 +
    * are given a comma separator.  Count entries while passing.
 +
    */
 +
    cnt = 0;
 +
    value = 0;
 +
    n_str = cp;
 +
   
 +
    while (*n_str != '\0')
 +
    {
 +
      while (is_separator(*n_str))
 +
      {
 +
        n_str++;
 +
        value = 0;
 +
        negated = false;
 +
        started = false;
 +
        gotNumber = false;
 +
        finished = false;
 +
        bogus = false;
 +
      }
 +
     
 +
      if (*n_str == '\0')
 +
      {
 +
        break;
 +
      }
 +
     
 +
      if (*n_str == '-')
 +
      {
 +
        if (gotNumber)
 +
        {
 +
          finished = true;
 +
        }
 +
        if (!finished)
 +
        {
 +
          if (started)
 +
            negated = false;
 +
          else
 +
          {
 +
            if (!bogus)
 +
              negated = true;
 +
          }
 +
        } 
 +
        started = true;
 +
        n_str++;
 +
      }
 +
      else if (*n_str >= '0' && *n_str <= '9')
 +
      {
 +
        if (!finished)
 +
        {
 +
          value *= 10;
 +
          value += *n_str - '0';
 +
          started = true;
 +
          gotNumber = true;
 +
          n_str++;
 +
        } 
 +
     
 +
        if (is_separator(*n_str))
 +
        {
 +
          if (!gotNumber)
 +
          {
 +
            break;
 +
          } 
 +
          if (negated)
 +
          {
 +
            value *= -1;
 +
          } 
 +
          value_list[cnt] = value;
 +
          cnt++;
 +
        } 
 +
      }
 +
      else
 +
      {
 +
        if (!finished)
 +
        {
 +
          negated = false;
 +
          bogus = true;
 +
          if (started)
 +
          {
 +
            break;
 +
          }
 +
        }
 +
      }
 +
     
 +
    }
  
 +
    mNumCoords = cnt;
 +
    mCoords = value_list;
  
 +
    NS_Free(cp);
 +
}
 +
</source></div>
 +
------
 +
<div id="Apr6">
 +
 +
=== Apr6 ===
 
<source lang="java">
 
<source lang="java">
 
+
// Modified based on Matt Postil's Version
diff -r ec44e31cc46b layout/generic/nsImageMap.cpp
+
diff -r e6b318aca788 layout/generic/nsImageMap.cpp
--- a/layout/generic/nsImageMap.cpp Wed Mar 30 20:48:32 2011 -0400
+
--- a/layout/generic/nsImageMap.cpp Wed Apr 06 17:38:21 2011 -0700
+++ b/layout/generic/nsImageMap.cpp Wed Apr 06 22:11:22 2011 -0400
+
+++ b/layout/generic/nsImageMap.cpp Sat Apr 09 20:50:51 2011 -0400
@@ -107,18 +107,21 @@ Area::~Area()
+
@@ -112,12 +112,7 @@
  delete [] mCoords;
 
}
 
 
#include <stdlib.h>
 
 
 
  inline PRBool
 
  inline PRBool
 
  is_space(char c)
 
  is_space(char c)
Line 17: Line 137:
 
-  return (c == ' ' ||
 
-  return (c == ' ' ||
 
-          c == '\f' ||
 
-          c == '\f' ||
+  return (c == ' ');  
+
-          c == '\n' ||
 
+
-          c == '\r' ||
 +
-          c == '\t' ||
 +
-          c == '\v');
 +
+  return c == ' ';
 +
}
 +
 
  static void logMessage(nsIContent*      aContent,
 
  static void logMessage(nsIContent*      aContent,
                        const nsAString& aCoordsSpec,
+
@@ -186,12 +181,17 @@
@@ -181,21 +184,33 @@ void Area::ParseCoords(const nsAString&
 
    while (*n_str != '\0')
 
    {
 
      PRBool has_comma;
 
 
      /*
 
 
         * Skip to a separator
 
         * Skip to a separator
 
         */
 
         */
 
       tptr = n_str;
 
       tptr = n_str;
 
-      while (!is_space(*tptr) && *tptr != ',' && *tptr != '\0')
 
-      while (!is_space(*tptr) && *tptr != ',' && *tptr != '\0')
+      while (!is_space(*tptr) && *tptr != ',' && *tptr != ';' && *tptr != '\0')
+
+      while (!is_space(*tptr) && *tptr != ',' && *tptr != ';' && *tptr != '\0')
 
       {
 
       {
-        tptr++;
+
         tptr++;
+        if (not_space(*tptr))
 
+        {
 
+          break;
 
+        }
 
+        else
 
+        {
 
+         tptr++;
 
+        }
 
 
       }
 
       }
 
       n_str = tptr;
 
       n_str = tptr;
+     
 
+      if (*tptr == ';')
 
+      {
 
+        *tptr = ',';
 
+      }
 
 
   
 
   
 
       /*
 
       /*
 
         * If no more entries, break out here
 
         * If no more entries, break out here
 
         */
 
         */
      if (*n_str == '\0')
+
@@ -205,7 +205,7 @@
      {
+
        * comma.
        break;
+
        */
      }
+
      has_comma = PR_FALSE;
@@ -256,17 +271,17 @@ void Area::ParseCoords(const nsAString&
+
-     while (is_space(*tptr) || *tptr == ',')
    {
+
+     while (is_space(*tptr) || *tptr == ',' || *tptr == ';')
      return;
 
    }
 
 
    /*
 
      * Second pass to copy integer values into list.
 
      */
 
    tptr = cp;
 
-   for (i=0; i<cnt; i++)
 
+   for (i = 0; i < cnt; i++)
 
    {
 
      char *ptr;
 
 
      ptr = strchr(tptr, ',');
 
      if (ptr)
 
 
       {
 
       {
         *ptr = '\0';
+
         if (*tptr == ',')
      }
+
        {
 
+
</source></div>
</source>
 

Latest revision as of 21:33, 20 April 2011

Apr16

The review of the bug suggests to start over the function based on the HTML5 specs.
However, the spec is using an integer list to add the valid values dynamically. There are memory allocation problems with that in c++.
Seems the existing method is more reasonable for doing the same concept but not following exact same steps.
Also I'm not sure how using aSpec of type nsAString is doable instead of converting it using ToNewCString(aSpec)
So, still working on these issues...
 void Area::ParseCoords(const nsAString& aSpec)
{
  char* cp = ToNewCString(aSpec);
  if (!cp) {
    return;
  }
    char *tptr;
    char *n_str;
    PRInt32 i, cnt, pos, value;
    PRInt32 *value_list;
    PRBool negated = false;
    PRBool started = false;
    PRBool gotNumber = false;
    PRBool finished = false;
    PRBool bogus = false;

    /*
     * Nothing in an empty list
     */
    mNumCoords = 0;
    mCoords = nsnull;

    value_list = new int [5];

    /*
     * Make a pass where any two numbers separated by just whitespace
     * are given a comma separator.  Count entries while passing.
     */
    cnt = 0;
    value = 0;
    n_str = cp;
    
    while (*n_str != '\0')
    {
      while (is_separator(*n_str))
      {
        n_str++;
        value = 0;
        negated = false;
        started = false;
        gotNumber = false;
        finished = false;
        bogus = false;
      }
      
      if (*n_str == '\0')
      {
        break;
      }
      
      if (*n_str == '-') 
      {
        if (gotNumber)
        {
          finished = true;
        }
        if (!finished)
        {
          if (started)
            negated = false;
          else 
          {
            if (!bogus)
              negated = true;
          }
        }  
        started = true;
        n_str++;
      }
      else if (*n_str >= '0' && *n_str <= '9') 
      {
        if (!finished)
        {
          value *= 10;
          value += *n_str - '0';
          started = true;
          gotNumber = true;
          n_str++;
        }  
      
        if (is_separator(*n_str)) 
        {
          if (!gotNumber)
          {
            break;
          }  
          if (negated)
          {
            value *= -1;
          }  
          value_list[cnt] = value;
          cnt++;
        }  
      }
      else 
      {
        if (!finished)
        {
          negated = false;
          bogus = true;
          if (started)
          {
            break;
          }
        }
      }
      
    }

    mNumCoords = cnt;
    mCoords = value_list;

    NS_Free(cp);
}

Apr6

// Modified based on Matt Postil's Version
diff -r e6b318aca788 layout/generic/nsImageMap.cpp
--- a/layout/generic/nsImageMap.cpp	Wed Apr 06 17:38:21 2011 -0700
+++ b/layout/generic/nsImageMap.cpp	Sat Apr 09 20:50:51 2011 -0400
@@ -112,12 +112,7 @@
 inline PRBool
 is_space(char c)
 {
-  return (c == ' ' ||
-          c == '\f' ||
-          c == '\n' ||
-          c == '\r' ||
-          c == '\t' ||
-          c == '\v');
+  return c == ' ';
 }
 
 static void logMessage(nsIContent*      aContent,
@@ -186,12 +181,17 @@
        * Skip to a separator
        */
       tptr = n_str;
-      while (!is_space(*tptr) && *tptr != ',' && *tptr != '\0')
+      while (!is_space(*tptr) && *tptr != ',' &&  *tptr != ';' && *tptr != '\0')
       {
         tptr++;
       }
       n_str = tptr;
 
       /*
        * If no more entries, break out here
        */
@@ -205,7 +205,7 @@
        * comma.
        */
       has_comma = PR_FALSE;
-      while (is_space(*tptr) || *tptr == ',')
+      while (is_space(*tptr) || *tptr == ',' || *tptr == ';')
       {
         if (*tptr == ',')
         {