gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11341: Don't pass as_objects by val


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11341: Don't pass as_objects by value, or the GC will blow up when it tries to
Date: Thu, 30 Jul 2009 11:39:40 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11341
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-07-30 11:39:40 +0200
message:
  Don't pass as_objects by value, or the GC will blow up when it tries to
  delete them. The new code works perfectly well when it's passed by reference.
  
  Drop the unused TextFormat_as member of TextField until there's a need for
  it (it should also be initialized in the ctor and markedReachable
  if it's reintroduced).
added:
  testsuite/actionscript.all/TextFieldHTML.as
modified:
  libcore/TextField.cpp
  libcore/TextField.h
  testsuite/actionscript.all/Makefile.am
    ------------------------------------------------------------
    revno: 11339.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: temp
    timestamp: Thu 2009-07-30 09:27:09 +0200
    message:
      Change "DisplayObject" to "character" in HTML error messages (it was
      accidentally changed ages ago when renaming the character class).
      
      Use std::make_pair for concision.
    modified:
      libcore/TextField.cpp
    ------------------------------------------------------------
    revno: 11339.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: temp
    timestamp: Thu 2009-07-30 10:23:36 +0200
    message:
      Add test for HTML in TextFields (a new file because TextField is too 
long).
    added:
      testsuite/actionscript.all/TextFieldHTML.as
    ------------------------------------------------------------
    revno: 11339.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: temp
    timestamp: Thu 2009-07-30 10:24:02 +0200
    message:
      Run test.
    modified:
      testsuite/actionscript.all/Makefile.am
    ------------------------------------------------------------
    revno: 11339.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: temp
    timestamp: Thu 2009-07-30 10:31:32 +0200
    message:
      Don't run tests for SWF5, as various things weren't available in that
      version.
    modified:
      testsuite/actionscript.all/TextFieldHTML.as
    ------------------------------------------------------------
    revno: 11339.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: temp
    timestamp: Thu 2009-07-30 10:48:39 +0200
    message:
      Revert minor TextField changes because it's changed in trunk.
    modified:
      libcore/TextField.cpp
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-07-30 08:07:31 +0000
+++ b/libcore/TextField.cpp     2009-07-30 09:39:40 +0000
@@ -704,7 +704,7 @@
 }
 
 void
