aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2015-01-08 12:31:53 +0100
committerSebastian Geerken <devnull@localhost>2015-01-08 12:31:53 +0100
commit428094b178eb03d8e500c81837caac402e4b138c (patch)
tree353456467cadd4c258b8a8c3f306d817925500b6
parentd37efc2feb2b387d879962f4ef3fed2b9bf5a5e9 (diff)
RegardingBorder; fixes problems with <hr/>.
-rw-r--r--dw/Makefile.am2
-rw-r--r--dw/regardingborder.cc39
-rw-r--r--dw/regardingborder.hh27
-rw-r--r--dw/ruler.hh13
-rw-r--r--dw/textblock.cc29
-rw-r--r--dw/textblock.hh15
6 files changed, 100 insertions, 25 deletions
diff --git a/dw/Makefile.am b/dw/Makefile.am
index 0b4b7bb4..68410805 100644
--- a/dw/Makefile.am
+++ b/dw/Makefile.am
@@ -71,6 +71,8 @@ libDw_widgets_a_SOURCES = \
listitem.hh \
outofflowmgr.cc \
outofflowmgr.hh \
+ regardingborder.cc \
+ regardingborder.hh \
ruler.cc \
ruler.hh \
simpletablecell.cc \
diff --git a/dw/regardingborder.cc b/dw/regardingborder.cc
new file mode 100644
index 00000000..2eb0b4bf
--- /dev/null
+++ b/dw/regardingborder.cc
@@ -0,0 +1,39 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2015 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "regardingborder.hh"
+
+#include <stdio.h>
+
+namespace dw {
+
+int RegardingBorder::CLASS_ID = -1;
+
+RegardingBorder::RegardingBorder ()
+{
+ DBG_OBJ_CREATE ("dw::RegardingBorder");
+ registerName ("dw::RegardingBorder", &CLASS_ID);
+}
+
+RegardingBorder::~RegardingBorder ()
+{
+ DBG_OBJ_DELETE ();
+}
+
+} // namespace dw
diff --git a/dw/regardingborder.hh b/dw/regardingborder.hh
new file mode 100644
index 00000000..4c8951ad
--- /dev/null
+++ b/dw/regardingborder.hh
@@ -0,0 +1,27 @@
+#ifndef __DW_REGARDINGBORDER_HH__
+#define __DW_REGARDINGBORDER_HH__
+
+#include "core.hh"
+
+namespace dw {
+
+/**
+ * \brief Base class (rather a tag interface) for those widgets
+ * regarding borders defined by floats, and so allocated on the
+ * full width.
+ *
+ * Will, when integrated to the "dillo_grows" repository, become a sub
+ * class of OOFAwareWidget.
+ */
+class RegardingBorder: public core::Widget
+{
+public:
+ static int CLASS_ID;
+
+ RegardingBorder ();
+ ~RegardingBorder ();
+};
+
+} // namespace dw
+
+#endif // __DW_REGARDINGBORDER_HH__
diff --git a/dw/ruler.hh b/dw/ruler.hh
index 63662383..cd4f63f4 100644
--- a/dw/ruler.hh
+++ b/dw/ruler.hh
@@ -1,7 +1,7 @@
#ifndef __RULER_HH__
#define __RULER_HH__
-#include "core.hh"
+#include "regardingborder.hh"
namespace dw {
@@ -10,10 +10,15 @@ namespace dw {
*
* This is really an empty widget, the HTML parser puts a border
* around it, and drawing is done in dw::core::Widget::drawWidgetBox.
- * The only remarkable point is that the HAS_CONTENT flag is
- * cleared.
+ *
+ * Ruler implements RegardingBorder; this way, it is simpler to fit
+ * the ruler exactly within the space between floats. Currently, the
+ * drawn area of the ruler is too large (but most of the superfluous
+ * part is hidden by the floats); this problem will not solved but in
+ * "dillo_grows", where RegardingBorder is a sub class of
+ * OOFAwareWidget.
*/
-class Ruler: public core::Widget
+class Ruler: public RegardingBorder
{
protected:
void sizeRequestImpl (core::Requisition *requisition);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index a9fa87c5..e7c49f27 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3133,44 +3133,45 @@ void Textblock::oofSizeChanged (bool extremesChanged)
DBG_OBJ_LEAVE ();
}
-Textblock *Textblock::getTextblockForLine (Line *line)
+RegardingBorder *Textblock::getWidgetRegardingBorderForLine (Line *line)
{
- return getTextblockForLine (line->firstWord, line->lastWord);
+ return getWidgetRegardingBorderForLine (line->firstWord, line->lastWord);
}
-Textblock *Textblock::getTextblockForLine (int lineNo)
+RegardingBorder *Textblock::getWidgetRegardingBorderForLine (int lineNo)
{
// Can also be used for a line not yet existing.
int firstWord = lineNo == 0 ? 0 : lines->getRef(lineNo - 1)->lastWord + 1;
int lastWord = lineNo < lines->size() ?
lines->getRef(lineNo)->lastWord : words->size() - 1;
- return getTextblockForLine (firstWord, lastWord);
+ return getWidgetRegardingBorderForLine (firstWord, lastWord);
}
-Textblock *Textblock::getTextblockForLine (int firstWord, int lastWord)
+RegardingBorder *Textblock::getWidgetRegardingBorderForLine (int firstWord,
+ int lastWord)
{
- DBG_OBJ_ENTER ("resize", 0, "getTextblockForLine", "%d, %d",
+ DBG_OBJ_ENTER ("resize", 0, "getWidgetRegardingBorderForLine", "%d, %d",
firstWord, lastWord);
DBG_OBJ_MSGF ("resize", 1, "words.size = %d", words->size ());
- Textblock *textblock = NULL;
+ RegardingBorder *widgetRegardingBorder = NULL;
if (firstWord < words->size ()) {
- // A textblock is always between two line breaks, and so the
- // first word of the line.
+ // Any instance of a subclass of WidgetRegardingBorder is always
+ // between two line breaks, and so the first word of the line.
Word *word = words->getRef (firstWord);
DBG_MSG_WORD ("resize", 1, "<i>first word:</i> ", firstWord, "");
if (word->content.type == core::Content::WIDGET_IN_FLOW) {
Widget *widget = word->content.widget;
- if (widget->instanceOf (Textblock::CLASS_ID) &&
- // Exclude some cases where a textblock constitutes a new
+ if (widget->instanceOf (RegardingBorder::CLASS_ID) &&
+ // Exclude some cases where a widget constitutes a new
// container (see definition of float container in
// Textblock::isContainingBlock).
widget->getStyle()->display != core::style::DISPLAY_INLINE_BLOCK &&
widget->getStyle()->overflow == core::style::OVERFLOW_VISIBLE)
- textblock = (Textblock*)widget;
+ widgetRegardingBorder = (RegardingBorder*)widget;
// (TODO: It would look nicer if there is one common place
// for such definitions. Will be fixed in "dillo_grows", not
@@ -3178,9 +3179,9 @@ Textblock *Textblock::getTextblockForLine (int firstWord, int lastWord)
}
}
- DBG_OBJ_MSGF ("resize", 1, "=> %p", textblock);
+ DBG_OBJ_MSGF ("resize", 1, "=> %p", widgetRegardingBorder);
DBG_OBJ_LEAVE ();
- return textblock;
+ return widgetRegardingBorder;
}
/**
diff --git a/dw/textblock.hh b/dw/textblock.hh
index cb040c0a..162088dc 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -3,7 +3,7 @@
#include <limits.h>
-#include "core.hh"
+#include "regardingborder.hh"
#include "outofflowmgr.hh"
#include "../lout/misc.hh"
@@ -196,7 +196,7 @@ namespace dw {
* necessary, or otherwise the line from which a rewrap is necessary.
*
*/
-class Textblock: public core::Widget
+class Textblock: public RegardingBorder
{
private:
/**
@@ -691,12 +691,12 @@ protected:
*/
inline bool mustBorderBeRegarded (Line *line)
{
- return getTextblockForLine (line) == NULL;
+ return getWidgetRegardingBorderForLine (line) == NULL;
}
inline bool mustBorderBeRegarded (int lineNo)
{
- return getTextblockForLine (lineNo) == NULL;
+ return getWidgetRegardingBorderForLine (lineNo) == NULL;
}
inline int _lineYOffsetWidgetAllocation (Line *line,
@@ -761,9 +761,10 @@ protected:
}
}
- Textblock *getTextblockForLine (Line *line);
- Textblock *getTextblockForLine (int lineNo);
- Textblock *getTextblockForLine (int firstWord, int lastWord);
+ RegardingBorder *getWidgetRegardingBorderForLine (Line *line);
+ RegardingBorder *getWidgetRegardingBorderForLine (int lineNo);
+ RegardingBorder *getWidgetRegardingBorderForLine (int firstWord,
+ int lastWord);
void printBorderChangedErrorAndAbort (int y, Widget *vloat,
int wrapLineIndex);
int yOffsetOfLineToBeCreated ();