Skip to content

Commit

Permalink
Revert of Revert of Implement unset value handling (patchset #1 id:1 of
Browse files Browse the repository at this point in the history
https://codereview.chromium.org/782853002/)

Reason for revert:
A build fix has landed, so the revert is no longer necessary.

Original issue's description:
> Revert of Implement unset value handling (patchset #4 id:80001 of https://codereview.chromium.org/775153002/)
> 
> Reason for revert:
> This broke the Linux Oilpan Builder.
> 
> Logs: http://build.chromium.org/p/chromium.perf/builders/Linux%20Oilpan%20Builder/builds/13454/steps/compile/logs/stdio#error1
> 
> BUG=439604
> 
> Original issue's description:
> > Implement unset value handling
> > 
> > This patch accepts unset as a valid CSS value and creates
> > a CSSUnsetValue object for it. Then when resolving it the
> > rules stated in below link are implemented:
> > 
> > http://dev.w3.org/csswg/css-cascade/#valuedef-unset
> > 
> > Add a test for the new behavior.
> > 
> > BUG=431689
> > 
> > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=186604
> 
> TBR=timloh@chromium.org,rob.buis@samsung.com
> NOTREECHECKS=true
> NOTRY=true
> BUG=431689
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=186627

TBR=timloh@chromium.org,rob.buis@samsung.com
NOTREECHECKS=true
NOTRY=true
BUG=439604

Review URL: https://codereview.chromium.org/773483003

git-svn-id: svn://svn.chromium.org/blink/trunk@186637 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
ishermandom committed Dec 6, 2014
1 parent 4425411 commit 3537c9a
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 2 deletions.
4 changes: 4 additions & 0 deletions LayoutTests/fast/css/unset-keyword-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<body>
<span>all</span><br>
<span style="color: green">unset</span>
</body>
25 changes: 25 additions & 0 deletions LayoutTests/fast/css/unset-keyword.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<style>
span {
font-weight: bold;
color: yellow;
border: 5px solid red;
display: none;
}

.all {
all: unset;
}

.unset {
font-weight: unset;
color: unset;
border: unset;
display: unset;
}
</style>
<body>
<span class="all">all</span><br>
<div style="color: green; font-weight: normal;">
<span class="unset">unset</span>
</span>
</body>
2 changes: 2 additions & 0 deletions Source/core/core.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@
'css/CSSUnicodeRangeValue.cpp',
'css/CSSUnicodeRangeValue.h',
'css/CSSUnknownRule.h',
'css/CSSUnsetValue.cpp',
'css/CSSUnsetValue.h',
'css/CSSValue.cpp',
'css/CSSValueList.cpp',
'css/CSSValuePool.cpp',
Expand Down
17 changes: 17 additions & 0 deletions Source/core/css/CSSUnsetValue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "core/css/CSSUnsetValue.h"

#include "wtf/text/WTFString.h"

namespace blink {

String CSSUnsetValue::customCSSText() const
{
return "unset";
}

} // namespace blink
37 changes: 37 additions & 0 deletions Source/core/css/CSSUnsetValue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CSSUnsetValue_h
#define CSSUnsetValue_h

#include "core/css/CSSValue.h"
#include "wtf/PassRefPtr.h"

namespace blink {

class CSSUnsetValue : public CSSValue {
public:
static PassRefPtrWillBeRawPtr<CSSUnsetValue> create()
{
return adoptRefWillBeNoop(new CSSUnsetValue);
}

String customCSSText() const;

bool equals(const CSSUnsetValue&) const { return true; }

void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(visitor); }

private:
CSSUnsetValue()
: CSSValue(UnsetClass)
{
}
};

DEFINE_CSS_VALUE_TYPE_CASTS(CSSUnsetValue, isUnsetValue());

} // namespace blink

#endif // CSSUnsetValue_h
14 changes: 14 additions & 0 deletions Source/core/css/CSSValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "core/css/CSSTimingFunctionValue.h"
#include "core/css/CSSTransformValue.h"
#include "core/css/CSSUnicodeRangeValue.h"
#include "core/css/CSSUnsetValue.h"
#include "core/css/CSSValueList.h"

namespace blink {
Expand Down Expand Up @@ -121,6 +122,8 @@ bool CSSValue::equals(const CSSValue& other) const
return compareCSSValues<CSSInheritedValue>(*this, other);
case InitialClass:
return compareCSSValues<CSSInitialValue>(*this, other);
case UnsetClass:
return compareCSSValues<CSSUnsetValue>(*this, other);
case GridLineNamesClass:
return compareCSSValues<CSSGridLineNamesValue>(*this, other);
case GridTemplateAreasClass:
Expand Down Expand Up @@ -191,6 +194,8 @@ String CSSValue::cssText() const
return toCSSImageValue(this)->customCSSText();
case InheritedClass:
return toCSSInheritedValue(this)->customCSSText();
case UnsetClass:
return toCSSUnsetValue(this)->customCSSText();
case InitialClass:
return toCSSInitialValue(this)->customCSSText();
case GridLineNamesClass:
Expand Down Expand Up @@ -272,6 +277,9 @@ void CSSValue::destroy()
case InitialClass:
delete toCSSInitialValue(this);
return;
case UnsetClass:
delete toCSSUnsetValue(this);
return;
case GridLineNamesClass:
delete toCSSGridLineNamesValue(this);
return;
Expand Down Expand Up @@ -366,6 +374,9 @@ void CSSValue::finalizeGarbageCollectedObject()
case InitialClass:
toCSSInitialValue(this)->~CSSInitialValue();
return;
case UnsetClass:
toCSSUnsetValue(this)->~CSSUnsetValue();
return;
case GridLineNamesClass:
toCSSGridLineNamesValue(this)->~CSSGridLineNamesValue();
return;
Expand Down Expand Up @@ -460,6 +471,9 @@ void CSSValue::trace(Visitor* visitor)
case InitialClass:
toCSSInitialValue(this)->traceAfterDispatch(visitor);
return;
case UnsetClass:
toCSSUnsetValue(this)->traceAfterDispatch(visitor);
return;
case GridLineNamesClass:
toCSSGridLineNamesValue(this)->traceAfterDispatch(visitor);
return;
Expand Down
2 changes: 2 additions & 0 deletions Source/core/css/CSSValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CSSValue> {
bool isImageValue() const { return m_classType == ImageClass; }
bool isImplicitInitialValue() const;
bool isInheritedValue() const { return m_classType == InheritedClass; }
bool isUnsetValue() const { return m_classType == UnsetClass; }
bool isInitialValue() const { return m_classType == InitialClass; }
bool isLinearGradientValue() const { return m_classType == LinearGradientClass; }
bool isRadialGradientValue() const { return m_classType == RadialGradientClass; }
Expand Down Expand Up @@ -121,6 +122,7 @@ class CSSValue : public RefCountedWillBeGarbageCollectedFinalized<CSSValue> {

InheritedClass,
InitialClass,
UnsetClass,

ReflectClass,
ShadowClass,
Expand Down
1 change: 1 addition & 0 deletions Source/core/css/CSSValuePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CSSValuePool::CSSValuePool()
: m_inheritedValue(CSSInheritedValue::create())
, m_implicitInitialValue(CSSInitialValue::createImplicit())
, m_explicitInitialValue(CSSInitialValue::createExplicit())
, m_unsetValue(CSSUnsetValue::create())
, m_colorTransparent(CSSPrimitiveValue::createColor(Color::transparent))
, m_colorWhite(CSSPrimitiveValue::createColor(Color::white))
, m_colorBlack(CSSPrimitiveValue::createColor(Color::black))
Expand Down
3 changes: 3 additions & 0 deletions Source/core/css/CSSValuePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "core/css/CSSInheritedValue.h"
#include "core/css/CSSInitialValue.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSUnsetValue.h"
#include "wtf/HashMap.h"
#include "wtf/RefPtr.h"
#include "wtf/text/AtomicStringHash.h"
Expand All @@ -47,6 +48,7 @@ class CSSValuePool : public NoBaseWillBeGarbageCollected<CSSValuePool> {
PassRefPtrWillBeRawPtr<CSSInheritedValue> createInheritedValue() { return m_inheritedValue; }
PassRefPtrWillBeRawPtr<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue; }
PassRefPtrWillBeRawPtr<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue; }
PassRefPtrWillBeRawPtr<CSSUnsetValue> createUnsetValue() { return m_unsetValue; }
PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier);
PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier);
PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createColorValue(unsigned rgbValue);
Expand All @@ -64,6 +66,7 @@ class CSSValuePool : public NoBaseWillBeGarbageCollected<CSSValuePool> {
RefPtrWillBeMember<CSSInheritedValue> m_inheritedValue;
RefPtrWillBeMember<CSSInitialValue> m_implicitInitialValue;
RefPtrWillBeMember<CSSInitialValue> m_explicitInitialValue;
RefPtrWillBeMember<CSSUnsetValue> m_unsetValue;

WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>, numCSSValueKeywords> m_identifierValueCache;

Expand Down
8 changes: 6 additions & 2 deletions Source/core/css/parser/CSSPropertyParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,16 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
return false;
addExpandedPropertyForValue(propId, cssValuePool().createInheritedValue(), important);
return true;
}
else if (id == CSSValueInitial) {
} else if (id == CSSValueInitial) {
if (num != 1)
return false;
addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitialValue(), important);
return true;
} else if (id == CSSValueUnset) {
if (num != 1)
return false;
addExpandedPropertyForValue(propId, cssValuePool().createUnsetValue(), important);
return true;
}

if (CSSParserFastPaths::isKeywordPropertyID(propId)) {
Expand Down
8 changes: 8 additions & 0 deletions Source/core/css/resolver/StyleResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,14 @@ void StyleResolver::applyProperties(StyleResolverState& state, const StyleProper
if (!isPropertyForPass<pass>(property))
continue;

if (current.value()->isUnsetValue()) {
if (CSSPropertyMetadata::isInheritedProperty(property))
StyleBuilder::applyProperty(property, state, cssValuePool().createInheritedValue().get());
else
StyleBuilder::applyProperty(property, state, cssValuePool().createExplicitInitialValue().get());
continue;
}

StyleBuilder::applyProperty(current.id(), state, current.value());
}
}
Expand Down

0 comments on commit 3537c9a

Please sign in to comment.