-TextField::setTextFormat(TextFormat_as tf)
+TextField::setTextFormat(TextFormat_as& tf)
 {
     //TODO: this is lazy. we should set all the TextFormat variables HERE, i 
think
     //This is just so we can set individual variables without having to call 
format_text()

=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h       2009-07-30 08:07:31 +0000
+++ b/libcore/TextField.h       2009-07-30 09:39:40 +0000
@@ -24,7 +24,6 @@
 #include "Range2d.h"
 #include "rect.h" // for inlines
 #include "Font.h" // for visibility of font add_ref/drop_ref
-//#include "TextFormat_as.h"
 
 #include <vector>
 
@@ -486,11 +485,7 @@
        void setTarget(std::string target);
        void setDisplay(TextFormatDisplay display);
 
-       TextFormat_as* getTextFormat() const
-       {
-               return _textFormat;
-       }
-       void setTextFormat(TextFormat_as tf);
+       void setTextFormat(TextFormat_as& tf);
 
        const rect& getTextBoundingBox() const
        {
@@ -627,8 +622,6 @@
     /// easier.
        std::wstring _text;
 
-       TextFormat_as* _textFormat;
-
        /// This flag will be true as soon as the TextField
        /// is assigned a text value. Only way to be false is
        /// when definition has the hasText flag set to false

=== modified file 'testsuite/actionscript.all/Makefile.am'
--- a/testsuite/actionscript.all/Makefile.am    2009-07-14 15:55:13 +0000
+++ b/testsuite/actionscript.all/Makefile.am    2009-07-30 08:24:02 +0000
@@ -113,6 +113,7 @@
        String.as               \
        System.as               \
        TextField.as            \
+       TextFieldHTML.as                \
        TextFormat.as           \
        TextSnapshot.as         \
        Transform.as            \

=== added file 'testsuite/actionscript.all/TextFieldHTML.as'
--- a/testsuite/actionscript.all/TextFieldHTML.as       1970-01-01 00:00:00 
+0000
+++ b/testsuite/actionscript.all/TextFieldHTML.as       2009-07-30 08:31:32 
+0000
@@ -0,0 +1,137 @@
+// 
+//   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+//
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+#include "check.as"
+
+#if OUTPUT_VERSION < 6
+
+ totals(0);
+
+#else
+
+ _root.createTextField("textfield1", 1, 10, 10, 100, 100);
+ tf = _root.textfield1;
+
+ // Text is not parsed as HTML unless the html property is true, regardless
+ // of whether you set htmlText or Text.
+ tf.htmlText = "<b>bold</b>";
+ check_equals(tf.text, "<b>bold</b>");
+ tf.text = "<i>italic</i>";
+ check_equals(tf.text, "<i>italic</i>");
+
+ // Changing the property afterwards makes no difference.
+ tf.html = true;
+ check_equals(tf.text, "<i>italic</i>");
+ tf.text = "<b>bold</b>";
+
+ // Only setting the htmlText property causes tag parsing.
+ check_equals(tf.text, "<b>bold</b>");
+ tf.htmlText = "<i>italic</i>";
+ xcheck_equals(tf.text, "italic");
+ 
+ tf.html = false;
+ 
+ // The htmlText value is generated on-the-fly from the text's properties,
+ // but only when the html property is true.
+ tf.htmlText = "<font>font</font>";
+ check_equals(tf.text, "<font>font</font>");
+
+ // Here there is no html output.
+ check_equals(tf.htmlText, "<font>font</font>");
+
+ tf.html = true;
+
+ // Here there is html output, even though the text has not changed.
+ xcheck_equals(tf.htmlText, '<P ALIGN="LEFT"><FONT FACE="Times" SIZE="12" 
COLOR="#000000" LETTERSPACING="0" 
KERNING="0">&lt;font&gt;font&lt;/font&gt;</FONT></P>');
+
+ // Check font color attribute.
+ // The html property is still true now.
+
+ tf.htmlText = '<font color="#00FF00">green</font>';
+ xcheck_equals(tf.text, "green");
+ // The TextField textColor remains black.
+ check_equals(tf.textColor, 0);
+ // The characters are green.
+ format = tf.getTextFormat(1, 4);
+ xcheck_equals(format.color, 0x00ff00);
+ 
+ // This fails (no quotes)
+ tf.htmlText = '<font color=#00FF00>green2</font>';
+ xcheck_equals(tf.text, "");
+ // The TextField textColor remains black.
+ check_equals(tf.textColor, 0);
+
+ // Lower case is fine.
+ tf.htmlText = '<font color="#0000ff">blue</font>';
+ xcheck_equals(tf.text, "blue");
+ // The TextField textColor remains black.
+ check_equals(tf.textColor, 0);
+ format = tf.getTextFormat(1, 4);
+ xcheck_equals(format.color, 0x0000ff);
+
+// WARNING!! The disabled code crashes Gnash at the moment.
+// When that's fixed, this code can be reenabled to get the totals() pass,
+// and the failures in this section (only!) can be expected.
+#if 0
+
+ // A color string that is this short doesn't change the color.
+ tf.htmlText = '<font color="#ff">too short</font>';
+ check_equals(tf.text, "too short");
+ format = tf.getTextFormat(1, 4);
+ check_equals(format.color, 0x0000ff);
+
+ // When it's three characters it does change the color.
+ tf.htmlText = '<font color="#ff0">a bit short</font>';
+ check_equals(tf.text, "a bit short");
+ format = tf.getTextFormat(1, 4);
+ check_equals(format.color, 0x000ff0);
+ 
+ // Without a hash it sets the color to black.
+ tf.htmlText = '<font color="ff00ff">no hash</font>';
+ check_equals(tf.text, "no hash");
+ format = tf.getTextFormat(1, 4);
+ check_equals(format.color, 0);
+
+ tf.htmlText = '<font color="hi">no hash 2</font>';
+ check_equals(tf.text, "no hash 2");
+ format = tf.getTextFormat(1, 4);
+ check_equals(format.color, 0);
+
+ tf.htmlText = '<font color="">empty</font>';
+ check_equals(tf.text, "empty");
+ format = tf.getTextFormat(1, 4);
+ check_equals(format.color, 0);
+
+#endif
+
+ // Extra long strings are truncated, but the end counts, not the beginning.
+ tf.htmlText = '<font color="#ff00ffffee">long</font>';
+ xcheck_equals(tf.text, "long");
+ format = tf.getTextFormat(1, 4);
+ xcheck_equals(format.color, 0xffffee);
+
+ // Strings containing non-hex characters ignore those characters.
+ tf.htmlText = '<font color="#ff00gp">corrupt</font>';
+ xcheck_equals(tf.text, "corrupt");
+ format = tf.getTextFormat(1, 4);
+ xcheck_equals(format.color, 0x00ff00);
+
+ xtotals(30);
+
+#endif


reply via email to

[Prev in Thread] Current Thread [Next in Thread]