//----------------------------------------------------------------------------
CSSBorder::Offsets CSSBorder::getRelOffsets(const SGRect<int>& dim) const
{
- Offsets ret;
+ Offsets ret = {{0}};
+ if( !valid )
+ return ret;
+
for(int i = 0; i < 4; ++i)
{
ret.val[i] = offsets.val[i];
if( !types.rel[i] )
ret.val[i] /= (i & 1) ? dim.height() : dim.width();
}
+
return ret;
}
//----------------------------------------------------------------------------
CSSBorder::Offsets CSSBorder::getAbsOffsets(const SGRect<int>& dim) const
{
- Offsets ret;
+ Offsets ret = {{0}};
+ if( !valid )
+ return ret;
+
for(int i = 0; i < 4; ++i)
{
ret.val[i] = offsets.val[i];
if( types.rel[i] )
ret.val[i] *= (i & 1) ? dim.height() : dim.width();
}
+
return ret;
}
VERIFY(b.getKeyword().empty());
VERIFY(b.isNone());
+ CSSBorder b2;
+ VERIFY(!b2.isValid());
+ o = b.getAbsOffsets(SGRect<int>(0,0,200,200));
+ COMPARE(o.t, 0);
+ COMPARE(o.r, 0);
+ COMPARE(o.b, 0);
+ COMPARE(o.l, 0);
+ o = b.getRelOffsets(SGRect<int>(0,0,200,200));
+ COMPARE(o.t, 0);
+ COMPARE(o.r, 0);
+ COMPARE(o.b, 0);
+ COMPARE(o.l, 0);
+
std::cout << "all tests passed successfully!" << std::endl;
return 0;
}