Changeset 207471 in webkit


Ignore:
Timestamp:
Oct 18, 2016 10:41:14 AM (8 years ago)
Author:
Said Abou-Hallawa
Message:

SVGCSSParser: m_implicitShorthand value is not reset after adding the shorthand property
https://bugs.webkit.org/show_bug.cgi?id=116470

Reviewed by Simon Fraser.

Source/WebCore:

When we encounter a shorthand css property, we set m_implicitShorthand
to true to tell addProperty() later that the individual properties are
all set through a short hand one. We need to make sure that setting
m_implicitShorthand to true will not be leaked after finishing parsing
the short hand property.

Test: fast/css/implicit-property-restore.html

  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseFillShorthand):
(WebCore::CSSParser::parseShorthand):
(WebCore::CSSParser::parse4Values):
(WebCore::CSSParser::parseBorderRadius):
(WTF::ImplicitScope::ImplicitScope): Deleted.
(WTF::ImplicitScope::~ImplicitScope): Deleted.
Get rid of ImplicitScope and replace its calls by TemporaryChange<bool>.

  • css/parser/SVGCSSParser.cpp:

(WebCore::CSSParser::parseSVGValue):
Restore m_implicitShorthand value after setting it temporarily to true.

Source/WTF:

  • wtf/TemporaryChange.h:

(WTF::TemporaryChange::TemporaryChange):
Add a new constructor to make TemporaryChange work as a restorer. The
temporary change will happen after we construct the object.

LayoutTests:

  • fast/css/implicit-property-restore-expected.txt: Added.
  • fast/css/implicit-property-restore.html: Added.
  • fast/css/remove-shorthand-expected.txt:

