aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/style.hh36
-rw-r--r--dw/table.cc126
-rw-r--r--dw/table.hh4
-rw-r--r--dw/textblock.cc30
-rw-r--r--dw/textblock_linebreaking.cc4
-rw-r--r--src/form.cc37
-rw-r--r--test/liang.cc58
7 files changed, 177 insertions, 118 deletions
diff --git a/dw/style.hh b/dw/style.hh
index b284d191..752f6a64 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -410,12 +410,44 @@ inline bool isRelLength(Length l) { return (l & 3) == 3; }
/** \brief Returns the value of a length in pixels, as an integer. */
inline int absLengthVal(Length l) { return l >> 2; }
-/** \brief Returns the value of a percentage, relative to 1, as a double. */
+/** \brief Returns the value of a percentage, relative to 1, as a double.
+ *
+ * When possible, do not use this function directly; it may be removed
+ * soon. Instead, use multiplyWithPerLength or multiplyWithPerLengthRounded.
+ */
inline double perLengthVal(Length l) { return (double)(l & ~3) / (1 << 18); }
-/** \brief Returns the value of a relative length, as a float. */
+/** \brief Returns the value of a relative length, as a float.
+ *
+ * When possible, do not use this function directly; it may be removed
+ * soon.
+ */
inline double relLengthVal(Length l) { return (double)(l & ~3) / (1 << 18); }
+/**
+ * \brief Multiply an int with a percentage length, returning int.
+ *
+ * Use this instead of perLengthVal, when possible.
+ */
+inline int multiplyWithPerLength(int x, Length l) {
+ return x * perLengthVal(l);
+}
+
+/**
+ * \brief Like multiplyWithPerLength, but rounds to nearest integer
+ * instead of down.
+ *
+ * (This function exists for backward compatibility.)
+ */
+inline int multiplyWithPerLengthRounded (int x, Length l) {
+ return lout::misc::roundInt (x * perLengthVal(l));
+}
+
+inline int multiplyWithRelLength(int x, Length l) {
+ return x * relLengthVal(l);
+}
+
+
enum {
/** \brief Represents "auto" lengths. */
LENGTH_AUTO = 0
diff --git a/dw/table.cc b/dw/table.cc
index defc4259..59a725f9 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -23,8 +23,6 @@
#include "../lout/msg.h"
#include "../lout/misc.hh"
-#define MAX misc::max
-
using namespace lout;
namespace dw {
@@ -62,7 +60,7 @@ Table::Table(bool limitTextWidth)
rowStyle = new misc::SimpleVector <core::style::Style*> (8);
hasColPercent = 0;
- colPercents = new misc::SimpleVector <float> (8);
+ colPercents = new misc::SimpleVector <core::style::Length> (8);
redrawX = 0;
redrawY = 0;
@@ -137,11 +135,11 @@ void Table::getExtremesImpl (core::Extremes *extremes)
}
if (core::style::isAbsLength (getStyle()->width)) {
extremes->minWidth =
- MAX (extremes->minWidth,
- core::style::absLengthVal(getStyle()->width));
+ misc::max (extremes->minWidth,
+ core::style::absLengthVal(getStyle()->width));
extremes->maxWidth =
- MAX (extremes->maxWidth,
- core::style::absLengthVal(getStyle()->width));
+ misc::max (extremes->maxWidth,
+ core::style::absLengthVal(getStyle()->width));
}
_MSG(" Table::getExtremesImpl, {%d, %d} numCols=%d\n",
@@ -297,7 +295,7 @@ void Table::addCell (Widget *widget, int colspan, int rowspan)
}
if (colspan == 0) {
- colspanEff = MAX (numCols - curCol, 1);
+ colspanEff = misc::max (numCols - curCol, 1);
rowClosed = true;
} else
colspanEff = colspan;
@@ -503,9 +501,9 @@ void Table::forceCalcCellSizes ()
* as defined by CSS2.)
*/
totalWidth =
- (int)(availWidth
- * misc::min (core::style::perLengthVal (getStyle()->width),
- 1.0));
+ misc::min (core::style::multiplyWithPerLength (availWidth,
+ getStyle()->width),
+ availWidth);
} else if (getStyle()->width == core::style::LENGTH_AUTO) {
totalWidth = availWidth;
forceTotalWidth = 0;
@@ -557,7 +555,7 @@ void Table::forceCalcCellSizes ()
children->get(n)->cell.widget->sizeRequest (&childRequisition);
childHeight = childRequisition.ascent + childRequisition.descent;
if (children->get(n)->cell.rowspan == 1) {
- rowHeight = MAX (rowHeight, childHeight);
+ rowHeight = misc::max (rowHeight, childHeight);
} else {
rowSpanCells->increase();
rowSpanCells->set(rowSpanCells->size()-1, n);
@@ -660,7 +658,7 @@ void Table::forceCalcColumnExtremes ()
for (int col = 0; col < numCols; col++) {
colExtremes->getRef(col)->minWidth = 0;
colExtremes->getRef(col)->maxWidth = 0;
- colPercents->set(col, LEN_AUTO);
+ colPercents->set(col, core::style::LENGTH_AUTO);
for (int row = 0; row < numRows; row++) {
int n = row * numCols + col;
@@ -677,8 +675,8 @@ void Table::forceCalcColumnExtremes ()
if (core::style::isAbsLength (width)) {
// Fixed lengths include table padding, border and margin.
cellMinW = cellExtremes.minWidth;
- cellMaxW = MAX (cellMinW,
- core::style::absLengthVal(width) - pbm);
+ cellMaxW = misc::max (cellMinW,
+ core::style::absLengthVal(width) - pbm);
} else {
cellMinW = cellExtremes.minWidth;
cellMaxW = cellExtremes.maxWidth;
@@ -691,22 +689,24 @@ void Table::forceCalcColumnExtremes ()
cellMinW, cellMaxW);
colExtremes->getRef(col)->minWidth =
- MAX (colExtremes->getRef(col)->minWidth, cellMinW);
+ misc::max (colExtremes->getRef(col)->minWidth, cellMinW);
colExtremes->getRef(col)->maxWidth =
- MAX (colExtremes->getRef(col)->minWidth, MAX (
- colExtremes->getRef(col)->maxWidth,
- cellMaxW));
+ misc::max (colExtremes->getRef(col)->minWidth, misc::max (
+ colExtremes->getRef(col)->maxWidth,
+ cellMaxW));
// Also fill the colPercents array in this pass
if (core::style::isPerLength (width)) {
hasColPercent = 1;
- if (colPercents->get(col) == LEN_AUTO)
- colPercents->set(col, core::style::perLengthVal(width));
+ if (colPercents->get(col) == core::style::LENGTH_AUTO)
+ colPercents->set(col, width);
} else if (core::style::isAbsLength (width)) {
// We treat LEN_ABS as a special case of LEN_AUTO.
/*
* if (colPercents->get(col) == LEN_AUTO)
* colPercents->set(col, LEN_ABS);
+ *
+ * (Hint: that's old code!)
*/
}
} else {
@@ -732,7 +732,8 @@ void Table::forceCalcColumnExtremes ()
if (core::style::isAbsLength (width)) {
// Fixed lengths include table padding, border and margin.
cellMinW = cellExtremes.minWidth;
- cellMaxW = MAX (cellMinW, core::style::absLengthVal(width) - pbm);
+ cellMaxW =
+ misc::max (cellMinW, core::style::absLengthVal(width) - pbm);
} else {
cellMinW = cellExtremes.minWidth;
cellMaxW = cellExtremes.maxWidth;
@@ -750,10 +751,10 @@ void Table::forceCalcColumnExtremes ()
continue;
// Cell size is too small; apportion {min,max} for this colspan.
- int spanMinW = MAX (MAX(cs, minSumCols),
- cellMinW - (cs-1) * getStyle()->hBorderSpacing),
- spanMaxW = MAX (MAX(cs, maxSumCols),
- cellMaxW - (cs-1) * getStyle()->hBorderSpacing);
+ int spanMinW = misc::max (misc::max (cs, minSumCols),
+ cellMinW - (cs-1) * getStyle()->hBorderSpacing),
+ spanMaxW = misc::max (misc::max (cs, maxSumCols),
+ cellMaxW - (cs-1) * getStyle()->hBorderSpacing);
if (minSumCols == 0) {
// No single cells defined for this span => pre-apportion equally
@@ -767,13 +768,13 @@ void Table::forceCalcColumnExtremes ()
}
}
- // This numbers will help if the span has percents.
+ // These values will help if the span has percents.
int spanHasColPercent = 0;
int availSpanMinW = spanMinW;
float cumSpanPercent = 0.0f;
for (int i = col; i < col + cs; ++i) {
- if (colPercents->get(i) > 0.0f) {
- cumSpanPercent += colPercents->get(i);
+ if (core::style::isPerLength (colPercents->get(i))) {
+ cumSpanPercent += core::style::perLengthVal (colPercents->get(i));
++spanHasColPercent;
} else
availSpanMinW -= colExtremes->getRef(i)->minWidth;
@@ -799,9 +800,9 @@ void Table::forceCalcColumnExtremes ()
curAppW -= d_a;
} else {
if (colPercents->get(i) > 0.0f) {
- wMin = MAX (colExtremes->getRef(i)->minWidth,
- (int)(availSpanMinW
- * colPercents->get(i)/cumSpanPercent));
+ wMin = misc::max (colExtremes->getRef(i)->minWidth,
+ (int)(availSpanMinW
+ * colPercents->get(i)/cumSpanPercent));
colExtremes->getRef(i)->minWidth = wMin;
}
}
@@ -810,7 +811,7 @@ void Table::forceCalcColumnExtremes ()
(int)((float)(goalMaxW-cumMaxWnew)
* colExtremes->getRef(i)->maxWidth
/ (maxSumCols-cumMaxWold));
- wMax = MAX (wMin, wMax);
+ wMax = misc::max (wMin, wMax);
cumMaxWnew += wMax;
cumMaxWold += colExtremes->getRef(i)->maxWidth;
colExtremes->getRef(i)->maxWidth = wMax;
@@ -850,17 +851,18 @@ void Table::apportion2 (int totalWidth, int forceTotalWidth)
#endif
int minAutoWidth = 0, maxAutoWidth = 0, availAutoWidth = totalWidth;
for (int col = 0; col < numCols; col++) {
- if (colPercents->get(col) == LEN_ABS) { // set absolute lengths
+ if (core::style::isAbsLength (colPercents->get(col))) {
+ // set absolute lengths
setColWidth (col, colExtremes->get(col).minWidth);
}
- if (colPercents->get(col) == LEN_AUTO) {
+ if (colPercents->get(col) == core::style::LENGTH_AUTO) {
maxAutoWidth += colExtremes->get(col).maxWidth;
minAutoWidth += colExtremes->get(col).minWidth;
} else
availAutoWidth -= colWidths->get(col);
}
- if (!maxAutoWidth) // no LEN_AUTO cols!
+ if (!maxAutoWidth) // no core::style::LENGTH_AUTO cols!
return;
colWidths->setSize (colExtremes->size (), 0);
@@ -871,7 +873,7 @@ void Table::apportion2 (int totalWidth, int forceTotalWidth)
}
// General case.
- int curTargetWidth = MAX (availAutoWidth, minAutoWidth);
+ int curTargetWidth = misc::max (availAutoWidth, minAutoWidth);
int curExtraWidth = curTargetWidth - minAutoWidth;
int curMaxWidth = maxAutoWidth;
int curNewWidth = minAutoWidth;
@@ -880,7 +882,7 @@ void Table::apportion2 (int totalWidth, int forceTotalWidth)
col, colExtremes->getRef(col)->minWidth,
colExtremes->get(col).maxWidth);
- if (colPercents->get(col) != LEN_AUTO)
+ if (colPercents->get(col) != core::style::LENGTH_AUTO)
continue;
int colMinWidth = colExtremes->getRef(col)->minWidth;
@@ -937,7 +939,7 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
// It has only a table-wide percentage. Apportion non-absolute widths.
int sumMaxWidth = 0, perAvailWidth = totalWidth;
for (int col = 0; col < numCols; col++) {
- if (colPercents->get(col) == LEN_ABS)
+ if (core::style::isAbsLength (colPercents->get(col)))
perAvailWidth -= colExtremes->getRef(col)->maxWidth;
else
sumMaxWidth += colExtremes->getRef(col)->maxWidth;
@@ -948,8 +950,9 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
for (int col = 0; col < numCols; col++) {
int max_wi = colExtremes->getRef(col)->maxWidth, new_wi;
- if (colPercents->get(col) != LEN_ABS) {
- new_wi = MAX (colExtremes->getRef(col)->minWidth,
+ if (!core::style::isAbsLength (colPercents->get(col))) {
+ new_wi =
+ misc::max (colExtremes->getRef(col)->minWidth,
(int)((float)max_wi * perAvailWidth/sumMaxWidth));
setColWidth (col, new_wi);
perAvailWidth -= new_wi;
@@ -972,12 +975,13 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
int hasAutoCol = 0;
int sumMinWidth = 0, sumMaxWidth = 0, sumMinNonPer = 0, sumMaxNonPer = 0;
for (int col = 0; col < numCols; col++) {
- if (colPercents->get(col) > 0.0f) {
- cumPercent += colPercents->get(col);
+ if (core::style::isPerLength (colPercents->get(col))) {
+ cumPercent += core::style::perLengthVal (colPercents->get(col));
} else {
sumMinNonPer += colExtremes->getRef(col)->minWidth;
sumMaxNonPer += colExtremes->getRef(col)->maxWidth;
- hasAutoCol += (colPercents->get(col) == LEN_AUTO);
+ if (colPercents->get(col) == core::style::LENGTH_AUTO)
+ hasAutoCol++;
}
sumMinWidth += colExtremes->getRef(col)->minWidth;
sumMaxWidth += colExtremes->getRef(col)->maxWidth;
@@ -990,17 +994,19 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
if (!forceTotalWidth) {
if (sumMaxNonPer == 0 || cumPercent < 0.99f) {
// only percentage columns, or cumPercent < 100% => restrict width
- int totW = (int)(sumMaxNonPer/(1.0f-cumPercent));
+ int totW = (int)(sumMaxNonPer / (1.0f - cumPercent));
for (int col = 0; col < numCols; col++) {
- totW = MAX (totW, (int)(colExtremes->getRef(col)->maxWidth
- / colPercents->get(col)));
+ totW = misc::max
+ (totW,
+ (int)(colExtremes->getRef(col)->maxWidth
+ / core::style::perLengthVal (colPercents->get(col))));
}
totalWidth = misc::min (totW, totalWidth);
}
}
// make sure there's enough space
- totalWidth = MAX (totalWidth, sumMinWidth);
+ totalWidth = misc::max (totalWidth, sumMinWidth);
// extraWidth is always >= 0
int extraWidth = totalWidth - sumMinWidth;
int sumMinWidthPer = sumMinWidth - sumMinNonPer;
@@ -1019,8 +1025,9 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
for (int col = 0; col < numCols; col++) {
int colMinWidth = colExtremes->getRef(col)->minWidth;
- if (colPercents->get(col) >= 0.0f) {
- int w = (int)(workingWidth * colPercents->get(col));
+ if (core::style::isPerLength (colPercents->get(col))) {
+ int w = core::style::multiplyWithPerLength (workingWidth,
+ colPercents->get(col));
if (w < colMinWidth)
w = colMinWidth;
else if (curPerWidth - colMinWidth + w > workingWidth)
@@ -1044,7 +1051,7 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
#endif
curPerWidth -= sumMinNonPer;
int perWidth = (int)(curPerWidth/cumPercent);
- totalWidth = MAX (totalWidth, perWidth);
+ totalWidth = misc::max (totalWidth, perWidth);
totalWidth = misc::min (totalWidth, oldTotalWidth);
_MSG("APP_P, curPerWidth=%d perWidth=%d, totalWidth=%d\n",
@@ -1055,8 +1062,19 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
// We'll honor totalWidth by expanding the percentage cols.
int extraWidth = totalWidth - curPerWidth - sumMinNonPer;
for (int col = 0; col < numCols; col++) {
- if (colPercents->get(col) >= 0.0f) {
- int d = (int)(extraWidth * colPercents->get(col)/cumPercent);
+ if (core::style::isPerLength (colPercents->get(col))) {
+ // This could cause rounding errors:
+ //
+ // int d =
+ // core::dw::multiplyWithPerLength (extraWidth,
+ // colPercents->get(col))
+ // / cumPercent;
+ //
+ // Thus the "old" way:
+ int d =
+ (int)(extraWidth *
+ core::style::perLengthVal (colPercents->get(col))
+ / cumPercent);
setColWidth (col, colWidths->get(col) + d);
}
}
@@ -1073,7 +1091,7 @@ void Table::apportion_percentages2(int totalWidth, int forceTotalWidth)
#ifdef DBG
MSG("APP_P, percent={");
for (int col = 0; col < numCols; col++)
- MSG("%f ", colPercents->get(col));
+ MSG("%f ", core::dw::_getPerVal (colPercents->get(col)));
MSG("}\n");
MSG("APP_P, result ={ ");
for (int col = 0; col < numCols; col++)
diff --git a/dw/table.hh b/dw/table.hh
index b8feb835..1d14ec07 100644
--- a/dw/table.hh
+++ b/dw/table.hh
@@ -393,11 +393,9 @@ private:
/**
* hasColPercent becomes true when any cell specifies a percentage width.
- * A negative value in colPercents means LEN_AUTO or LEN_ABS.
*/
- enum { LEN_AUTO = -1, LEN_ABS = -2};
int hasColPercent;
- lout::misc::SimpleVector<float> *colPercents;
+ lout::misc::SimpleVector<core::style::Length> *colPercents;
inline bool childDefined(int n)
{
diff --git a/dw/textblock.cc b/dw/textblock.cc
index a79462e1..a45b3da5 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -909,8 +909,8 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
size->width = core::style::absLengthVal (wstyle->width)
+ wstyle->boxDiffWidth ();
else
- size->width = (int) (core::style::perLengthVal (wstyle->width)
- * availWidth);
+ size->width =
+ core::style::multiplyWithPerLength (availWidth, wstyle->width);
if (wstyle->height == core::style::LENGTH_AUTO) {
size->ascent = requisition.ascent;
@@ -922,9 +922,10 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
+ wstyle->boxDiffHeight ();
size->descent = 0;
} else {
- double len = core::style::perLengthVal (wstyle->height);
- size->ascent = (int) (len * availAscent);
- size->descent = (int) (len * availDescent);
+ size->ascent =
+ core::style::multiplyWithPerLength (wstyle->height, availAscent);
+ size->descent =
+ core::style::multiplyWithPerLength (wstyle->height, availDescent);
}
}
@@ -1619,6 +1620,8 @@ void Textblock::calcTextSize (const char *text, size_t len,
core::style::Style *style,
core::Requisition *size, bool isStart, bool isEnd)
{
+ int requiredAscent, requiredDescent;
+
size->width = textWidth (text, 0, len, style, isStart, isEnd);
size->ascent = style->font->ascent;
size->descent = style->font->descent;
@@ -1645,9 +1648,9 @@ void Textblock::calcTextSize (const char *text, size_t len,
if (core::style::isAbsLength (style->lineHeight))
height = core::style::absLengthVal(style->lineHeight);
else
- height = lout::misc::roundInt (
- core::style::perLengthVal(style->lineHeight) *
- style->font->size);
+ height =
+ core::style::multiplyWithPerLengthRounded (style->font->size,
+ style->lineHeight);
leading = height - style->font->size;
size->ascent += leading / 2;
@@ -1657,10 +1660,13 @@ void Textblock::calcTextSize (const char *text, size_t len,
/* In case of a sub or super script we increase the word's height and
* potentially the line's height.
*/
- if (style->valign == core::style::VALIGN_SUB)
- size->descent += (style->font->ascent / 3);
- else if (style->valign == core::style::VALIGN_SUPER)
- size->ascent += (style->font->ascent / 2);
+ if (style->valign == core::style::VALIGN_SUB) {
+ requiredDescent = style->font->descent + style->font->ascent / 3;
+ size->descent = misc::max (size->descent, requiredDescent);
+ } else if (style->valign == core::style::VALIGN_SUPER) {
+ requiredAscent = style->font->ascent + style->font->ascent / 2;
+ size->ascent = misc::max (size->ascent, requiredAscent);
+ }
}
/**
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index b1a2cbd9..c07dc602 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1113,8 +1113,8 @@ void Textblock::initLine1Offset (int wordIndex)
/* don't use text-indent when nesting blocks */
} else {
if (core::style::isPerLength(getStyle()->textIndent)) {
- indent = misc::roundInt(this->availWidth *
- core::style::perLengthVal (getStyle()->textIndent));
+ indent = core::style::multiplyWithPerLengthRounded
+ (this->availWidth, getStyle()->textIndent);
} else {
indent = core::style::absLengthVal (getStyle()->textIndent);
}
diff --git a/src/form.cc b/src/form.cc
index a91e170b..b6df56f5 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -785,14 +785,14 @@ void Html_tag_close_select(DilloHtml *html)
html->InFlags &= ~IN_OPTION;
DilloHtmlInput *input = Html_get_current_input(html);
- DilloHtmlSelect *select = input->select;
-
- if (input->type == DILLO_HTML_INPUT_SELECT) {
- // option menu interface requires that something be selected */
- select->ensureSelection ();
+ if (input) {
+ DilloHtmlSelect *select = input->select;
+ if (input->type == DILLO_HTML_INPUT_SELECT) {
+ // option menu interface requires that something be selected */
+ select->ensureSelection ();
+ }
+ select->addOptsTo ((SelectionResource*)input->embed->getResource());
}
- SelectionResource *res = (SelectionResource*)input->embed->getResource();
- select->addOptsTo (res);
}
}
@@ -814,9 +814,9 @@ void Html_tag_open_optgroup(DilloHtml *html, const char *tag, int tagsize)
html->InFlags |= IN_OPTGROUP;
DilloHtmlInput *input = Html_get_current_input(html);
-
- if (input->type == DILLO_HTML_INPUT_SELECT ||
- input->type == DILLO_HTML_INPUT_SEL_LIST) {
+ if (input &&
+ (input->type == DILLO_HTML_INPUT_SELECT ||
+ input->type == DILLO_HTML_INPUT_SEL_LIST)) {
char *label = a_Html_get_attr_wdef(html, tag, tagsize, "label", NULL);
bool enabled = (a_Html_get_attr(html, tag, tagsize, "disabled") == NULL);
@@ -843,9 +843,9 @@ void Html_tag_close_optgroup(DilloHtml *html)
}
DilloHtmlInput *input = Html_get_current_input(html);
-
- if (input->type == DILLO_HTML_INPUT_SELECT ||
- input->type == DILLO_HTML_INPUT_SEL_LIST) {
+ if (input &&
+ (input->type == DILLO_HTML_INPUT_SELECT ||
+ input->type == DILLO_HTML_INPUT_SEL_LIST)) {
DilloHtmlOptgroupClose *opt = new DilloHtmlOptgroupClose ();
input->select->addOpt(opt);
@@ -867,9 +867,9 @@ void Html_tag_open_option(DilloHtml *html, const char *tag, int tagsize)
html->InFlags |= IN_OPTION;
DilloHtmlInput *input = Html_get_current_input(html);
-
- if (input->type == DILLO_HTML_INPUT_SELECT ||
- input->type == DILLO_HTML_INPUT_SEL_LIST) {
+ if (input &&
+ (input->type == DILLO_HTML_INPUT_SELECT ||
+ input->type == DILLO_HTML_INPUT_SEL_LIST)) {
char *value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL);
char *label = a_Html_get_attr_wdef(html, tag, tagsize, "label", NULL);
bool selected = (a_Html_get_attr(html, tag, tagsize,"selected") != NULL);
@@ -2027,8 +2027,9 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize)
static void Html_option_finish(DilloHtml *html)
{
DilloHtmlInput *input = Html_get_current_input(html);
- if (input->type == DILLO_HTML_INPUT_SELECT ||
- input->type == DILLO_HTML_INPUT_SEL_LIST) {
+ if (input &&
+ (input->type == DILLO_HTML_INPUT_SELECT ||
+ input->type == DILLO_HTML_INPUT_SEL_LIST)) {
DilloHtmlOptbase *opt = input->select->getCurrentOpt ();
opt->setContent (html->Stash->str, html->Stash->len);
}
diff --git a/test/liang.cc b/test/liang.cc
index ce5036fa..932a1f54 100644
--- a/test/liang.cc
+++ b/test/liang.cc
@@ -25,33 +25,37 @@ int main (int argc, char *argv[])
{
dw::fltk::FltkPlatform p;
- hyphenateWord (&p, "...");
- hyphenateWord (&p, "Jahrhundertroman");
- hyphenateWord (&p, "JAHRHUNDERTROMAN");
- hyphenateWord (&p, "„Jahrhundertroman“");
- hyphenateWord (&p, "währenddessen");
- hyphenateWord (&p, "„währenddessen“");
- hyphenateWord (&p, "Ückendorf");
- hyphenateWord (&p, "über");
- hyphenateWord (&p, "aber");
- hyphenateWord (&p, "Ackermann");
- hyphenateWord (&p, "„Ackermann“");
- hyphenateWord (&p, "entscheidet.");
- hyphenateWord (&p, "Grundstücksverkehrsgenehmigungszuständigkeits"
- "übertragungsverordnung");
- hyphenateWord (&p, "„Grundstücksverkehrsgenehmigungszuständigkeits"
- "übertragungsverordnung“");
- hyphenateWord (&p, "Grundstücksverkehrsgenehmigungszuständigkeit");
- hyphenateWord (&p, "„Grundstücksverkehrsgenehmigungszuständigkeit“");
- hyphenateWord (&p, "(6R,7R)-7-[2-(2-Amino-4-thiazolyl)-glyoxylamido]-3-"
- "(2,5-dihydro-6-hydroxy-2-methyl-5-oxo-1,2,4-triazin-3-yl-"
- "thiomethyl)-8-oxo-5-thia-1-azabicyclo[4.2.0]oct-2-en-2-"
- "carbonsäure-7²-(Z)-(O-methyloxim)");
- hyphenateWord (&p, "Abtei-Stadt");
- hyphenateWord (&p, "Nordrhein-Westfalen");
- hyphenateWord (&p, "kurz\xc2\xa0und\xc2\xa0knapp");
- hyphenateWord (&p, "weiß");
- hyphenateWord (&p, "www.dillo.org");
+ if (argc > 1) {
+ hyphenateWord (&p, argv[1]);
+ } else {
+ hyphenateWord (&p, "...");
+ hyphenateWord (&p, "Jahrhundertroman");
+ hyphenateWord (&p, "JAHRHUNDERTROMAN");
+ hyphenateWord (&p, "„Jahrhundertroman“");
+ hyphenateWord (&p, "währenddessen");
+ hyphenateWord (&p, "„währenddessen“");
+ hyphenateWord (&p, "Ückendorf");
+ hyphenateWord (&p, "über");
+ hyphenateWord (&p, "aber");
+ hyphenateWord (&p, "Ackermann");
+ hyphenateWord (&p, "„Ackermann“");
+ hyphenateWord (&p, "entscheidet.");
+ hyphenateWord (&p, "Grundstücksverkehrsgenehmigungszuständigkeits"
+ "übertragungsverordnung");
+ hyphenateWord (&p, "„Grundstücksverkehrsgenehmigungszuständigkeits"
+ "übertragungsverordnung“");
+ hyphenateWord (&p, "Grundstücksverkehrsgenehmigungszuständigkeit");
+ hyphenateWord (&p, "„Grundstücksverkehrsgenehmigungszuständigkeit“");
+ hyphenateWord (&p, "(6R,7R)-7-[2-(2-Amino-4-thiazolyl)-glyoxylamido]-3-"
+ "(2,5-dihydro-6-hydroxy-2-methyl-5-oxo-1,2,4-triazin-3-yl-"
+ "thiomethyl)-8-oxo-5-thia-1-azabicyclo[4.2.0]oct-2-en-2-"
+ "carbonsäure-7²-(Z)-(O-methyloxim)");
+ hyphenateWord (&p, "Abtei-Stadt");
+ hyphenateWord (&p, "Nordrhein-Westfalen");
+ hyphenateWord (&p, "kurz\xc2\xa0und\xc2\xa0knapp");
+ hyphenateWord (&p, "weiß");
+ hyphenateWord (&p, "www.dillo.org");
+ }
return 0;
}