aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/oofawarewidget.cc4
-rw-r--r--dw/oofawarewidget.hh2
-rw-r--r--dw/ooffloatsmgr.cc26
-rw-r--r--dw/textblock.cc24
-rw-r--r--dw/textblock.hh2
-rw-r--r--dw/textblock_linebreaking.cc38
-rw-r--r--src/html.cc20
7 files changed, 87 insertions, 29 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index 025111ae..8f704f40 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -573,9 +573,9 @@ void OOFAwareWidget::oofSizeChanged (bool extremesChanged)
DBG_OBJ_LEAVE ();
}
-int OOFAwareWidget::getGeneratorX (int oofmIndex)
+int OOFAwareWidget::getC0RelX (int oofmIndex)
{
- notImplemented ("OOFAwareWidget::getGeneratorX");
+ notImplemented ("OOFAwareWidget::getC0RelX");
return 0;
}
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index e49cce14..d72b894a 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -276,7 +276,7 @@ public:
* Return position relative to container, not regarding
* margin/border/padding, Called by OOFFloatsMgr to position floats.
*/
- virtual int getGeneratorX (int oofmIndex);
+ virtual int getC0RelX (int oofmIndex);
/**
* Return position relative to container, not regarding
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 84b2f6ff..cadf980e 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -20,6 +20,7 @@
#include "ooffloatsmgr.hh"
#include "oofawarewidget.hh"
#include "../lout/debug.hh"
+#include "../lout/msg.h"
#include <limits.h>
@@ -433,12 +434,13 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
OOFAwareWidget *generator = vloat->generator;
ensureFloatSize (vloat);
+ MSG("calcFloatX: ");
switch (vloat->getWidget()->getStyle()->vloat) {
case FLOAT_LEFT:
// Left floats are always aligned on the left side of the generator
// (content, not allocation) ...
- x = generator->getGeneratorX (oofmIndex)
+ x = generator->getC0RelX (oofmIndex)
+ generator->getStyle()->boxOffsetX();
// ... but when the float exceeds the line break width of the container,
@@ -473,13 +475,27 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
// (ii) If there is more than one line, the line break will already be
// exceeded, and so be smaller that GB width + float width.
effGeneratorWidth =
+ //min (vloat->generator->getGeneratorWidth (0, 0),
min (vloat->generator->getGeneratorWidth (0, 0) + vloat->size.width,
vloat->generator->getMaxGeneratorWidth ());
+ MSG("UsesMaxGenW=%d gen->MaxGenW()=%d genW00=%d effGenW=%d ",
+ vloat->generator->usesMaxGeneratorWidth(),
+ vloat->generator->getMaxGeneratorWidth (),
+ vloat->generator->getGeneratorWidth (0, 0),
+ effGeneratorWidth);
- x = max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth
+ x = max (generator->getC0RelX (oofmIndex) + effGeneratorWidth
- vloat->size.width - generator->getStyle()->boxRestWidth(),
+ //- generator->getStyle()->boxRestWidth(),
// Do not exceed container allocation:
0);
+
+ //if (x == 356) x -= 34;
+
+ MSG("vloatW=%d gen->getC0RelX()=%d g->boxRestWidth()=%d x=%d",
+ vloat->size.width,
+ generator->getC0RelX (oofmIndex),
+ generator->getStyle()->boxRestWidth(), x);
break;
default:
@@ -487,8 +503,8 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
x = 0;
break;
}
-
DBG_OBJ_LEAVE_VAL ("%d", x);
+ MSG("\n");
return x;
}
@@ -1106,7 +1122,7 @@ int OOFFloatsMgr::getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
int d;
switch (side) {
case LEFT:
- d = vloat->generator->getGeneratorX (oofmIndex)
+ d = vloat->generator->getC0RelX (oofmIndex)
+ vloat->generator->getStyle()->boxOffsetX ();
break;
@@ -1116,7 +1132,7 @@ int OOFFloatsMgr::getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
// left border, see above). We have to calculate the difference
// between the maximal widths.
d = container->getMaxGeneratorWidth ()
- - (vloat->generator->getGeneratorX (oofmIndex)
+ - (vloat->generator->getC0RelX (oofmIndex)
+ vloat->generator->getMaxGeneratorWidth ())
+ vloat->generator->getStyle()->boxRestWidth ();
break;
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 4fe19fdd..ce93fd36 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3067,9 +3067,9 @@ void Textblock::oofSizeChanged (bool extremesChanged)
DBG_OBJ_LEAVE ();
}
-int Textblock::getGeneratorX (int oofmIndex)
+int Textblock::getC0RelX (int oofmIndex)
{
- DBG_OBJ_ENTER ("resize", 0, "Textblock::getGeneratorX", "%d", oofmIndex);
+ DBG_OBJ_ENTER ("resize", 0, "Textblock::getC0RelX", "%d", oofmIndex);
int x, xRef;
if (findSizeRequestReference (oofmIndex, &xRef, NULL))
@@ -3119,7 +3119,7 @@ int Textblock::getGeneratorRest (int oofmIndex)
int width = getGeneratorWidth (0, 0);
rest = container->getGeneratorWidth (xRef, width) - (xRef + width);
} else {
- // Only callend for floats, so this should not happen:
+ // Only called for floats, so this should not happen:
assertNotReached ();
rest = 0;
}
@@ -3132,15 +3132,31 @@ int Textblock::getGeneratorWidth (int callerX, int callerWidth)
{
DBG_OBJ_ENTER ("resize", 0, "Textblock::getGeneratorWidth", "%d, %d",
callerX, callerWidth);
-
+
+ if (0 && lines->size () > 0) {
+ Word *lastWordOfLine, *lwol0;
+ lwol0 = words->getRef(lines->getRef(0)->lastWord);
+ lastWordOfLine = words->getRef(lines->getLastRef()->lastWord);
+ MSG("lww=%d lwol0=%d ", lastWordOfLine->totalWidth, lwol0->totalWidth);
+ MSG("lbw0=%d lbwl=%d\n",
+ calcLineBreakWidth(0),
+ calcLineBreakWidth(lines->size() - 1));
+ }
// Cf. sizeRequestImpl.
if (usesMaxGeneratorWidth ()) {
DBG_OBJ_LEAVE_VAL ("%d", lineBreakWidth);
return lineBreakWidth;
} else {
+#if 0
+ int w0 = max (lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0,
+ callerX + callerWidth);
+ ...
+ w = min (w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth);
+#else
int w0 = max (lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0,
callerX + callerWidth),
w = min (w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth);
+#endif
DBG_OBJ_LEAVE_VAL ("min (%d + %d + %d, %d) = %d",
w0, leftInnerPadding, boxDiffWidth (), lineBreakWidth,
w);
diff --git a/dw/textblock.hh b/dw/textblock.hh
index fd92b636..98a0f9bb 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -902,7 +902,7 @@ public:
void widgetRefSizeChanged (int externalIndex);
void clearPositionChanged ();
void oofSizeChanged (bool extremesChanged);
- int getGeneratorX (int oofmIndex);
+ int getC0RelX (int oofmIndex);
int getGeneratorY (int oofmIndex);
int getGeneratorWidth (int callerX, int callerWidth);
int getMaxGeneratorWidth ();
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index fddfb44f..e48c9a6e 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -575,7 +575,7 @@ int Textblock::wordWrap (int wordIndex, bool wrapAll)
n = wrapWordOofRef (wordIndex, wrapAll);
else
n = wrapWordInFlow (wordIndex, wrapAll);
-
+ _MSG("wordWrap word[%d] wtW=%d\n", wordIndex, word->totalWidth);
DBG_OBJ_MSGF ("construct.word", 1, "=> %d", n);
DBG_OBJ_LEAVE ();
@@ -758,7 +758,6 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
// (currently?).
lastFloatPos = newFloatPos;
-
Widget *widget =
words->getRef(lastFloatPos)->content.widgetReference->widget;
int oofmIndex = getWidgetOOFIndex (widget);
@@ -813,7 +812,6 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
}
addLine (firstIndex, breakPos, lastFloatPos, tempNewLine, minHeight);
-
DBG_OBJ_MSGF ("construct.word", 1,
"accumulating again from %d to %d",
breakPos + 1, wordIndexEnd);
@@ -823,7 +821,12 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
// update word pointer as hyphenateWord() can trigger a
// reorganization of the words structure
word = words->getRef (wordIndex);
-
+ MSG("wrapWordInFlow brkPos=%d, wIdxEnd=%d, word[%d].totalWidth=%d\n",
+ breakPos, wordIndexEnd,
+ wordIndex, words->getRef(wordIndex)->totalWidth);
+ if (words->getRef(wordIndex)->totalWidth == 36) {
+ MSG("*");
+ }
penaltyIndex = calcPenaltyIndexForNewLine ();
}
} while (newLine);
@@ -1654,7 +1657,6 @@ void Textblock::accumulateWordData (int wordIndex)
word->maxDescent = word->size.descent;
word->totalSpaceStretchability = 0;
word->totalSpaceShrinkability = 0;
-
DBG_OBJ_MSGF ("construct.word.accum", 1,
"first word of line: words[%d].totalWidth = %d + %d = %d; "
"maxAscent = %d, maxDescent = %d",
@@ -1666,6 +1668,7 @@ void Textblock::accumulateWordData (int wordIndex)
word->totalWidth = prevWord->totalWidth
+ prevWord->origSpace - prevWord->hyphenWidth
+ word->size.width + word->hyphenWidth;
+ _MSG("wtW=%d ", word->totalWidth);
word->maxAscent = max (prevWord->maxAscent, word->size.ascent);
word->maxDescent = max (prevWord->maxDescent, word->size.descent);
word->totalSpaceStretchability =
@@ -1965,6 +1968,21 @@ void Textblock::rewrap ()
// So this is necessary: word = words->getRef (i);
}
+ MSG("rewrap tb=%p: totalWidth { ", this);
+ for (int i = firstWord; i < words->size (); i++) {
+ Word *word = words->getRef (i);
+ MSG("w%d=%d ", i, word->totalWidth);
+ }
+ MSG("}");
+
+ MSG(", Lines MaxW{ ");
+ for (int i = 0; i < lines->size (); ++i) {
+ Line *line = lines->getRef(i);
+ MSG("l%d=%d ", i, line->maxLineWidth);
+ //Line *lastLine = lines->getLastRef();
+ }
+ MSG("}\n");
+
// Next time, the page will not have to be rewrapped.
wrapRefLines = -1;
DBG_OBJ_SET_NUM ("wrapRefLines", wrapRefLines);
@@ -2053,7 +2071,7 @@ void Textblock::calcBorders (int lastOofRef, int height)
{
DBG_OBJ_ENTER ("construct.line", 0, "calcBorders", "%d, %d",
lastOofRef, height);
-
+ MSG("calcBorders tb=%p ", this);
newLineHasFloatLeft = newLineHasFloatRight = false;
newLineLeftBorder = newLineRightBorder = 0;
newLineLeftFloatHeight = newLineRightFloatHeight = 0;
@@ -2112,6 +2130,7 @@ void Textblock::calcBorders (int lastOofRef, int height)
newLineHasFloatLeft = newLineHasFloatLeft || thisHasLeft;
thisHasRight = oofm->hasFloatRight (y, height, this, effOofRef);
newLineHasFloatRight = newLineHasFloatRight || thisHasRight;
+ MSG("nlhFR=%d thR=%d ", newLineHasFloatRight, thisHasRight);
// TODO "max" is not really correct for the heights. (Does
// not matter, since only one, the float manager, returns
@@ -2120,7 +2139,7 @@ void Textblock::calcBorders (int lastOofRef, int height)
newLineLeftBorder =
max (newLineLeftBorder,
oofm->getLeftBorder (y, height, this, effOofRef)
- - getGeneratorX (i));
+ - getC0RelX (i));
newLineLeftFloatHeight =
max (newLineLeftFloatHeight,
oofm->getLeftFloatHeight (y, height, this, effOofRef));
@@ -2129,8 +2148,12 @@ void Textblock::calcBorders (int lastOofRef, int height)
if (thisHasRight) {
newLineRightBorder =
max (newLineRightBorder,
+#if 0
+ oofm->getRightBorder (y, height, this, effOofRef));
+#else
oofm->getRightBorder (y, height, this, effOofRef)
- getGeneratorRest (i));
+#endif
newLineRightFloatHeight =
max (newLineRightFloatHeight,
oofm->getRightFloatHeight (y, height, this, effOofRef));
@@ -2147,6 +2170,7 @@ void Textblock::calcBorders (int lastOofRef, int height)
}
}
}
+ MSG("\n");
DBG_OBJ_SET_BOOL ("newLineHasFloatLeft", newLineHasFloatLeft);
DBG_OBJ_SET_BOOL ("newLineHasFloatRight", newLineHasFloatRight);
diff --git a/src/html.cc b/src/html.cc
index b73fd8f7..1e693d6d 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1436,25 +1436,27 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int new_idx)
}
/*
- * Avoid nesting and inter-nesting of BUTTON, SELECT and TEXTAREA,
+ * Avoid nesting and inter-nesting of BUTTON, SELECT, TEXTAREA and A,
* by closing them before opening another.
* This is not an HTML SPEC restriction , but it avoids lots of trouble
* inside dillo (concurrent inputs), and makes almost no sense to have.
*/
-static void Html_tag_cleanup_nested_inputs(DilloHtml *html, int new_idx)
+static void Html_tag_cleanup_nested_elements(DilloHtml *html, int new_idx)
{
- static int i_BUTTON = a_Html_tag_index("button"),
+ static int i_A = a_Html_tag_index("a"),
+ i_BUTTON = a_Html_tag_index("button"),
i_SELECT = a_Html_tag_index("select"),
i_TEXTAREA = a_Html_tag_index("textarea");
int stack_idx, u_idx, matched = 0;
- dReturn_if_fail(html->InFlags & (IN_BUTTON | IN_SELECT | IN_TEXTAREA));
+ dReturn_if_fail(html->InFlags & (IN_BUTTON |IN_SELECT |IN_TEXTAREA |IN_A));
dReturn_if_fail(new_idx == i_BUTTON || new_idx == i_SELECT ||
- new_idx == i_TEXTAREA);
+ new_idx == i_TEXTAREA || new_idx == i_A);
/* Get the unclosed tag index */
u_idx = (html->InFlags & IN_BUTTON) ? i_BUTTON :
- (html->InFlags & IN_SELECT) ? i_SELECT : i_TEXTAREA;
+ (html->InFlags & IN_SELECT) ? i_SELECT :
+ (html->InFlags & IN_TEXTAREA) ? i_TEXTAREA : i_A;
/* Look for it inside the stack */
stack_idx = html->stack->size();
@@ -1475,7 +1477,7 @@ static void Html_tag_cleanup_nested_inputs(DilloHtml *html, int new_idx)
"was found in the stack\n", Tags[u_idx].name);
}
- html->InFlags &= ~(IN_BUTTON | IN_SELECT | IN_TEXTAREA);
+ html->InFlags &= ~(IN_BUTTON | IN_SELECT | IN_TEXTAREA | IN_A);
}
@@ -4045,8 +4047,8 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
BUG_MSG("<pre> is not allowed to contain <%s>.", Tags[ni].name);
/* Make sure these elements don't nest each other */
- if (html->InFlags & (IN_BUTTON | IN_SELECT | IN_TEXTAREA))
- Html_tag_cleanup_nested_inputs(html, ni);
+ if (html->InFlags & (IN_BUTTON | IN_SELECT | IN_TEXTAREA | IN_A))
+ Html_tag_cleanup_nested_elements(html, ni);
/* Push the tag into the stack */
Html_push_tag(html, ni);