From a4ee55bc416d5afdd9538f951c27e2df2379a76c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 15 Nov 2019 14:08:04 +0100 Subject: Add unlinking function to CRStyleSheet. --- src/3rdparty/libcroco/cr-stylesheet.c | 43 +++++++++++++++++++++++++++++++++++ src/3rdparty/libcroco/cr-stylesheet.h | 7 ++++++ 2 files changed, 50 insertions(+) diff --git a/src/3rdparty/libcroco/cr-stylesheet.c b/src/3rdparty/libcroco/cr-stylesheet.c index c80c40b93..3f554b18c 100644 --- a/src/3rdparty/libcroco/cr-stylesheet.c +++ b/src/3rdparty/libcroco/cr-stylesheet.c @@ -180,6 +180,7 @@ cr_stylesheet_append_stylesheet (CRStyleSheet * a_this, CRStyleSheet * a_new_sty for (cur = a_this; cur->next; cur = cur->next) ; cur->next = a_new_stylesheet; + a_new_stylesheet->prev = cur; /* The "origin" must apriori be the same for all stylesheets in a list. We must set it correctly or errors will occur in @@ -190,6 +191,48 @@ cr_stylesheet_append_stylesheet (CRStyleSheet * a_this, CRStyleSheet * a_new_sty return a_this; } +/** + * cr_stylesheet_unlink: + *@a_this: the stylesheet to unlink. + * + *Unlinks the stylesheet from the stylesheet list. + * + *Returns a pointer to the unlinked stylesheet in + *case of a successfull completion, NULL otherwise. + */ +CRStyleSheet * +cr_stylesheet_unlink (CRStyleSheet * a_this) +{ + CRStyleSheet *result = a_this; + + g_return_val_if_fail (result, NULL); + + /* + *some sanity checks first + */ + if (a_this->prev) { + g_return_val_if_fail (a_this->prev->next == a_this, NULL); + + } + if (a_this->next) { + g_return_val_if_fail (a_this->next->prev == a_this, NULL); + } + + /* + *now, the real unlinking job. + */ + if (a_this->prev) { + a_this->prev->next = a_this->next; + } + if (a_this->next) { + a_this->next->prev = a_this->prev; + } + + a_this->next = NULL; + a_this->prev = NULL; + + return a_this; +} /** *Appends a new import stylesheet to the current list of imports. diff --git a/src/3rdparty/libcroco/cr-stylesheet.h b/src/3rdparty/libcroco/cr-stylesheet.h index 7ebaf7a60..d6e720d90 100644 --- a/src/3rdparty/libcroco/cr-stylesheet.h +++ b/src/3rdparty/libcroco/cr-stylesheet.h @@ -91,6 +91,11 @@ struct _CRStyleSheet * A link to the next stylesheet. */ CRStyleSheet *next; + + /** + * A link to the previous stylesheet. + */ + CRStyleSheet *prev; } ; CRStyleSheet * cr_stylesheet_new (CRStatement *a_stmts) ; @@ -107,6 +112,8 @@ CRStyleSheet * cr_stylesheet_append_import (CRStyleSheet *a_this, CRStyleSheet * CRStyleSheet * cr_stylesheet_append_stylesheet (CRStyleSheet *a_this, CRStyleSheet *a_new_stylesheet) ; +CRStyleSheet * cr_stylesheet_unlink (CRStyleSheet *a_this) ; + void cr_stylesheet_ref (CRStyleSheet *a_this) ; gboolean cr_stylesheet_unref (CRStyleSheet *a_this) ; -- cgit v1.2.3