diff options
author | Sebastian Geerken <devnull@localhost> | 2014-11-08 14:13:39 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-11-08 14:13:39 +0100 |
commit | 550d933b21d548411fe862d6a24ce73e4d5621c5 (patch) | |
tree | b57cb83557230bbc3933ea8a8da5d864231411ee | |
parent | 88943c42e9d667f93b4ec12b5eb0c886a29a02a1 (diff) |
Removed code for absolute positions; this is solved in a different way in the dillo_grows repository.
-rw-r--r-- | doc/dw-out-of-flow.doc | 41 | ||||
-rw-r--r-- | dw/outofflowmgr.cc | 144 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 52 |
3 files changed, 16 insertions, 221 deletions
diff --git a/doc/dw-out-of-flow.doc b/doc/dw-out-of-flow.doc index d02c3b28..ea4a52bc 100644 --- a/doc/dw-out-of-flow.doc +++ b/doc/dw-out-of-flow.doc @@ -209,45 +209,6 @@ Integration of line breaking and floats Absolute and fixed positiones ============================= -If you look at dw::OutOfFlowMgr in detail, you will find that some -work on **absolute positions** has already be done, but is -deactivated. Absolutely positioned elements will also be handled by -dw::OutOfFlowMgr, in a way transparent to dw::Textblock. Positioning -is much simpler than for floats: the complicated relation between -dw::Textblock and dw::OutOfFlowMgr (calculation of the vertical -position of floats on one hand, limiting line widths by floats on the -other hand) does not occur here. - -Since handling sizes becomes an important part for absolute positions, -the full implementation will be realized after finishing the planned -redesign of widget sizes (see \ref dw-grows). - -(One note already about the *z-index* attribute: different blocks, -represented by widgets, may overlap; *z-index* has an influence the -order in which - -1. widgets are drawn (in *ascending* order of *z-index*), and -2. mouse events are deligated to the widgets (in *descending* oder of - *z-index*). - -Something similar is already done for floats: effectively, floats have -a larger *z-index* than the textblocks in flow. (See *end* of -dw::Textblock::draw and *beginning* of -dw::Textblock::getWidgetAtPoint.) - -For a complete implementation, handling *z-index* becomes a bit more -complicated. An idea is to keep track of the minimum and maximum value -of *z-index*, and then iterating over all possible values (ascending -for drawing, descending for event handling), handling only widgets -with a specific *z-index* in one iteration.) - -There are currently no plans for an implementation of **fixed -positions** soon. These problems have to be considered: - -- Generally attaching dillo widgets to the viewport, not the canvas; - this is also required for the implementation of - *background-attachment*, see \ref dw-images-and-backgrounds. -- To which containing block are elements with fixed position related? - To the same as floats and absolutely positioned? +See <http://flpsed.org/hgweb/dillo_grows>. */
\ No newline at end of file diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index a128a5c4..8f82ea21 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -493,16 +493,6 @@ void OutOfFlowMgr::TBInfo::updateAllocation () DBG_OBJ_LEAVE_O (getWidget ()); } -OutOfFlowMgr::AbsolutelyPositioned::AbsolutelyPositioned (OutOfFlowMgr *oofm, - Widget *widget, - Textblock - *generatingBlock, - int externalIndex) -{ - this->widget = widget; - dirty = true; -} - OutOfFlowMgr::OutOfFlowMgr (Textblock *containingBlock) { DBG_OBJ_CREATE ("dw::OutOfFlowMgr"); @@ -530,8 +520,6 @@ OutOfFlowMgr::OutOfFlowMgr (Textblock *containingBlock) leftFloatsMark = rightFloatsMark = 0; lastLeftTBIndex = lastRightTBIndex = 0; - absolutelyPositioned = new Vector<AbsolutelyPositioned> (1, true); - containingBlockWasAllocated = containingBlock->wasAllocated (); containingBlockAllocation = *(containingBlock->getAllocation()); @@ -558,8 +546,6 @@ OutOfFlowMgr::~OutOfFlowMgr () delete leftFloatsAll; delete rightFloatsAll; - delete absolutelyPositioned; - DBG_OBJ_DELETE (); } @@ -692,8 +678,6 @@ void OutOfFlowMgr::containerSizeChangedForChildren () leftFloatsAll->get(i)->getWidget()->containerSizeChanged (); for (int i = 0; i < rightFloatsAll->size (); i++) rightFloatsAll->get(i)->getWidget()->containerSizeChanged (); - for (int i = 0; i < absolutelyPositioned->size(); i++) - absolutelyPositioned->get(i)->widget->containerSizeChanged (); DBG_OBJ_LEAVE (); } @@ -1294,7 +1278,6 @@ void OutOfFlowMgr::draw (View *view, Rectangle *area) { drawFloats (leftFloatsCB, view, area); drawFloats (rightFloatsCB, view, area); - drawAbsolutelyPositioned (view, area); } void OutOfFlowMgr::drawFloats (SortedFloatsVector *list, View *view, @@ -1311,16 +1294,6 @@ void OutOfFlowMgr::drawFloats (SortedFloatsVector *list, View *view, } } -void OutOfFlowMgr::drawAbsolutelyPositioned (View *view, Rectangle *area) -{ - for (int i = 0; i < absolutelyPositioned->size(); i++) { - AbsolutelyPositioned *abspos = absolutelyPositioned->get(i); - Rectangle childArea; - if (abspos->widget->intersects (area, &childArea)) - abspos->widget->draw (view, &childArea); - } -} - /** * This method consideres also the attributes not yet considered by * dillo, so that the containing block is determined correctly, which @@ -1340,9 +1313,7 @@ bool OutOfFlowMgr::isWidgetOutOfFlow (Widget *widget) bool OutOfFlowMgr::isWidgetHandledByOOFM (Widget *widget) { - // May be extended for fixed (and relative?) positions. return isWidgetFloat (widget); - // TODO temporary disabled: || isWidgetAbsolutelyPositioned (widget); } void OutOfFlowMgr::addWidgetInFlow (Textblock *textblock, @@ -1447,13 +1418,6 @@ void OutOfFlowMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, leftFloatsAll->size() + rightFloatsAll->size() - 1; floatsByWidget->put (new TypedPointer<Widget> (widget), vloat); - } else if (isWidgetAbsolutelyPositioned (widget)) { - AbsolutelyPositioned *abspos = - new AbsolutelyPositioned (this, widget, generatingBlock, - externalIndex); - absolutelyPositioned->put (abspos); - widget->parentRef = - createRefAbsolutelyPositioned (absolutelyPositioned->size() - 1); } else // May be extended. assertNotReached(); @@ -1523,9 +1487,6 @@ void OutOfFlowMgr::markSizeChange (int ref) // sizeAllocateEnd.) Could be faster (cf. hasRelationChanged, which // differentiates many special cases), but the size is not known yet, vloat->generatingBlock->borderChanged (vloat->yReal, vloat->getWidget ()); - } else if (isRefAbsolutelyPositioned (ref)) { - int i = getAbsolutelyPositionedIndexFromRef (ref); - absolutelyPositioned->get(i)->dirty = true; } else assertNotReached(); @@ -1543,8 +1504,6 @@ Widget *OutOfFlowMgr::getWidgetAtPoint (int x, int y, int level) Widget *childAtPoint = getFloatWidgetAtPoint (leftFloatsCB, x, y, level); if (childAtPoint == NULL) childAtPoint = getFloatWidgetAtPoint (rightFloatsCB, x, y, level); - if (childAtPoint == NULL) - childAtPoint = getAbsolutelyPositionedWidgetAtPoint (x, y, level); return childAtPoint; } @@ -1565,22 +1524,6 @@ Widget *OutOfFlowMgr::getFloatWidgetAtPoint (SortedFloatsVector *list, return NULL; } -Widget *OutOfFlowMgr::getAbsolutelyPositionedWidgetAtPoint (int x, int y, - int level) -{ - for (int i = 0; i < absolutelyPositioned->size(); i++) { - AbsolutelyPositioned *abspos = absolutelyPositioned->get(i); - if (abspos->widget->wasAllocated ()) { - Widget *childAtPoint = - abspos->widget->getWidgetAtPoint (x, y, level + 1); - if (childAtPoint) - return childAtPoint; - } - } - - return NULL; -} - void OutOfFlowMgr::tellPosition (Widget *widget, int yReq) { if (isWidgetFloat (widget)) @@ -1825,20 +1768,17 @@ void OutOfFlowMgr::getSize (Requisition *cbReq, int *oofWidth, int *oofHeight) { DBG_OBJ_ENTER0 ("resize.oofm", 0, "getSize"); - int oofWidthAbsPos, oofHeightAbsPos; - getAbsolutelyPositionedSize (cbReq, &oofWidthAbsPos, &oofHeightAbsPos); - int oofWidthtLeft, oofWidthRight, oofHeightLeft, oofHeightRight; getFloatsSize (cbReq, LEFT, &oofWidthtLeft, &oofHeightLeft); getFloatsSize (cbReq, RIGHT, &oofWidthRight, &oofHeightRight); - *oofWidth = max (oofWidthtLeft, oofWidthRight, oofWidthAbsPos); - *oofHeight = max (oofHeightLeft, oofHeightRight, oofHeightAbsPos); + *oofWidth = max (oofWidthtLeft, oofWidthRight); + *oofHeight = max (oofHeightLeft, oofHeightRight); DBG_OBJ_MSGF ("resize.oofm", 1, - "=> (a: %d, l: %d, r: %d => %d) * (a: %d, l: %d, r: %d => %d)", - oofWidthAbsPos, oofWidthtLeft, oofWidthRight, *oofWidth, - oofHeightAbsPos, oofHeightLeft, oofHeightRight, *oofHeight); + "=> (l: %d, r: %d => %d) * (l: %d, r: %d => %d)", + oofWidthtLeft, oofWidthRight, *oofWidth, + oofHeightLeft, oofHeightRight, *oofHeight); DBG_OBJ_LEAVE (); } @@ -1900,22 +1840,17 @@ void OutOfFlowMgr::getExtremes (Extremes *cbExtr, int *oofMinWidth, DBG_OBJ_ENTER ("resize.oofm", 0, "getExtremes", "(%d / %d), ...", cbExtr->minWidth, cbExtr->maxWidth); - int oofMinWidthAbsPos, oofMaxWidthAbsPos; - getAbsolutelyPositionedExtremes (cbExtr, &oofMinWidthAbsPos, - &oofMaxWidthAbsPos); - int oofMinWidthtLeft, oofMinWidthRight, oofMaxWidthLeft, oofMaxWidthRight; getFloatsExtremes (cbExtr, LEFT, &oofMinWidthtLeft, &oofMaxWidthLeft); getFloatsExtremes (cbExtr, RIGHT, &oofMinWidthRight, &oofMaxWidthRight); - *oofMinWidth = max (oofMinWidthtLeft, oofMinWidthRight, oofMinWidthAbsPos); - *oofMaxWidth = max (oofMaxWidthLeft, oofMaxWidthRight, oofMaxWidthAbsPos); + *oofMinWidth = max (oofMinWidthtLeft, oofMinWidthRight); + *oofMaxWidth = max (oofMaxWidthLeft, oofMaxWidthRight); DBG_OBJ_MSGF ("resize.oofm", 1, - "=> (a: %d, l: %d, r: %d => %d) / (a: %d, l: %d, r: %d => %d)", - oofMinWidthAbsPos, oofMinWidthtLeft, oofMinWidthRight, - *oofMinWidth, oofMaxWidthAbsPos, oofMaxWidthLeft, - oofMaxWidthRight, *oofMaxWidth); + "=> (l: %d, r: %d => %d) / (l: %d, r: %d => %d)", + oofMinWidthtLeft, oofMinWidthRight, *oofMinWidth, + oofMaxWidthLeft, oofMaxWidthRight, *oofMaxWidth); DBG_OBJ_LEAVE (); } @@ -2347,63 +2282,4 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat) DBG_OBJ_LEAVE (); } -void OutOfFlowMgr::getAbsolutelyPositionedSize (Requisition *cbReq, int *width, - int *height) -{ - // TODO - *width = *height = 0; -} - -void OutOfFlowMgr::getAbsolutelyPositionedExtremes (Extremes *cbExtr, - int *minWidth, - int *maxWidth) -{ - // TODO - *minWidth = *maxWidth = 0; -} - -void OutOfFlowMgr::ensureAbsolutelyPositionedSizeAndPosition - (AbsolutelyPositioned *abspos) -{ - // TODO - assertNotReached (); -} - -int OutOfFlowMgr::calcValueForAbsolutelyPositioned - (AbsolutelyPositioned *abspos, Length styleLen, int refLen) -{ - assert (styleLen != LENGTH_AUTO); - if (isAbsLength (styleLen)) - return absLengthVal (styleLen); - else if (isPerLength (styleLen)) - return multiplyWithPerLength (refLen, styleLen); - else { - assertNotReached (); - return 0; // compiler happiness - } -} - -void OutOfFlowMgr::sizeAllocateAbsolutelyPositioned () -{ - for (int i = 0; i < absolutelyPositioned->size(); i++) { - Allocation *cbAllocation = getAllocation (containingBlock); - AbsolutelyPositioned *abspos = absolutelyPositioned->get (i); - ensureAbsolutelyPositionedSizeAndPosition (abspos); - - Allocation childAllocation; - childAllocation.x = cbAllocation->x + abspos->xCB; - childAllocation.y = cbAllocation->y + abspos->yCB; - childAllocation.width = abspos->width; - childAllocation.ascent = abspos->height; - childAllocation.descent = 0; // TODO - - abspos->widget->sizeAllocate (&childAllocation); - - printf ("[%p] allocating child %p at: (%d, %d), %d x (%d + %d)\n", - containingBlock, abspos->widget, childAllocation.x, - childAllocation.y, childAllocation.width, childAllocation.ascent, - childAllocation.descent); - } -} - } // namespace dw diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index a42afd1d..179d4aa0 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -215,18 +215,6 @@ private: inline Textblock *getTextblock () { return (Textblock*)getWidget (); } }; - class AbsolutelyPositioned: public lout::object::Object - { - public: - core::Widget *widget; - int xCB, yCB; // relative to the containing block - int width, height; - bool dirty; - - AbsolutelyPositioned (OutOfFlowMgr *oofm, core::Widget *widget, - Textblock *generatingBlock, int externalIndex); - }; - // These two lists store all floats, in the order in which they are // defined. Only used for iterators. lout::container::typed::Vector<Float> *leftFloatsAll, *rightFloatsAll; @@ -246,8 +234,6 @@ private: lout::container::typed::HashTable<lout::object::TypedPointer <Textblock>, TBInfo> *tbInfosByTextblock; - lout::container::typed::Vector<AbsolutelyPositioned> *absolutelyPositioned; - int lastLeftTBIndex, lastRightTBIndex, leftFloatsMark, rightFloatsMark; /** @@ -294,10 +280,8 @@ private: void drawFloats (SortedFloatsVector *list, core::View *view, core::Rectangle *area); - void drawAbsolutelyPositioned (core::View *view, core::Rectangle *area); core::Widget *getFloatWidgetAtPoint (SortedFloatsVector *list, int x, int y, int level); - core::Widget *getAbsolutelyPositionedWidgetAtPoint (int x, int y, int level); bool collidesV (Float *vloat, Float *other, SFVType type, int *yReal); bool collidesH (Float *vloat, Float *other, SFVType type); @@ -329,21 +313,8 @@ private: void tellFloatPosition (core::Widget *widget, int yReq); - void getAbsolutelyPositionedSize (core::Requisition *cbReq, int *width, - int *height); - void getAbsolutelyPositionedExtremes (core::Extremes *cbExtr, int *minWidth, - int *maxWidth); - void ensureAbsolutelyPositionedSizeAndPosition (AbsolutelyPositioned - *abspos); - int calcValueForAbsolutelyPositioned (AbsolutelyPositioned *abspos, - core::style::Length styleLen, - int refLen); - void sizeAllocateAbsolutelyPositioned (); - static inline bool isWidgetFloat (core::Widget *widget) { return widget->getStyle()->vloat != core::style::FLOAT_NONE; } - static inline bool isWidgetAbsolutelyPositioned (core::Widget *widget) - { return widget->getStyle()->position == core::style::POSITION_ABSOLUTE; } /* * Format for parent ref (see also below for isRefOutOfFlow, @@ -367,11 +338,8 @@ private: * | right float index | 1 | 0 | 1 | * +---+ - - - +---+---+- - - - - -+---+---+---+---+ * - * Absolutely positioned blocks: - * - * +---+ - - - +---+---+- - - - - -+---+---+---+---+ - * | index | 1 | 1 | - * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * Absolutely positioned blocks: solved differently in the + * "dillo_grows" repository. */ inline static bool isRefFloat (int ref) @@ -380,20 +348,14 @@ private: { return ref != -1 && (ref & 7) == 1; } inline static bool isRefRightFloat (int ref) { return ref != -1 && (ref & 7) == 5; } - inline static bool isRefAbsolutelyPositioned (int ref) - { return ref != -1 && (ref & 3) == 3; } inline static int createRefLeftFloat (int index) { return (index << 3) | 1; } inline static int createRefRightFloat (int index) { return (index << 3) | 5; } - inline static int createRefAbsolutelyPositioned (int index) - { return (index << 2) | 3; } inline static int getFloatIndexFromRef (int ref) { return ref == -1 ? ref : (ref >> 3); } - inline static int getAbsolutelyPositionedIndexFromRef (int ref) - { return ref == -1 ? ref : (ref >> 2); } public: OutOfFlowMgr (Textblock *containingBlock); @@ -447,18 +409,14 @@ public: { return ref == -1 ? ref : (ref >> 1); } // for iterators - inline int getNumWidgets () { - return leftFloatsAll->size() + rightFloatsAll->size() + - absolutelyPositioned->size(); } + inline int getNumWidgets () + { return leftFloatsAll->size() + rightFloatsAll->size(); } inline core::Widget *getWidget (int i) { if (i < leftFloatsAll->size()) return leftFloatsAll->get(i)->getWidget (); - else if (i < leftFloatsAll->size() + rightFloatsAll->size()) - return rightFloatsAll->get(i - leftFloatsAll->size())->getWidget (); else - return absolutelyPositioned->get(i - (leftFloatsAll->size() + - rightFloatsAll->size()))->widget; + return rightFloatsAll->get(i - leftFloatsAll->size())->getWidget (); } inline bool affectsLeftBorder (core::Widget *widget) { |