Merge pull request #563 from sbcgua/master

lcl_html performance tuning
This commit is contained in:
Lars Hvam 2017-01-22 19:26:43 +01:00 committed by GitHub
commit 6a5147b9f9
7 changed files with 284 additions and 153 deletions

View File

@ -251,9 +251,11 @@ CLASS lcl_gui IMPLEMENTATION.
METHOD render. METHOD render.
DATA lv_url TYPE w3url. DATA: lv_url TYPE w3url,
lo_html TYPE REF TO lcl_html.
lv_url = cache_html( mi_cur_page->render( )->mv_html ). lo_html = mi_cur_page->render( ).
lv_url = cache_html( lo_html->render( iv_no_indent_jscss = abap_true ) ).
mo_html_viewer->show_url( lv_url ). mo_html_viewer->show_url( lv_url ).

View File

@ -9,19 +9,24 @@ END-OF-DEFINITION.
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* CLASS lcl_html DEFINITION * CLASS lcl_html DEFINITION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
CLASS lcl_html DEFINITION FINAL. CLASS lcl_html DEFINITION FINAL.
PUBLIC SECTION. PUBLIC SECTION.
CONSTANTS: c_indent_size TYPE i VALUE 2. CONSTANTS: c_indent_size TYPE i VALUE 2.
DATA mv_html TYPE string READ-ONLY. CLASS-METHODS class_constructor.
DATA mv_indent TYPE i READ-ONLY.
DATA mv_within_style TYPE i READ-ONLY.
DATA mv_within_js TYPE i READ-ONLY.
METHODS add IMPORTING iv_chunk TYPE any.
METHODS reset. METHODS reset.
METHODS add
IMPORTING iv_chunk TYPE any.
METHODS render
IMPORTING iv_no_indent_jscss TYPE abap_bool OPTIONAL
RETURNING VALUE(rv_html) TYPE string.
METHODS is_empty
RETURNING VALUE(rv_yes) TYPE abap_bool.
METHODS add_a IMPORTING iv_txt TYPE string METHODS add_a
IMPORTING
iv_txt TYPE string
iv_act TYPE string iv_act TYPE string
iv_typ TYPE char1 DEFAULT gc_action_type-sapevent iv_typ TYPE char1 DEFAULT gc_action_type-sapevent
iv_opt TYPE clike OPTIONAL iv_opt TYPE clike OPTIONAL
@ -29,12 +34,16 @@ CLASS lcl_html DEFINITION FINAL.
iv_id TYPE string OPTIONAL iv_id TYPE string OPTIONAL
iv_style TYPE string OPTIONAL. iv_style TYPE string OPTIONAL.
METHODS add_icon IMPORTING iv_name TYPE string METHODS add_icon
IMPORTING
iv_name TYPE string
iv_hint TYPE string OPTIONAL iv_hint TYPE string OPTIONAL
iv_alt TYPE string OPTIONAL iv_alt TYPE string OPTIONAL
iv_class TYPE string OPTIONAL. iv_class TYPE string OPTIONAL.
CLASS-METHODS a IMPORTING iv_txt TYPE string CLASS-METHODS a
IMPORTING
iv_txt TYPE string
iv_act TYPE string iv_act TYPE string
iv_typ TYPE char1 DEFAULT gc_action_type-sapevent iv_typ TYPE char1 DEFAULT gc_action_type-sapevent
iv_opt TYPE clike OPTIONAL iv_opt TYPE clike OPTIONAL
@ -43,15 +52,49 @@ CLASS lcl_html DEFINITION FINAL.
iv_style TYPE string OPTIONAL iv_style TYPE string OPTIONAL
RETURNING VALUE(rv_str) TYPE string. RETURNING VALUE(rv_str) TYPE string.
CLASS-METHODS icon IMPORTING iv_name TYPE string CLASS-METHODS icon
IMPORTING
iv_name TYPE string
iv_hint TYPE string OPTIONAL iv_hint TYPE string OPTIONAL
iv_alt TYPE string OPTIONAL iv_alt TYPE string OPTIONAL
iv_class TYPE string OPTIONAL iv_class TYPE string OPTIONAL
RETURNING VALUE(rv_str) TYPE string. RETURNING VALUE(rv_str) TYPE string.
PRIVATE SECTION. PRIVATE SECTION.
METHODS _add_str IMPORTING iv_str TYPE csequence. CLASS-DATA go_single_tags_re TYPE REF TO cl_abap_regex.
METHODS _add_htm IMPORTING io_html TYPE REF TO lcl_html. DATA mt_buffer TYPE string_table.
TYPES:
BEGIN OF ty_indent_context,
no_indent_jscss TYPE abap_bool,
within_style TYPE abap_bool,
within_js TYPE abap_bool,
indent TYPE i,
indent_str TYPE string,
END OF ty_indent_context,
BEGIN OF ty_study_result,
style_open TYPE abap_bool,
style_close TYPE abap_bool,
script_open TYPE abap_bool,
script_close TYPE abap_bool,
tag_close TYPE abap_bool,
curly_close TYPE abap_bool,
openings TYPE i,
closings TYPE i,
singles TYPE i,
END OF ty_study_result.
METHODS indent_line
CHANGING
cs_context TYPE ty_indent_context
cv_line TYPE string.
METHODS study_line
IMPORTING
iv_line TYPE string
is_context TYPE ty_indent_context
RETURNING VALUE(rs_result) TYPE ty_study_result.
ENDCLASS. "lcl_html DEFINITION ENDCLASS. "lcl_html DEFINITION
@ -62,26 +105,28 @@ CLASS lcl_html IMPLEMENTATION.
METHOD add. METHOD add.
DATA lo_type TYPE REF TO cl_abap_typedescr. DATA: lv_type TYPE c,
DATA lo_html TYPE REF TO lcl_html. lo_html TYPE REF TO lcl_html.
lo_type = cl_abap_typedescr=>describe_by_data( iv_chunk ). FIELD-SYMBOLS: <tab> TYPE string_table,
<str> LIKE LINE OF <tab>.
CASE lo_type->type_kind. DESCRIBE FIELD iv_chunk TYPE lv_type. " Describe is faster than RTTI classes
WHEN cl_abap_typedescr=>typekind_char
OR cl_abap_typedescr=>typekind_string. CASE lv_type.
IF strlen( iv_chunk ) = 0. WHEN 'C' OR 'g'. " Char or string
RETURN. APPEND iv_chunk TO mt_buffer.
ENDIF. WHEN 'h'. " Table
_add_str( iv_chunk ). ASSIGN iv_chunk TO <tab>. " Assuming table of strings ! Will dump otherwise
WHEN cl_abap_typedescr=>typekind_oref. APPEND LINES OF <tab> TO mt_buffer.
WHEN 'r'. " Object ref
ASSERT iv_chunk IS BOUND. " Dev mistake ASSERT iv_chunk IS BOUND. " Dev mistake
TRY. TRY.
lo_html ?= iv_chunk. lo_html ?= iv_chunk.
CATCH cx_sy_move_cast_error. CATCH cx_sy_move_cast_error.
ASSERT 1 = 0. " Dev mistake ASSERT 1 = 0. " Dev mistake
ENDTRY. ENDTRY.
_add_htm( lo_html ). APPEND LINES OF lo_html->mt_buffer TO mt_buffer.
WHEN OTHERS. WHEN OTHERS.
ASSERT 1 = 0. " Dev mistake ASSERT 1 = 0. " Dev mistake
ENDCASE. ENDCASE.
@ -89,88 +134,147 @@ CLASS lcl_html IMPLEMENTATION.
ENDMETHOD. " add ENDMETHOD. " add
METHOD reset. METHOD reset.
CLEAR: me->mv_html, me->mv_indent. CLEAR me->mt_buffer.
ENDMETHOD. "reset ENDMETHOD. "reset
METHOD _add_str. METHOD is_empty.
rv_yes = boolc( lines( mt_buffer ) = 0 ).
ENDMETHOD. "is_empty
CONSTANTS lc_single_tags_re TYPE string " HTML5 singleton tags METHOD class_constructor.
VALUE '<(area|base|br|col|command|embed|hr|img|input|link|meta|param|source|!)'. CREATE OBJECT go_single_tags_re
EXPORTING
pattern = '<(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|LINK|META|PARAM|SOURCE|!)'
ignore_case = abap_false.
ENDMETHOD. "class_constructor
DATA lv_tags TYPE i. METHOD study_line.
DATA lv_tags_open TYPE i.
DATA lv_tags_close TYPE i.
DATA lv_tags_single TYPE i.
DATA lv_close_offs TYPE i.
DATA lv_shift_back TYPE i.
DATA lv_style_tag_open TYPE i.
DATA lv_style_tag_close TYPE i.
DATA lv_js_tag_open TYPE i.
DATA lv_js_tag_close TYPE i.
DATA lv_curly TYPE i.
FIND FIRST OCCURRENCE OF '</' IN iv_str MATCH OFFSET lv_close_offs. DATA: lv_line TYPE string,
IF sy-subrc = 0 AND lv_close_offs = 0 AND mv_indent > 0. " Found close tag @beginning lv_len TYPE i.
lv_shift_back = 1.
lv_line = to_upper( shift_left( val = iv_line sub = ` ` ) ).
lv_len = strlen( lv_line ).
" Some assumptions for simplification and speed
" - style & scripts tag should be opened/closed in a separate line
" - style & scripts opening and closing in one line is possible but only once
" TODO & Issues
" - What if the string IS a well formed html already not just single line ?
IF is_context-within_js = abap_true OR is_context-within_style = abap_true.
IF is_context-within_js = abap_true AND lv_len >= 8 AND lv_line(8) = '</SCRIPT'.
rs_result-script_close = abap_true.
ELSEIF is_context-within_style = abap_true AND lv_len >= 7 AND lv_line(7) = '</STYLE'.
rs_result-style_close = abap_true.
ENDIF. ENDIF.
FIND FIRST OCCURRENCE OF '}' IN iv_str MATCH OFFSET lv_close_offs. " Find close } @beginning IF is_context-no_indent_jscss = abap_false.
IF ( mv_within_style > 0 OR mv_within_js > 0 ) IF lv_len >= 1 AND lv_line(1) = '}'.
AND sy-subrc = 0 AND lv_close_offs = 0 AND mv_indent > 0. rs_result-curly_close = abap_true.
lv_shift_back = 1.
ENDIF. ENDIF.
mv_html = mv_html FIND ALL OCCURRENCES OF '{' IN lv_line MATCH COUNT rs_result-openings.
&& repeat( val = ` ` occ = ( mv_indent - lv_shift_back ) * c_indent_size ) FIND ALL OCCURRENCES OF '}' IN lv_line MATCH COUNT rs_result-closings.
&& iv_str
&& gc_newline.
FIND ALL OCCURRENCES OF '<' IN iv_str MATCH COUNT lv_tags.
FIND ALL OCCURRENCES OF '</' IN iv_str MATCH COUNT lv_tags_close.
FIND ALL OCCURRENCES OF REGEX lc_single_tags_re IN iv_str MATCH COUNT lv_tags_single.
lv_tags_open = lv_tags - lv_tags_close - lv_tags_single.
FIND ALL OCCURRENCES OF '<style' IN iv_str MATCH COUNT lv_style_tag_open IGNORING CASE.
FIND ALL OCCURRENCES OF '</style>' IN iv_str MATCH COUNT lv_style_tag_close IGNORING CASE.
mv_within_style = mv_within_style + lv_style_tag_open - lv_style_tag_close.
FIND ALL OCCURRENCES OF '<script' IN iv_str MATCH COUNT lv_js_tag_open IGNORING CASE.
FIND ALL OCCURRENCES OF '</script>' IN iv_str MATCH COUNT lv_js_tag_close IGNORING CASE.
mv_within_js = mv_within_js + lv_js_tag_open - lv_js_tag_close.
IF mv_within_style > 0 OR mv_within_js > 0.
FIND ALL OCCURRENCES OF '{' IN iv_str MATCH COUNT lv_curly.
lv_tags_open = lv_tags_open + lv_curly.
FIND ALL OCCURRENCES OF '}' IN iv_str MATCH COUNT lv_curly.
lv_tags_close = lv_tags_close + lv_curly.
ENDIF. ENDIF.
ELSE.
IF lv_len >= 7 AND lv_line(7) = '<SCRIPT'.
FIND FIRST OCCURRENCE OF '</SCRIPT' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-script_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 6 AND lv_line(6) = '<STYLE'.
FIND FIRST OCCURRENCE OF '</STYLE' IN lv_line.
IF sy-subrc > 0. " Not found
rs_result-style_open = abap_true.
ENDIF.
ENDIF.
IF lv_len >= 2 AND lv_line(2) = '</'.
rs_result-tag_close = abap_true.
ENDIF.
FIND ALL OCCURRENCES OF '<' IN lv_line MATCH COUNT rs_result-openings.
FIND ALL OCCURRENCES OF '</' IN lv_line MATCH COUNT rs_result-closings.
FIND ALL OCCURRENCES OF REGEX go_single_tags_re IN lv_line MATCH COUNT rs_result-singles.
rs_result-openings = rs_result-openings - rs_result-closings - rs_result-singles.
ENDIF.
ENDMETHOD. "study_line
METHOD indent_line.
DATA: ls_study TYPE ty_study_result,
lv_x_str TYPE string.
ls_study = study_line(
is_context = cs_context
iv_line = cv_line ).
" First closing tag - shift back exceptionally
IF ( ls_study-script_close = abap_true
OR ls_study-style_close = abap_true
OR ls_study-curly_close = abap_true
OR ls_study-tag_close = abap_true )
AND cs_context-indent > 0.
lv_x_str = repeat( val = ` ` occ = ( cs_context-indent - 1 ) * c_indent_size ).
cv_line = lv_x_str && cv_line.
ELSE.
cv_line = cs_context-indent_str && cv_line.
ENDIF.
" Context status update
CASE abap_true.
WHEN ls_study-script_open.
cs_context-within_js = abap_true.
cs_context-within_style = abap_false.
WHEN ls_study-style_open.
cs_context-within_js = abap_false.
cs_context-within_style = abap_true.
WHEN ls_study-script_close OR ls_study-style_close.
cs_context-within_js = abap_false.
cs_context-within_style = abap_false.
ls_study-closings = ls_study-closings + 1.
ENDCASE.
" More-less logic chosen due to possible double tags in a line '<a><b>' " More-less logic chosen due to possible double tags in a line '<a><b>'
IF lv_tags_open > lv_tags_close. IF ls_study-openings <> ls_study-closings.
mv_indent = mv_indent + 1. IF ls_study-openings > ls_study-closings.
ELSEIF lv_tags_open < lv_tags_close AND mv_indent > 0. cs_context-indent = cs_context-indent + 1.
mv_indent = mv_indent - 1. ELSEIF cs_context-indent > 0. " AND ls_study-openings < ls_study-closings
cs_context-indent = cs_context-indent - 1.
ENDIF.
cs_context-indent_str = repeat( val = ` ` occ = cs_context-indent * c_indent_size ).
ENDIF. ENDIF.
ENDMETHOD. "_add_str ENDMETHOD. "indent_line
METHOD _add_htm. METHOD render.
DATA lt_strtab TYPE TABLE OF string. DATA: ls_context TYPE ty_indent_context,
DATA lv_str TYPE string. lt_temp TYPE string_table.
SPLIT io_html->mv_html AT gc_newline INTO TABLE lt_strtab. FIELD-SYMBOLS: <line> LIKE LINE OF lt_temp,
LOOP AT lt_strtab INTO lv_str. <line_c> LIKE LINE OF lt_temp.
SHIFT lv_str LEFT DELETING LEADING space.
_add_str( lv_str ). ls_context-no_indent_jscss = iv_no_indent_jscss.
LOOP AT mt_buffer ASSIGNING <line>.
APPEND <line> TO lt_temp ASSIGNING <line_c>.
indent_line( CHANGING cs_context = ls_context cv_line = <line_c> ).
ENDLOOP. ENDLOOP.
ENDMETHOD. "_add_htm CONCATENATE LINES OF lt_temp INTO rv_html SEPARATED BY gc_newline.
ENDMETHOD. "render
METHOD add_a. METHOD add_a.
_add_str( a( iv_txt = iv_txt add( a( iv_txt = iv_txt
iv_act = iv_act iv_act = iv_act
iv_typ = iv_typ iv_typ = iv_typ
iv_opt = iv_opt iv_opt = iv_opt
@ -228,7 +332,7 @@ CLASS lcl_html IMPLEMENTATION.
METHOD add_icon. METHOD add_icon.
_add_str( icon( iv_name = iv_name add( icon( iv_name = iv_name
iv_class = iv_class iv_class = iv_class
iv_alt = iv_alt iv_alt = iv_alt
iv_hint = iv_hint ) ). iv_hint = iv_hint ) ).

View File

@ -173,7 +173,7 @@ CLASS lcl_gui_page IMPLEMENTATION.
lo_script = scripts( ). lo_script = scripts( ).
IF lo_script IS BOUND AND lo_script->mv_html IS NOT INITIAL. IF lo_script IS BOUND AND lo_script->is_empty( ) = abap_false.
ro_html->add( '<script type="text/javascript">' ). ro_html->add( '<script type="text/javascript">' ).
ro_html->add( lo_script ). ro_html->add( lo_script ).
ro_html->add( 'debugOutput("js: OK");' ). ro_html->add( 'debugOutput("js: OK");' ).

View File

@ -85,7 +85,7 @@ CLASS lcl_gui_page_debuginfo IMPLEMENTATION.
ENDIF. ENDIF.
ENDLOOP. ENDLOOP.
rv_html = |</p>Supported objects: { lv_list }</p>|. rv_html = |<p>Supported objects: { lv_list }</p>|.
ENDMETHOD. " render_supported_object_types ENDMETHOD. " render_supported_object_types

View File

@ -151,12 +151,14 @@ CLASS lcl_gui_page_stage IMPLEMENTATION.
LOOP AT ms_files-local ASSIGNING <ls_local>. LOOP AT ms_files-local ASSIGNING <ls_local>.
AT FIRST. AT FIRST.
ro_html->add('<thead><tr>'). ro_html->add('<thead><tr>').
ro_html->add('<th></th><th colspan="2">LOCAL</th><th>' ). ro_html->add('<th></th><th colspan="2">LOCAL</th>' ).
ro_html->add('<th>' ).
IF lines( ms_files-local ) > 1. IF lines( ms_files-local ) > 1.
ro_html->add_a( iv_txt = |{ lines( ms_files-local ) } diffs| ro_html->add_a( iv_txt = |{ lines( ms_files-local ) } diffs|
iv_act = |{ gc_action-go_diff }?key={ mo_repo->get_key( ) }| ). iv_act = |{ gc_action-go_diff }?key={ mo_repo->get_key( ) }| ).
ENDIF. ENDIF.
ro_html->add('</th></tr></thead>'). ro_html->add('</th>').
ro_html->add('</tr></thead>').
ro_html->add('<tbody class="local">'). ro_html->add('<tbody class="local">').
ENDAT. ENDAT.

View File

@ -1234,7 +1234,7 @@ CLASS ltcl_git_pack IMPLEMENTATION.
ENDCLASS. "lcl_abap_unit IMPLEMENTATION ENDCLASS. "lcl_abap_unit IMPLEMENTATION
CLASS ltcl_html_helper DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL. CLASS ltcl_html DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
PRIVATE SECTION. PRIVATE SECTION.
DATA: mo_html TYPE REF TO lcl_html. DATA: mo_html TYPE REF TO lcl_html.
@ -1251,9 +1251,9 @@ CLASS ltcl_html_helper DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
last_line last_line
RETURNING VALUE(rv_line) TYPE string. RETURNING VALUE(rv_line) TYPE string.
ENDCLASS. ENDCLASS. "ltcl_html
CLASS ltcl_html_helper IMPLEMENTATION. CLASS ltcl_html IMPLEMENTATION.
METHOD setup. METHOD setup.
CREATE OBJECT mo_html. CREATE OBJECT mo_html.
@ -1261,49 +1261,73 @@ CLASS ltcl_html_helper IMPLEMENTATION.
METHOD indent1. METHOD indent1.
DATA lv_exp TYPE string.
mo_html->add( '<td>' ). mo_html->add( '<td>' ).
mo_html->add( 'hello world' ). mo_html->add( 'hello world' ).
mo_html->add( '</td>' ). mo_html->add( '</td>' ).
lv_exp = '<td>' && gc_newline &&
' hello world' && gc_newline &&
'</td>'.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = last_line( ) act = mo_html->render( )
exp = '</td>' ). exp = lv_exp ).
ENDMETHOD. ENDMETHOD.
METHOD indent2. METHOD indent2.
DATA lv_exp TYPE string.
mo_html->add( '<td>' ). mo_html->add( '<td>' ).
mo_html->add( '<input name="comment" type="text">' ). mo_html->add( '<input name="comment" type="text">' ).
mo_html->add( '</td>' ). mo_html->add( '</td>' ).
lv_exp = '<td>' && gc_newline &&
' <input name="comment" type="text">' && gc_newline &&
'</td>'.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = last_line( ) act = mo_html->render( )
exp = '</td>' ). exp = lv_exp ).
ENDMETHOD. ENDMETHOD.
METHOD indent3. METHOD indent3.
DATA lv_exp TYPE string.
mo_html->add( '<td>' ). mo_html->add( '<td>' ).
mo_html->add( '<textarea name="body" rows="10" cols="72"></textarea>' ). mo_html->add( '<textarea name="body" rows="10" cols="72"></textarea>' ).
mo_html->add( '</td>' ). mo_html->add( '</td>' ).
lv_exp = '<td>' && gc_newline &&
' <textarea name="body" rows="10" cols="72"></textarea>' && gc_newline &&
'</td>'.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = last_line( ) act = mo_html->render( )
exp = '</td>' ). exp = lv_exp ).
ENDMETHOD. ENDMETHOD.
METHOD indent4. METHOD indent4.
DATA lv_exp TYPE string.
mo_html->add( '<td>' ). mo_html->add( '<td>' ).
mo_html->add( 'foo<br>bar' ). mo_html->add( 'foo<br>bar' ).
mo_html->add( '</td>' ). mo_html->add( '</td>' ).
lv_exp = '<td>' && gc_newline &&
' foo<br>bar' && gc_newline &&
'</td>'.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = last_line( ) act = mo_html->render( )
exp = '</td>' ). exp = lv_exp ).
ENDMETHOD. ENDMETHOD.
@ -1311,33 +1335,37 @@ CLASS ltcl_html_helper IMPLEMENTATION.
DATA: lt_strings TYPE STANDARD TABLE OF string WITH DEFAULT KEY. DATA: lt_strings TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
SPLIT mo_html->mv_html AT gc_newline INTO TABLE lt_strings. SPLIT mo_html->render( ) AT gc_newline INTO TABLE lt_strings.
READ TABLE lt_strings INDEX lines( lt_strings ) INTO rv_line. READ TABLE lt_strings INDEX lines( lt_strings ) INTO rv_line.
ENDMETHOD. ENDMETHOD.
METHOD style1. METHOD style1.
DATA lv_exp TYPE string.
mo_html->add( '<style type="text/css">' ). mo_html->add( '<style type="text/css">' ).
mo_html->add( '.class1 { color: red }' ). mo_html->add( '.class1 { color: red }' ).
mo_html->add( '.class2 {' ). mo_html->add( '.class2 {' ).
mo_html->add( 'color: red' ). mo_html->add( 'color: red' ).
cl_abap_unit_assert=>assert_equals( act = last_line( ) exp = ' color: red' ).
mo_html->add( '}' ). mo_html->add( '}' ).
cl_abap_unit_assert=>assert_equals( act = last_line( ) exp = ' }' ).
mo_html->add( '</style>' ). mo_html->add( '</style>' ).
cl_abap_unit_assert=>assert_equals( act = last_line( ) exp = '</style>' ). lv_exp = '<style type="text/css">' && gc_newline &&
' .class1 { color: red }' && gc_newline &&
' .class2 {' && gc_newline &&
' color: red' && gc_newline &&
' }' && gc_newline &&
'</style>'.
cl_abap_unit_assert=>assert_equals(
act = mo_html->render( )
exp = lv_exp ).
ENDMETHOD. ENDMETHOD.
ENDCLASS. ENDCLASS. "ltcl_html
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* CLASS ltcl_serialize DEFINITION * CLASS ltcl_serialize DEFINITION

