diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/Pair.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/Pair.h')
-rw-r--r-- | Source/WebCore/css/Pair.h | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/Source/WebCore/css/Pair.h b/Source/WebCore/css/Pair.h index 621187379..2166e2ef1 100644 --- a/Source/WebCore/css/Pair.h +++ b/Source/WebCore/css/Pair.h @@ -1,6 +1,6 @@ /* * (C) 1999-2003 Lars Knoll (knoll@kde.org) - * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2005, 2006, 2015 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,62 +18,56 @@ * Boston, MA 02110-1301, USA. */ -#ifndef Pair_h -#define Pair_h +#pragma once #include <wtf/RefCounted.h> -#include "CSSPrimitiveValue.h" -#include <wtf/PassRefPtr.h> -#include <wtf/text/StringBuilder.h> namespace WebCore { +class CSSPrimitiveValue; + // A primitive value representing a pair. This is useful for properties like border-radius, background-size/position, // and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for // border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use // it (eliminating some extra -webkit- internal properties). -class Pair : public RefCounted<Pair> { +class Pair final : public RefCounted<Pair> { public: - static PassRefPtr<Pair> create() + enum class IdenticalValueEncoding { + DoNotCoalesce, + Coalesce + }; + + static Ref<Pair> create(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second) { - return adoptRef(new Pair); + return adoptRef(*new Pair(WTFMove(first), WTFMove(second))); } - static PassRefPtr<Pair> create(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second) + static Ref<Pair> create(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second, IdenticalValueEncoding encoding) { - return adoptRef(new Pair(first, second)); + return adoptRef(*new Pair(WTFMove(first), WTFMove(second), encoding)); } virtual ~Pair() { } CSSPrimitiveValue* first() const { return m_first.get(); } CSSPrimitiveValue* second() const { return m_second.get(); } - void setFirst(PassRefPtr<CSSPrimitiveValue> first) { m_first = first; } - void setSecond(PassRefPtr<CSSPrimitiveValue> second) { m_second = second; } - String cssText() const { - - return generateCSSString(first()->cssText(), second()->cssText()); + String first = this->first()->cssText(); + String second = this->second()->cssText(); + if (m_encoding == IdenticalValueEncoding::Coalesce && first == second) + return first; + return first + ' ' + second; } bool equals(const Pair& other) const { return compareCSSValuePtr(m_first, other.m_first) && compareCSSValuePtr(m_second, other.m_second); } private: - Pair() : m_first(0), m_second(0) { } - Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second) - : m_first(first), m_second(second) { } - - static String generateCSSString(const String& first, const String& second) - { - if (first == second) - return first; - return first + ' ' + second; - } + Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second) : m_first(WTFMove(first)), m_second(WTFMove(second)) { } + Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second, IdenticalValueEncoding encoding) : m_first(WTFMove(first)), m_second(WTFMove(second)), m_encoding(encoding) { } RefPtr<CSSPrimitiveValue> m_first; RefPtr<CSSPrimitiveValue> m_second; + IdenticalValueEncoding m_encoding { IdenticalValueEncoding::Coalesce }; }; } // namespace - -#endif |