Merge branch 'feature/svg_pull' into feature/svg

This commit is contained in:
Kirill Polyakov
2023-07-26 13:31:42 +03:00
committed by GitHub
9877 changed files with 403029 additions and 633035 deletions

View File

@ -490,4 +490,172 @@ namespace NSCSS
return m_sId;
}
}
=======
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Default){}
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
m_pFont(oStyle.m_pFont), m_pMargin(oStyle.m_pMargin), m_pBackground(oStyle.m_pBackground),
m_pText(oStyle.m_pText), m_pBorder(oStyle.m_pBorder), m_pDisplay(oStyle.m_pDisplay){}
CCompiledStyle::~CCompiledStyle()
{
m_arParentsStyles.clear();
}
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
{
m_pBackground += oElement.m_pBackground;
m_pBorder = oElement.m_pBorder;
m_pFont += oElement.m_pFont;
m_pMargin += oElement.m_pMargin;
m_pText += oElement.m_pText;
m_pDisplay += oElement.m_pDisplay;
return *this;
}
CCompiledStyle& CCompiledStyle::operator= (const CCompiledStyle &oElement)
{
m_sId = oElement.m_sId;
m_arParentsStyles = oElement.m_arParentsStyles;
m_nDpi = oElement.m_nDpi;
m_UnitMeasure = oElement.m_UnitMeasure;
m_pBackground = oElement.m_pBackground;
m_pBorder = oElement.m_pBorder;
m_pFont = oElement.m_pFont;
m_pMargin = oElement.m_pMargin;
m_pText = oElement.m_pText;
m_pDisplay = oElement.m_pDisplay;
return *this;
}
bool CCompiledStyle::operator== (const CCompiledStyle& oStyle) const
{
return GetId()[0] == oStyle.GetId()[0] &&
m_arParentsStyles == oStyle.m_arParentsStyles &&
m_pBackground == oStyle.m_pBackground &&
m_pBorder == oStyle.m_pBorder &&
m_pFont == oStyle.m_pFont &&
m_pMargin == oStyle.m_pMargin &&
m_pText == oStyle.m_pText &&
m_pDisplay == oStyle.m_pDisplay;
}
void CCompiledStyle::StyleEquation(CCompiledStyle &oFirstStyle, CCompiledStyle &oSecondStyle)
{
NSConstValues::NSCssProperties::Font::FontEquation(oFirstStyle.m_pFont, oSecondStyle.m_pFont);
NSConstValues::NSCssProperties::Margin::MarginEquation(oFirstStyle.m_pMargin, oSecondStyle.m_pMargin);
NSConstValues::NSCssProperties::Background::BackgroundEquation(oFirstStyle.m_pBackground, oSecondStyle.m_pBackground);
NSConstValues::NSCssProperties::Text::TextEquation(oFirstStyle.m_pText, oSecondStyle.m_pText);
NSConstValues::NSCssProperties::Border::BorderEquation(oFirstStyle.m_pBorder, oSecondStyle.m_pBorder);
NSConstValues::NSCssProperties::Display::DisplayEquation(oFirstStyle.m_pDisplay, oSecondStyle.m_pDisplay);
oFirstStyle.ClearImportants();
oSecondStyle.ClearImportants();
}
void CCompiledStyle::SetDpi(const unsigned short &uiDpi)
{
m_nDpi = uiDpi;
}
void CCompiledStyle::SetUnitMeasure(const UnitMeasure &enUnitMeasure)
{
m_UnitMeasure = enUnitMeasure;
}
void CCompiledStyle::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_oSourceWindow = oSizeWindow;
}
void CCompiledStyle::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_oDeviceWindow = oSizeWindow;
}
bool CCompiledStyle::Empty() const
{
return m_pBackground.Empty() && m_pBorder.Empty() &&
m_pFont.Empty() && m_pMargin.Empty() && m_pText.Empty() && m_pDisplay.Empty();
}
void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode)
{
AddStyle({{sProperty, sValue}}, unLevel, bHardMode);
}
void CCompiledStyle::AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode)
{
const bool bIsThereBorder = (m_pBorder.Empty()) ? false : true;
const float fSize = m_pFont.GetSize();
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
{
std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower);
SWITCH(pPropertie.first)
{
//FONT
CASE(L"font"):
{
const size_t unPositionImp = pPropertie.second.find(L"!i");
if (unPositionImp == std::wstring::npos)
{
m_pFont.SetFont(ConvertUnitMeasure(pPropertie.second.c_str(), fSize), unLevel, bHardMode);
}
else if (unPositionImp != 0)
{
m_pFont.SetFont(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), fSize), unLevel, true);
m_pFont.SetImportantAll(true);
}
break;
}
CASE(L"font-size"):
CASE(L"font-size-adjust"):
{
const size_t unPositionImp = pPropertie.second.find(L"!i");
if (unPositionImp == std::wstring::npos)
{
m_pFont.SetSize(ConvertUnitMeasure(pPropertie.second, fSize), unLevel, bHardMode);
}
else if (unPositionImp != 0)
{
m_pFont.SetSize(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), fSize), unLevel, true);
m_pFont.SetImportantSize(true);
}
break;
}
CASE(L"font-stretch"):
{
const size_t unPositionImp = pPropertie.second.find(L"!i");
if (unPositionImp == std::wstring::npos)
{
m_pFont.SetStretch(pPropertie.second, unLevel, bHardMode);
}
else if (unPositionImp != 0)
{
m_pFont.SetStretch(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true);
m_pFont.SetImportantenStretch(true);
}
break;
}
CASE(L"font-style"):
{
const size_t unPositionImp = pPropertie.second.find(L"!i");
if (unPositionImp == std::wstring::npos)
{
m_pFont.SetStyle(pPropertie.second, unLevel, bHardMode);
}
else if (unPositionImp != 0)
{

View File

@ -127,6 +127,272 @@ namespace NSCSS
extern const std::wstring PSEUDO_CLASSES[33];
#endif
}
=======
typedef enum {
Default = 0,
Pixel,
Point,
Cantimeter,
Millimeter,
Inch,
Peak
} UnitMeasure;
typedef enum
{
ScalingDirectionNone = 0,
ScalingDirectionX = 1,
ScalingDirectionY = 2
} ScalingDirection;
struct CSizeWindow
{
unsigned short m_ushWidth;
unsigned short m_ushHeight;
CSizeWindow()
: m_ushWidth(0), m_ushHeight(0) {};
CSizeWindow(unsigned short unWidth, unsigned short unHeight)
: m_ushWidth(unWidth), m_ushHeight(unHeight) {};
bool Empty() const
{
return ((0 == m_ushWidth) && (0 == m_ushHeight));
}
void Clear()
{
m_ushWidth = m_ushHeight = 0;
}
bool operator==(const CSizeWindow& oSizeWindow) const
{
return ((m_ushWidth == oSizeWindow.m_ushWidth) && (m_ushHeight == oSizeWindow.m_ushHeight));
}
bool operator!=(const CSizeWindow& oSizeWindow) const
{
return ((m_ushWidth != oSizeWindow.m_ushWidth) || (m_ushHeight != oSizeWindow.m_ushHeight));
}
};
struct StatistickElement
{
enum TypeElement
{
IsStyle = 0,
IsId
} m_enType;
std::wstring sValue;
bool operator<(const StatistickElement& oStatistickElement) const
{
return sValue < oStatistickElement.sValue;
}
};
struct CTree
{
NSCSS::CNode m_oNode;
std::vector<CTree> m_arrChild;
inline static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
{
if (!oTree.m_oNode.m_sId.empty())
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_sId}];
if (!oTree.m_oNode.m_sStyle.empty())
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_sStyle}];
if (!oTree.m_arrChild.empty())
for (const CTree& oChildren : oTree.m_arrChild)
CountingNumberRepetitions(oChildren, mStatictics);
}
};
namespace NSConstValues
{
namespace NSMaps {
const std::map<std::wstring, std::wstring> mColors {
/* Red tones */
{L"indianeed", L"CD5C5C"}, {L"lightcoral", L"F08080"}, {L"salmon", L"FA8072"},
{L"darksalmon", L"E9967A"}, {L"lightsalmon", L"FFA07A"}, {L"crimson", L"DC143C"},
{L"red", L"FF0000"}, {L"firebrick", L"B22222"}, {L"darkred", L"8B0000"},
/* Pink tones */
{L"pink", L"FFC0CB"}, {L"lightpink", L"FFB6C1"}, {L"hotpink", L"FF69B4"},
{L"deeppink", L"FF1493"}, {L"mediumvioletred", L"C71585"}, {L"palevioleteed", L"DB7093"},
/* Orange tones */
{L"lightsalmon", L"FFA07A"}, {L"coral", L"FF7F50"}, {L"tomato", L"FF6347"},
{L"orangered", L"FF4500"}, {L"darkorange", L"FF8C00"}, {L"orange", L"FFA500"},
/* Yellow tones */
{L"gold", L"FFD700"}, {L"yellow", L"FFFF00"}, {L"lightyellow", L"FFFFE0"},
{L"lemonchiffon", L"FFFACD"}, {L"lightgoldenrodyellow", L"FAFAD2"}, {L"papayawhip", L"FFEFD5"},
{L"moccasin", L"FFE4B5"}, {L"peachpuff", L"FFDAB9"}, {L"palegoldenrod", L"EEE8AA"},
{L"khaki", L"F0E68C"}, {L"darkkhaki", L"BDB76B"},
/* Purple tones */
{L"lavender", L"E6E6FA"}, {L"thistle", L"D8BFD8"}, {L"plum", L"DDA0DD"},
{L"violet", L"EE82EE"}, {L"orchid", L"DA70D6"}, {L"fuchsia", L"FF00FF"},
{L"magenta", L"FF00FF"}, {L"mediumorchid", L"BA55D3"}, {L"mediumpurple", L"9370DB"},
{L"blueviolet", L"8A2BE2"}, {L"darkviolet", L"9400D3"}, {L"darkorchid", L"9932CC"},
{L"darkmagenta", L"8B008B"}, {L"purple", L"800080"}, {L"indigo", L"4B0082"},
{L"slateblue", L"6A5ACD"}, {L"darkslateblue", L"483D8B"},
/* Brown tones */
{L"cornsilk", L"FFF8DC"}, {L"blanchedalmond", L"FFEBCD"}, {L"bisque", L"FFE4C4"},
{L"navajowhite", L"FFDEAD"}, {L"wheat", L"F5DEB3"}, {L"burlywood", L"DEB887"},
{L"tan", L"D2B48C"}, {L"rosybrown", L"BC8F8F"}, {L"sandybrown", L"F4A460"},
{L"goldenrod", L"DAA520"}, {L"darkgoldenrod", L"B8860B"}, {L"peru", L"CD853F"},
{L"chocolate", L"D2691E"}, {L"saddlebrown", L"8B4513"}, {L"sienna", L"A0522D"},
{L"brown", L"A52A2A"}, {L"maroon", L"800000"},
/* Green tones */
{L"greenyellow", L"ADFF2F"}, {L"chartreuse", L"7FFF00"}, {L"lawngreen", L"7CFC00"},
{L"lime", L"00FF00"}, {L"limegreen", L"32CD32"}, {L"palegreen", L"98FB98"},
{L"lightgreen", L"90EE90"}, {L"mediumspringgreen", L"00FA9A"}, {L"springgreen", L"00FF7F"},
{L"mediumseagreen", L"3CB371"}, {L"seagreen", L"2E8B57"}, {L"forestgreen", L"228B22"},
{L"green", L"008000"}, {L"darkgreen", L"006400"}, {L"yellowgreen", L"9ACD32"},
{L"olivedrab", L"6B8E23"}, {L"olive", L"808000"}, {L"darkolivegreen",L"556B2F"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumaquamarine", L"66CDAA"}, {L"darkseagreen", L"8FBC8F"}, {L"lightseagreen", L"20B2AA"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"darkcyan", L"008B8B"}, {L"teal", L"008080"},
/* Blue tones */
{L"aqua", L"00FFFF"}, {L"cyan", L"00FFFF"}, {L"lightcyan", L"E0FFFF"},
{L"paleturquoise", L"AFEEEE"}, {L"aquamarine", L"7FFFD4"}, {L"turquoise", L"40E0D0"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumturquoise", L"48D1CC"}, {L"darkturquoise", L"00CED1"}, {L"cadetblue", L"5F9EA0"},
{L"steelblue", L"4682B4"}, {L"lightsteelblue", L"B0C4DE"}, {L"powderblue", L"B0E0E6"},
{L"lightblue", L"ADD8E6"}, {L"skyblue", L"87CEEB"}, {L"lightskyblue", L"87CEFA"},
{L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"},
{L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"},
{L"midnightblue", L"191970"},
/* White tones */
{L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"},
{L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"},
{L"ghostwhite", L"F8F8FF"}, {L"whitesmoke", L"F5F5F5"}, {L"seashell", L"FFF5EE"},
{L"beige", L"F5F5DC"}, {L"oldlace", L"FDF5E6"}, {L"floralwhite", L"FFFAF0"},
{L"ivory", L"FFFFF0"}, {L"antiquewhite", L"FAEBD7"}, {L"linen", L"FAF0E6"},
{L"lavenderblush", L"FFF0F5"}, {L"mistyrose", L"FFE4E1"},
/* Gray tones */
{L"gainsboro", L"DCDCDC"}, {L"lightgrey", L"D3D3D3"}, {L"silver", L"C0C0C0"},
{L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"},
{L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"},
{L"black", L"000000"},
/* Outdated */
{L"windowtext", L"000000"}, {L"transparent", L"000000"}
};
}
static const std::vector<std::wstring> arDisplayValues =
{
/* <display-outside> values */
L"block", L"inline", L"run-in",
/* <display-inside> values */
L"flow", L"flow-root", L"table", L"flex", L"grid", L"ruby",
/* <display-outside> plus <display-inside> values */
L"block flow", L"inline table", L"flex run-in",
/* <display-listitem> values */
L"list-item", L"list-item block", L"list-item inline", L"list-item flow",
L"list-item flow-root", L"list-item block flow",
L"list-item block flow-root", L"flow list-item block",
/* <display-internal> values */
L"table-row-group", L"table-header-group", L"table-footer-group",
L"table-row", L"table-cell", L"table-column-group", L"table-column",
L"table-caption", L"ruby-base", L"ruby-text", L"ruby-base-container",
L"ruby-text-container",
/* <display-box> values */
L"contents", L"none",
/* <display-legacy> values */
L"inline-block", L"inline-table", L"inline-flex", L"inline-grid",
/* Global values */
L"inherit", L"initial", L"unset"
};
namespace NSProperties {
typedef enum
{
B_CustomStyle = 0,
B_StyleId = 1,
B_Type = 2,
B_Default = 3,
B_Name = 4,
B_BasedOn = 5,
B_QFormat = 6,
B_Link = 7,
B_UnhideWhenUsed = 8,
B_UiPriority = 9,
} BasicProperties;
typedef enum
{
P_Jc = 0,
P_Spacing = 1,
P_ContextualSpacing = 2,
P_Ind = 3,
P_OutlineLvl = 4,
P_Shd = 5,
// <pBdr>
P_TopBorder = 6,
P_LeftBorder = 7,
P_BottomBorder = 8,
P_RightBorder = 9,
// </pBdr>
P_KeepLines = 10,
P_KeepNext = 11,
} ParagraphProperties;
typedef enum
{
R_RFonts = 0,
R_Sz = 1,
R_B = 2,
R_I = 3,
R_Color = 4,
R_U = 5,
R_Highlight = 6,
R_SmallCaps = 7
} RunnerProperties;
typedef enum
{
T_TblInd = 0,
// <tblCellMar>
T_CellTop = 1,
T_CellLeft = 2,
T_CellBottom = 3,
T_CellRight = 4,
// <tblCellMar>
// <tblBorders>
T_BorderTop = 5,
T_BorderLeft = 6,
T_BorderBottom = 7,
T_BorderRight = 8,
T_BorderInsideH = 9,
T_BorderInsideV = 10
// </tblBorders>
} TableProperties;
}
namespace NSCssProperties
{
const float fNoneValue = -99999999999.0f;
enum class FontStretch
{
none = 0,
normal,
ultraCondensed,
extraCondensed,
condensed,
semiCondensed,
semiExpanded,
expanded,
extraExpanded,
ultraExpanded,
};
enum class FontStyle
{
none = 0,
normal,
italic,
}
#endif // CONSTVALUES_H

View File

@ -17,12 +17,12 @@ if not base.is_dir("gumbo-parser"):
base.replaceInFile(base_directory + "/gumbo-parser/src/tag.c", "isspace(*c)", "isspace((unsigned char)*c)")
if not base.is_dir("katana-parser"):
base.cmd("git", ["clone", "https://github.com/hackers-painters/katana-parser.git"])
base.cmd_in_dir("katana-parser", "git", ["checkout", "499118d32c387a893fdc9dda2cb95eee524bdb9b"])
base.cmd("git", ["clone", "https://github.com/jasenhuang/katana-parser.git"])
base.cmd_in_dir("katana-parser", "git", ["checkout", "be6df458d4540eee375c513958dcb862a391cdd1"])
# fix katana
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool katana_is_html_space(char c);", "static inline bool2 katana_is_html_space(char c);")
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "inline bool katana_is_html_space(char c)", "static inline bool katana_is_html_space(char c)")
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
base.replaceInFile(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
base.replaceInFile(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")

File diff suppressed because it is too large Load Diff