Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
Nimetu 2016-01-06 01:02:22 +02:00
commit 410ddea49d
2 changed files with 123 additions and 92 deletions

View file

@ -438,25 +438,20 @@ namespace NLGUI
return _PRE.back(); return _PRE.back();
} }
// UL mode
std::vector<bool> _UL;
inline bool getUL() const
{
if (_UL.empty())
return false;
return _UL.back();
}
// DL list // DL list
std::vector<bool> _DL; class HTMLDListElement {
inline bool getDL() const public:
{ HTMLDListElement()
if (_DL.empty()) : DT(false), DD(false)
return false; { }
return _DL.back();
}
// OL public:
bool DT;
bool DD;
};
std::vector<HTMLDListElement> _DL;
// OL and UL
class HTMLOListElement { class HTMLOListElement {
public: public:
HTMLOListElement(int start, std::string type) HTMLOListElement(int start, std::string type)
@ -469,7 +464,7 @@ namespace NLGUI
std::string Type; std::string Type;
bool First; bool First;
}; };
std::vector<HTMLOListElement> _OL; std::vector<HTMLOListElement> _UL;
// A mode // A mode
std::vector<bool> _A; std::vector<bool> _A;
@ -482,7 +477,6 @@ namespace NLGUI
// IL mode // IL mode
bool _LI; bool _LI;
bool _DT;
// Current text color // Current text color
std::vector<NLMISC::CRGBA> _TextColor; std::vector<NLMISC::CRGBA> _TextColor;

View file

