Ticket #8979: 8979_2.patch

File 8979_2.patch, 4.2 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/font/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    8282                                                        var currentValue = this.getValue();
    8383
    8484                                                        var elementPath = ev.data.path,
    85                                                                 elements = elementPath.elements;
     85                                                                elements = elementPath.elements,
     86                                                                style;
    8687
    8788                                                        // For each element into the elements path.
    8889                                                        for ( var i = 0, element ; i < elements.length ; i++ )
     
    9394                                                                // the styles.
    9495                                                                for ( var value in styles )
    9596                                                                {
    96                                                                         if ( styles[ value ].checkElementRemovable( element, true ) )
     97                                                                        style = styles[ value ];
     98
     99                                                                        // Check if element style matches precisely.
     100                                                                        if ( style.checkElementMatch( element, true ) )
    97101                                                                        {
    98102                                                                                if ( value != currentValue )
    99103                                                                                        this.setValue( value );
     
    230234        {
    231235                element         : 'span',
    232236                styles          : { 'font-size' : '#(size)' },
    233                 overrides       : [ { element : 'font', attributes : { 'size' : null } } ]
     237                overrides       : [ { element : 'font', styles  : { 'font-size' : '#(size)' } } ]
    234238        };
  • _source/plugins/styles/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    222222                // current style definition.
    223223                checkElementRemovable : function( element, fullMatch )
    224224                {
     225                        // Check element matches the style itself.
     226                        if ( this.checkElementMatch( element, fullMatch ) )
     227                                return true;
     228
     229                        // Check if the element matches the style overrides.
     230                        var override = getOverrides( this )[ element.getName() ] ;
     231                        if ( override )
     232                        {
     233                                // If no attributes have been defined, remove the element.
     234                                if ( !( attribs = override.attributes ) )
     235                                        return true;
     236
     237                                for ( var i = 0 ; i < attribs.length ; i++ )
     238                                {
     239                                        attName = attribs[i][0];
     240                                        var actualAttrValue = element.getAttribute( attName );
     241                                        if ( actualAttrValue )
     242                                        {
     243                                                var attValue = attribs[i][1];
     244
     245                                                // Remove the attribute if:
     246                                                //    - The override definition value is null;
     247                                                //    - The override definition value is a string that
     248                                                //      matches the attribute value exactly.
     249                                                //    - The override definition value is a regex that
     250                                                //      has matches in the attribute value.
     251                                                if ( attValue === null ||
     252                                                                ( typeof attValue == 'string' && actualAttrValue == attValue ) ||
     253                                                                attValue.test( actualAttrValue ) )
     254                                                        return true;
     255                                        }
     256                                }
     257                        }
     258                        return false;
     259                },
     260
     261                // Check if the element matches the current style definition.
     262                checkElementMatch : function( element, fullMatch )
     263                {
    225264                        var def = this._.definition;
    226265
    227266                        if ( !element || !def.ignoreReadonly && element.isReadOnly() )
     
    266305                                        return true;
    267306                        }
    268307
    269                         // Check if the element can be somehow overriden.
    270                         var override = getOverrides( this )[ element.getName() ] ;
    271                         if ( override )
    272                         {
    273                                 // If no attributes have been defined, remove the element.
    274                                 if ( !( attribs = override.attributes ) )
    275                                         return true;
    276 
    277                                 for ( var i = 0 ; i < attribs.length ; i++ )
    278                                 {
    279                                         attName = attribs[i][0];
    280                                         var actualAttrValue = element.getAttribute( attName );
    281                                         if ( actualAttrValue )
    282                                         {
    283                                                 var attValue = attribs[i][1];
    284 
    285                                                 // Remove the attribute if:
    286                                                 //    - The override definition value is null;
    287                                                 //    - The override definition value is a string that
    288                                                 //      matches the attribute value exactly.
    289                                                 //    - The override definition value is a regex that
    290                                                 //      has matches in the attribute value.
    291                                                 if ( attValue === null ||
    292                                                                 ( typeof attValue == 'string' && actualAttrValue == attValue ) ||
    293                                                                 attValue.test( actualAttrValue ) )
    294                                                         return true;
    295                                         }
    296                                 }
    297                         }
    298308                        return false;
    299309                },
    300310
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy