home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / layout.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  63.9 KB  |  1,602 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef _Layout_h_
  20. #define _Layout_h_
  21.  
  22. #define M12N                    /* XXXM12N include m12n changes, exclude old
  23.                                    stuff. */
  24.  
  25. #include "xp_core.h"
  26. #include "net.h"
  27. #include "cl_types.h"
  28.  
  29. #include "xp_obs.h"             /* Observer/observables. */
  30. #include "il_types.h"
  31.  
  32. /* stylesheets stuff */
  33. #include "stystruc.h"
  34. #include "stystack.h"
  35.  
  36. #include "libmocha.h"
  37.  
  38. #define MEMORY_ARENAS 1
  39.  
  40. #define NEXT_ELEMENT    state->top_state->element_id++
  41.  
  42. #define MAX_INPUT_WRITE_LEVEL   10
  43. #define LINE_BUF_INC        200
  44. #define FONT_HASH_SIZE        127
  45. #define DEFAULT_BASE_FONT_SIZE    3
  46.  
  47. #define PRE_TEXT_NO        0
  48. #define PRE_TEXT_YES        1
  49. #define PRE_TEXT_WRAP        2
  50. #define PRE_TEXT_COLS        3
  51.  
  52. #define QUOTE_NONE        0
  53. #define QUOTE_MQUOTE        1
  54. #define QUOTE_JWZ        2
  55. #define QUOTE_CITE        3
  56.  
  57. #define SUBDOC_NOT        0
  58. #define SUBDOC_IS        1
  59. #define SUBDOC_CELL        2
  60. #define SUBDOC_CAPTION        3
  61.  
  62. #define LO_ALIGN_DEFAULT    -1
  63. #define LO_ALIGN_CENTER        0
  64. #define LO_ALIGN_LEFT        1
  65. #define LO_ALIGN_RIGHT        2
  66. #define LO_ALIGN_TOP        3
  67. #define LO_ALIGN_BOTTOM        4
  68. #define LO_ALIGN_BASELINE    5
  69. #define LO_ALIGN_NCSA_CENTER    6
  70. #define LO_ALIGN_NCSA_BOTTOM    7
  71. #define LO_ALIGN_NCSA_TOP    8
  72. #define LO_ALIGN_JUSTIFY    9
  73.  
  74. #define ICON_X_OFFSET 4
  75. #define ICON_Y_OFFSET 4
  76.  
  77. #ifdef EDITOR
  78. extern char* lo_alignStrings[];
  79. #endif
  80.  
  81. #define    S_FORM_TYPE_TEXT    "text"
  82. #define    S_FORM_TYPE_RADIO    "radio"
  83. #define    S_FORM_TYPE_CHECKBOX    "checkbox"
  84. #define    S_FORM_TYPE_HIDDEN    "hidden"
  85. #define    S_FORM_TYPE_SUBMIT    "submit"
  86. #define    S_FORM_TYPE_RESET    "reset"
  87. #define    S_FORM_TYPE_PASSWORD    "password"
  88. #define    S_FORM_TYPE_BUTTON    "button"
  89. #define    S_FORM_TYPE_IMAGE    "image"
  90. #define    S_FORM_TYPE_FILE    "file"
  91. #define    S_FORM_TYPE_JOT        "jot"
  92. #define    S_FORM_TYPE_READONLY    "readonly"
  93. #define    S_FORM_TYPE_OBJECT    "object"
  94.  
  95. #define    S_AREA_SHAPE_DEFAULT    "default"
  96. #define    S_AREA_SHAPE_RECT    "rect"
  97. #define    S_AREA_SHAPE_CIRCLE    "circle"
  98. #define    S_AREA_SHAPE_POLY    "poly"
  99. #define    S_AREA_SHAPE_POLYGON    "polygon"    /* maps to AREA_SHAPE_POLY */
  100.  
  101. #define    AREA_SHAPE_UNKNOWN    0
  102. #define    AREA_SHAPE_DEFAULT    1
  103. #define    AREA_SHAPE_RECT        2
  104. #define    AREA_SHAPE_CIRCLE    3
  105. #define    AREA_SHAPE_POLY        4
  106.  
  107. #define    BODY_ATTR_BACKGROUND    0x01
  108. #define    BODY_ATTR_BGCOLOR    0x02
  109. #define    BODY_ATTR_TEXT        0x04
  110. #define    BODY_ATTR_LINK        0x08
  111. #define    BODY_ATTR_VLINK        0x10
  112. #define    BODY_ATTR_ALINK        0x20
  113. #define    BODY_ATTR_MARGINS    0x40
  114. #define    BODY_ATTR_JAVA        0x80
  115.  
  116. #define DEF_TAB_WIDTH        8
  117.  
  118. extern LO_Color lo_master_colors[];
  119.  
  120. typedef struct lo_NameList_struct {
  121.     int32 x, y;
  122.     LO_Element *element;
  123.     PA_Block name;     /* really a (char *) */
  124.     struct lo_NameList_struct *next;
  125. #ifdef MOCHA
  126.         uint32 index;           /* Needed because with nested tables, the list
  127.                                    is not guaranteed to be ordered. */
  128.     struct JSObject *mocha_object;
  129. #endif
  130. } lo_NameList;
  131.  
  132. typedef struct lo_SavedFormListData_struct {
  133.     XP_Bool valid;
  134.     int32 data_index;
  135.     int32 data_count;
  136.     PA_Block data_list;     /* really a (LO_FormElementData **) */
  137.     struct lo_SavedFormListData_struct *next;
  138. } lo_SavedFormListData;
  139.  
  140. typedef void (*lo_FreeProc)(MWContext*, void*);
  141.  
  142. typedef struct lo_EmbedDataElement {
  143.     void *data;
  144.     lo_FreeProc freeProc;
  145. } lo_EmbedDataElement;
  146.  
  147. typedef struct lo_SavedEmbedListData_struct {
  148.     int32 embed_count;
  149.     PA_Block embed_data_list;     /* really a (lo_EmbedDataElement **) */
  150. } lo_SavedEmbedListData;
  151.  
  152. typedef struct lo_SavedGridData_struct {
  153.     int32 main_width;
  154.     int32 main_height;
  155.     struct lo_GridRec_struct *the_grid;
  156. } lo_SavedGridData;
  157.  
  158. typedef struct lo_MarginStack_struct {
  159.     int32 margin;
  160.     int32 y_min, y_max;
  161.     struct lo_MarginStack_struct *next;
  162. } lo_MarginStack;
  163.  
  164.  
  165. typedef struct lo_FontStack_struct {
  166.     int32 tag_type;
  167.     LO_TextAttr *text_attr;
  168.     struct lo_FontStack_struct *next;
  169. } lo_FontStack;
  170.  
  171.  
  172. typedef struct lo_AlignStack_struct {
  173.     intn type;
  174.     int32 alignment;
  175.     struct lo_AlignStack_struct *next;
  176. } lo_AlignStack;
  177.  
  178.  
  179. typedef struct lo_ListStack_struct {
  180.     intn level;
  181.     int type;
  182.     int32 value;
  183.     Bool compact;
  184.     int bullet_type;
  185.     int8 quote_type;
  186.     int32 mquote_line_num; /* First line to put the mquote bullets on. */
  187.     int32 mquote_x; /* How far to indent the mquote. */
  188.     int32 old_left_margin;
  189.     int32 old_right_margin;
  190.     struct lo_ListStack_struct *next;
  191. } lo_ListStack;
  192.  
  193. typedef struct lo_LayerDocState lo_LayerDocState;
  194. typedef struct lo_LayerStack lo_LayerStack;
  195.  
  196. typedef struct lo_ObjectStack_struct {
  197.     LO_ObjectStruct *object;
  198.     struct lo_ObjectStack_struct *next;
  199.     uint32 param_count;
  200.     char** param_names;
  201.     char** param_values;
  202.     char* data_url;
  203.     MWContext* context;
  204.     struct lo_DocState_struct* state;
  205.     PA_Tag* real_tag;
  206.     PA_Tag* clone_tag;
  207.     Bool read_params;
  208.     Bool formatted_object;
  209. } lo_ObjectStack;
  210.  
  211.  
  212. typedef struct lo_LineHeightStack_struct {
  213.     int32  height;
  214.     struct lo_LineHeightStack_struct *next;
  215. } lo_LineHeightStack;
  216.  
  217. typedef struct lo_FormData_struct {
  218.     intn id;
  219.     PA_Block action;
  220.     PA_Block encoding;
  221.     PA_Block window_target;
  222.     int32 method;
  223.     int32 form_ele_cnt;
  224.     int32 form_ele_size;
  225.     PA_Block form_elements;        /* really a (LO_Element **) */
  226.     struct lo_FormData_struct *next;
  227. #ifdef MOCHA
  228.     PA_Block name;
  229.     struct JSObject *mocha_object;
  230. #endif
  231. } lo_FormData;
  232.  
  233.  
  234. typedef struct lo_TableCell_struct {
  235.     Bool start_in_form;
  236.     intn form_id;
  237.     int32 form_ele_cnt;
  238.     int32 form_data_index;
  239.     int32 embed_count_base;
  240.     int32 url_count_base;
  241.         int32 image_list_count_base;
  242.         int32 applet_list_count_base;
  243.         int32 embed_list_count_base;
  244.         int32 current_layer_num_base;
  245.     Bool must_relayout;
  246.     intn is_a_subdoc;
  247.     PA_Tag *subdoc_tags;
  248.     PA_Tag *subdoc_tags_end;
  249.     int32 max_y;
  250.     int32 horiz_alignment;
  251.     int32 vert_alignment;
  252.     int32 cell_base_x;
  253.     int32 cell_base_y;
  254.  
  255.     Bool cell_done;
  256.     Bool nowrap;
  257.     Bool is_a_header;
  258.     int32 specified_width, specified_height;
  259.     int32 percent_width, percent_height;
  260.     int32 min_width, max_width;
  261.     int32 height, baseline;
  262.     int32 rowspan, colspan;
  263.     LO_CellStruct *cell;
  264.     struct lo_TableCell_struct *next;
  265.     int32 beginning_tag_count;
  266.     Bool in_nested_table;    /* Can be removed once we remove subdoc tags.                               
  267.                              * Used to figure out whether we shoul free subdoc tags or not 
  268.                              */
  269. } lo_TableCell;
  270.  
  271.  
  272. typedef struct lo_TableRow_struct {
  273.     Bool row_done;
  274.     Bool has_percent_width_cells;
  275.     lo_Backdrop backdrop;       /* default for cells to inherit */
  276.     int32 cells;            /* is a counter that gets updated as a new cell is seen for a row */
  277.     int32 cells_in_row;        /* is the exact number of LO_CELLS in the line list for each row.  Calculated in lo_fill_cell_array */
  278.     int32 vert_alignment;
  279.     int32 horiz_alignment;
  280.     lo_TableCell *cell_list;
  281.     lo_TableCell *cell_ptr;
  282.     struct lo_TableRow_struct *next;
  283. } lo_TableRow;
  284.  
  285.  
  286. typedef struct lo_TableCaption_struct {
  287.     int32 vert_alignment;
  288.     int32 horiz_alignment;
  289.     int32 min_width, max_width;
  290.     int32 height;
  291.     int32 rowspan, colspan;
  292.     LO_SubDocStruct *subdoc;
  293.     LO_CellStruct *cell_ele;    /* Kept around for relayout without reload */
  294. } lo_TableCaption;
  295.  
  296.  
  297. typedef struct lo_table_span_struct {
  298.     int32 dim, min_dim;
  299.     int32 span;
  300.     struct lo_table_span_struct *next;
  301. } lo_table_span;
  302.  
  303. typedef struct lo_TableRec_struct {
  304.     intn draw_borders;
  305.     Bool has_percent_width_cells;
  306.     Bool table_width_fixed;
  307.     Bool has_percent_height_cells;
  308.     int32 percent_width;
  309.     int32 percent_height;
  310.     lo_Backdrop backdrop;       /* default for cells to inherit */
  311.     int32 rows, cols;
  312.     int32 width, height;
  313.     int32 inner_top_pad;
  314.     int32 inner_bottom_pad;
  315.     int32 inner_left_pad;
  316.     int32 inner_right_pad;
  317.     int32 inter_cell_pad;
  318.     int32 default_cell_width;
  319.     int32 fixed_cols;
  320.     int32 fixed_width_remaining;
  321.     lo_table_span *width_spans;
  322.     lo_table_span *width_span_ptr;
  323.     lo_table_span *height_spans;
  324.     lo_table_span *height_span_ptr;
  325.     lo_TableCaption *caption;
  326.     LO_TableStruct *table_ele;
  327.     LO_SubDocStruct *current_subdoc;
  328.     lo_TableRow *row_list;
  329.     lo_TableRow *row_ptr;
  330.     int32 *fixed_col_widths;
  331. } lo_TableRec;
  332.  
  333.  
  334. /*
  335.  * This structure contains all the element lists associated with a
  336.  * document that are reflected into mocha. There's one per top-level
  337.  * document (in the top_state), and one per layer.
  338.  * XXX BUGBUG The things that are missing from this list include:
  339.  *  - The savedData stuff
  340.  *  - A document's map_list
  341.  * Why? I don't feel comfortable moving these guys around at this point.
  342.  */
  343. typedef struct lo_DocLists_struct {
  344.     LO_EmbedStruct *embed_list;     /* embeds linked in reverse order */
  345.     int32 embed_list_count;         /* The number of embeds in the list */
  346.     
  347.     LO_JavaAppStruct *applet_list;  /* applets linked in reverse order */
  348.     int32 applet_list_count;        /* The number of applets in the list */
  349.  
  350.     LO_ImageStruct *image_list;        /* list of images in doc */
  351.     LO_ImageStruct *last_image;        /* last image in image_list */
  352.     uint32 image_list_count;        /* Number of images in the list */
  353.  
  354.     lo_NameList *name_list;    /* list of positions of named anchors */
  355.     uint32 anchor_count;        /* Count of named anchors in this document */
  356.  
  357.     lo_FormData *form_list;    /* list of forms in doc */
  358.     intn current_form_num;      /* The id of the next form to lay out */
  359.  
  360. #ifdef XP_WIN16
  361.     intn ulist_array_size;
  362.     XP_Block ulist_array;    /* really a (XP_Block *) */
  363. #endif /* XP_WIN16 */
  364.     XP_Block url_list;        /* really a (LO_AnchorData **) PA_Block */
  365.     intn url_list_len;          /* Number of URLs in the list */
  366.     intn url_list_size;         /* Size of the list buffer */
  367.  
  368. } lo_DocLists;
  369.  
  370. typedef struct lo_MultiCol_struct {
  371.     LO_Element *end_last_line;
  372.     int32 start_ele;
  373.     int32 start_line, end_line;
  374.     int32 start_y, end_y;
  375.     int32 start_x;
  376.     int32 cols;
  377.     int32 col_width;
  378.     int32 orig_margin;
  379.     int32 orig_min_width;
  380.     int32 orig_display_blocking_element_y;
  381.     int32 gutter;
  382.     Bool orig_display_blocked;
  383.     Bool close_table;
  384.     int32 width;            /* For relayout without reload */
  385.     Bool isPercentWidth;    /* For relayout without reload */
  386.     struct lo_MultiCol_struct *next;
  387. } lo_MultiCol;
  388.  
  389. #define    LO_PERCENT_NORMAL    0
  390. #define    LO_PERCENT_FREE        1
  391. #define    LO_PERCENT_FIXED    2
  392.  
  393. typedef struct lo_GridPercent_struct {
  394.     uint8 type;
  395.     int32 value;
  396.     int32 original_value;
  397. } lo_GridPercent;
  398.  
  399. typedef struct lo_GridHistory_struct {
  400.     void *hist;        /* really a SHIST history pointer */
  401.     int32 position;
  402. } lo_GridHistory;
  403.  
  404. typedef struct lo_GridCellRec_struct {
  405.     int32 x, y;
  406.     int32 width, height;
  407.     int32 margin_width, margin_height;
  408.     intn width_percent;
  409.     intn height_percent;
  410.     char *url;
  411.     char *name;
  412.     MWContext *context;
  413.     void *hist_list;        /* really a (XP_List *) */
  414.     lo_GridHistory *hist_array;
  415.     int32 hist_indx;
  416.     int8 scrolling;
  417.     Bool resizable;
  418.     Bool no_edges;
  419.     int16 edge_size;
  420.     int8 color_priority;
  421.     LO_Color *border_color;
  422.     struct lo_GridEdge_struct *side_edges[4]; /* top, bottom, left, right */
  423.     struct lo_GridCellRec_struct *next;
  424.     struct lo_GridRec_struct *subgrid;
  425.  
  426.     Bool needs_restructuring;
  427. } lo_GridCellRec;
  428.  
  429. typedef struct lo_GridEdge_struct {
  430.     int32 x, y;
  431.     int32 width, height;
  432.     Bool is_vertical;
  433.     int32 left_top_bound;
  434.     int32 right_bottom_bound;
  435.     int32 cell_cnt;
  436.     int32 cell_max;
  437.     lo_GridCellRec **cell_array;
  438.     LO_EdgeStruct *fe_edge;
  439.     struct lo_GridEdge_struct *next;
  440.  
  441.     Bool dealt_with_in_relayout;
  442. } lo_GridEdge;
  443.  
  444. typedef struct lo_GridRec_struct {
  445.     int32 main_width, main_height;
  446.     int32 current_hist, max_hist, hist_size;
  447.     int32 grid_cell_border;
  448.     int32 grid_cell_min_dim;
  449.     int32 rows, cols;
  450.     int32 current_cell_margin_width;
  451.     int32 current_cell_margin_height;
  452.     lo_GridPercent *row_percents;
  453.     lo_GridPercent *col_percents;
  454.     lo_GridCellRec *cell_list;
  455.     lo_GridCellRec *cell_list_last;
  456.     int32 cell_count;
  457.     Bool no_edges;
  458.     int16 edge_size;
  459.     int8 color_priority;
  460.     LO_Color *border_color;
  461.     lo_GridEdge *edge_list;
  462.     struct lo_GridRec_struct *subgrid;
  463. } lo_GridRec;
  464.  
  465. extern lo_GridCellRec *
  466. lo_ContextToCell(MWContext *context, Bool reconnect, lo_GridRec **grid_ptr);
  467.  
  468.  
  469. typedef struct lo_MapRec_struct {
  470.     char *name;
  471.     struct lo_MapAreaRec_struct *areas;
  472.     struct lo_MapAreaRec_struct *areas_last;
  473.     struct lo_MapRec_struct *next;
  474. } lo_MapRec;
  475.  
  476. typedef struct lo_MapAreaRec_struct {
  477.     int16 type;
  478.     int16 alt_len;
  479.     PA_Block alt;
  480.     int32 *coords;
  481.     int32 coord_cnt;
  482.     LO_AnchorData *anchor;
  483.     struct lo_MapAreaRec_struct *next;
  484. } lo_MapAreaRec;
  485.  
  486. #ifdef HTML_CERTIFICATE_SUPPORT
  487. typedef struct lo_Certificate_struct {
  488.     PA_Block name;        /* really a (char *) */
  489.     void *cert;        /* really a (char *) */
  490.     struct lo_Certificate_struct *next;
  491. } lo_Certificate;
  492. #endif /* HTML_CERTIFICATE_SUPPORT */
  493.  
  494. typedef struct lo_TopState_struct     lo_TopState;
  495.  
  496.  
  497. #ifdef TEST_16BIT
  498. #define XP_WIN16
  499. #endif /* TEST_16BIT */
  500. typedef struct lo_DocState_struct {
  501.     lo_TopState *top_state;
  502.     PA_Tag *subdoc_tags;    /* tags that created this subdoc */
  503.     PA_Tag *subdoc_tags_end;    /* End of subdoc tags list */
  504.  
  505.     int32 base_x, base_y;    /* upper left of document */
  506.     int32 x, y;            /* upper left of element in progress */
  507.     int32 width;        /* width of element in progress */
  508.     int32 win_width;            /* Document or subdoc dimensions */
  509.     int32 win_height;
  510.     int32 max_height;        /* farthest down item so far. */
  511.     int32 max_width;        /* width of widest line so far. */
  512.     int32 min_width;        /* minimum possible line width */
  513.     int32 break_holder;        /* holder for last break position width */
  514.     int32 line_num;        /* line number of the next line to be placed */
  515.     int32 preformat_cols;    /* Column to break special PRE_TEXT_COLS at */
  516.     intn linefeed_state;
  517.     int8 preformatted;        /* processing preformatted (maybe wrap) text */
  518.     Bool allow_amp_escapes;    /* Let & entites be expanded */
  519.     Bool breakable;        /* Working on a breakable element */
  520.     Bool delay_align;        /* in subdoc, delay aligning lines */
  521.     Bool display_blocked;    /* do not display during layout */
  522.     Bool in_paragraph;        /* inside an HTML 3.0 paragraph container */
  523.     int32 display_blocking_element_id;
  524.     int32 display_blocking_element_y;
  525.  
  526.     int32 win_top;
  527.     int32 win_bottom;
  528.     int32 win_left;
  529.     int32 win_right;
  530.     int32 left_margin;
  531.     int32 right_margin;
  532.     lo_MarginStack *left_margin_stack;
  533.     lo_MarginStack *right_margin_stack;
  534.  
  535.     int32 text_divert;    /* the tag type of a text diverter (like P_TITLE) */
  536.  
  537. #ifdef XP_WIN16
  538.     intn larray_array_size;
  539.     XP_Block larray_array;    /* really a (XP_Block *) */
  540. #endif /* XP_WIN16 */
  541.     intn line_array_size;
  542.     XP_Block line_array;    /* really a (LO_Element **) */
  543.     LO_Element *line_list;    /* Element list for the current line so far */
  544.     LO_Element *end_last_line;    /* Element at end of last line */
  545.  
  546.     LO_Element *float_list;    /* Floating element list for the current doc */
  547.  
  548.     intn base_font_size;    /* size of font at bottom of font stack */
  549.     lo_FontStack *font_stack;
  550.  
  551.     lo_AlignStack *align_stack;
  552.  
  553.     lo_ListStack *list_stack;
  554.  
  555.     lo_LineHeightStack *line_height_stack;
  556.  
  557.     LO_TextInfo text_info;    /* for text of last text element created */
  558.     /* this is a buffer for a single (currently processed) line of text */
  559.     PA_Block line_buf;        /* lock to a (char *) */
  560.     int32 line_buf_len;
  561.     int32 line_buf_size;
  562.     int32 baseline;
  563.     int32 line_height;
  564.     int32 default_line_height;
  565.     int32 break_pos;        /* position in middle of current element */
  566.     int32 break_width;
  567.     Bool last_char_CR;
  568.     Bool trailing_space;
  569.     Bool at_begin_line;
  570.     Bool hide_content;  /* set to not display text */
  571.  
  572.     LO_TextStruct *old_break;
  573.     LO_TextBlock *old_break_block;
  574.     int32 old_break_pos;    /* in middle of older element on this line */
  575.     int32 old_break_width;
  576.  
  577.     PA_Block current_named_anchor;    /* lock to a (char *) */
  578.     LO_AnchorData *current_anchor;
  579.  
  580.     intn cur_ele_type;
  581.     LO_Element *current_ele;    /* element in process, no end tag yet */
  582.  
  583.     LO_JavaAppStruct *current_java; /* java applet in process, no end tag yet */
  584.     
  585.     lo_TableRec *current_table;
  586.     lo_GridRec *current_grid;
  587.     lo_MultiCol *current_multicol;
  588.     intn layer_nest_level;    /* Layer nesting level for this (sub)doc */
  589.  
  590.     Bool start_in_form;        /* Was in a form at start of (sub)doc */
  591.     intn form_id;        /* first form entering this (sub)doc */
  592.     int32 form_ele_cnt;        /* first form element entering this (sub)doc */
  593.     int32 form_data_index;    /* first form data entering this (sub)doc */
  594.     int32 embed_count_base;    /* number of embedded elements (applets and embeds) before beginning this (sub)doc */
  595.     /* 
  596.      * Just to clarify: the embed_count is the total of all applets and 
  597.      * embeds in the document. This is used for indexing into the saved
  598.      * data structure. The applet_list_count and embed_list_count are
  599.      * applets and embeds in the current container. This is used to index
  600.      * into the applet and embed lists of the container.
  601.      */
  602.     int32 url_count_base;    /* number of anchors before beginning this (sub)doc */
  603.     int32 image_list_count_base;  /* number of images before this (sub)doc */
  604.     int32 applet_list_count_base; /* number of applets before this (sub)doc */
  605.     int32 embed_list_count_base;  /* number of embeds before this (sub)doc */
  606.     int32 current_layer_num_base; /* id of last layer before this (sub)doc */
  607.     int32 current_layer_num_max;  /* id of the last layer in this (sub)doc */
  608.     Bool must_relayout_subdoc;
  609.     Bool allow_percent_width;
  610.     Bool allow_percent_height;
  611.     intn is_a_subdoc;
  612.     int32 current_subdoc;
  613.     XP_Block sub_documents;    /* really a lo_DocState ** array */
  614.     struct lo_DocState_struct *sub_state;
  615.  
  616.     LO_Element *current_cell;
  617.  
  618.     Bool extending_start;
  619.     LO_Element *selection_start;
  620.     int32 selection_start_pos;
  621.     LO_Element *selection_end;
  622.     int32 selection_end_pos;
  623.     LO_Element *selection_new;
  624.     int32 selection_new_pos;
  625.     CL_Layer *selection_layer;
  626.  
  627.     LO_Color text_fg;
  628.     LO_Color text_bg;
  629.     LO_Color anchor_color;
  630.     LO_Color visited_anchor_color;
  631.     LO_Color active_anchor_color;
  632.     ED_Element *edit_current_element;
  633.     int edit_current_offset;
  634.     Bool edit_force_offset;
  635.     Bool edit_relayout_display_blocked;
  636. #ifdef MOCHA
  637.     Bool in_relayout;    /* true if we're in lo_RelayoutSubdoc */
  638. #endif
  639.  
  640.     int32 tab_stop;
  641.     int32 beginning_tag_count;  /* the tag count at the beginning of this state */
  642.     
  643.     LO_TextBlock * cur_text_block;
  644.     Bool need_min_width;
  645.     uint32 src_text_offset;
  646. } lo_DocState;
  647.  
  648. #ifdef TEST_16BIT
  649. #undef XP_WIN16
  650. #endif /* TEST_16BIT */
  651.  
  652. #define STATE_DEFAULT_FG_RED(state)        ((state)->text_fg.red)
  653. #define STATE_DEFAULT_FG_GREEN(state)        ((state)->text_fg.green)
  654. #define STATE_DEFAULT_FG_BLUE(state)        ((state)->text_fg.blue)
  655.  
  656. #define STATE_DEFAULT_BG_RED(state)        ((state)->text_bg.red)
  657. #define STATE_DEFAULT_BG_GREEN(state)        ((state)->text_bg.green)
  658. #define STATE_DEFAULT_BG_BLUE(state)        ((state)->text_bg.blue)
  659.  
  660. #define STATE_UNVISITED_ANCHOR_RED(state)    ((state)->anchor_color.red)
  661. #define STATE_UNVISITED_ANCHOR_GREEN(state)    ((state)->anchor_color.green)
  662. #define STATE_UNVISITED_ANCHOR_BLUE(state)    ((state)->anchor_color.blue)
  663.  
  664. #define STATE_VISITED_ANCHOR_RED(state)        ((state)->visited_anchor_color.red)
  665. #define STATE_VISITED_ANCHOR_GREEN(state)    ((state)->visited_anchor_color.green)
  666. #define STATE_VISITED_ANCHOR_BLUE(state)    ((state)->visited_anchor_color.blue)
  667.  
  668. #define STATE_SELECTED_ANCHOR_RED(state)    ((state)->active_anchor_color.red)
  669. #define STATE_SELECTED_ANCHOR_GREEN(state)    ((state)->active_anchor_color.green)
  670. #define STATE_SELECTED_ANCHOR_BLUE(state)    ((state)->active_anchor_color.blue)
  671.  
  672.  
  673. #ifdef MEMORY_ARENAS
  674. typedef struct lo_arena_struct {
  675.         struct lo_arena_struct *next;
  676.         char *limit;
  677.         char *avail;
  678. } lo_arena;
  679. #endif /* MEMORY_ARENAS */
  680.  
  681. /*
  682. ** This is just like SHIST_SavedData except the fields are more strictly
  683. ** typed.
  684. */
  685. typedef struct lo_SavedData {
  686.     lo_SavedFormListData*    FormList;    /* Data for all form elements in doc */
  687.     lo_SavedEmbedListData*    EmbedList;    /* session data for all embeds and applets in doc */
  688.     lo_SavedGridData*        Grid;        /* saved for grid history. */
  689. #ifdef MOCHA
  690.     PA_Block            OnLoad;        /* JavaScript onload event handler source */
  691.     PA_Block            OnUnload;    /* JavaScript onunload event handler source */
  692.     PA_Block            OnFocus;    /* JavaScript onfocus event handler source */
  693.     PA_Block            OnBlur;        /* JavaScript onblur event handler source */
  694.     PA_Block            OnHelp;        /* JavaScript onhelp event handler source */
  695.     PA_Block            OnMouseOver;    /* JavaScript onmouseover event handler source */
  696.     PA_Block            OnMouseOut;    /* JavaScript onmouseout event handler source */
  697.     PA_Block            OnDragDrop;    /* JavaScript ondragdrop event handler source */
  698.     PA_Block            OnMove;        /* JavaScript onmove event handler source */
  699.     PA_Block            OnResize;    /* JavaScript onresize event handler source */
  700. #endif
  701. } lo_SavedData;
  702.  
  703. /* 
  704.  * This is used when we have an input stream and we need to defer
  705.  * the destruction of the main parser stream till we're done 
  706.  * processing all inline streams.
  707.  */
  708. typedef void lo_FreeStreamFunc(MWContext *, NET_StreamClass *);
  709.  
  710. /*
  711.  * Top level state
  712.  */
  713. struct lo_TopState_struct {
  714. #ifdef MEMORY_ARENAS
  715.     lo_arena *first_arena;
  716.     lo_arena *current_arena;
  717. #endif /* MEMORY_ARENAS */
  718.     PA_Tag *tags;        /* Held tags while layout is blocked */
  719.     PA_Tag **tags_end;        /* End of held tags list */
  720.     PRPackedBool doc_specified_bg;
  721.     PRPackedBool nothing_displayed;
  722.     PRPackedBool in_head;    /* Still in the HEAD of the HTML doc. */
  723.     PRPackedBool in_body;    /* In the BODY of the HTML doc. */
  724.     PRPackedBool scrolling_doc;    /* Is this a special scrolling doc (hack) */
  725.     PRPackedBool have_title;    /* set by first <TITLE> */
  726.     PRPackedBool in_form;    /* true if in <FORM>...</FORM> */
  727.     uint8 body_attr;        /* What attributes were set by BODY */
  728.     char *unknown_head_tag;    /* ignore content in this case if non-NULL */
  729.     char *base_target;        /* Base target of urls in this document */
  730.     char *base_url;        /* Base url of this document */
  731.     char *inline_stream_blocked_base_url; /* Base url for prefetched images */
  732.     char *main_stream_blocked_base_url; /* Base url for prefetched images */
  733.     char *url;            /* Real url of this document */
  734.     char *name_target;        /* The #name part of the url */
  735.     int32 element_id;
  736.     LO_Element *layout_blocking_element;
  737.     LO_Element *current_script;
  738.     intn layout_status;
  739.  
  740.     lo_DocLists doc_lists;      /* Lists of reflected elements */
  741.  
  742.     lo_LayerDocState **layers;  /* Array of ptrs to all layers in current doc */
  743.     int32 num_layers_allocated; /* Length of layers array */
  744.     int32 current_layer_num;    /* Id of last layer to be laid out */
  745.     int32 max_layer_num;        /* Largest id of any layer yet laid out */
  746.     
  747.     lo_LayerStack *layer_stack;
  748.  
  749.     lo_MapRec *map_list;    /* list of maps in doc */
  750.     lo_MapRec *current_map;    /* Current open MAP tag */
  751.  
  752.     int32 embed_count;            /* master count of embeds in this document */
  753.     lo_SavedData savedData;    /* layout data */
  754.  
  755.     int32 total_bytes;
  756.     int32 current_bytes;
  757.     int32 layout_bytes;
  758.     int32 script_bytes;
  759.     intn layout_percent;
  760.  
  761.     lo_GridRec *the_grid;
  762.     lo_GridRec *old_grid;
  763.  
  764.     PRPackedBool is_grid;    /* once a grid is started, ignore other tags */
  765.     int ignore_tag_nest_level;   /* For NOSCRIPT, NOEMBED, NOLAYER */
  766.     int ignore_layer_nest_level; /* For <LAYER SUPPRESS> */
  767.     
  768.     PRPackedBool in_nogrids;    /* special way to ignore tags in <noframes> */
  769.     PRPackedBool in_applet;    /* special way to ignore tags in java applet */
  770.     PRPackedBool is_binary;    /* hack for images instead of HTML doc */
  771.     PRPackedBool insecure_images; /* secure doc with insecure images */
  772.     PRPackedBool out_of_memory;    /* ran out of memory mid-layout */
  773.     NET_ReloadMethod
  774.          force_reload;        /* URL_Struct reload flag */
  775.     intn auto_scroll;        /* Chat auto-scrolling layout, # of lines */
  776.     intn security_level;    /* non-zero for secure docs. */
  777.     URL_Struct *nurl;        /* the netlib url struct */
  778.  
  779.     PA_Block font_face_array;    /* really a (char **) */
  780.     intn font_face_array_len;
  781.     intn font_face_array_size;
  782.  
  783.     XP_Block text_attr_hash;    /* really a (LO_TextAttr **) */
  784.  
  785.     LO_Element *recycle_list;    /* List of Elements to be reused */
  786.     LO_Element *trash;        /* List of Elements to discard later */
  787.  
  788.     lo_DocState *doc_state;
  789.  
  790.     ED_Buffer *edit_buffer;
  791. #ifdef MOCHA
  792.     uint32 script_tag_count;    /* number of script tags processed so far */
  793.     uint script_lineno;    /* parser newline count at last <SCRIPT> tag */
  794.     int8 in_script;        /* script type if in script, see below */
  795.     PRPackedBool in_blocked_script; /* inside blocked <SCRIPT> tag container */
  796.     int8 default_style_script_type;    /* the default script type or the last 
  797.                     * type of script encountered 
  798.                      */
  799.     PRPackedBool resize_reload;    /* is this a resize-induced reload? */
  800.     PRPackedBool mocha_has_onload;
  801.     PRPackedBool mocha_has_onunload;
  802.     JSVersion version;
  803.     uint32 mocha_loading_applets_count;
  804.     uint32 mocha_loading_embeds_count;
  805.     NET_StreamClass *mocha_write_stream;
  806.     void *scriptData;
  807. #endif
  808.  
  809.     struct pa_DocData_struct *doc_data;
  810.     PA_Tag **input_write_point[MAX_INPUT_WRITE_LEVEL];
  811.     uint32 input_write_level;
  812.     PRPackedBool tag_from_inline_stream;
  813.  
  814. #ifdef HTML_CERTIFICATE_SUPPORT
  815.     lo_Certificate *cert_list;    /* list of certificates in doc */
  816. #endif
  817.     StyleAndTagStack * style_stack;
  818.     char *small_bm_icon;
  819.     char *large_bm_icon;
  820.  
  821.     Bool diff_state;        /* set if our state record is different but at the same level */
  822.     int32 state_pushes;        /* how many new states have we added */
  823.     int32 state_pops;        /* how many states have we removed */
  824.     CL_Layer *doc_layer;        /* Root document layer */
  825.     CL_Layer *body_layer;       /* Layer enclosing contents of BODY tag */
  826.     lo_ObjectStack *object_stack;    /* See layobj.c */
  827.     lo_ObjectStack *object_cache;
  828.     int32 tag_count;            /* sequential tag numbering */
  829.     PRPackedBool flushing_blockage;
  830.     PRPackedBool wedged_on_mocha;
  831.     Bool in_cell_relayout;
  832. #ifdef DEBUG_ScriptPlugin
  833.     char * mimetype;
  834. #endif 
  835. };
  836.  
  837. /* Script type codes, stored in top_state->in_script. */
  838. #define SCRIPT_TYPE_NOT        0
  839. #define SCRIPT_TYPE_MOCHA    1
  840. #define SCRIPT_TYPE_CSS        2
  841. #define SCRIPT_TYPE_JSSS    3
  842. #define SCRIPT_TYPE_UNKNOWN    4
  843. #ifdef DEBUG_ScriptPlugin
  844. #define SCRIPT_TYPE_PLUGIN  5
  845. #endif
  846. #ifdef MOCHA
  847. extern void 
  848. lo_DestroyScriptData(void *data); 
  849. #endif
  850.  
  851. /* Define to get the reload flag of the current document */
  852. #define FORCE_RELOAD_FLAG(top_state) \
  853.     ((top_state)->resize_reload ? NET_RESIZE_RELOAD : (top_state)->force_reload)
  854.  
  855.  
  856. /*
  857.     Internal Prototypes
  858. */
  859.  
  860. extern lo_FontStack *lo_DefaultFont(lo_DocState *, MWContext *);
  861. extern Bool lo_FilterTag(MWContext *, lo_DocState *, PA_Tag *);
  862. extern void lo_LayoutTag(MWContext *, lo_DocState *, PA_Tag *);
  863. extern void lo_PreLayoutTag(MWContext *, lo_DocState *, PA_Tag *);
  864. extern void lo_PostLayoutTag(MWContext *, lo_DocState *, PA_Tag *, XP_Bool);
  865. extern void lo_SaveSubdocTags(MWContext *, lo_DocState *, PA_Tag *);
  866. extern void lo_FreshText(lo_DocState *);
  867. extern void lo_InsertLineBreak(MWContext *, lo_DocState *, uint32, uint32, Bool);
  868. extern void lo_HardLineBreak(MWContext *, lo_DocState *, Bool);
  869. extern void lo_HardLineBreakWithClearType(MWContext *, lo_DocState *, uint32, Bool);
  870. extern void lo_SoftLineBreak(MWContext *, lo_DocState *, Bool);
  871. extern void lo_SetSoftLineBreakState(MWContext *, lo_DocState *, Bool, intn);
  872. extern void lo_SetLineBreakState(MWContext *context, lo_DocState *state, Bool breaking,
  873.     uint32 break_type, intn linefeed_state, Bool relayout);
  874. extern void lo_InsertWordBreak(MWContext *, lo_DocState *);
  875. extern void lo_FormatText(MWContext *, lo_DocState *, char *);
  876. extern void lo_PreformatedText(MWContext *, lo_DocState *, char *);
  877. extern LO_Element * lo_RelayoutTextBlock ( MWContext * context, lo_DocState * state, LO_TextBlock * block, LO_TextStruct * fromElement );
  878. extern Bool lo_ChangeText ( LO_TextBlock * block, char * text );
  879. extern void lo_FlushLineBuffer(MWContext *, lo_DocState *);
  880. extern void lo_FlushTextBlock ( MWContext *context, lo_DocState *state );
  881. extern void lo_ResetFontStack(MWContext *, lo_DocState *);
  882. extern void lo_ChangeBodyTextFGColor(MWContext *context, lo_DocState *state, LO_Color *color);
  883. extern void lo_PushFont(lo_DocState *, intn, LO_TextAttr *);
  884. extern LO_TextAttr *lo_PopFont(lo_DocState *, intn);
  885. extern void lo_PopAllAnchors(lo_DocState *);
  886. extern void lo_FlushLineList(MWContext *, lo_DocState *, uint32, uint32, Bool);
  887. extern LO_LinefeedStruct *lo_NewLinefeed(lo_DocState *, MWContext *, uint32, uint32);
  888. extern void lo_HorizontalRule(MWContext *, lo_DocState *, PA_Tag *);
  889. extern void lo_FormatImage(MWContext *, lo_DocState *, PA_Tag *);
  890. extern void lo_FormatEmbed(MWContext *, lo_DocState *, PA_Tag *);
  891. extern void lo_RelayoutEmbed ( MWContext *context, lo_DocState *state,
  892.     LO_EmbedStruct * embed, PA_Tag * tag );
  893. extern void lo_FormatJavaApp(MWContext *, lo_DocState *, PA_Tag *);
  894. extern void lo_JavaAppParam(MWContext *, lo_DocState *, PA_Tag *, LO_JavaAppStruct *);
  895. extern void lo_CloseJavaApp(MWContext *, lo_DocState *, LO_JavaAppStruct *);
  896. void lo_RelayoutJavaApp(MWContext *, lo_DocState *, PA_Tag *, LO_JavaAppStruct * );
  897. extern void lo_ProcessSpacerTag(MWContext *, lo_DocState *, PA_Tag *);
  898. extern void lo_ProcessBodyTag(MWContext *, lo_DocState *, PA_Tag *);
  899. extern char *lo_ParseBackgroundAttribute(MWContext *, 
  900.                                          lo_DocState *, PA_Tag *, 
  901.                                          Bool);
  902. extern void lo_BodyBackground(MWContext *, lo_DocState *, PA_Tag *, Bool);
  903. extern void lo_BodyForeground(MWContext *, lo_DocState *, PA_Tag *);
  904. extern int32 lo_ValueOrPercent(char *, Bool *);
  905. extern void lo_BreakOldElement(MWContext *, lo_DocState *);
  906. extern void lo_BreakOldTextBlockElement(MWContext *context, lo_DocState *state);
  907. extern int32 lo_baseline_adjust(MWContext *context, lo_DocState *state, LO_Element *ele_list,
  908.     int32 old_baseline, int32 old_line_height);
  909. extern void lo_UpdateElementPosition ( lo_DocState * state, LO_Element * element );
  910. extern void lo_CopyTextAttr(LO_TextAttr *, LO_TextAttr *);
  911. extern LO_TextAttr *lo_FetchTextAttr(lo_DocState *, LO_TextAttr *);
  912. extern void lo_FindLineMargins(MWContext *, lo_DocState *, Bool updateFE);
  913. extern void lo_AddMarginStack(lo_DocState *, int32, int32, int32, int32,
  914.                 int32, int32, int32, intn);
  915. extern LO_AnchorData *lo_NewAnchor(lo_DocState *, PA_Block, PA_Block);
  916. extern void lo_DestroyAnchor(LO_AnchorData *anchor_data);
  917. extern void lo_AddToUrlList(MWContext *, lo_DocState *, LO_AnchorData *);
  918. extern void lo_AddEmbedData(MWContext *, void *, lo_FreeProc, int32);
  919. extern lo_ListStack *lo_DefaultList(lo_DocState *);
  920. extern void lo_PushList(lo_DocState *, PA_Tag *, int8);
  921. extern lo_ListStack *lo_PopList(lo_DocState *, PA_Tag *);
  922.  
  923. extern void lo_PushAlignment(lo_DocState *, intn, int32);
  924. extern lo_AlignStack *lo_PopAlignment(lo_DocState *);
  925.  
  926. extern void lo_PushLineHeight(lo_DocState *, int32);
  927. extern lo_LineHeightStack *lo_PopLineHeight(lo_DocState *);
  928.  
  929. extern Bool lo_InitDocLists(MWContext *context, lo_DocLists *doc_lists);
  930. extern void lo_DeleteDocLists(MWContext *context, lo_DocLists *doc_lists);
  931.  
  932. extern lo_TopState *lo_NewTopState(MWContext *, char *);
  933. extern void lo_PushStateLevel(MWContext *context);
  934. extern void lo_PopStateLevel(MWContext *context);
  935. extern lo_DocState *lo_NewLayout(MWContext *, int32, int32, int32, int32,
  936.                 lo_DocState*);
  937. extern lo_DocState *
  938. lo_InitDocState(lo_DocState *state, MWContext *context,
  939.                 int32 width, int32 height,
  940.                 int32 margin_width, int32 margin_height,
  941.                 lo_DocState* clone_state,
  942.                 lo_DocLists *doc_lists,
  943.                 PRBool is_for_new_layer);
  944.  
  945. extern lo_SavedFormListData *lo_NewDocumentFormListData(void);
  946. extern Bool lo_StoreTopState(int32, lo_TopState *);
  947. extern lo_TopState *lo_FetchTopState(int32);
  948. extern lo_DocState *lo_TopSubState(lo_TopState *);
  949. extern lo_DocState *lo_CurrentSubState(lo_DocState *);
  950.  
  951. extern void lo_InheritParentState(MWContext *, lo_DocState *, lo_DocState *);
  952. extern void lo_InheritParentColors(MWContext *context, lo_DocState *child_state, lo_DocState *parent_state);
  953. extern void lo_GetImage(MWContext *context, IL_GroupContext *img_cx,
  954.                         LO_ImageStruct *lo_image, XP_ObserverList obs_list,
  955.                         NET_ReloadMethod requested_reload_method);
  956. extern void lo_NoMoreImages(MWContext *);
  957. extern void lo_FinishImage(MWContext *, lo_DocState *, LO_ImageStruct *);
  958. extern void lo_FinishEmbed(MWContext *, lo_DocState *, LO_EmbedStruct *);
  959. extern void lo_BlockedImageLayout(MWContext *, lo_DocState *, PA_Tag *, char *base_url);
  960. extern void lo_PartialFormatImage(MWContext *, lo_DocState *, PA_Tag *);
  961. extern void lo_FlushBlockage(MWContext *, lo_DocState *, lo_DocState *);
  962. extern void lo_FinishLayout(MWContext *, lo_DocState *, int32);
  963. extern void lo_FreeLayoutData(MWContext *, lo_DocState *);
  964. extern void lo_CloseMochaWriteStream(lo_TopState *top_state, int mocha_event);
  965. struct pa_DocData_struct;
  966. extern LO_Element *lo_InternalDiscardDocument(MWContext *, lo_DocState *, struct pa_DocData_struct *, Bool bWholeDoc);
  967. extern void lo_FreePartialTable(MWContext *, lo_DocState *, lo_TableRec *);
  968. extern void lo_FreePartialSubDoc(MWContext *, lo_DocState *, LO_SubDocStruct *);
  969. extern void lo_FreePartialCell(MWContext *context, lo_DocState *state,
  970.                 LO_CellStruct *cell);
  971. extern void lo_FreeElement(MWContext *context, LO_Element *, Bool);
  972. extern void lo_FreeElementList(MWContext *, LO_Element *);
  973. extern void lo_FreeImageAttributes(LO_ImageAttr *image_attr);
  974. extern void lo_ScrapeElement(MWContext *context, LO_Element *);
  975. extern int32 lo_FreeRecycleList(MWContext *context, LO_Element *);
  976. extern void lo_FreeGridRec(lo_GridRec *);
  977. extern void lo_FreeGridCellRec(MWContext *, lo_GridRec *, lo_GridCellRec *);
  978. extern void lo_FreeGridEdge(lo_GridEdge *);
  979. extern void lo_FreeFormElementData(LO_FormElementData *element_data);
  980. extern void lo_free_table_record(MWContext *context, lo_DocState *state,
  981.             lo_TableRec *table, Bool partial);
  982.  
  983. #ifdef MEMORY_ARENAS
  984. extern void lo_InitializeMemoryArena(lo_TopState *);
  985. extern int32 lo_FreeMemoryArena(lo_arena *);
  986. extern char *lo_MemoryArenaAllocate(lo_TopState *, int32);
  987. #endif /* MEMORY_ARENAS */
  988.  
  989. extern void lo_fillin_text_info(MWContext *context, lo_DocState *state);
  990. extern char *lo_FetchFontFace(MWContext *, lo_DocState *, char *);
  991. extern PA_Block lo_FetchParamValue(MWContext *, PA_Tag *, char *);
  992. extern PA_Block lo_ValueToAlpha(int32, Bool, intn *);
  993. extern void lo_PlaceQuoteMarker(MWContext *, lo_DocState *, lo_ListStack *);
  994. extern void lo_PlaceBulletStr(MWContext *, lo_DocState *);
  995. extern void lo_PlaceBullet (MWContext *, lo_DocState *);
  996. extern PA_Block lo_ValueToRoman(int32, Bool, intn *);
  997. extern void lo_ConvertAllValues(MWContext *, char **, int32, uint);
  998. extern void lo_CloseOutLayout(MWContext *, lo_DocState *);
  999. extern void lo_CloseOutTable(MWContext *, lo_DocState *);
  1000. extern void lo_CloseParagraph(MWContext *context, lo_DocState **state, PA_Tag *tag, intn blank_lines);
  1001. extern void lo_CloseTable(MWContext *, lo_DocState *); /* from laytags.c */
  1002. extern void lo_ShiftMarginsUp(MWContext *, lo_DocState *, int32);
  1003. extern void lo_ClearToLeftMargin(MWContext *, lo_DocState *);
  1004. extern void lo_ClearToRightMargin(MWContext *, lo_DocState *);
  1005. extern void lo_ClearToBothMargins(MWContext *, lo_DocState *);
  1006. extern void lo_BeginForm(MWContext *, lo_DocState *, PA_Tag *);
  1007. extern void lo_ProcessInputTag(MWContext *, lo_DocState *, PA_Tag *);
  1008. extern void lo_FreeDocumentGridData(MWContext *, lo_SavedGridData *);
  1009. extern void lo_FreeDocumentEmbedListData(MWContext *, lo_SavedEmbedListData *);
  1010. extern void lo_FreeDocumentFormListData(MWContext *, lo_SavedFormListData *);
  1011. extern void lo_SaveFormElementStateInFormList(MWContext *context, lo_FormData *form_list, Bool discard_elements);
  1012. extern void lo_SaveFormElementState(MWContext *, lo_DocState *, Bool);
  1013. extern void lo_BeginTextareaTag(MWContext *, lo_DocState *, PA_Tag *);
  1014. extern void lo_EndTextareaTag(MWContext *, lo_DocState *, PA_Block );
  1015. extern void lo_BeginOptionTag(MWContext *, lo_DocState *, PA_Tag *);
  1016. extern void lo_EndOptionTag(MWContext *, lo_DocState *, PA_Block );
  1017. extern void lo_BeginSelectTag(MWContext *, lo_DocState *, PA_Tag *);
  1018. extern void lo_EndSelectTag(MWContext *, lo_DocState *);
  1019. extern void lo_ProcessKeygenTag(MWContext *, lo_DocState *, PA_Tag *);
  1020. extern void lo_BeginSubDoc(MWContext *, lo_DocState *, PA_Tag *);
  1021. extern void lo_EndSubDoc(MWContext *, lo_DocState *,lo_DocState *,LO_Element *);
  1022. extern void lo_BeginCell(MWContext *, lo_DocState *, PA_Tag *);
  1023. extern void lo_EndCell(MWContext *, lo_DocState *, LO_Element *);
  1024. extern void lo_RecreateGrid(MWContext *, lo_DocState *, lo_GridRec *);
  1025. extern void lo_BeginGrid(MWContext *, lo_DocState *, PA_Tag *);
  1026. extern void lo_EndGrid(MWContext *, lo_DocState *, lo_GridRec *);
  1027. extern void lo_BeginGridCell(MWContext *, lo_DocState *, PA_Tag *);
  1028. extern void lo_BeginSubgrid(MWContext *, lo_DocState *, PA_Tag *);
  1029. extern void lo_EndSubgrid(MWContext *, lo_DocState *, lo_GridRec *);
  1030. extern void lo_BeginMap(MWContext *, lo_DocState *, PA_Tag *);
  1031. extern void lo_EndMap(MWContext *, lo_DocState *, lo_MapRec *);
  1032. extern lo_MapRec *lo_FreeMap(lo_MapRec *);
  1033. extern void lo_BeginMapArea(MWContext *, lo_DocState *, PA_Tag *);
  1034. extern lo_MapRec *lo_FindNamedMap(MWContext *, lo_DocState *, char *);
  1035. extern LO_AnchorData *lo_MapXYToAnchorData(MWContext *, lo_DocState *,
  1036.                 lo_MapRec *, int32, int32);
  1037. extern void lo_BeginLayerTag(MWContext *, lo_DocState *, PA_Tag *);
  1038. extern void lo_EndLayer(MWContext *, lo_DocState *, PRBool);
  1039. extern void lo_BeginMulticolumn(MWContext *context, lo_DocState *state, PA_Tag *tag, 
  1040.                                 LO_MulticolumnStruct *multicolEle);
  1041. extern void lo_EndMulticolumn(MWContext *context, lo_DocState *state, PA_Tag *tag,
  1042.             lo_MultiCol *multicol, Bool relayout);
  1043. extern void lo_AppendMultiColToLineList (MWContext *context, lo_DocState *state, 
  1044.                                          LO_MulticolumnStruct *multicol);
  1045. extern void lo_AppendZeroWidthAndHeightLF(MWContext *context, lo_DocState *state);
  1046.  
  1047. extern void lo_BeginTable(MWContext *, lo_DocState *, PA_Tag *);
  1048. extern void lo_EndTable(MWContext *context, lo_DocState *state, lo_TableRec *table, Bool relayout);
  1049.  
  1050. extern void lo_BeginTableAttributes(MWContext *context,
  1051.                 lo_DocState *state,
  1052.                 char *align_attr,
  1053.                 char *border_attr,
  1054.                 char *border_top_attr,
  1055.                 char *border_bottom_attr,
  1056.                 char *border_left_attr,
  1057.                 char *border_right_attr,
  1058.                 char *border_color_attr,
  1059.                 char *border_style_attr,
  1060.                 char *vspace_attr,
  1061.                 char *hspace_attr,
  1062.                 char *bgcolor_attr,
  1063.                 char *background_attr,
  1064.                 char *width_attr,
  1065.                 char *height_attr,
  1066.                 char *cellpad_attr,
  1067.                 char *toppad_attr,
  1068.                 char *bottompad_attr,
  1069.                 char *leftpad_attr,
  1070.                 char *rightpad_attr,
  1071.                 char *cellspace_attr,
  1072.                 char *cols_attr);
  1073.  
  1074. extern void lo_BeginTableRow(MWContext *, lo_DocState *,lo_TableRec *,PA_Tag *);
  1075.  
  1076. void lo_BeginTableRowAttributes(MWContext *context,
  1077.                             lo_DocState *state,
  1078.                             lo_TableRec *table,
  1079.                             char *bgcolor_attr,
  1080.                             char *background_attr,     
  1081.                             char *valign_attr,
  1082.                             char *halign_attr);
  1083.  
  1084. extern void lo_EndTableRow(MWContext *, lo_DocState *, lo_TableRec *);
  1085. extern void lo_BeginTableCell(MWContext *, lo_DocState *, lo_TableRec *,
  1086.                 PA_Tag *, Bool);
  1087. extern void lo_BeginTableCellAttributes(MWContext *context,
  1088.                             lo_DocState *state,
  1089.                             lo_TableRec *table,
  1090.                             char * colspan_attr,
  1091.                             char * rowspan_attr,
  1092.                             char * nowrap_attr,
  1093.                             char * bgcolor_attr,
  1094.                             char * background_attr,
  1095.                             lo_TileMode tile_mode,
  1096.                             char * valign_attr,
  1097.                             char * halign_attr,
  1098.                             char * width_attr,
  1099.                             char * height_attr,
  1100.                             Bool is_a_header,
  1101.                 Bool normal_borders);
  1102.  
  1103. extern void lo_EndTableCell(MWContext *, lo_DocState *, Bool relayout);
  1104. extern void lo_BeginTableCaption(MWContext *, lo_DocState *, lo_TableRec *,
  1105.                 PA_Tag *);
  1106. extern void lo_EndTableCaption(MWContext *, lo_DocState *);
  1107. extern int32 lo_GetSubDocBaseline(LO_SubDocStruct *);
  1108. extern int32 lo_GetCellBaseline(LO_CellStruct *);
  1109. extern LO_CellStruct *lo_CaptureLines(MWContext *, lo_DocState *,
  1110.                 int32, int32, int32, int32, int32);
  1111. extern LO_CellStruct *lo_SmallSquishSubDocToCell(MWContext *, lo_DocState *,
  1112.             LO_SubDocStruct *, int32 *ptr_dx, int32 *ptr_dy);
  1113. extern LO_CellStruct *lo_SquishSubDocToCell(MWContext *, lo_DocState *,
  1114.                 LO_SubDocStruct *, Bool);
  1115. extern LO_Element *lo_JumpCellWall(MWContext *, lo_DocState *, LO_Element *);
  1116.  
  1117. extern LO_TextAttr *lo_GetElementTextAttr(LO_Element *element);
  1118. extern void lo_SetElementTextAttr(LO_Element *element, LO_TextAttr *attr);
  1119. extern void lo_GetElementBbox(LO_Element *element, XP_Rect *rect);
  1120. extern void lo_RefreshElement(LO_Element *element, CL_Layer *layer, 
  1121.                               Bool update_now);
  1122. extern LO_AnchorData *lo_GetElementAnchor(LO_Element *element);
  1123. extern void lo_GetElementFGColor(LO_Element *element, LO_Color *color);
  1124. extern void lo_SetElementFGColor(LO_Element *element, LO_Color *color);
  1125.  
  1126. extern void lo_ShiftElementList(LO_Element *, int32, int32);
  1127. extern void lo_RenumberCell(lo_DocState *, LO_CellStruct *);
  1128. extern void lo_ShiftCell(LO_CellStruct *, int32, int32);
  1129. extern int32 lo_CleanTextWhitespace(char *, int32);
  1130. extern void lo_ProcessIsIndexTag(MWContext *, lo_DocState *, PA_Tag *);
  1131. extern void lo_EndForm(MWContext *, lo_DocState *);
  1132. extern void lo_RecycleElements(MWContext *, lo_DocState *, LO_Element *);
  1133. extern void lo_relayout_recycle(MWContext *context, lo_DocState *state,
  1134.                 LO_Element *elist);
  1135. extern LO_Element *lo_NewElement(MWContext *, lo_DocState *, intn,
  1136.                 ED_Element *, intn edit_offset);
  1137. extern void lo_AppendToLineList(MWContext *, lo_DocState *, LO_Element *,int32);
  1138. extern void lo_SetLineArrayEntry(lo_DocState *, LO_Element *, int32);
  1139. extern LO_Element *lo_FirstElementOfLine(MWContext *, lo_DocState *, int32);
  1140. extern void lo_ClipLines(MWContext *, lo_DocState *, int32);
  1141. extern void lo_SetDefaultFontAttr(lo_DocState *, LO_TextAttr *, MWContext *);
  1142. extern Bool lo_EvalTrueOrFalse(char *str, Bool default_val);
  1143. extern intn lo_EvalAlignParam(char *str, Bool *floating);
  1144. extern intn lo_EvalVAlignParam(char *str);
  1145. extern void lo_EvalStyleSheetAlignment(StyleStruct *, intn *, Bool *floating);
  1146. void lo_SetStyleSheetLayerProperties(MWContext *context,
  1147.                                      lo_DocState *state,
  1148.                                      StyleStruct *style_struct,
  1149.                                      PA_Tag *tag);
  1150. char * lo_ParseStyleSheetURL(char *url_string);
  1151. extern intn lo_EvalCellAlignParam(char *str);
  1152. extern intn lo_EvalDivisionAlignParam(char *str);
  1153. extern PA_Block lo_ConvertToFELinebreaks(char *, int32, int32 *);
  1154. extern PA_Block lo_FEToNetLinebreaks(PA_Block);
  1155. extern void lo_CleanFormElementData(LO_FormElementData *);
  1156. extern Bool lo_SetNamedAnchor(lo_DocState *, PA_Block);
  1157. extern void lo_AddNameList(lo_DocState *, lo_DocState *);
  1158. extern void lo_CheckNameList(MWContext *, lo_DocState *, int32);
  1159. extern int32 lo_StripTextWhitespace(char *, int32);
  1160. extern int32 lo_StripTextNewlines(char *, int32);
  1161. extern int32 lo_ResolveInputType(char *);
  1162. extern Bool lo_IsValidTarget(char *);
  1163. extern Bool lo_IsAnchorInDoc(lo_DocState *, char *);
  1164.  
  1165. extern void lo_DisplayElement(MWContext *context, LO_Element *tptr,
  1166.                   int32 base_x, int32 base_y,
  1167.                   int32 x, int32 y,
  1168.                   uint32 width, uint32 height);
  1169. extern void lo_DisplaySubtext(MWContext *context, LO_TextStruct *text,
  1170.                   int32 start_pos, int32 end_pos, Bool need_bg,
  1171.                   CL_Layer *sel_layer);
  1172. extern void lo_DisplayText(MWContext *, LO_TextStruct *, Bool);
  1173. extern void lo_DisplayEmbed(MWContext *, LO_EmbedStruct *);
  1174. extern void lo_DisplayJavaApp(MWContext *, LO_JavaAppStruct *);
  1175. extern void lo_DisplayImageWithoutCompositor(MWContext *, LO_ImageStruct *);
  1176. extern void lo_DisplaySubImageWithoutCompositor(MWContext *, LO_ImageStruct *,
  1177.     int32, int32, uint32, uint32);
  1178. extern void lo_ClipImage(MWContext *, LO_ImageStruct *,
  1179.     int32, int32, uint32, uint32);
  1180. extern void lo_DisplaySubDoc(MWContext *, LO_SubDocStruct *);
  1181. extern void lo_DisplayCell(MWContext *, LO_CellStruct *);
  1182. extern void lo_DisplayCellContents(MWContext *context, LO_CellStruct *cell,
  1183.                        int32 base_x, int32 base_y,
  1184.                        int32 x, int32 y,
  1185.                        uint32 width, uint32 height);
  1186. extern void lo_DisplayEdge(MWContext *, LO_EdgeStruct *);
  1187. extern void lo_DisplayTable(MWContext *, LO_TableStruct *);
  1188. extern void lo_DisplayLineFeed(MWContext *,  LO_LinefeedStruct *, Bool);
  1189. extern void lo_DisplayHR(MWContext *, LO_HorizRuleStruct *);
  1190. extern void lo_DisplayBullet(MWContext *, LO_BullettStruct *);
  1191. extern void lo_DisplayFormElement(MWContext *, LO_FormElementStruct *);
  1192. extern void LO_HighlightSelection(MWContext *, Bool);
  1193.  
  1194. extern void lo_RefreshDocumentArea(MWContext *, lo_DocState *,
  1195.     int32, int32, uint32, uint32);
  1196.  
  1197. extern intn lo_GetCurrentGridCellStatus(lo_GridCellRec *);
  1198. extern char *lo_GetCurrentGridCellUrl(lo_GridCellRec *);
  1199. extern void lo_GetGridCellMargins(MWContext *, int32 *, int32 *);
  1200. extern LO_Element *lo_XYToGridEdge(MWContext *, lo_DocState *, int32, int32);
  1201. extern LO_Element *lo_XYToDocumentElement(MWContext *, lo_DocState *,
  1202.     int32, int32, Bool, Bool, Bool, int32 *, int32 *);
  1203. extern LO_Element *lo_XYToDocumentElement2(MWContext *, lo_DocState *,
  1204.     int32, int32, Bool, Bool, Bool, Bool, int32 *, int32 *);
  1205. extern LO_Element *lo_XYToCellElement(MWContext *, lo_DocState *,
  1206.     LO_CellStruct *, int32, int32, Bool, Bool, Bool);
  1207. extern LO_Element *lo_XYToNearestCellElement(MWContext *, lo_DocState *,
  1208.     LO_CellStruct *, int32, int32);
  1209. extern void lo_RegionToLines (MWContext *, lo_DocState *, int32 x, int32 y,
  1210.     uint32 width, uint32 height, Bool dontCrop,
  1211.     int32* topLine, int32* bottomLine);
  1212. extern int32 lo_PointToLine (MWContext *, lo_DocState *, int32 x, int32 y);
  1213. extern void lo_GetLineEnds(MWContext *, lo_DocState *,
  1214.     int32 line, LO_Element** retBegin, LO_Element** retEnd);
  1215. extern void lo_CalcAlignOffsets(lo_DocState *, LO_TextInfo *, intn,
  1216.     int32, int32, int16 *, int32 *, int32 *, int32 *);
  1217. extern intn LO_CalcPrintArea(MWContext *, int32 x, int32 y,
  1218.     uint32 width, uint32 height, int32* top, int32* bottom);
  1219. extern Bool lo_FindWord(MWContext *, lo_DocState *,
  1220.     LO_Position *where, LO_Selection *word);
  1221.  
  1222. /* Object */
  1223. extern void lo_FormatObject(MWContext*, lo_DocState*, PA_Tag*);
  1224. extern void lo_ObjectParam(MWContext*, lo_DocState*, PA_Tag*, uint32*, char***, char***);
  1225. extern void lo_ProcessObjectTag(MWContext*, lo_DocState*, PA_Tag*, Bool);
  1226. extern void lo_ProcessParamTag(MWContext*, lo_DocState*, PA_Tag*, Bool);
  1227. extern void lo_FormatEmbedObject(MWContext*, lo_DocState*, PA_Tag*, LO_EmbedStruct*, Bool,
  1228.                                  uint32 count, char** names, char** values);
  1229. extern void lo_FormatJavaObject(MWContext *context, lo_DocState *state,
  1230.                                 PA_Tag *tag, LO_JavaAppStruct *object);
  1231. extern void lo_AppendParamList(uint32* count1, char*** names1, char*** values1,
  1232.                                   uint32 count2, char** names2, char** values2);
  1233. extern void lo_DeleteObjectStack(lo_ObjectStack*);
  1234.  
  1235. extern void lo_BlockTag(MWContext *context, lo_DocState *state, 
  1236.     PA_Tag *tag);
  1237. extern void lo_ReflectFormElement(MWContext *context, 
  1238.     lo_DocState *doc_state, PA_Tag *tag, 
  1239.     LO_FormElementStruct *form_element);
  1240.  
  1241.  
  1242. extern void lo_ProcessParagraphElement(MWContext *context, lo_DocState **state,
  1243.                        LO_ParagraphStruct *paragraph,
  1244.                        XP_Bool in_relayout);
  1245.  
  1246. extern void lo_ProcessCenterElement(MWContext *context, lo_DocState **state,
  1247.                     LO_CenterStruct *center,
  1248.                     XP_Bool in_relayout);
  1249.  
  1250. extern void lo_ProcessMulticolumnElement(MWContext *context,
  1251.                                          lo_DocState **state,
  1252.                                          LO_MulticolumnStruct *multicolumn);
  1253.  
  1254. extern void lo_ProcessDescTitleElement(MWContext *context,
  1255.                        lo_DocState *state,
  1256.                        LO_DescTitleStruct *title,
  1257.                        XP_Bool in_relayout);
  1258. extern void lo_ProcessDescTextElement(MWContext *context,
  1259.                       lo_DocState *state,
  1260.                       LO_DescTextStruct *text,
  1261.                       XP_Bool in_relayout);
  1262. extern void lo_ProcessBlockQuoteElement(MWContext *context,
  1263.                     lo_DocState *state,
  1264.                     LO_BlockQuoteStruct *quote,
  1265.                     XP_Bool in_relayout);
  1266.  
  1267. /* 
  1268.  * Functions that get called from layout and non-destructive relayout 
  1269.  *
  1270.  */
  1271. extern void lo_FillInImageGeometry( lo_DocState *state, LO_ImageStruct *image );
  1272. extern void lo_LayoutFloatImage( MWContext *context, lo_DocState *state, LO_ImageStruct *image, Bool updateFE );
  1273. extern void lo_LayoutInflowImage(MWContext *context, lo_DocState *state, LO_ImageStruct *image,
  1274.                                 Bool inRelayout, int32 *line_inc, int32 *baseline_inc);
  1275. extern void lo_UpdateStateAfterImageLayout( lo_DocState *state, LO_ImageStruct *image, int32 line_inc, int32 baseline_inc );
  1276.  
  1277. extern void lo_FillInJavaAppGeometry(lo_DocState *state, LO_JavaAppStruct *java_app, Bool relayout);
  1278. extern void lo_LayoutFloatJavaApp( MWContext *context, lo_DocState *state, LO_JavaAppStruct *java_app, Bool updateFE );
  1279. extern void lo_LayoutInflowJavaApp(MWContext *context, lo_DocState *state, LO_JavaAppStruct *java_app,
  1280.                                    Bool inRelayout, int32 *line_inc, int32 *baseline_inc);
  1281. extern void lo_UpdateStateAfterJavaAppLayout( lo_DocState *state, LO_JavaAppStruct *java_app,
  1282.                                               int32 line_inc, int32 baseline_inc );
  1283.  
  1284. extern void lo_FillInEmbedGeometry(lo_DocState *state, LO_EmbedStruct *embed, Bool relayout);
  1285. extern void lo_LayoutInflowEmbed(MWContext *context, lo_DocState *state, LO_EmbedStruct *embed,
  1286.                                    Bool inRelayout, int32 *line_inc, int32 *baseline_inc);
  1287. extern void lo_LayoutFloatEmbed(MWContext *context, lo_DocState *state, LO_EmbedStruct *embed, Bool updateFE);
  1288. extern void lo_UpdateStateAfterEmbedLayout( lo_DocState *state, LO_EmbedStruct *embed,
  1289.                                               int32 line_inc, int32 baseline_inc );
  1290.  
  1291. extern void lo_LayoutInflowFormElement(MWContext *context, lo_DocState *state, LO_FormElementStruct *form_element,
  1292.                            int32 *baseline_inc, Bool inRelayout);
  1293. extern void lo_UpdateStateAfterFormElement(MWContext *context, lo_DocState *state, LO_FormElementStruct *form_element,
  1294.                                            int32 baseline_inc);
  1295.  
  1296. extern void lo_StartHorizontalRuleLayout(MWContext *, lo_DocState *, LO_HorizRuleStruct*);
  1297. extern void lo_FillInHorizontalRuleGeometry(MWContext *context, lo_DocState *state, LO_HorizRuleStruct *hrule);
  1298. extern void lo_FinishHorizontalRuleLayout(MWContext *, lo_DocState *, LO_HorizRuleStruct*);
  1299. extern void lo_UpdateStateAfterHorizontalRule(lo_DocState *state, LO_HorizRuleStruct *hrule);
  1300.  
  1301. extern void lo_FormatBullet(MWContext *context, lo_DocState *state,
  1302.                 LO_BulletStruct *bullet,
  1303.                 int32 *line_height,
  1304.                 int32 *baseline);
  1305. extern void lo_UpdateStateAfterBullet(MWContext *context, lo_DocState *state,
  1306.                       LO_BulletStruct *bullet,
  1307.                       int32 line_height,
  1308.                       int32 baseline);
  1309.  
  1310. extern void lo_FormatBulletStr(MWContext *context, lo_DocState *state,
  1311.                    LO_TextStruct *bullet_text,
  1312.                    int32 *line_height,
  1313.                    int32 *baseline);
  1314. extern void lo_UpdateStateAfterBulletStr(MWContext *context, lo_DocState *state,
  1315.                      LO_TextStruct *bullet_text,
  1316.                      int32 line_height,
  1317.                      int32 baseline);
  1318.  
  1319. extern void lo_SetupStateForList(MWContext *context,
  1320.                  lo_DocState *state,
  1321.                  LO_ListStruct *list,
  1322.                  XP_Bool in_resize_reflow);
  1323. extern void lo_UpdateStateAfterList(MWContext *context,
  1324.                     lo_DocState *state,
  1325.                     LO_ListStruct *list,
  1326.                     XP_Bool in_resize_reflow);
  1327.  
  1328. extern void lo_UpdateStateAfterLineBreak( MWContext *context, lo_DocState *state, Bool updateFE);
  1329. extern void lo_UpdateFEProgressBar( MWContext *context, lo_DocState *state );
  1330. extern void lo_UpdateFEDocSize( MWContext *context, lo_DocState *state );
  1331. extern void lo_FillInLineFeed( MWContext *context, lo_DocState *state, int32 break_type, uint32 clear_type, LO_LinefeedStruct *linefeed );
  1332.  
  1333. extern void lo_UpdateStateWhileFlushingLine( MWContext *context, lo_DocState *state );
  1334. extern void lo_AppendLineFeed( MWContext *context, lo_DocState *state, LO_LinefeedStruct *linefeed, int32 breaking, Bool updateFE );
  1335. extern void lo_UpdateStateAfterFlushingLine( MWContext *context, lo_DocState *state, LO_LinefeedStruct *linefeed, Bool inRelayout );
  1336. extern void lo_AppendFloatInLineList( lo_DocState *state, LO_Element *ele, LO_Element *restOfLine);
  1337.  
  1338. /*
  1339.  * Common code for layout and relayout of tables
  1340.  */
  1341. extern void lo_PositionTableElement(lo_DocState *state, LO_TableStruct *table_ele);
  1342. extern void lo_SetTableDimensions( lo_DocState *state, lo_TableRec *table, int32 allow_percent_width, int32 allow_percent_height);
  1343. extern void lo_CalcFixedColWidths( MWContext *context, lo_DocState *state, lo_TableRec *table);
  1344. extern void lo_UpdateStateAfterBeginTable( lo_DocState *state, lo_TableRec *table);
  1345. extern void lo_UpdateTableStateForBeginRow(lo_TableRec *table, lo_TableRow *table_row);
  1346. extern void lo_InitForBeginCell(lo_TableRow *table_row, lo_TableCell *table_cell);
  1347. extern void lo_InitSubDocForBeginCell( MWContext *context, lo_DocState *state, lo_TableRec *table);
  1348. extern void lo_InitTableRecord( lo_TableRec *table );
  1349. extern void lo_CreateCellFromSubDoc( MWContext *context, lo_DocState *state, LO_SubDocStruct *subdoc, LO_CellStruct *cell, int32 *ptr_dx, int32 *ptr_dy );
  1350. extern void lo_EndLayoutDuringReflow( MWContext *context, lo_DocState *state );
  1351. extern void lo_AppendLineListToLineArray( MWContext *context, lo_DocState *state, LO_Element *lastElementOnLineList);
  1352.  
  1353. /* Common code for layout and relayout of multicols */
  1354. extern void lo_StartMultiColInit( lo_DocState *state, lo_MultiCol *multicol );
  1355. extern void lo_SetupStateForBeginMulticol( lo_DocState *state, lo_MultiCol *multicol, int32 doc_width );
  1356.  
  1357. /* Common code for layout and relayout of spacers */
  1358. extern void lo_LayoutSpacerElement(MWContext *context, lo_DocState *state, LO_SpacerStruct *spacer, Bool relayout);
  1359.  
  1360. /* 
  1361.  * Adds a soft line break to the end of the line list and adds the line list to the line array.  
  1362.  * Resets line list to NULL.  Should be used during relayout only.
  1363.  */
  1364.  
  1365. extern void lo_rl_AddSoftBreakAndFlushLine( MWContext *context, lo_DocState *state );
  1366. extern void lo_rl_AddBreakAndFlushLine( MWContext *context, lo_DocState *state, int32 break_type, uint32 clear_type, Bool breaking);
  1367. extern void lo_rl_AppendLinefeedAndFlushLine( MWContext *context, lo_DocState *state, LO_LinefeedStruct *linefeed, int32 break_type, uint32 clear_type,
  1368.                                       Bool breaking, Bool createNewLF);
  1369. extern void lo_FillInLineFeed( MWContext *context, lo_DocState *state, int32 break_type, uint32 clear_type, LO_LinefeedStruct *linefeed );
  1370.  
  1371. extern void lo_rl_ReflowCell( MWContext *context, lo_DocState *state, LO_CellStruct *cell);
  1372. extern void lo_rl_ReflowDocState( MWContext *context, lo_DocState *state );
  1373. extern void lo_PrepareElementForReuse( MWContext *context, lo_DocState *state, LO_Element * eptr,
  1374.         ED_Element *edit_element, intn edit_offset);
  1375. extern void LO_Reflow(MWContext *context, lo_DocState * state, LO_Element *startElement,
  1376.     LO_Element *endElement);
  1377.  
  1378. extern Bool lo_IsDummyLayoutElement(LO_Element *ele);
  1379.  
  1380. /* Useful Macros */
  1381.  
  1382. #define    COPY_COLOR(from_color, to_color)    \
  1383.     to_color.red = from_color.red;        \
  1384.     to_color.green = from_color.green;    \
  1385.     to_color.blue = from_color.blue
  1386.  
  1387.  
  1388. extern Bool lo_FindBestPositionOnLine( MWContext *pContext,
  1389.             lo_DocState* state, int32 iLine,
  1390.             int32 iDesiredX, int32 iDesiredY,
  1391.             Bool bForward, int32* pRetX, int32 *pRetY );
  1392.  
  1393. extern LO_Element * lo_GetLastElementInList( LO_Element *eleList );
  1394.  
  1395. #ifdef EDITOR
  1396.  
  1397. #ifdef DEBUG
  1398. /* lo_VerifyLayout does a consistency check on the layout structure.
  1399.  * returns TRUE if the layout structure is consistent. */
  1400. extern Bool lo_VerifyLayout(MWContext *pContext);
  1401.  
  1402. /* PrintLayout prints the layout structure. */
  1403. extern void lo_PrintLayout(MWContext *pContext);
  1404. extern Bool
  1405. lo_VerifyList( MWContext *pContext, lo_TopState* top_state,
  1406.               lo_DocState* state,
  1407.               LO_Element* start,
  1408.               LO_Element* end,
  1409.               LO_Element* floating,
  1410.               Bool print);
  1411.  
  1412. #endif /* DEBUG */
  1413.  
  1414. #endif /* EDITOR */
  1415.  
  1416. /*
  1417.  * Returns length in selectable parts of this element. 1 for images, length of text for text, etc.
  1418.  */
  1419. int32
  1420. lo_GetElementLength(LO_Element* eptr);
  1421.  
  1422. extern Bool lo_EditableElement(int iType);
  1423.  
  1424. /* Moves by one editable position forward or backward. Returns FALSE if it couldn't.
  1425.  * position can be denormalized on entry and may be denormalized on exit.
  1426.  */
  1427.  
  1428. Bool
  1429. lo_BumpEditablePosition(MWContext *context, lo_DocState *state,
  1430.     LO_Element **pEptr, int32 *pPosition, Bool direction);
  1431.  
  1432. #ifdef MOCHA
  1433.  
  1434. extern lo_TopState *
  1435. lo_GetMochaTopState(MWContext *context);
  1436.  
  1437. extern void
  1438. lo_BeginReflectForm(MWContext *context, lo_DocState *state, PA_Tag *tag,
  1439.                     lo_FormData *form);
  1440.  
  1441. extern void
  1442. lo_EndReflectForm(MWContext *context, lo_FormData *form);
  1443.  
  1444. extern void
  1445. lo_ReflectImage(MWContext *context, lo_DocState *doc_state, PA_Tag *tag,
  1446.                 LO_ImageStruct *image_data, Bool blocked, int32 layer_id);
  1447.  
  1448. extern void
  1449. lo_ReflectNamedAnchor(MWContext *context, lo_DocState *state, PA_Tag *tag,
  1450.                       lo_NameList *name_rec, int32 layer_id);
  1451.  
  1452. extern void
  1453. lo_ReflectLink(MWContext *context, lo_DocState *state, PA_Tag *tag,
  1454.                LO_AnchorData *anchor_data, int32 layer_id, uint index);
  1455.  
  1456. extern XP_Bool
  1457. lo_ProcessContextEventHandlers(MWContext *context, lo_DocState *state,
  1458.                                PA_Tag *tag);
  1459.  
  1460. extern void
  1461. lo_RestoreContextEventHandlers(MWContext *context, lo_DocState *state,
  1462.                                PA_Tag *tag, SHIST_SavedData *saved_data);
  1463.  
  1464. extern void
  1465. lo_ProcessScriptTag(MWContext *context, lo_DocState *state, PA_Tag *tag,
  1466.                     struct JSObject * /* scope to use. can be NULL */);
  1467.  
  1468.  
  1469. extern XP_Bool
  1470. lo_ProcessStyleAttribute(MWContext *context, lo_DocState *state, PA_Tag *tag, char *script_buff);
  1471.  
  1472. extern void
  1473. lo_ProcessStyleTag(MWContext *context, lo_DocState *state, PA_Tag *tag);
  1474.  
  1475. extern void
  1476. lo_BlockScriptTag(MWContext *context, lo_DocState *state, PA_Tag *tag);
  1477. #endif /* MOCHA */
  1478.  
  1479. extern lo_DocLists *
  1480. lo_GetCurrentDocLists(lo_DocState *state);
  1481.  
  1482. extern lo_DocLists *
  1483. lo_GetDocListsById(lo_DocState *state, int32 id);
  1484.  
  1485. Bool
  1486. lo_CloneTagAndBlockLayout(MWContext *context, lo_DocState *state, PA_Tag *tag);
  1487.  
  1488. void
  1489. lo_UnblockLayout(MWContext *context, lo_TopState *top_state);
  1490.  
  1491. void 
  1492. lo_UnblockLayoutAndFreeExtraElement(MWContext *context);
  1493.  
  1494. extern void
  1495. lo_SetBaseUrl(lo_TopState *top_state, char *url, Bool is_blocked);
  1496.  
  1497. extern void
  1498. lo_FlushedBlockedTags(lo_TopState *top_state);
  1499.  
  1500. extern int32 *
  1501. lo_parse_coord_list(char *str, int32 *value_cnt, Bool must_be_odd);
  1502.  
  1503. extern void
  1504. lo_add_leading_bullets(MWContext *context, lo_DocState *state,
  1505.                        int32 start,int32 end,int32 mquote_x);
  1506.  
  1507. extern void
  1508. lo_TeardownList(MWContext *context, lo_DocState *state, PA_Tag *tag);
  1509.  
  1510.  
  1511. extern void 
  1512. lo_SetDocumentDimension( MWContext* context, lo_DocState *state );
  1513.  
  1514. extern void
  1515. lo_ScriptEvalExitFn(void * data, char * str, size_t len, char * wysiwyg_url,
  1516.             char * base_href, Bool valid);
  1517.  
  1518. extern Bool
  1519. lo_ConvertMochaEntities(MWContext * context, lo_DocState *state, PA_Tag * tag);
  1520.  
  1521. extern void
  1522. LO_EditorReflow(MWContext *context, ED_TagCursor *pCursor, 
  1523.             int32 iStartLine, int iStartEditOffset, XP_Bool bDisplayTables);
  1524.  
  1525. /********************** Image observers and observer lists. ******************/
  1526. /* The layout observer for an image request. */
  1527. extern void
  1528. lo_ImageObserver(XP_Observable observable, XP_ObservableMsg message,
  1529.                  void *message_data, void *closure);
  1530.  
  1531. /* Create a new observer list which will be passed into to IL_GetImage (via
  1532.    FE_GetImageInfo) in order to permit an Image Library request to be
  1533.    monitored. The layout image observer is added to this new observer list
  1534.    before the function returns. */
  1535. extern XP_ObserverList
  1536. lo_NewImageObserverList(MWContext *context, LO_ImageStruct *lo_image);
  1537.  
  1538.  
  1539. /* #ifndef NO_TAB_NAVIGATION */
  1540. extern lo_MapAreaRec *LO_getTabableMapArea(MWContext *context, LO_ImageStruct *image, int32 wantedIndex );
  1541. extern Bool LO_findApointInArea( lo_MapAreaRec *pArea, int32 *xx, int32 *yy );
  1542. /* NO_TAB_NAVIGATION  */
  1543.  
  1544. /****************************************************************************/
  1545. /* Converts ("snaps") input X, Y (doc coordinates) to X, Y needed for drop caret 
  1546.  *  and calls appropriate front-end FE_Display<Text|Generic|Image>Caret to use show where
  1547.  *  a drop would occur. It does NOT change current selection or internal caret position
  1548.  *  Returns the element that we will drop at and position 
  1549.  *   within this element for text data
  1550. */
  1551. LO_Element * lo_PositionDropCaret(MWContext *pContext, int32 x, int32 y, int32 * pPosition);
  1552.  
  1553. void
  1554. lo_free_layout_state_data(MWContext *context, lo_DocState *state);
  1555.  
  1556. extern void
  1557. lo_use_default_doc_background(MWContext *context, lo_DocState *state);
  1558.  
  1559. Bool
  1560. lo_BindNamedAnchorToElement(lo_DocState *state, PA_Block name,
  1561.                            LO_Element *element);
  1562.  
  1563. /* Return the table element containing the given element (usually a LO_CELL type) */
  1564. LO_TableStruct *lo_GetParentTable(MWContext *pContext, LO_Element *pElement);
  1565.  
  1566. /* Return the cell element containing the given element */
  1567. LO_CellStruct *lo_GetParentCell(MWContext *pContext, LO_Element *pElement);
  1568.  
  1569. /* Find the first cell with with closest left border x-value less than the given x
  1570.  * value or, if bGetColumn=FALSE, find the cell with closest top border y-value less
  1571.  *   than the given Y value. Also returns the pointer to the last LO element in row/column so
  1572.  *   we can search for other cells until last is reached.
  1573.  * pElement is any element in the table
  1574.  * This is most efficient if pElement is LO_TABLE containg cursor,
  1575.  *   very efficient if pElement is LO_CELL,
  1576.  *   and least if any other type (must search through all nested tables to find enclosing cell)
  1577. */
  1578. LO_Element* lo_GetFirstCellInColumnOrRow(MWContext *pContext, LO_Element *pElement, int32 x, int32 y, XP_Bool bGetColumn, LO_Element **ppLastCellInTable);
  1579.  
  1580. /* Returns first cell in table, and last cell if pLastCell != NULL 
  1581.  * pElement can be any LO_Element in the table (quickest search if it is a LO_TABLE or LO_CELL)
  1582. */
  1583. LO_Element *lo_GetFirstAndLastCellsInTable(MWContext *pContext, LO_Element *pElement, LO_Element **ppLastCell);
  1584.  
  1585. /* Find first and last cell from any cell in the table 
  1586.  * pElement->type MUST be LO_CELL
  1587. */
  1588. LO_Element *lo_GetFirstAndLastCellsInColumnOrRow(LO_Element *pElement, LO_Element **ppLastCell, XP_Bool bInColumn);
  1589.  
  1590. /* Check if all cells containing given cell are selected */
  1591. XP_Bool lo_AllCellsSelectedInColumnOrRow(LO_CellStruct *pCell, XP_Bool bInColumn );
  1592.  
  1593. int32 lo_GetNumberOfCellsInTable(LO_TableStruct *pTable );
  1594.  
  1595. /* Subtract borders and inter-cell spacing to get the available table width
  1596.  *   to use when cell width in HTML is "percent of table"
  1597.  * Element MUST be of type LO_CELL (LO_CellStruct not used to avoid unecessary casting)
  1598. */
  1599. int32 lo_CalcTableWidthForPercentMode(LO_Element *pCellElement);
  1600.  
  1601. #endif /* _Layout_h_ */
  1602.