diff options
-rw-r--r-- | dw/outofflowmgr.cc | 220 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 94 | ||||
-rw-r--r-- | dw/style.cc | 20 | ||||
-rw-r--r-- | dw/style.hh | 10 | ||||
-rw-r--r-- | src/cssparser.cc | 14 | ||||
-rw-r--r-- | src/styleengine.cc | 15 |
6 files changed, 340 insertions, 33 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index e85c630e..75457cb7 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -289,6 +289,16 @@ OutOfFlowMgr::TBInfo::~TBInfo () delete rightFloatsGB; } +OutOfFlowMgr::AbsolutelyPositioned::AbsolutelyPositioned (OutOfFlowMgr *oofm, + core::Widget *widget, + Textblock + *generatingBlock, + int externalIndex) +{ + this->widget = widget; + dirty = true; +} + OutOfFlowMgr::OutOfFlowMgr (Textblock *containingBlock) { //printf ("OutOfFlowMgr::OutOfFlowMgr\n"); @@ -310,6 +320,8 @@ OutOfFlowMgr::OutOfFlowMgr (Textblock *containingBlock) leftFloatsMark = rightFloatsMark = 0; lastLeftTBIndex = lastRightTBIndex = 0; + absolutelyPositioned = new Vector<AbsolutelyPositioned> (1, true); + containingBlockWasAllocated = containingBlock->wasAllocated (); if (containingBlockWasAllocated) containingBlockAllocation = *(containingBlock->getAllocation()); @@ -336,6 +348,8 @@ OutOfFlowMgr::~OutOfFlowMgr () // last. delete leftFloatsAll; delete rightFloatsAll; + + delete absolutelyPositioned; } void OutOfFlowMgr::sizeAllocateStart (Allocation *containingBlockAllocation) @@ -354,9 +368,10 @@ void OutOfFlowMgr::sizeAllocateEnd () moveFromGBToCB (LEFT); moveFromGBToCB (RIGHT); - // 2. Floats have to be allocated + // 2. Floats and absolutely positioned blocks have to be allocated sizeAllocateFloats (LEFT); sizeAllocateFloats (RIGHT); + sizeAllocateAbsolutelyPositioned (); // 3. Textblocks have already been allocated, but we store some // information for later use. TODO: Update this comment! @@ -574,11 +589,13 @@ void OutOfFlowMgr::sizeAllocateFloats (Side side) void OutOfFlowMgr::draw (View *view, Rectangle *area) { - draw (leftFloatsCB, view, area); - draw (rightFloatsCB, view, area); + drawFloats (leftFloatsCB, view, area); + drawFloats (rightFloatsCB, view, area); + drawAbsolutelyPositioned (view, area); } -void OutOfFlowMgr::draw (SortedFloatsVector *list, View *view, Rectangle *area) +void OutOfFlowMgr::drawFloats (SortedFloatsVector *list, View *view, + Rectangle *area) { // This could be improved, since the list is sorted: search the // first float fitting into the area, and iterate until one is @@ -591,10 +608,20 @@ void OutOfFlowMgr::draw (SortedFloatsVector *list, View *view, Rectangle *area) } } +void OutOfFlowMgr::drawAbsolutelyPositioned (View *view, Rectangle *area) +{ + for (int i = 0; i < absolutelyPositioned->size(); i++) { + AbsolutelyPositioned *abspos = absolutelyPositioned->get(i); + core::Rectangle childArea; + if (abspos->widget->intersects (area, &childArea)) + abspos->widget->draw (view, &childArea); + } +} + bool OutOfFlowMgr::isWidgetOutOfFlow (core::Widget *widget) { - // Will be extended for absolute positions. - return widget->getStyle()->vloat != FLOAT_NONE; + // May be extended for fixed (and relative?) positions. + return isWidgetFloat (widget) || isWidgetAbsolutelyPositioned (widget); } void OutOfFlowMgr::addWidgetInFlow (Textblock *textblock, @@ -618,7 +645,7 @@ void OutOfFlowMgr::addWidgetInFlow (Textblock *textblock, void OutOfFlowMgr::addWidgetOOF (Widget *widget, Textblock *generatingBlock, int externalIndex) { - if (widget->getStyle()->vloat != FLOAT_NONE) { + if (isWidgetFloat (widget)) { TBInfo *tbInfo = getTextblock (generatingBlock); Float *vloat = new Float (this, widget, generatingBlock, externalIndex); @@ -688,8 +715,15 @@ 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 - // Will continue here for absolute positions. + // May be extended. assertNotReached(); } @@ -745,9 +779,10 @@ void OutOfFlowMgr::markSizeChange (int ref) // TODO May cause problems (endless resizing?) when float has no // defined position. vloat->generatingBlock->borderChanged (vloat->yReal, vloat->widget); - } else - // later: absolute positions - assertNotReached(); + } else if (isRefAbsolutelyPositioned (ref)) { + int i = getAbsolutelyPositionedIndexFromRef (ref); + absolutelyPositioned->get(i)->dirty = true; + } } @@ -758,14 +793,16 @@ void OutOfFlowMgr::markExtremesChange (int ref) Widget *OutOfFlowMgr::getWidgetAtPoint (int x, int y, int level) { - Widget *childAtPoint = getWidgetAtPoint (leftFloatsCB, x, y, level); + Widget *childAtPoint = getFloatWidgetAtPoint (leftFloatsCB, x, y, level); if (childAtPoint == NULL) - childAtPoint = getWidgetAtPoint (rightFloatsCB, x, y, level); + childAtPoint = getFloatWidgetAtPoint (rightFloatsCB, x, y, level); + if (childAtPoint == NULL) + childAtPoint = getAbsolutelyPositionedWidgetAtPoint (x, y, level); return childAtPoint; } -Widget *OutOfFlowMgr::getWidgetAtPoint (SortedFloatsVector *list, - int x, int y, int level) +Widget *OutOfFlowMgr::getFloatWidgetAtPoint (SortedFloatsVector *list, + int x, int y, int level) { for (int i = 0; i < list->size(); i++) { // Could use binary search to be faster. @@ -778,9 +815,30 @@ Widget *OutOfFlowMgr::getWidgetAtPoint (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); + 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)) + tellFloatPosition (widget, yReq); + + // Nothing to do for absolutely positioned blocks. +} + + +void OutOfFlowMgr::tellFloatPosition (Widget *widget, int yReq) +{ assert (yReq >= 0); Float *vloat = findFloatByWidget(widget); @@ -977,12 +1035,14 @@ void OutOfFlowMgr::getSize (int cbWidth, int cbHeight, //printf ("[%p] GET_SIZE (%d / %d floats)...\n", // containingBlock, leftFloatsCB->size(), rightFloatsCB->size()); - *oofWidth = cbWidth; /* This (or "<=" instead of "=") should be - the case for floats. */ + int oofWidthAbsPos, oofHeightAbsPos; + getAbsolutelyPositionedSize (&oofWidthAbsPos, &oofHeightAbsPos); int oofHeightLeft = getFloatsSize (leftFloatsCB); int oofHeightRight = getFloatsSize (rightFloatsCB); - *oofHeight = max (oofHeightLeft, oofHeightRight); + + *oofWidth = cbWidth; /* Floats should play no role for the width. */ + *oofHeight = max (oofHeightLeft, oofHeightRight, oofWidthAbsPos); //printf (" => %d x %d => %d x %d (%d / %d)\n", // cbWidth, cbHeight, *oofWidth, *oofHeight, @@ -1050,6 +1110,7 @@ void OutOfFlowMgr::getExtremes (int cbMinWidth, int cbMaxWidth, *oofMinWidth = *oofMaxWidth = 0; accumExtremes (leftFloatsCB, oofMinWidth, oofMaxWidth); accumExtremes (rightFloatsCB, oofMinWidth, oofMaxWidth); + // TODO Absolutely positioned elements } void OutOfFlowMgr::accumExtremes (SortedFloatsVector *list, int *oofMinWidth, @@ -1314,6 +1375,129 @@ int OutOfFlowMgr::getBorderDiff (Textblock *textblock, Float *vloat, Side side) } } +void OutOfFlowMgr::getAbsolutelyPositionedSize (int *oofWidthAbsPos, + int *oofHeightAbsPos) +{ + *oofWidthAbsPos = *oofHeightAbsPos = 0; + + for (int i = 0; i < absolutelyPositioned->size(); i++) { + AbsolutelyPositioned *abspos = absolutelyPositioned->get (i); + ensureAbsolutelyPositionedSizeAndPosition (abspos); + *oofWidthAbsPos = max (*oofWidthAbsPos, abspos->xCB + abspos->width); + *oofHeightAbsPos = max (*oofHeightAbsPos, abspos->yCB + abspos->height); + } +} + +void OutOfFlowMgr::ensureAbsolutelyPositionedSizeAndPosition + (AbsolutelyPositioned *abspos) +{ + // TODO Similar to floats, changes of the available size of the + // containing block are not noticed; which is a bit more severe as + // for floats. Find a general solution for both floats and + // absolutely positioned blocks. + + // TODO Compare to ensureFloatSize: some parts are + // missing. Nevertheless, a simpler approach should be focussed on. + + if (abspos->dirty) { + Style *style = abspos->widget->getStyle(); + int availWidth = containingBlock->getAvailWidth(); + int availHeight = + containingBlock->getAvailAscent() + containingBlock->getAvailDescent(); + + if (style->left == LENGTH_AUTO) + abspos->xCB = 0; + else + abspos->xCB = + calcValueForAbsolutelyPositioned (abspos, style->left, availWidth); + + if (style->top == LENGTH_AUTO) + abspos->yCB = 0; + else + abspos->yCB = + calcValueForAbsolutelyPositioned (abspos, style->top, availHeight); + + abspos->width = -1; // undefined + if (style->width != LENGTH_AUTO) + abspos->width = calcValueForAbsolutelyPositioned (abspos, style->width, + availWidth); + else if (style->right != LENGTH_AUTO) { + int right = calcValueForAbsolutelyPositioned (abspos, style->right, + availWidth); + abspos->width = max (0, availWidth - (abspos->xCB + right)); + } + + abspos->height = -1; // undefined + if (style->height != LENGTH_AUTO) + abspos->height = calcValueForAbsolutelyPositioned (abspos, + style->height, + availHeight); + else if (style->bottom != LENGTH_AUTO) { + int bottom = calcValueForAbsolutelyPositioned (abspos, style->bottom, + availHeight); + abspos->height = max (0, availHeight - (abspos->yCB + bottom)); + } + + if (abspos->width != -1) + abspos->widget->setWidth (abspos->width); + + if (abspos->height != -1) { + abspos->widget->setAscent (abspos->height); + abspos->widget->setDescent (0); // TODO + } + + if (abspos->width == -1 || abspos->height == -1) { + Requisition req; + abspos->widget->sizeRequest (&req); + + if (abspos->width == -1) + abspos->width = req.width; + + if (abspos->height == -1) + abspos->height = req.ascent + req.descent; + } + + abspos->dirty = false; + } +} + +int OutOfFlowMgr::calcValueForAbsolutelyPositioned + (AbsolutelyPositioned *abspos, Length styleLen, int refLen) +{ + assert (styleLen != LENGTH_AUTO); + if (isAbsLength (styleLen)) + return absLengthVal (styleLen); + else if (isPerLength (styleLen)) + return refLen * perLengthVal (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); + } +} + // TODO Latest change: Check also Textblock::borderChanged: looks OK, // but the comment ("... (i) with canvas coordinates ...") looks wrong // (and looks as having always been wrong). diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 97473145..c19f0428 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -141,6 +141,18 @@ private: ~TBInfo (); }; + 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; @@ -155,6 +167,8 @@ private: lout::container::typed::Vector<TBInfo> *tbInfos; lout::container::typed::HashTable<lout::object::TypedPointer <Textblock>, TBInfo> *tbInfosByTextblock; + + lout::container::typed::Vector<AbsolutelyPositioned> *absolutelyPositioned; int lastLeftTBIndex, lastRightTBIndex, leftFloatsMark, rightFloatsMark; @@ -189,10 +203,13 @@ private: int tbx, int tby, int tbWidth, int tbHeight, int *floatPos, core::Widget **vloat); - void draw (SortedFloatsVector *list, core::View *view, - core::Rectangle *area); - core::Widget *getWidgetAtPoint (SortedFloatsVector *list, int x, int y, - int level); + 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 collides (Float *vloat, Float *other, int *yReal); void checkCoverage (Float *vloat, int oldY); @@ -213,20 +230,69 @@ private: void ensureFloatSize (Float *vloat); int getBorderDiff (Textblock *textblock, Float *vloat, Side side); + void tellFloatPosition (core::Widget *widget, int yReq); + + void getAbsolutelyPositionedSize (int *oofWidthAbsPos, int *oofHeightAbsPos); + 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, + * createRefNormalFlow, and getLineNoFromRef. + * + * Widget in flow: + * + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * | line number | 0 | + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * + * So, anything with the least signifant bit set to 1 is out of flow. + * + * Floats: + * + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * | left float index | 0 | 0 | 1 | + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * | right float index | 1 | 0 | 1 | + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * + * Absolutely positioned blocks: + * + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + * | index | 1 | 1 | + * +---+ - - - +---+---+- - - - - -+---+---+---+---+ + */ + inline static bool isRefFloat (int ref) - { return ref != -1 && (ref & 1) == 1; } - inline static bool isRefLeftFloat (int ref) { return ref != -1 && (ref & 3) == 1; } + inline static bool isRefLeftFloat (int ref) + { 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 << 2) | 1; } + { 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: @@ -273,10 +339,18 @@ public: // for iterators inline int getNumWidgets () { - return leftFloatsAll->size() + rightFloatsAll->size(); } + return leftFloatsAll->size() + rightFloatsAll->size() + + absolutelyPositioned->size(); } + inline core::Widget *getWidget (int i) { - return i < leftFloatsAll->size() ? leftFloatsAll->get(i)->widget : - rightFloatsAll->get(i - leftFloatsAll->size())->widget; } + if (i < leftFloatsAll->size()) + return leftFloatsAll->get(i)->widget; + else if (i < leftFloatsAll->size() + rightFloatsAll->size()) + return rightFloatsAll->get(i - leftFloatsAll->size())->widget; + else + return absolutelyPositioned->get(i - (leftFloatsAll->size() + + rightFloatsAll->size()))->widget; + } inline bool affectsLeftBorder (core::Widget *widget) { return widget->getStyle()->vloat == core::style::FLOAT_LEFT; } diff --git a/dw/style.cc b/dw/style.cc index 2f64e468..51dda098 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -49,6 +49,8 @@ void StyleAttrs::initValues () width = height = lineHeight = LENGTH_AUTO; vloat = FLOAT_NONE; clear = CLEAR_NONE; + position = POSITION_STATIC; + top = bottom = left = right = LENGTH_AUTO; textIndent = 0; margin.setVal (0); borderWidth.setVal (0); @@ -77,6 +79,9 @@ void StyleAttrs::resetValues () textAlignChar = '.'; vloat = FLOAT_NONE; /** \todo Correct? Check specification. */ clear = CLEAR_NONE; /** \todo Correct? Check specification. */ + position = POSITION_STATIC; /** \todo Correct? Check specification. */ + top = bottom = left = right = LENGTH_AUTO; /** \todo Correct? Check + specification. */ backgroundColor = NULL; width = LENGTH_AUTO; height = LENGTH_AUTO; @@ -124,6 +129,11 @@ bool StyleAttrs::equals (object::Object *other) { textTransform == otherAttrs->textTransform && vloat == otherAttrs->vloat && clear == otherAttrs->clear && + position == otherAttrs->position && + top == otherAttrs->top && + bottom == otherAttrs->bottom && + left == otherAttrs->left && + right == otherAttrs->right && hBorderSpacing == otherAttrs->hBorderSpacing && vBorderSpacing == otherAttrs->vBorderSpacing && wordSpacing == otherAttrs->wordSpacing && @@ -166,6 +176,11 @@ int StyleAttrs::hashValue () { textTransform + vloat + clear + + position + + top + + bottom + + left + + right + hBorderSpacing + vBorderSpacing + wordSpacing + @@ -260,6 +275,11 @@ void Style::copyAttrs (StyleAttrs *attrs) textTransform = attrs->textTransform; vloat = attrs->vloat; clear = attrs->clear; + position = attrs->position; + top = attrs->top; + bottom = attrs->bottom; + left = attrs->left; + right = attrs->right; hBorderSpacing = attrs->hBorderSpacing; vBorderSpacing = attrs->vBorderSpacing; wordSpacing = attrs->wordSpacing; diff --git a/dw/style.hh b/dw/style.hh index 41784c79..92ea0fe7 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -316,6 +316,13 @@ enum FontVariant { FONT_VARIANT_SMALL_CAPS }; +enum Position { + POSITION_STATIC, + POSITION_RELATIVE, + POSITION_ABSOLUTE, + POSITION_FIXED, +}; + enum TextDecoration { TEXT_DECORATION_NONE = 0, TEXT_DECORATION_UNDERLINE = 1 << 0, @@ -466,6 +473,9 @@ public: FloatType vloat; /* "float" is a keyword. */ ClearType clear; + Position position; + Length top, bottom, left, right; + int hBorderSpacing, vBorderSpacing, wordSpacing; Length width, height, lineHeight, textIndent; diff --git a/src/cssparser.cc b/src/cssparser.cc index 5096fb96..3caa62c1 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -117,6 +117,10 @@ static const char *const Css_list_style_type_enum_vals[] = { "katakana-iroha", "none", NULL }; +static const char *const Css_position_enum_vals[] = { + "static", "relative", "absolute", "fixed", NULL +}; + static const char *const Css_text_align_enum_vals[] = { "left", "right", "center", "justify", "string", NULL }; @@ -175,7 +179,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { Css_border_style_enum_vals}, {"border-top-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, Css_border_width_enum_vals}, - {"bottom", {CSS_TYPE_UNUSED}, NULL}, + {"bottom", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"caption-side", {CSS_TYPE_UNUSED}, NULL}, {"clear", {CSS_TYPE_UNUSED}, NULL}, {"clip", {CSS_TYPE_UNUSED}, NULL}, @@ -199,7 +203,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"font-weight", {CSS_TYPE_ENUM, CSS_TYPE_FONT_WEIGHT, CSS_TYPE_UNUSED}, Css_font_weight_enum_vals}, {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, - {"left", {CSS_TYPE_UNUSED}, NULL}, + {"left", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"letter-spacing", {CSS_TYPE_ENUM, CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED}, Css_letter_spacing_enum_vals}, {"line-height", @@ -228,9 +232,9 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"padding-left", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, {"padding-right", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, {"padding-top", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL}, - {"position", {CSS_TYPE_UNUSED}, NULL}, + {"position", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_position_enum_vals}, {"quotes", {CSS_TYPE_UNUSED}, NULL}, - {"right", {CSS_TYPE_UNUSED}, NULL}, + {"right", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"text-align", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_text_align_enum_vals}, {"text-decoration", {CSS_TYPE_MULTI_ENUM, CSS_TYPE_UNUSED}, Css_text_decoration_enum_vals}, @@ -238,7 +242,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"text-shadow", {CSS_TYPE_UNUSED}, NULL}, {"text-transform", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_text_transform_enum_vals}, - {"top", {CSS_TYPE_UNUSED}, NULL}, + {"top", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, {"unicode-bidi", {CSS_TYPE_UNUSED}, NULL}, {"vertical-align",{CSS_TYPE_ENUM, CSS_TYPE_UNUSED},Css_vertical_align_vals}, {"visibility", {CSS_TYPE_UNUSED}, NULL}, diff --git a/src/styleengine.cc b/src/styleengine.cc index 5407408f..890f6bcb 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -495,6 +495,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { computeValue (&attrs->hBorderSpacing, p->value.intVal,attrs->font); computeValue (&attrs->vBorderSpacing, p->value.intVal,attrs->font); break; + case CSS_PROPERTY_BOTTOM: + computeLength (&attrs->bottom, p->value.intVal, attrs->font); + break; case CSS_PROPERTY_COLOR: attrs->color = Color::create (layout, p->value.intVal); break; @@ -507,6 +510,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { case CSS_PROPERTY_FLOAT: attrs->vloat = (FloatType) p->value.intVal; break; + case CSS_PROPERTY_LEFT: + computeLength (&attrs->left, p->value.intVal, attrs->font); + break; case CSS_PROPERTY_LINE_HEIGHT: if (p->type == CSS_TYPE_ENUM) { //only valid enum value is "normal" attrs->lineHeight = dw::core::style::LENGTH_AUTO; @@ -558,6 +564,12 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { case CSS_PROPERTY_PADDING_RIGHT: computeValue (&attrs->padding.right, p->value.intVal, attrs->font); break; + case CSS_PROPERTY_POSITION: + attrs->position = (Position) p->value.intVal; + break; + case CSS_PROPERTY_RIGHT: + computeLength (&attrs->right, p->value.intVal, attrs->font); + break; case CSS_PROPERTY_TEXT_ALIGN: attrs->textAlign = (TextAlignType) p->value.intVal; break; @@ -570,6 +582,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) { case CSS_PROPERTY_TEXT_TRANSFORM: attrs->textTransform = (TextTransform) p->value.intVal; break; + case CSS_PROPERTY_TOP: + computeLength (&attrs->top, p->value.intVal, attrs->font); + break; case CSS_PROPERTY_VERTICAL_ALIGN: attrs->valign = (VAlignType) p->value.intVal; break; |