<commit_before>/* Swfdec
 * Copyright (C) 2006 <NAME> <<EMAIL>>
 *               2007 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>
#include <math.h>
#include <pango/pangocairo.h>

#include "swfdec_text_field_movie.h"
#include "swfdec_as_context.h"
#include "swfdec_as_strings.h"
#include "swfdec_as_interpret.h"
#include "swfdec_text_format.h"
#include "swfdec_xml.h"
#include "swfdec_debug.h"
#include "swfdec_player_internal.h"

G_DEFINE_TYPE (SwfdecTextFieldMovie, swfdec_text_field_movie, SWFDEC_TYPE_MOVIE)

#define EXTRA_MARGIN 2
#define BULLET_MARGIN 36

static void
swfdec_text_field_movie_update_extents (SwfdecMovie *movie,
    SwfdecRect *extents)
{
  SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
  SwfdecRect extended;

  extended = SWFDEC_GRAPHIC (text->text)->extents;

  // border is drawn partly outside the extents
  if (text->text->border) {
    extended.x1 += SWFDEC_TWIPS_TO_DOUBLE (1);
    extended.y1 += SWFDEC_TWIPS_TO_DOUBLE (1);
  }

  swfdec_rect_union (extents, extents, &extended);
}

static void
swfdec_text_field_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
{
  SwfdecRect rect;
  
  swfdec_rect_transform (&rect, 
    &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents, matrix);
  swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
}

static void
swfdec_text_field_movie_ensure_asterisks (SwfdecTextFieldMovie *text,
    guint length)
{
  g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));<commit_msg>Oops, managed to change update_extents instead of invalidate earlier<commit_after>/* Swfdec
 * Copyright (C) 2006 <NAME> <<EMAIL>>
 *               2007 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>
#include <math.h>
#include <pango/pangocairo.h>

#include "swfdec_text_field_movie.h"
#include "swfdec_as_context.h"
#include "swfdec_as_strings.h"
#include "swfdec_as_interpret.h"
#include "swfdec_text_format.h"
#include "swfdec_xml.h"
#include "swfdec_debug.h"
#include "swfdec_player_internal.h"

G_DEFINE_TYPE (SwfdecTextFieldMovie, swfdec_text_field_movie, SWFDEC_TYPE_MOVIE)

#define EXTRA_MARGIN 2
#define BULLET_MARGIN 36

static void
swfdec_text_field_movie_update_extents (SwfdecMovie *movie,
    SwfdecRect *extents)
{
  swfdec_rect_union (extents, extents,
      &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents);
}

static void
swfdec_text_field_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
{
  SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
  SwfdecRect rect, extended;

  extended = SWFDEC_GRAPHIC (text->text)->extents;

  // border is drawn partly outside the extents
  if (text->text->border) {
    extended.x1 += SWFDEC_TWIPS_TO_DOUBLE (1);
    extended.y1 += SWFDEC_TWIPS_TO_DOUBLE (1);
  }

  swfdec_rect_transform (&rect, &extended, matrix);
  swfdec_player_invalidate (
      SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
}

static void
swfdec_text_field_movie_ensure_asterisks (SwfdecTextFieldMovie *text,
    guint length)
{
  g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
{'fraction_non_alphanumeric': 0.08928950159066808, 'fraction_numerical': 0.011876988335100742, 'mean_word_length': 4.992376111817027, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326601', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1596, 'n_words': 468}