Changeset 17208 in josm for trunk/src/org


Ignore:
Timestamp:
2020-10-15T17:00:31+02:00 (4 years ago)
Author:
GerdP
Message:

see #19875: Inactive Map Paint styles cause bad performance

  • remove support for deprecated @media in mapcss parser
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r15988 r17208  
    77PARSER_BEGIN(MapCSSParser)
    88package org.openstreetmap.josm.gui.mappaint.mapcss.parsergen;
    9 
    10 import static org.openstreetmap.josm.tools.I18n.tr;
    119
    1210import java.io.InputStream;
     
    1614import java.util.Collections;
    1715import java.util.List;
    18 import java.util.Locale;
    1916
    2017import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     
    5148 * (a) the preprocessor and (b) the main mapcss parser.
    5249 *
    53  * The preprocessor handles @supports and @media syntax (@media is deprecated).
     50 * The preprocessor handles @supports syntax.
    5451 * Basically this allows to write one style for different versions of JOSM (or different editors).
    5552 * When the @supports condition is not fulfilled, it should simply skip over
     
    137134|   < PP_NOT: "not" >
    138135|   < PP_SUPPORTS: "@supports" >
    139 |   < PP_MEDIA: "@media" >
    140136|   < PP_NEWLINECHAR: "\n" | "\r" | "\f" >
    141137|   < PP_WHITESPACE: " " | "\t" >
     
    294290            pp_supports(!write)
    295291        |
    296             pp_media(!write)
    297         |
    298292            t=<LBRACE> { if (write) sb.append(t.image); } pp_black_box(write) t=<RBRACE> { if (write) sb.append(t.image); }
    299293    )*
     
    377371 */
    378372boolean pp_supports_declaration_condition():
    379 {
    380     Token t;
    381     String feature;
    382     Object val = null;
    383 }
    384 {
    385     <LPAR> pp_w() t=<IDENT> { feature = t.image; } pp_w() ( <COLON> pp_w() val=literal() )? <RPAR>
    386     { return this.sheet.evalSupportsDeclCondition(feature, val); }
    387 }
    388 
    389 // deprecated
    390 void pp_media(boolean ignore):
    391 {
    392     boolean pass = false;
    393     boolean q;
    394     boolean empty = true;
    395 }
    396 {
    397     {
    398         if (sheet != null) {
    399             String msg = tr("Detected deprecated ''{0}'' in ''{1}'' which will be removed shortly. Use ''{2}'' instead.",
    400                             "@media", sheet.getDisplayString(), "@supports");
    401             Logging.error(msg);
    402             sheet.logWarning(msg);
    403         }
    404     }
    405     <PP_MEDIA> pp_w()
    406     ( q=pp_media_query() { pass = pass || q; empty = false; }
    407         ( <COMMA> pp_w() q=pp_media_query() { pass = pass || q; } )*
    408     )?
    409     <LBRACE>
    410     pp_black_box((empty || pass) && !ignore)
    411     <RBRACE>
    412 }
    413 
    414 // deprecated
    415 boolean pp_media_query():
    416 {
    417     Token t;
    418     String mediatype = "all";
    419     boolean pass = true;
    420     boolean invert = false;
    421     boolean e;
    422 }
    423 {
    424     ( <PP_NOT> { invert = true; } pp_w() )?
    425     (
    426             t=<IDENT> { mediatype = t.image.toLowerCase(Locale.ENGLISH); } pp_w()
    427             ( <PP_AND> pp_w() e=pp_media_expression() { pass = pass && e; } pp_w() )*
    428         |
    429             e=pp_media_expression() { pass = pass && e; } pp_w()
    430             ( <PP_AND> pp_w() e=pp_media_expression() { pass = pass && e; } pp_w() )*
    431     )
    432     {
    433         if (!"all".equals(mediatype)) {
    434             pass = false;
    435         }
    436         return invert ? (!pass) : pass;
    437     }
    438 }
    439 
    440 /**
    441  * Parse an @media expression.
    442  *
    443  * The parsing rule {@link #literal()} from the main mapcss parser is reused here.
    444  *
    445  * @return true if the condition is fulfilled
    446  * @throws ParseException in case of parsing error
    447  */
    448 // deprecated
    449 boolean pp_media_expression():
    450373{
    451374    Token t;
Note: See TracChangeset for help on using the changeset viewer.