View File

@ -522,31 +522,26 @@ CLASS lcl_gui_view_repo_content IMPLEMENTATION.
METHOD build_dir_jump_link. METHOD build_dir_jump_link.
DATA: lv_path TYPE string, DATA: lv_path TYPE string,
lv_encode TYPE string, lv_encode TYPE string.
lo_html TYPE REF TO lcl_html.
lv_path = iv_path. lv_path = iv_path.
REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''. REPLACE FIRST OCCURRENCE OF mv_cur_dir IN lv_path WITH ''.
lv_encode = lcl_html_action_utils=>dir_encode( lv_path ). lv_encode = lcl_html_action_utils=>dir_encode( lv_path ).
CREATE OBJECT lo_html. rv_html = lcl_html=>a( iv_txt = lv_path
lo_html->add_a( iv_txt = lv_path iv_act = |{ c_actions-change_dir }?{ lv_encode }| ). iv_act = |{ c_actions-change_dir }?{ lv_encode }| ).
rv_html = lo_html->mv_html.
ENDMETHOD. "build_dir_jump_link ENDMETHOD. "build_dir_jump_link
METHOD build_obj_jump_link. METHOD build_obj_jump_link.
DATA: lv_encode TYPE string, DATA: lv_encode TYPE string.
lo_html TYPE REF TO lcl_html.
lv_encode = lcl_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type lv_encode = lcl_html_action_utils=>jump_encode( iv_obj_type = is_item-obj_type
iv_obj_name = is_item-obj_name ). iv_obj_name = is_item-obj_name ).
CREATE OBJECT lo_html. rv_html = lcl_html=>a( iv_txt = |{ is_item-obj_name }|
lo_html->add_a( iv_txt = |{ is_item-obj_name }|
iv_act = |{ gc_action-jump }?{ lv_encode }| ). iv_act = |{ gc_action-jump }?{ lv_encode }| ).
rv_html = lo_html->mv_html.
ENDMETHOD. "build_obj_jump_link ENDMETHOD. "build_obj_jump_link