- Revision
- 259988
- Author
- [email protected]
- Date
- 2020-04-12 12:33:30 -0700 (Sun, 12 Apr 2020)
Log Message
Refactor and tighten up the CSSVariableReferenceValue class
https://bugs.webkit.org/show_bug.cgi?id=210406
Reviewed by Anders Carlsson.
* css/CSSCustomPropertyValue.h: Remove uneeded forward declaration of
CSSVariableReferenceValue, since it's not used here. Added inclde of
CSSVariableData.h since the use of Variant in this class does require
that header, which we were getting indirectly before from
CSSVariableReferenceValue.h in some translation units.
* css/CSSVariableReferenceValue.cpp:
(WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): Moved here
from the header.
(WebCore::CSSVariableReferenceValue::create): Ditto.
(WebCore::CSSVariableReferenceValue::equals const): Ditto.
(WebCore::CSSVariableReferenceValue::customCSSText const): Use non-null to
indicate this is not serialized.
* css/CSSVariableReferenceValue.h: Reduced includes, inlining, marked
constructor explicit, removed unneeded m_serialized boolean.
* rendering/style/StyleCustomPropertyData.h: Remove unneeded include
of CSSVariableReferenceValue.h, not used here.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (259987 => 259988)
--- trunk/Source/WebCore/ChangeLog 2020-04-12 19:31:08 UTC (rev 259987)
+++ trunk/Source/WebCore/ChangeLog 2020-04-12 19:33:30 UTC (rev 259988)
@@ -1,5 +1,31 @@
2020-04-12 Darin Adler <[email protected]>
+ Refactor and tighten up the CSSVariableReferenceValue class
+ https://bugs.webkit.org/show_bug.cgi?id=210406
+
+ Reviewed by Anders Carlsson.
+
+ * css/CSSCustomPropertyValue.h: Remove uneeded forward declaration of
+ CSSVariableReferenceValue, since it's not used here. Added inclde of
+ CSSVariableData.h since the use of Variant in this class does require
+ that header, which we were getting indirectly before from
+ CSSVariableReferenceValue.h in some translation units.
+
+ * css/CSSVariableReferenceValue.cpp:
+ (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): Moved here
+ from the header.
+ (WebCore::CSSVariableReferenceValue::create): Ditto.
+ (WebCore::CSSVariableReferenceValue::equals const): Ditto.
+ (WebCore::CSSVariableReferenceValue::customCSSText const): Use non-null to
+ indicate this is not serialized.
+ * css/CSSVariableReferenceValue.h: Reduced includes, inlining, marked
+ constructor explicit, removed unneeded m_serialized boolean.
+
+ * rendering/style/StyleCustomPropertyData.h: Remove unneeded include
+ of CSSVariableReferenceValue.h, not used here.
+
+2020-04-12 Darin Adler <[email protected]>
+
Fix some strange uses of start/endOfDocument
https://bugs.webkit.org/show_bug.cgi?id=210408
Modified: trunk/Source/WebCore/css/CSSCustomPropertyValue.h (259987 => 259988)
--- trunk/Source/WebCore/css/CSSCustomPropertyValue.h 2020-04-12 19:31:08 UTC (rev 259987)
+++ trunk/Source/WebCore/css/CSSCustomPropertyValue.h 2020-04-12 19:33:30 UTC (rev 259988)
@@ -25,19 +25,16 @@
#pragma once
-#include "CSSRegisteredCustomProperty.h"
#include "CSSValue.h"
+#include "CSSVariableData.h"
#include "CSSVariableReferenceValue.h"
#include "Length.h"
#include "StyleImage.h"
-#include <wtf/RefPtr.h>
#include <wtf/Variant.h>
-#include <wtf/text/WTFString.h>
namespace WebCore {
class CSSParserToken;
-class CSSVariableReferenceValue;
class RenderStyle;
class CSSCustomPropertyValue final : public CSSValue {
@@ -85,9 +82,9 @@
String customCSSText() const;
const AtomString& name() const { return m_name; }
- bool isResolved() const { return !WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(m_value); }
- bool isUnset() const { return WTF::holds_alternative<CSSValueID>(m_value) && WTF::get<CSSValueID>(m_value) == CSSValueUnset; }
- bool isInvalid() const { return WTF::holds_alternative<CSSValueID>(m_value) && WTF::get<CSSValueID>(m_value) == CSSValueInvalid; }
+ bool isResolved() const { return !WTF::holds_alternative<Ref<CSSVariableReferenceValue>>(m_value); }
+ bool isUnset() const { return WTF::holds_alternative<CSSValueID>(m_value) && WTF::get<CSSValueID>(m_value) == CSSValueUnset; }
+ bool isInvalid() const { return WTF::holds_alternative<CSSValueID>(m_value) && WTF::get<CSSValueID>(m_value) == CSSValueInvalid; }
const VariantValue& value() const { return m_value; }
@@ -110,7 +107,7 @@
, m_stringValue(other.m_stringValue)
, m_serialized(other.m_serialized)
{
- // No copy constructor for Ref<CSSVariableData>, so we have to do this ourselves
+ // No copy constructor for Ref<>, so we have to do this ourselves
auto visitor = WTF::makeVisitor([&](const Ref<CSSVariableReferenceValue>& value) {
m_value = value.copyRef();
}, [&](const CSSValueID& value) {
@@ -129,7 +126,7 @@
VariantValue m_value;
mutable String m_stringValue;
- mutable bool m_serialized { false };
+ mutable bool m_serialized { false }; // FIXME: Should use null m_stringValue instead of a separate boolean.
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSVariableReferenceValue.cpp (259987 => 259988)
--- trunk/Source/WebCore/css/CSSVariableReferenceValue.cpp 2020-04-12 19:31:08 UTC (rev 259987)
+++ trunk/Source/WebCore/css/CSSVariableReferenceValue.cpp 2020-04-12 19:33:30 UTC (rev 259988)
@@ -1,5 +1,5 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2020 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -30,6 +30,7 @@
#include "config.h"
#include "CSSVariableReferenceValue.h"
+#include "CSSVariableData.h"
#include "RenderStyle.h"
#include "StyleBuilder.h"
#include "StyleResolver.h"
@@ -36,17 +37,31 @@
namespace WebCore {
+static bool resolveTokenRange(CSSParserTokenRange, Vector<CSSParserToken>&, Style::BuilderState&);
+
+CSSVariableReferenceValue::CSSVariableReferenceValue(Ref<CSSVariableData>&& data)
+ : CSSValue(VariableReferenceClass)
+ , m_data(WTFMove(data))
+{
+}
+
+Ref<CSSVariableReferenceValue> CSSVariableReferenceValue::create(const CSSParserTokenRange& range)
+{
+ return adoptRef(*new CSSVariableReferenceValue(CSSVariableData::create(range)));
+}
+
+bool CSSVariableReferenceValue::equals(const CSSVariableReferenceValue& other) const
+{
+ return m_data.get() == other.m_data.get();
+}
+
String CSSVariableReferenceValue::customCSSText() const
{
- if (!m_serialized) {
- m_serialized = true;
+ if (m_stringValue.isNull())
m_stringValue = m_data->tokenRange().serialize();
- }
return m_stringValue;
}
-static bool resolveTokenRange(CSSParserTokenRange, Vector<CSSParserToken>&, Style::BuilderState&);
-
static bool resolveVariableFallback(CSSParserTokenRange range, Vector<CSSParserToken>& result, Style::BuilderState& builderState)
{
if (range.atEnd())
@@ -108,9 +123,7 @@
RefPtr<CSSVariableData> CSSVariableReferenceValue::resolveVariableReferences(Style::BuilderState& builderState) const
{
Vector<CSSParserToken> resolvedTokens;
- CSSParserTokenRange range = m_data->tokenRange();
-
- if (!resolveTokenRange(range, resolvedTokens, builderState))
+ if (!resolveTokenRange(m_data->tokenRange(), resolvedTokens, builderState))
return nullptr;
return CSSVariableData::create(resolvedTokens);
Modified: trunk/Source/WebCore/css/CSSVariableReferenceValue.h (259987 => 259988)
--- trunk/Source/WebCore/css/CSSVariableReferenceValue.h 2020-04-12 19:31:08 UTC (rev 259987)
+++ trunk/Source/WebCore/css/CSSVariableReferenceValue.h 2020-04-12 19:33:30 UTC (rev 259988)
@@ -1,5 +1,5 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
-// Copyright (C) 2016 Apple Inc. All rights reserved.
+// Copyright (C) 2016-2020 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -29,17 +29,12 @@
#pragma once
-#include "CSSParserToken.h"
-#include "CSSParserTokenRange.h"
#include "CSSValue.h"
-#include "CSSVariableData.h"
-#include <wtf/HashSet.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
namespace WebCore {
class CSSParserTokenRange;
+class CSSVariableData;
namespace Style {
class BuilderState;
@@ -47,26 +42,18 @@
class CSSVariableReferenceValue : public CSSValue {
public:
- static Ref<CSSVariableReferenceValue> create(const CSSParserTokenRange& range)
- {
- return adoptRef(*new CSSVariableReferenceValue(CSSVariableData::create(range)));
- }
+ static Ref<CSSVariableReferenceValue> create(const CSSParserTokenRange&);
- bool equals(const CSSVariableReferenceValue& other) const { return m_data.get() == other.m_data.get(); }
+ bool equals(const CSSVariableReferenceValue&) const;
String customCSSText() const;
RefPtr<CSSVariableData> resolveVariableReferences(Style::BuilderState&) const;
private:
- CSSVariableReferenceValue(Ref<CSSVariableData>&& data)
- : CSSValue(VariableReferenceClass)
- , m_data(WTFMove(data))
- {
- }
+ explicit CSSVariableReferenceValue(Ref<CSSVariableData>&&);
Ref<CSSVariableData> m_data;
mutable String m_stringValue;
- mutable bool m_serialized { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h (259987 => 259988)
--- trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h 2020-04-12 19:31:08 UTC (rev 259987)
+++ trunk/Source/WebCore/rendering/style/StyleCustomPropertyData.h 2020-04-12 19:33:30 UTC (rev 259988)
@@ -22,7 +22,6 @@
#pragma once
#include "CSSCustomPropertyValue.h"
-#include "CSSVariableReferenceValue.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>