⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 207971 in webkit


Ignore:
Timestamp:
Oct 27, 2016, 2:54:57 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r207471 - 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:
releases/WebKitGTK/webkit-2.14
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog

    r207961 r207971  
     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-14  Antti Koivisto  <antti@apple.com>
    217
  • releases/WebKitGTK/webkit-2.14/LayoutTests/fast/css/remove-shorthand-expected.txt

    r200357 r207971  
    4949and adds "".
    5050Removing list-style
    51 removes "list-style-type, list-style-position, list-style-image"
     51removes "list-style"
    5252and adds "".
    5353Removing margin
  • releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog

    r207103 r207971  
     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-09-26  Michael Catanzaro  <mcatanzaro@igalia.com>
    214
  • releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/TemporaryChange.h

    r111778 r207971  
    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:
  • releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog

    r207969 r207971  
     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-17  Alberto Garcia  <berto@igalia.com>
    231
  • releases/WebKitGTK/webkit-2.14/Source/WebCore/css/parser/CSSParser.cpp

    r205620 r207971  
    107107#include <wtf/NeverDestroyed.h>
    108108#include <wtf/StdLibExtras.h>
     109#include <wtf/TemporaryChange.h>
    109110#include <wtf/dtoa.h>
    110111#include <wtf/text/StringBuffer.h>
    … …  
    135136
    136137using namespace WTF;
    137 
    138 namespace {
    139 
    140 enum PropertyType {
    141     PropertyExplicit,
    142     PropertyImplicit
    143 };
    144 
    145 class ImplicitScope {
    146     WTF_MAKE_NONCOPYABLE(ImplicitScope);
    147 public:
    148     ImplicitScope(WebCore::CSSParser& parser, PropertyType propertyType)
    149         : m_parser(parser)
    150     {
    151         m_parser.m_implicitShorthand = propertyType == PropertyImplicit;
    152     }
    153 
    154     ~ImplicitScope()
    155     {
    156         m_parser.m_implicitShorthand = false;
    157     }
    158 
    159 private:
    160     WebCore::CSSParser& m_parser;
    161 };
    162 
    163 } // namespace
    164138
    165139namespace WebCore {
    … …  
    22302204            result = true;
    22312205        }
    2232         m_implicitShorthand = false;
    22332206        return result;
    22342207    }
    … …  
    36233596
    36243597    ShorthandScope scope(this, propId);
     3598    TemporaryChange<bool> change(m_implicitShorthand);
    36253599
    36263600    bool parsedProperty[cMaxFillProperties] = { false };
    … …  
    40374011    // Fill in any remaining properties with the initial value.
    40384012    auto& cssValuePool = CSSValuePool::singleton();
    4039     ImplicitScope implicitScope(*this, PropertyImplicit);
     4013    TemporaryChange<bool> change(m_implicitShorthand, true);
    40404014    const StylePropertyShorthand* propertiesForInitialization = shorthand.propertiesForInitialization();
    40414015    for (unsigned i = 0; i < shorthand.length(); ++i) {
    … …  
    40744048                return false;
    40754049            CSSValue* value = m_parsedProperties.last().value();
    4076             ImplicitScope implicitScope(*this, PropertyImplicit);
     4050            TemporaryChange<bool> change(m_implicitShorthand, true);
    40774051            addProperty(properties[1], value, important);
    40784052            addProperty(properties[2], value, important);
    … …  
    40844058                return false;
    40854059            CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
    4086             ImplicitScope implicitScope(*this, PropertyImplicit);
     4060            TemporaryChange<bool> change(m_implicitShorthand, true);
    40874061            addProperty(properties[2], value, important);
    40884062            value = m_parsedProperties[m_parsedProperties.size() - 2].value();
    … …  
    40944068                return false;
    40954069            CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
    4096             ImplicitScope implicitScope(*this, PropertyImplicit);
     4070            TemporaryChange<bool> change(m_implicitShorthand, true);
    40974071            addProperty(properties[3], value, important);
    40984072            break;
    … …  
    87318705        completeBorderRadii(radii[1]);
    87328706
    8733     ImplicitScope implicitScope(*this, PropertyImplicit);
     8707    TemporaryChange<bool> change(m_implicitShorthand, true);
    87348708    addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(WTFMove(radii[0][0]), WTFMove(radii[1][0])), important);
    87358709    addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(WTFMove(radii[0][1]), WTFMove(radii[1][1])), important);
  • releases/WebKitGTK/webkit-2.14/Source/WebCore/css/parser/SVGCSSParser.cpp

    r204852 r207971  
    3131#include "RenderTheme.h"
    3232#include "SVGPaint.h"
     33
     34#include <wtf/TemporaryChange.h>
    3335
    3436namespace WebCore {
    … …  
    292294    {
    293295        ShorthandScope scope(this, propId);
    294         m_implicitShorthand = true;
     296        TemporaryChange<bool> change(m_implicitShorthand, true);
    295297        if (!parseValue(CSSPropertyMarkerStart, important))
    296298            return false;
    … …  
    302304        addProperty(CSSPropertyMarkerMid, value, important);
    303305        addProperty(CSSPropertyMarkerEnd, value, important);
    304         m_implicitShorthand = false;
    305306        return true;
    306307    }
Note: See TracChangeset for help on using the changeset viewer.