Rebase-line the test expected results because of fixing the leak of
m_implicitShorthand. The bug was happening because "background: ..." property
comes immediately before the "list-style: ...." property.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207470 r207471  
     12016-10-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        SVGCSSParser: m_implicitShorthand value is not reset after adding the shorthand property
     4        https://bugs.webkit.org/show_bug.cgi?id=116470
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css/implicit-property-restore-expected.txt: Added.
     9        * fast/css/implicit-property-restore.html: Added.
     10
     11        * fast/css/remove-shorthand-expected.txt:
     12        Rebase-line the test expected results because of fixing the leak of
     13        m_implicitShorthand. The bug was happening because "background: ..." property
     14        comes immediately before the "list-style: ...." property.
     15
    1162016-10-18  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/LayoutTests/fast/css/remove-shorthand-expected.txt

    r200357 r207471  
    4949and adds "".
    5050Removing list-style
    51 removes "list-style-type, list-style-position, list-style-image"
     51removes "list-style"
    5252and adds "".
    5353Removing margin
  • trunk/Source/WTF/ChangeLog

    r207438 r207471  
     12016-10-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        SVGCSSParser: m_implicitShorthand value is not reset after adding the shorthand property
     4        https://bugs.webkit.org/show_bug.cgi?id=116470
     5
     6        Reviewed by Simon Fraser.
     7
     8        * wtf/TemporaryChange.h:
     9        (WTF::TemporaryChange::TemporaryChange):
     10        Add a new constructor to make TemporaryChange work as a restorer. The
     11        temporary change will happen after we construct the object.
     12
    1132016-10-17  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WTF/wtf/TemporaryChange.h

    r111778 r207471  
    4444    WTF_MAKE_NONCOPYABLE(TemporaryChange);
    4545public:
    46     TemporaryChange(T& scopedVariable, T newValue)
     46    TemporaryChange(T& scopedVariable)
    4747        : m_scopedVariable(scopedVariable)
    4848        , m_originalValue(scopedVariable)
     49    {
     50    }
     51    TemporaryChange(T& scopedVariable, T newValue)
     52        : TemporaryChange(scopedVariable)
    4953    {
    5054        m_scopedVariable = newValue;
     
    5559        m_scopedVariable = m_originalValue;
    5660    }
    57 
    5861
    5962private:
  • trunk/Source/WebCore/ChangeLog

    r207468 r207471  
     12016-10-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        SVGCSSParser: m_implicitShorthand value is not reset after adding the shorthand property
     4        https://bugs.webkit.org/show_bug.cgi?id=116470
     5
     6        Reviewed by Simon Fraser.
     7
     8        When we encounter a shorthand css property, we set m_implicitShorthand
     9        to true to tell addProperty() later that the individual properties are
     10        all set through a short hand one. We need to make sure that setting
     11        m_implicitShorthand to true will not be leaked after finishing parsing
     12        the short hand property.
     13
     14        Test: fast/css/implicit-property-restore.html
     15
     16        * css/parser/CSSParser.cpp:
     17        (WebCore::CSSParser::parseValue):
     18        (WebCore::CSSParser::parseFillShorthand):
     19        (WebCore::CSSParser::parseShorthand):
     20        (WebCore::CSSParser::parse4Values):
     21        (WebCore::CSSParser::parseBorderRadius):
     22        (WTF::ImplicitScope::ImplicitScope): Deleted.
     23        (WTF::ImplicitScope::~ImplicitScope): Deleted.
     24        Get rid of ImplicitScope and replace its calls by TemporaryChange<bool>.
     25       
     26        * css/parser/SVGCSSParser.cpp:
     27        (WebCore::CSSParser::parseSVGValue):
     28        Restore m_implicitShorthand value after setting it temporarily to true.
     29
    1302016-10-18  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r207442 r207471  
    110110#include <wtf/NeverDestroyed.h>
    111111#include <wtf/StdLibExtras.h>
     112#include <wtf/TemporaryChange.h>
    112113#include <wtf/dtoa.h>
    113114#include <wtf/text/StringBuffer.h>
     
    138139
    139140using namespace WTF;
    140 
    141 namespace {
    142 
    143 enum PropertyType {
    144     PropertyExplicit,
    145     PropertyImplicit
    146 };
    147 
    148 class ImplicitScope {
    149     WTF_MAKE_NONCOPYABLE(ImplicitScope);
    150 public:
    151     ImplicitScope(WebCore::CSSParser& parser, PropertyType propertyType)
    152         : m_parser(parser)
    153     {
    154         m_parser.m_implicitShorthand = propertyType == PropertyImplicit;
    155     }
    156 
    157     ~ImplicitScope()
    158     {
    159         m_parser.m_implicitShorthand = false;
    160     }
    161 
    162 private:
    163     WebCore::CSSParser& m_parser;
    164 };
    165 
    166 } // namespace
    167141
    168142namespace WebCore {
     
    21352109            result = true;
    21362110        }
    2137         m_implicitShorthand = false;
    21382111        return result;
    21392112    }
     
    33743347
    33753348    ShorthandScope scope(this, propId);
     3349    TemporaryChange<bool> change(m_implicitShorthand);
    33763350
    33773351    bool parsedProperty[cMaxFillProperties] = { false };
     
    37693743    // Fill in any remaining properties with the initial value.
    37703744    auto& cssValuePool = CSSValuePool::singleton();
    3771     ImplicitScope implicitScope(*this, PropertyImplicit);
     3745    TemporaryChange<bool> change(m_implicitShorthand, true);
    37723746    const StylePropertyShorthand* propertiesForInitialization = shorthand.propertiesForInitialization();
    37733747    for (unsigned i = 0; i < shorthand.length(); ++i) {
     
    38063780                return false;
    38073781            CSSValue* value = m_parsedProperties.last().value();
    3808             ImplicitScope implicitScope(*this, PropertyImplicit);
     3782            TemporaryChange<bool> change(m_implicitShorthand, true);
    38093783            addProperty(properties[1], value, important);
    38103784            addProperty(properties[2], value, important);
     
    38163790                return false;
    38173791            CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
    3818             ImplicitScope implicitScope(*this, PropertyImplicit);
     3792            TemporaryChange<bool> change(m_implicitShorthand, true);
    38193793            addProperty(properties[2], value, important);
    38203794            value = m_parsedProperties[m_parsedProperties.size() - 2].value();
     
    38263800                return false;
    38273801            CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
    3828             ImplicitScope implicitScope(*this, PropertyImplicit);
     3802            TemporaryChange<bool> change(m_implicitShorthand, true);
    38293803            addProperty(properties[3], value, important);
    38303804            break;
     
    85118485        completeBorderRadii(radii[1]);
    85128486
    8513     ImplicitScope implicitScope(*this, PropertyImplicit);
     8487    TemporaryChange<bool> change(m_implicitShorthand, true);
    85148488    addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(WTFMove(radii[0][0]), WTFMove(radii[1][0])), important);
    85158489    addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(WTFMove(radii[0][1]), WTFMove(radii[1][1])), important);
  • trunk/Source/WebCore/css/parser/SVGCSSParser.cpp

    r207361 r207471  
    3131#include "RenderTheme.h"
    3232#include "SVGPaint.h"
     33
     34#include <wtf/TemporaryChange.h>
    3335
    3436namespace WebCore {
     
    212214    {
    213215        ShorthandScope scope(this, propId);
    214         m_implicitShorthand = true;
     216        TemporaryChange<bool> change(m_implicitShorthand, true);
    215217        if (!parseValue(CSSPropertyMarkerStart, important))
    216218            return false;
     
    222224        addProperty(CSSPropertyMarkerMid, value, important);
    223225        addProperty(CSSPropertyMarkerEnd, value, important);
    224         m_implicitShorthand = false;
    225226        return true;
    226227    }
Note: See TracChangeset for help on using the changeset viewer.