[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.0/kdelibs/khtml/rendering
From:       Germain Garand <germain () ebooksfrance ! org>
Date:       2008-04-22 14:12:44
Message-ID: 1208873564.591129.12208.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 799842 by ggarand:

automatically merged revision 796955:
make vertical alignment of inline-tables and inline-blocks
comply with requirements of CSS 2.1 - 10.8.1.

we'll only apply the inline table logic to pure CSS tables though,
to remain compatible with what Gecko and Opera do.

merged WC helper getBaselineOfLastLineBox() in the process.

 M  +46 -2     render_block.cpp  
 M  +4 -1      render_block.h  
 M  +2 -5      render_object.cpp  
 M  +12 -5     render_table.cpp  


--- branches/KDE/4.0/kdelibs/khtml/rendering/render_block.cpp #799841:799842
@@ -4,8 +4,8 @@
  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
  *           (C) 1999-2003 Antti Koivisto (koivisto@kde.org)
  *           (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- *           (C) 2003-2007 Apple Computer, Inc.
- *           (C) 2004-2007 Germain Garand (germain@ebooksfrance.org)
+ *           (C) 2003-2008 Apple Computer, Inc.
+ *           (C) 2004-2008 Germain Garand (germain@ebooksfrance.org)
  *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
  *           (C) 2006 Charles Samuels (charles@kde.org)
  *
@@ -431,6 +431,50 @@
     m_firstLineBox = m_lastLineBox = 0;
 }
 
+short RenderBlock::baselinePosition( bool firstLine ) const
+{
+    // CSS2.1-10.8.1 "The baseline of an 'inline-block' is the baseline of its last \
line box  +    // in the normal flow, unless it has either no in-flow line boxes or \
if its 'overflow'  +    // property has a computed value other than 'visible', in \
which case the baseline is the bottom margin edge." +
+    if (isReplaced() && !hasOverflowClip() && !needsLayout()) {
+        int res = getBaselineOfLastLineBox();
+        if (res != -1) {
+            return  res +marginTop();
+        }
+    }
+    RenderBox::baselinePosition(firstLine);
+}
+
+int RenderBlock::getBaselineOfLastLineBox() const
+{
+    if (!isBlockFlow())
+        return -1;
+
+    if (childrenInline()) {
+//       if (!firstLineBox() && hasLineIfEmpty())
+//            return RenderFlow::baselinePosition(true) + borderTop() + \
paddingTop(); +        if (lastLineBox())
+            return lastLineBox()->yPos() + lastLineBox()->baseline();
+        return -1;
+    }
+    else {
+//        bool haveNormalFlowChild = false;
+        for (RenderObject* curr = lastChild(); curr; curr = curr->previousSibling()) \
{ +            if (!curr->isFloatingOrPositioned() && curr->isBlockFlow()) {
+//                haveNormalFlowChild = true;
+                int result = \
static_cast<RenderBlock*>(curr)->getBaselineOfLastLineBox(); +                if \
(result != -1) +                    return curr->yPos() + result; // Translate to our \
coordinate space. +            }
+        }
+//        if (!haveNormalFlowChild && isRenderButton()) // hasLineIfEmpty()
+//            return RenderFlow::baselinePosition(true) + borderTop() + \
paddingTop(); +    }
+
+    return -1;
+}
+
 void RenderBlock::makeChildrenNonInline(RenderObject *insertionPoint)
 {
     // makeChildrenNonInline takes a block whose children are *all* inline and it
--- branches/KDE/4.0/kdelibs/khtml/rendering/render_block.h #799841:799842
@@ -41,12 +41,15 @@
     virtual const char *renderName() const;
 
     virtual bool isRenderBlock() const { return true; }
-    virtual bool isBlockFlow() const { return !isInline() && !isTable(); }
+    virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && \
                !isTable(); }
     virtual bool isInlineFlow() const { return isInline() && !isReplaced(); }
     virtual bool isInlineBlockOrInlineTable() const { return isInline() && \
isReplaced(); }  
     virtual bool childrenInline() const { return m_childrenInline; }
     virtual void setChildrenInline(bool b) { m_childrenInline = b; }
+    virtual short baselinePosition( bool firstLine ) const;
+    
+    int getBaselineOfLastLineBox() const;
     void makeChildrenNonInline(RenderObject* insertionPoint = 0);
 
     void makePageBreakAvoidBlocks();
--- branches/KDE/4.0/kdelibs/khtml/rendering/render_object.cpp #799841:799842
@@ -1965,11 +1965,8 @@
 
 short RenderObject::baselinePosition( bool firstLine ) const
 {
-    // Inline blocks are replaced elements. Otherwise, just pass off to
-    // the base class.  If we're being queried as though we're the root line
-    // box, then the fact that we're an inline-block is irrelevant, and we behave
-    // just like a block.
-
+    // If we're an inline-block and need layout, it means our replaced boundaries
+    // are not yet fully established, so we behave just like a block.
     if (isReplaced() && (!isInlineBlockOrInlineTable() || !needsLayout()))
         return height()+marginTop()+marginBottom();
 
--- branches/KDE/4.0/kdelibs/khtml/rendering/render_table.cpp #799841:799842
@@ -8,6 +8,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2003 Apple Computer, Inc.
  *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
+ *           (C) 2008 Germain Garand (germain@ebooksfrance.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -122,11 +123,17 @@
 
 short RenderTable::baselinePosition(bool b) const
 {
-    // Inline tables are replaced elements. Otherwise, just pass off to
-    // the base class.
-    if (isReplaced())
-        return height()+marginTop()+marginBottom();
-    return RenderBlock::baselinePosition(b);
+    // CSS2.1 - 10.8.1 The baseline of an 'inline-table' is the baseline of the \
first row of the table. +    if (isReplaced() && !needsLayout()) {
+        // compatibility with Gecko: only apply to generic containers, not to HTML \
Table. +        if (element() && element()->id() == ID_TABLE)
+            return height()+marginTop()+marginBottom();
+
+        if (firstBodySection() && firstBodySection()->grid.size())
+            return firstBodySection()->grid[0].baseLine + firstBodySection()->yPos() \
+ marginTop(); +        return 0;
+    }
+    return RenderBox::baselinePosition(b);
 }
 
 static inline void resetSectionPointerIfNotBefore(RenderTableSection*& ptr, \
RenderObject* before)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic