int InlineFlowBox::placeBoxesHorizontally(int x) { // Set our x position. setXPos(x); int startX = x; x += borderLeft() + paddingLeft(); for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { if (curr->object()->isText()) { InlineTextBox* text = static_cast<InlineTextBox*>(curr); text->setXPos(x); x += curr->width(); } else { if (curr->object()->isPositioned()) { if (curr->object()->parent()->style()->direction() == LTR) curr->setXPos(x); else { // Our offset that we cache needs to be from the edge of the right border box and // not the left border box. We have to subtract |x| from the width of the block // (which can be obtained by walking up to the root line box). InlineBox* root = this; while (!root->isRootInlineBox()) root = root->parent(); curr->setXPos(root->object()->width()-x); } continue; // The positioned object has no effect on the width. } if (curr->object()->isInlineFlow()) { InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); x += flow->marginLeft(); x = flow->placeBoxesHorizontally(x); x += flow->marginRight(); } else { x += curr->object()->marginLeft(); curr->setXPos(x); x += curr->width() + curr->object()->marginRight(); } } } x += borderRight() + paddingRight(); setWidth(x-startX); return x; }