Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Unified Diff: Source/core/rendering/style/BorderImageLength.h

Issue 55833002: Rewrite BorderImageLength to not use the Relative length type (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@length-relative-die-step-2-4
Patch Set: Rebased. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/style/BorderImageLength.h
diff --git a/Source/core/rendering/style/BorderImageLength.h b/Source/core/rendering/style/BorderImageLength.h
index 022796c612a2725b8a994b8a8873893c7e5c784f..7398760876de64ba95124af9f58493e7d48f741d 100644
--- a/Source/core/rendering/style/BorderImageLength.h
+++ b/Source/core/rendering/style/BorderImageLength.h
@@ -42,39 +42,53 @@ namespace WebCore {
class BorderImageLength {
public:
BorderImageLength()
+ : m_length(Auto)
+ , m_number(0)
+ , m_type(LengthType)
{
}
BorderImageLength(double number)
- : m_length(number, Relative)
+ : m_length(Undefined)
+ , m_number(number)
+ , m_type(NumberType)
{
}
BorderImageLength(const Length& length)
: m_length(length)
+ , m_number(0)
+ , m_type(LengthType)
{
}
- bool isNumber() const { return m_length.isRelative(); }
- bool isLength() const { return !isNumber(); }
+ bool isNumber() const { return m_type == NumberType; }
+ bool isLength() const { return m_type == LengthType; }
const Length& length() const { ASSERT(isLength()); return m_length; }
Length& length() { ASSERT(isLength()); return m_length; }
- double number() const { ASSERT(isNumber()); return m_length.value(); }
+ double number() const { ASSERT(isNumber()); return m_number; }
bool operator==(const BorderImageLength& other) const
{
- return m_length == other.m_length;
+ return m_type == other.m_type && m_length == other.m_length && m_number == other.m_number;
}
bool isZero() const
{
- return m_length.isZero();
+ return (isLength() && m_length.isZero()) || (isNumber() && m_number);
}
private:
+ // Ideally we would put the 2 following fields in a union, but Length has a constructor,
+ // a destructor and a copy assignment which isn't allowed.
Length m_length;
+ double m_number;
+ enum {
+ LengthType,
+ NumberType
+ } m_type;
};
} // namespace WebCore
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698