@ -1709,9 +1709,9 @@ namespace NLGUI
_SelectOption = true; _SelectOption = true;
break; break;
case HTML_LI: case HTML_LI:
if (getUL()) if (!_UL.empty())
{ {
// First LI ? // UL, OL top margin if this is the first LI
if (!_LI) if (!_LI)
{ {
_LI = true; _LI = true;
@ -1721,35 +1721,24 @@ namespace NLGUI
{ {
newParagraph(LIBeginSpace); newParagraph(LIBeginSpace);
} }
ucstring str;
str += (ucchar)0x2219;
str += (ucchar)' ';
addString (str);
flushString ();
getParagraph()->setFirstViewIndent(LIIndent);
}
else if (!_OL.empty())
{
if (_OL.back().First)
{
_OL.back().First = false;
newParagraph(ULBeginSpace);
}
else
{
newParagraph(LIBeginSpace);
}
// OL list index can be overridden by <li value="1"> attribute // OL list index can be overridden by <li value="1"> attribute
if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE]) if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE])
fromString(value[HTML_LI_VALUE], _OL.back().Value); fromString(value[HTML_LI_VALUE], _UL.back().Value);
ucstring str; ucstring str;
str.fromUtf8(_OL.back().getListMarkerText() + ". "); str.fromUtf8(_UL.back().getListMarkerText());
addString(str); addString (str);
flushString();
getParagraph()->setFirstViewIndent(LIIndent); sint32 indent = LIIndent;
_OL.back().Value++; // list-style-type: outside
if (_CurrentViewLink)
indent -= _CurrentViewLink->getMaxUsedW();
getParagraph()->setFirstViewIndent(indent);
flushString ();
_UL.back().Value++;
} }
break; break;
case HTML_P: case HTML_P:
@ -1934,10 +1923,16 @@ namespace NLGUI
} }
break; break;
case HTML_UL: case HTML_UL:
if (_UL.empty())
_UL.push_back(HTMLOListElement(1, "disc"));
else if (_UL.size() == 1)
_UL.push_back(HTMLOListElement(1, "circle"));
else
_UL.push_back(HTMLOListElement(1, "square"));
// if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1;
_Indent += ULIndent; _Indent += ULIndent;
_LI = false;
endParagraph(); endParagraph();
_UL.push_back(true);
break; break;
case HTML_OBJECT: case HTML_OBJECT:
_ObjectType = ""; _ObjectType = "";
@ -1996,42 +1991,56 @@ namespace NLGUI
_IgnoreText = true; _IgnoreText = true;
break; break;
case HTML_DL: case HTML_DL:
_DL.push_back(true); _DL.push_back(HTMLDListElement());
_LI = _DL.size() > 1 || !_UL.empty();
endParagraph(); endParagraph();
break; break;
case HTML_DT: case HTML_DT:
if (getDL()) if (!_DL.empty())
{ {
newParagraph(0);
// see if this is the first <dt>, closing tag not required // see if this is the first <dt>, closing tag not required
if (!_DT) if (!_DL.back().DT)
{ {
_DT = true; _DL.back().DT = true;
_FontWeight.push_back(FONT_WEIGHT_BOLD); _FontWeight.push_back(FONT_WEIGHT_BOLD);
} }
if (_DL.size() > 1) if (!_LI)
{ {
uint indent = (_DL.size()-1) * ULIndent; _LI = true;
getParagraph()->setFirstViewIndent(indent); newParagraph(ULBeginSpace);
}
else
{
newParagraph(LIBeginSpace);
} }
} }
break; break;
case HTML_DD: case HTML_DD:
if (getDL()) if (!_DL.empty())
{ {
newParagraph(0);
// if there was no closing tag for <dt>, then remove <dt> style // if there was no closing tag for <dt>, then remove <dt> style
if (_DT) if (_DL.back().DT)
{ {
_DT = false; _DL.back().DT = false;
popIfNotEmpty (_FontWeight); popIfNotEmpty (_FontWeight);
} }
uint indent = _DL.size()*ULIndent; if (!_DL.back().DD)
getParagraph()->setFirstViewIndent(indent); {
_Indent += ULIndent;
_DL.back().DD = true;
}
if (!_LI)
{
_LI = true;
newParagraph(ULBeginSpace);
}
else
{
newParagraph(LIBeginSpace);
}
} }
break; break;
case HTML_OL: case HTML_OL:
@ -2044,7 +2053,9 @@ namespace NLGUI
if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE])
type = value[HTML_OL_TYPE]; type = value[HTML_OL_TYPE];
_OL.push_back(HTMLOListElement(start, type)); _UL.push_back(HTMLOListElement(start, type));
// if LI is already present
_LI = _UL.size() > 1 || _DL.size() > 1;
_Indent += ULIndent; _Indent += ULIndent;
endParagraph(); endParagraph();
} }
@ -2218,46 +2229,58 @@ namespace NLGUI
} }
break; break;
case HTML_OL: case HTML_OL:
if (!_OL.empty())
{
_Indent -= ULIndent;
_Indent = std::max(_Indent, (uint)0);
endParagraph();
popIfNotEmpty(_OL);
}
break;
case HTML_UL: case HTML_UL:
if (getUL()) if (!_UL.empty())
{ {
_Indent -= ULIndent; if (_Indent > ULIndent)
_Indent = std::max(_Indent, (uint)0); _Indent = _Indent - ULIndent;
else
_Indent = 0;
endParagraph(); endParagraph();
popIfNotEmpty (_UL); popIfNotEmpty(_UL);
} }
break; break;
case HTML_DL: case HTML_DL:
if (getDL()) if (!_DL.empty())
{ {
endParagraph(); endParagraph();
popIfNotEmpty (_DL);
if (_DT) { // unclosed DT
_DT = false; if (_DL.back().DT)
{
popIfNotEmpty (_FontWeight); popIfNotEmpty (_FontWeight);
} }
// unclosed DD
if (_DL.back().DD)
{
if (_Indent > ULIndent)
_Indent = _Indent - ULIndent;
else
_Indent = 0;
}
popIfNotEmpty (_DL);
} }
break; break;
case HTML_DT: case HTML_DT:
if (getDL()) if (!_DL.empty())
{ {
if (_DT) _DL.back().DT = false;
{
_DT = false;
popIfNotEmpty (_FontWeight); popIfNotEmpty (_FontWeight);
} }
}
break; break;
case HTML_DD: case HTML_DD:
// style not changed if (!_DL.empty())
{
if (_Indent > ULIndent)
_Indent = _Indent - ULIndent;
else
_Indent = 0;
_DL.back().DD = false;
}
break; break;
case HTML_SPAN: case HTML_SPAN:
popIfNotEmpty (_FontSize); popIfNotEmpty (_FontSize);
@ -2368,7 +2391,6 @@ namespace NLGUI
_CurrentViewImage = NULL; _CurrentViewImage = NULL;
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_DT = false;
_SelectOption = false; _SelectOption = false;
_GroupListAdaptor = NULL; _GroupListAdaptor = NULL;
_UrlFragment.clear(); _UrlFragment.clear();
@ -4047,10 +4069,8 @@ namespace NLGUI
_FontStrikeThrough.clear(); _FontStrikeThrough.clear();
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_DT = false;
_UL.clear(); _UL.clear();
_DL.clear(); _DL.clear();
_OL.clear();
_A.clear(); _A.clear();
_Link.clear(); _Link.clear();
_LinkTitle.clear(); _LinkTitle.clear();
@ -5527,7 +5547,22 @@ namespace NLGUI
sint32 number = Value; sint32 number = Value;
bool upper = false; bool upper = false;
if (Type == "a" || Type == "A") if (Type == "disc")
{
// (ucchar)0x2219;
ret = "\xe2\x88\x99 ";
}
else if (Type == "circle")
{
// (uchar)0x26AA;
ret = "\xe2\x9a\xaa ";
}
else if (Type == "square")
{
// (ucchar)0x25AA;
ret = "\xe2\x96\xaa ";
}
else if (Type == "a" || Type == "A")
{ {
// @see toAlphabeticOrNumeric in WebKit // @see toAlphabeticOrNumeric in WebKit
static const char lower[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', static const char lower[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
@ -5549,6 +5584,7 @@ namespace NLGUI
number /= size; number /= size;
} }
} }
ret += ". ";
} }
else if (Type == "i" || Type == "I") else if (Type == "i" || Type == "I")
{ {
@ -5592,10 +5628,11 @@ namespace NLGUI
ret = toUpper(ret); ret = toUpper(ret);
} }
} }
ret += ". ";
} }
else else
{ {
ret = toString(Value); ret = toString(Value) + ". ";
} }
return ret; return ret;