|
using System;
using System.Collections.Generic;
namespace DOL.DHtml.DCssResolver
{
internal sealed class DCssSpecificity : IComparable<DCssSpecificity>
{
/////////////////////////////////////////////////////////////////////////////////
#region �ާ@
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
public DCssSpecificity()
{
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
/// <param name="other"></param>
public DCssSpecificity(DCssSpecificity other)
{
m_a = other.m_a;
m_b = other.m_b;
m_c = other.m_c;
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="c"></param>
public DCssSpecificity(int a, int b, int c)
{
m_a = a;
m_b = b;
m_c = c;
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
/// <param name="other"></param>
public void Add(DCssSpecificity other)
{
m_a += other.m_a;
m_b += other.m_b;
m_c += other.m_c;
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
public int A
{
get
{
return m_a;
}
set
{
m_a = value;
}
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
public int B
{
get
{
return m_b;
}
set
{
m_b = value;
}
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
public int C
{
get
{
return m_c;
}
set
{
m_c = value;
}
}
/////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public int CompareTo(DCssSpecificity other)
{
if(m_a > other.m_a)
return 1;
else if(m_a < other.m_a)
return -1;
else if(m_b > other.m_b)
return 1;
else if(m_b < other.m_b)
return -1;
else if(m_c > other.m_c)
return 1;
else if(m_c < other.m_c)
return -1;
return 0;
}
#endregion
/////////////////////////////////////////////////////////////////////////////////
#region �������
/// <summary>
///
/// </summary>
private int m_a = 0; // count the number of ID attributes in the selector (= a)
/// <summary>
///
/// </summary>
private int m_b = 0; // count the number of other attributes and pseudo-classes in the selector (= b)
/// <summary>
///
/// </summary>
private int m_c = 0; // count the number of element names in the selector (= c)
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
James S.F. Hsieh(Nomad Libra) Working as engineer for "Corel Intervideo" company situated in Taiwan.
He received his master degree in Graduate Institute of Network Learning Technology, National Central University, Taiwan in 2006.
His research interests are semantic Web services, intelligent software agent, machine learning, algorithm, software
engineering and multimedia programming.