summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2016-07-02 12:39:47 +0300
committerEli Zaretskii <eliz@gnu.org>2016-07-02 12:39:47 +0300
commit55d38fc89f5aeb9a73c9a8e13914fbb8a9a6a1af (patch)
tree46a5bde90a8759582c0c3f7071b7a533056eaa75 /src
parenta5ec5c073a182aa014d9d753f14751248ea5c9a7 (diff)
downloademacs-55d38fc89f5aeb9a73c9a8e13914fbb8a9a6a1af.tar.gz
Rename FACE_OPT_FROM_ID to FACE_FROM_ID_OR_NULL
* src/dispextern.h (FACE_FROM_ID_OR_NULL): Renamed from FACE_OPT_FROM_ID; all callers changed. * src/xdisp.c (extend_face_to_end_of_line): Call FACE_FROM_ID, not FACE_FROM_ID_OR_NULL, as the resulting face is immediately dereferenced. (fill_gstring_glyph_string): Call FACE_FROM_ID, not FACE_FROM_ID_OR_NULL, as the resulting face will be dereferenced when the glyph string is drawn. (BUILD_COMPOSITE_GLYPH_STRING): Call FACE_FROM_ID, not FACE_FROM_ID_OR_NULL, as the resulting face will be dereferenced in fill_composite_glyph_string. (calc_line_height_property): Call FACE_FROM_ID_OR_NULL rather that FACE_FROM_ID, since the function and its caller can cope with that situation. Conflate 3 tests of missing face or font into just one. * src/xfaces.c (Fx_list_fonts, Fface_font, lookup_face): Call FACE_FROM_ID_OR_NULL rather that FACE_FROM_ID, since these functions can cope with that situation. (lookup_derived_face): Don't call FACE_FROM_ID if the result will not be used. * src/w32console.c (w32_face_attributes): Remove redundant 'eassert'.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/dispextern.h2
-rw-r--r--src/fontset.c4
-rw-r--r--src/fringe.c5
-rw-r--r--src/macfont.m4
-rw-r--r--src/msdos.c6
-rw-r--r--src/nsfont.m3
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m22
-rw-r--r--src/w32console.c2
-rw-r--r--src/w32term.c10
-rw-r--r--src/xdisp.c48
-rw-r--r--src/xfaces.c31
-rw-r--r--src/xterm.c10
14 files changed, 74 insertions, 77 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5f9d6ada5a1..e25d91ff8aa 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6135,7 +6135,7 @@ mark_face_cache (struct face_cache *c)
int i, j;
for (i = 0; i < c->used; ++i)
{
- struct face *face = FACE_OPT_FROM_ID (c->f, i);
+ struct face *face = FACE_FROM_ID_OR_NULL (c->f, i);
if (face)
{
diff --git a/src/dispextern.h b/src/dispextern.h
index 08dcd89709a..1325ff9da28 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1821,7 +1821,7 @@ struct face_cache
/* Return a pointer to the face with ID on frame F, or null if such a
face doesn't exist. */
-#define FACE_OPT_FROM_ID(F, ID) \
+#define FACE_FROM_ID_OR_NULL(F, ID) \
(UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \
? FRAME_FACE_CACHE (F)->faces_by_id[ID] \
: NULL)
diff --git a/src/fontset.c b/src/fontset.c
index 81528de55a0..67696d0fead 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1305,7 +1305,7 @@ free_realized_fontsets (Lisp_Object base)
{
struct frame *f = XFRAME (FONTSET_FRAME (this));
int face_id = XINT (XCDR (XCAR (tail)));
- struct face *face = FACE_OPT_FROM_ID (f, face_id);
+ struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
/* Face THIS itself is also freed by the following call. */
free_realized_face (f, face);
@@ -1637,7 +1637,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
continue;
if (fontset_id != FRAME_FONTSET (f))
continue;
- face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (face)
font_object = font_load_for_lface (f, face->lface, font_spec);
else
diff --git a/src/fringe.c b/src/fringe.c
index 87ec9d15c01..986bde16f09 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -620,8 +620,7 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
break;
}
- p.face = FACE_OPT_FROM_ID (f, face_id);
-
+ p.face = FACE_FROM_ID_OR_NULL (f, face_id);
if (p.face == NULL)
{
/* This could happen after clearing face cache.
@@ -1627,7 +1626,7 @@ If FACE is nil, reset face to default fringe face. */)
{
struct frame *f = SELECTED_FRAME ();
- if (FACE_OPT_FROM_ID (f, FRINGE_FACE_ID)
+ if (FACE_FROM_ID_OR_NULL (f, FRINGE_FACE_ID)
&& lookup_derived_face (f, face, FRINGE_FACE_ID, 1) < 0)
error ("No such face");
}
diff --git a/src/macfont.m b/src/macfont.m
index 79001344769..4e4daba0707 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2856,8 +2856,8 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
{
if (s->hl == DRAW_MOUSE_FACE)
{
- face = FACE_OPT_FROM_ID (s->f,
- MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
diff --git a/src/msdos.c b/src/msdos.c
index c2b19a65173..73d755ae646 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -795,8 +795,8 @@ static void
IT_set_face (int face)
{
struct frame *sf = SELECTED_FRAME ();
- struct face *fp = FACE_OPT_FROM_ID (sf, face);
- struct face *dfp = FACE_OPT_FROM_ID (sf, DEFAULT_FACE_ID);
+ struct face *fp = FACE_FROM_ID_OR_NULL (sf, face);
+ struct face *dfp = FACE_FROM_ID_OR_NULL (sf, DEFAULT_FACE_ID);
unsigned long fg, bg, dflt_fg, dflt_bg;
struct tty_display_info *tty = FRAME_TTY (sf);
@@ -1076,7 +1076,7 @@ IT_clear_screen (struct frame *f)
any valid faces and will abort. Instead, use the initial screen
colors; that should mimic what a Unix tty does, which simply clears
the screen with whatever default colors are in use. */
- if (FACE_OPT_FROM_ID (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL)
+ if (FACE_FROM_ID_OR_NULL (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL)
ScreenAttrib = (initial_screen_colors[0] << 4) | initial_screen_colors[1];
else
IT_set_face (0);
diff --git a/src/nsfont.m b/src/nsfont.m
index 7c97c6fd0ae..569a69f9fe8 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -1071,7 +1071,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
face = s->face;
break;
case NS_DUMPGLYPH_MOUSEFACE:
- face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
break;
diff --git a/src/nsterm.h b/src/nsterm.h
index c2285c90e62..862ff2ec646 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1014,7 +1014,7 @@ struct x_output
#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
-#define FRAME_DEFAULT_FACE(f) FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID)
+#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID)
#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
diff --git a/src/nsterm.m b/src/nsterm.m
index 4b887ec0b50..4027f5c4615 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2882,7 +2882,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
ns_clip_to_row (w, glyph_row, TEXT_AREA, NO); /* do ns_focus(f, &r, 1); if remove */
- face = FACE_OPT_FROM_ID (f, phys_cursor_glyph->face_id);
+ face = FACE_FROM_ID_OR_NULL (f, phys_cursor_glyph->face_id);
if (face && NS_FACE_BACKGROUND (face)
== ns_index_color (FRAME_CURSOR_COLOR (f), f))
{
@@ -2954,7 +2954,7 @@ ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
NSTRACE ("ns_draw_vertical_window_border");
- face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
ns_focus (f, &r, 1);
if (face)
@@ -2977,7 +2977,7 @@ ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
NSTRACE ("ns_draw_window_divider");
- face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
ns_focus (f, &r, 1);
if (face)
@@ -3311,9 +3311,10 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
if (s->hl == DRAW_MOUSE_FACE)
{
- face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
- face = FACE_OPT_FROM_ID (s->f, MOUSE_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (s->f, MOUSE_FACE_ID);
}
else
face = s->face;
@@ -3379,8 +3380,8 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
if (s->hl == DRAW_MOUSE_FACE)
{
face
- = FACE_OPT_FROM_ID (s->f,
- MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
@@ -3446,7 +3447,8 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
with its background color), we must clear just the image area. */
if (s->hl == DRAW_MOUSE_FACE)
{
- face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
@@ -3563,8 +3565,8 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
if (s->hl == DRAW_MOUSE_FACE)
{
- face = FACE_OPT_FROM_ID (s->f,
- MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f,
+ MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
diff --git a/src/w32console.c b/src/w32console.c
index 98343a6c4ff..c71afb6f888 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -611,8 +611,6 @@ w32_face_attributes (struct frame *f, int face_id)
WORD char_attr;
struct face *face = FACE_FROM_ID (f, face_id);
- eassert (face != NULL);
-
char_attr = char_attr_normal;
/* Reverse the default color if requested. If background and
diff --git a/src/w32term.c b/src/w32term.c
index 7ef34079e30..5a11e2a871a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -611,7 +611,7 @@ w32_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
r.bottom = y1;
hdc = get_frame_dc (f);
- face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
if (face)
w32_fill_rect (f, hdc, face->foreground, &r);
else
@@ -628,11 +628,11 @@ w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
HDC hdc = get_frame_dc (f);
- struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+ struct face *face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
struct face *face_first
- = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+ = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
struct face *face_last
- = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+ = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
unsigned long color_first = (face_first
? face_first->foreground
@@ -991,7 +991,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
/* What face has to be used last for the mouse face? */
face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
- face = FACE_OPT_FROM_ID (s->f, face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f, face_id);
if (face == NULL)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
diff --git a/src/xdisp.c b/src/xdisp.c
index 1289515d918..2d0d67784cc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1813,7 +1813,7 @@ estimate_mode_line_height (struct frame *f, enum face_id face_id)
cache and mode line face are not yet initialized. */
if (FRAME_FACE_CACHE (f))
{
- struct face *face = FACE_OPT_FROM_ID (f, face_id);
+ struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
if (face)
{
if (face->font)
@@ -2918,7 +2918,7 @@ init_iterator (struct it *it, struct window *w,
/* If we have a boxed mode line, make the first character appear
with a left box line. */
- face = FACE_OPT_FROM_ID (it->f, remapped_base_face_id);
+ face = FACE_FROM_ID_OR_NULL (it->f, remapped_base_face_id);
if (face && face->box != FACE_NO_BOX)
it->start_of_box_run_p = true;
}
@@ -3877,9 +3877,9 @@ handle_face_prop (struct it *it)
{
struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
/* If it->face_id is -1, old_face below will be NULL, see
- the definition of FACE_OPT_FROM_ID. This will happen if this
- is the initial call that gets the face. */
- struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id);
+ the definition of FACE_FROM_ID_OR_NULL. This will happen
+ if this is the initial call that gets the face. */
+ struct face *old_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
/* If the value of face_id of the iterator is -1, we have to
look in front of IT's position and see whether there is a
@@ -3888,7 +3888,7 @@ handle_face_prop (struct it *it)
{
int prev_face_id = face_before_it_pos (it);
- old_face = FACE_OPT_FROM_ID (it->f, prev_face_id);
+ old_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id);
}
/* If the new face has a box, but the old face does not,
@@ -3988,7 +3988,7 @@ handle_face_prop (struct it *it)
if (new_face_id != it->face_id)
{
struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
- struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id);
+ struct face *old_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
/* If new face has a box but old face hasn't, this is the
start of a run of characters with box, i.e. it has a
@@ -6095,7 +6095,7 @@ pop_it (struct it *it)
break;
case GET_FROM_STRING:
{
- struct face *face = FACE_OPT_FROM_ID (it->f, it->face_id);
+ struct face *face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
/* Restore the face_box_p flag, since it could have been
overwritten by the face of the object that we just finished
@@ -6776,7 +6776,8 @@ static next_element_function const get_next_element[NUM_IT_METHODS] =
|| ((IT)->cmp_it.stop_pos == (CHARPOS) \
&& composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \
END_CHARPOS, (IT)->w, \
- FACE_OPT_FROM_ID ((IT)->f, (IT)->face_id), \
+ FACE_FROM_ID_OR_NULL ((IT)->f, \
+ (IT)->face_id), \
(IT)->string)))
@@ -7205,7 +7206,7 @@ get_next_display_element (struct it *it)
if (it->method == GET_FROM_STRING && it->sp)
{
int face_id = underlying_face_id (it);
- struct face *face = FACE_OPT_FROM_ID (it->f, face_id);
+ struct face *face = FACE_FROM_ID_OR_NULL (it->f, face_id);
if (face)
{
@@ -7738,8 +7739,8 @@ next_element_from_display_vector (struct it *it)
/* Glyphs in the display vector could have the box face, so we
need to set the related flags in the iterator, as
appropriate. */
- this_face = FACE_OPT_FROM_ID (it->f, it->face_id);
- prev_face = FACE_OPT_FROM_ID (it->f, prev_face_id);
+ this_face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
+ prev_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id);
/* Is this character the first character of a box-face run? */
it->start_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
@@ -7764,7 +7765,7 @@ next_element_from_display_vector (struct it *it)
it->saved_face_id);
}
}
- next_face = FACE_OPT_FROM_ID (it->f, next_face_id);
+ next_face = FACE_FROM_ID_OR_NULL (it->f, next_face_id);
it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
&& (!next_face
|| next_face->box == FACE_NO_BOX));
@@ -19675,14 +19676,15 @@ extend_face_to_end_of_line (struct it *it)
return;
/* The default face, possibly remapped. */
- default_face = FACE_OPT_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID));
+ default_face = FACE_FROM_ID_OR_NULL (f,
+ lookup_basic_face (f, DEFAULT_FACE_ID));
/* Face extension extends the background and box of IT->face_id
to the end of the line. If the background equals the background
of the frame, we don't have to do anything. */
- face = FACE_OPT_FROM_ID (f, (it->face_before_selective_p
- ? it->saved_face_id
- : it->face_id));
+ face = FACE_FROM_ID (f, (it->face_before_selective_p
+ ? it->saved_face_id
+ : it->face_id));
if (FRAME_WINDOW_P (f)
&& MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
@@ -24784,7 +24786,7 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
s->cmp_id = glyph->u.cmp.id;
s->cmp_from = glyph->slice.cmp.from;
s->cmp_to = glyph->slice.cmp.to + 1;
- s->face = FACE_OPT_FROM_ID (s->f, face_id);
+ s->face = FACE_FROM_ID (s->f, face_id);
lgstring = composition_gstring_from_id (s->cmp_id);
s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
glyph++;
@@ -25377,7 +25379,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
#define BUILD_COMPOSITE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
do { \
int face_id = (row)->glyphs[area][START].face_id; \
- struct face *base_face = FACE_OPT_FROM_ID (f, face_id); \
+ struct face *base_face = FACE_FROM_ID (f, face_id); \
ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id; \
struct composition *cmp = composition_table[cmp_id]; \
XChar2b *char2b; \
@@ -26694,12 +26696,8 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font,
struct face *face;
face_id = lookup_named_face (it->f, face_name, false);
- if (face_id < 0)
- return make_number (-1);
-
- face = FACE_FROM_ID (it->f, face_id);
- font = face->font;
- if (font == NULL)
+ face = FACE_FROM_ID_OR_NULL (it->f, face_id);
+ if (face == NULL || ((font = face->font) == NULL))
return make_number (-1);
boff = font->baseline_offset;
if (font->vertical_centering)
diff --git a/src/xfaces.c b/src/xfaces.c
index 97a5ae01e36..0a1315d6f0d 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1552,9 +1552,7 @@ the WIDTH times as wide as FACE on FRAME. */)
/* This is of limited utility since it works with character
widths. Keep it for compatibility. --gerd. */
int face_id = lookup_named_face (f, face, false);
- struct face *width_face = (face_id < 0
- ? NULL
- : FACE_FROM_ID (f, face_id));
+ struct face *width_face = FACE_FROM_ID_OR_NULL (f, face_id);
if (width_face && width_face->font)
{
@@ -3694,7 +3692,7 @@ Default face attributes override any local face attributes. */)
if (EQ (face, Qdefault))
{
struct face_cache *c = FRAME_FACE_CACHE (f);
- struct face *newface, *oldface = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
+ struct face *newface, *oldface = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
Lisp_Object attrs[LFACE_VECTOR_SIZE];
/* This can be NULL (e.g., in batch mode). */
@@ -3777,7 +3775,7 @@ return the font name used for CHARACTER. */)
{
struct frame *f = decode_live_frame (frame);
int face_id = lookup_named_face (f, face, true);
- struct face *fface = FACE_OPT_FROM_ID (f, face_id);
+ struct face *fface = FACE_FROM_ID_OR_NULL (f, face_id);
if (! fface)
return Qnil;
@@ -3786,9 +3784,9 @@ return the font name used for CHARACTER. */)
{
CHECK_CHARACTER (character);
face_id = FACE_FOR_CHAR (f, fface, XINT (character), -1, Qnil);
- fface = FACE_FROM_ID (f, face_id);
+ fface = FACE_FROM_ID_OR_NULL (f, face_id);
}
- return (fface->font
+ return ((fface && fface->font)
? fface->font->props[FONT_NAME_INDEX]
: Qnil);
#else /* !HAVE_WINDOW_SYSTEM */
@@ -4376,7 +4374,7 @@ lookup_face (struct frame *f, Lisp_Object *attr)
face = realize_face (cache, attr, -1);
#ifdef GLYPH_DEBUG
- eassert (face == FACE_FROM_ID (f, face->id));
+ eassert (face == FACE_FROM_ID_OR_NULL (f, face->id));
#endif /* GLYPH_DEBUG */
return face->id;
@@ -4429,7 +4427,7 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, bool signal_p)
{
Lisp_Object attrs[LFACE_VECTOR_SIZE];
Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
- struct face *default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
+ struct face *default_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (default_face == NULL)
{
@@ -4596,11 +4594,12 @@ lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id,
{
Lisp_Object attrs[LFACE_VECTOR_SIZE];
Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
- struct face *default_face = FACE_FROM_ID (f, face_id);
+ struct face *default_face;
if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
return -1;
+ default_face = FACE_FROM_ID (f, face_id);
memcpy (attrs, default_face->lface, sizeof attrs);
merge_face_vectors (f, symbol_attrs, attrs, 0);
return lookup_face (f, attrs);
@@ -4701,7 +4700,7 @@ x_supports_face_attributes_p (struct frame *f,
merge_face_vectors (f, attrs, merged_attrs, 0);
face_id = lookup_face (f, merged_attrs);
- face = FACE_OPT_FROM_ID (f, face_id);
+ face = FACE_FROM_ID_OR_NULL (f, face_id);
if (! face)
error ("Cannot make face");
@@ -4971,7 +4970,7 @@ face for italic. */)
attrs[i] = Qunspecified;
merge_face_ref (f, attributes, attrs, true, 0);
- def_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
+ def_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (def_face == NULL)
{
if (! realize_basic_faces (f))
@@ -5445,7 +5444,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
/* Determine the font to use. Most of the time, the font will be
the same as the font of the default face, so try that first. */
- default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
+ default_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (default_face
&& lface_same_font_attributes_p (default_face->lface, attrs))
{
@@ -6131,7 +6130,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
Lisp_Object attrs[LFACE_VECTOR_SIZE];
struct face *base_face;
- base_face = FACE_OPT_FROM_ID (f, base_face_id);
+ base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
if (!base_face)
return base_face_id;
@@ -6159,7 +6158,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
struct face *face;
if (face_id < 0)
return base_face_id;
- face = FACE_OPT_FROM_ID (f, face_id);
+ face = FACE_FROM_ID_OR_NULL (f, face_id);
if (!face)
return base_face_id;
merge_face_vectors (f, face->lface, attrs, 0);
@@ -6279,7 +6278,7 @@ DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */)
{
struct face *face;
CHECK_NUMBER (n);
- face = FACE_OPT_FROM_ID (SELECTED_FRAME (), XINT (n));
+ face = FACE_FROM_ID_OR_NULL (SELECTED_FRAME (), XINT (n));
if (face == NULL)
error ("Not a valid face");
dump_realized_face (face);
diff --git a/src/xterm.c b/src/xterm.c
index 9fb19a16f60..76b92dfb839 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1062,7 +1062,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
struct frame *f = XFRAME (WINDOW_FRAME (w));
struct face *face;
- face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+ face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
if (face)
XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
face->foreground);
@@ -1081,11 +1081,11 @@ static void
x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
- struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+ struct face *face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID);
struct face *face_first
- = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+ = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
struct face *face_last
- = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+ = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
unsigned long color_first = (face_first
? face_first->foreground
@@ -1507,7 +1507,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
/* What face has to be used last for the mouse face? */
face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
- face = FACE_OPT_FROM_ID (s->f, face_id);
+ face = FACE_FROM_ID_OR_NULL (s->f, face_id);
if (face == NULL)
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);