Absolute positioning patch

John-Mark Bell jmb202 at ecs.soton.ac.uk
Mon Jun 26 13:21:58 BST 2006


Hi,

I've produced the following patch for a couple of issues in the absolute 
positioning code. In summary:

* Fix use of margin[RIGHT] in calculation of right margin
* Fix available_width initialisation for shrink-to-fit widthing

This appears to fix the lack of text wrapping on CSS Zen Garden but 
appears to lose the links panel that should be on the right hand side. 
I've not investigated whether that's a side effect of my changes or 
something else, so haven't committed the change. James; if this patch is 
fine with you, I'll commit it.


John.


---

Index: render/layout.c
===================================================================
--- render/layout.c (revision 2648)
+++ render/layout.c (working copy)
@@ -368,7 +368,7 @@
   /* Absolutely positioned children. */
   if (!layout_absolute_children(block, content))
    return false;
-
+
   return true;
  }

@@ -2364,7 +2364,7 @@
     box->style->position == CSS_POSITION_RELATIVE);

   layout_compute_offsets(box, box->parent, &top, &right, &bottom, &left);
-
+
   if (left == AUTO && right == AUTO)
    left = right = 0;
   else if (left == AUTO)
@@ -2501,9 +2501,9 @@
    } else if (margin[RIGHT] == AUTO) {
     margin[RIGHT] = containing_block->width -
       left -
-     border[LEFT] - padding[LEFT] -
+     margin[LEFT] - border[LEFT] - padding[LEFT] -
       width -
-     padding[RIGHT] - border[RIGHT] - margin[RIGHT] -
+     padding[RIGHT] - border[RIGHT] -
       right;
    } else {
     right = containing_block->width -
@@ -2517,7 +2517,14 @@
     margin[LEFT] = 0;
    if (margin[RIGHT] == AUTO)
     margin[RIGHT] = 0;
+
+  available_width = containing_block->width -
+    margin[LEFT] - border[LEFT] - padding[LEFT] -
+    padding[RIGHT] - border[RIGHT] - margin[RIGHT];
+
    if (left == AUTO && width == AUTO && right != AUTO) {
+   available_width -= right;
+
     width = min(max(box->min_width, available_width), box->max_width);
     left = containing_block->width -
       margin[LEFT] - border[LEFT] - padding[LEFT] -
@@ -2532,6 +2539,8 @@
       width -
       padding[RIGHT] - border[RIGHT] - margin[RIGHT];
    } else if (left != AUTO && width == AUTO && right == AUTO) {
+   available_width -= left;
+
     width = min(max(box->min_width, available_width), box->max_width);
     right = containing_block->width -
       left -
@@ -2566,7 +2575,7 @@
   box->x = left;
   box->width = width;
   box->height = height;
-
+
   if (box->type == BOX_BLOCK || box->object) {
    if (!layout_block_context(box, content))
     return false;





More information about the netsurf-dev mailing list