This source file includes following definitions.
- m_columnCount
- stringForPosition
- customCSSText
#include "config.h"
#include "core/css/CSSGridTemplateAreasValue.h"
#include "wtf/text/StringBuilder.h"
namespace WebCore {
CSSGridTemplateAreasValue::CSSGridTemplateAreasValue(const NamedGridAreaMap& gridAreaMap, size_t rowCount, size_t columnCount)
: CSSValue(GridTemplateAreasClass)
, m_gridAreaMap(gridAreaMap)
, m_rowCount(rowCount)
, m_columnCount(columnCount)
{
ASSERT(m_rowCount);
ASSERT(m_columnCount);
}
static String stringForPosition(const NamedGridAreaMap& gridAreaMap, size_t row, size_t column)
{
Vector<String> candidates;
NamedGridAreaMap::const_iterator end = gridAreaMap.end();
for (NamedGridAreaMap::const_iterator it = gridAreaMap.begin(); it != end; ++it) {
const GridCoordinate& coordinate = it->value;
if (row >= coordinate.rows.initialPositionIndex && row <= coordinate.rows.finalPositionIndex)
candidates.append(it->key);
}
end = gridAreaMap.end();
for (NamedGridAreaMap::const_iterator it = gridAreaMap.begin(); it != end; ++it) {
const GridCoordinate& coordinate = it->value;
if (column >= coordinate.columns.initialPositionIndex && column <= coordinate.columns.finalPositionIndex && candidates.contains(it->key))
return it->key;
}
return ".";
}
String CSSGridTemplateAreasValue::customCSSText() const
{
StringBuilder builder;
for (size_t row = 0; row < m_rowCount; ++row) {
builder.append('\"');
for (size_t column = 0; column < m_columnCount; ++column) {
builder.append(stringForPosition(m_gridAreaMap, row, column));
if (column != m_columnCount - 1)
builder.append(' ');
}
builder.append('\"');
if (row != m_rowCount - 1)
builder.append(' ');
}
return builder.toString();
}
}