Title: [128633] trunk/Source/WebCore
Revision
128633
Author
[email protected]
Date
2012-09-14 11:42:53 -0700 (Fri, 14 Sep 2012)

Log Message

Simplify some code in RenderBox::computePercentageLogicalHeight
https://bugs.webkit.org/show_bug.cgi?id=96704

Reviewed by Tony Chang.

This is strictly code cleanup. No behavior change.
Also removed some comments that were what comments and/or were
getting stale.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::skipContainingBlockForPercentHeightCalculation):
(WebCore):
(WebCore::RenderBox::computePercentageLogicalHeight):
* rendering/RenderBox.h:
(RenderBox):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128632 => 128633)


--- trunk/Source/WebCore/ChangeLog	2012-09-14 18:26:16 UTC (rev 128632)
+++ trunk/Source/WebCore/ChangeLog	2012-09-14 18:42:53 UTC (rev 128633)
@@ -1,3 +1,21 @@
+2012-09-14  Ojan Vafai  <[email protected]>
+
+        Simplify some code in RenderBox::computePercentageLogicalHeight
+        https://bugs.webkit.org/show_bug.cgi?id=96704
+
+        Reviewed by Tony Chang.
+
+        This is strictly code cleanup. No behavior change.
+        Also removed some comments that were what comments and/or were
+        getting stale.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::skipContainingBlockForPercentHeightCalculation):
+        (WebCore):
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        * rendering/RenderBox.h:
+        (RenderBox):
+
 2012-09-14  Kent Tamura  <[email protected]>
 
         Unreviewed, a workaround for a mysterious crash on Apple Windows port.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (128632 => 128633)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-09-14 18:26:16 UTC (rev 128632)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-09-14 18:42:53 UTC (rev 128633)
@@ -2119,21 +2119,23 @@
     return -1;
 }
 
+bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const
+{
+    // For quirks mode and anonymous blocks, we skip auto-height containingBlocks when computing percentages.
+    // For standards mode, we treat the percentage as auto if it has an auto-height containing block.
+    if (!document()->inQuirksMode() && !containingBlock->isAnonymousBlock())
+        return false;
+    return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPositioned() && containingBlock->style()->logicalHeight().isAuto() && isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode();
+}
+
 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
 {
     LayoutUnit availableHeight = -1;
     
-    // In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
-    // block that may have a specified height and then use it. In strict mode, this violates the
-    // specification, which states that percentage heights just revert to auto if the containing
-    // block has an auto height. We still skip anonymous containing blocks in both modes, though, and look
-    // only at explicit containers.
     bool skippedAutoHeightContainingBlock = false;
     RenderBlock* cb = containingBlock();
     LayoutUnit rootMarginBorderPaddingHeight = 0;
-    while (!cb->isRenderView() && !cb->isTableCell() && !cb->isOutOfFlowPositioned() && cb->style()->logicalHeight().isAuto() && isHorizontalWritingMode() == cb->isHorizontalWritingMode()) {
-        if (!document()->inQuirksMode() && !cb->isAnonymousBlock())
-            break;
+    while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation(cb)) {
         if (cb->isBody() || cb->isRoot())
             rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfter() + cb->borderAndPaddingLogicalHeight();
         skippedAutoHeightContainingBlock = true;
@@ -2153,29 +2155,26 @@
 
     if (isHorizontalWritingMode() != cb->isHorizontalWritingMode())
         availableHeight = cb->contentLogicalWidth();
-    else if (cb->isTableCell()) {
+    else if (cb->isTableCell() && !skippedAutoHeightContainingBlock) {
         // Table cells violate what the CSS spec says to do with heights. Basically we
         // don't care if the cell specified a height or not. We just always make ourselves
         // be a percentage of the cell's current content height.
-        if (!skippedAutoHeightContainingBlock) {
-            if (!cb->hasOverrideHeight()) {
-                // Normally we would let the cell size intrinsically, but scrolling overflow has to be
-                // treated differently, since WinIE lets scrolled overflow regions shrink as needed.
-                // While we can't get all cases right, we can at least detect when the cell has a specified
-                // height or when the table has a specified height.  In these cases we want to initially have
-                // no size and allow the flexing of the table or the cell to its specified height to cause us
-                // to grow to fill the space.  This could end up being wrong in some cases, but it is
-                // preferable to the alternative (sizing intrinsically and making the row end up too big).
-                RenderTableCell* cell = toRenderTableCell(cb);
-                if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAuto() || !cell->table()->style()->logicalHeight().isAuto()))
-                    return 0;
-                return -1;
-            }
-            availableHeight = cb->overrideLogicalContentHeight();
-            includeBorderPadding = true;
+        if (!cb->hasOverrideHeight()) {
+            // Normally we would let the cell size intrinsically, but scrolling overflow has to be
+            // treated differently, since WinIE lets scrolled overflow regions shrink as needed.
+            // While we can't get all cases right, we can at least detect when the cell has a specified
+            // height or when the table has a specified height. In these cases we want to initially have
+            // no size and allow the flexing of the table or the cell to its specified height to cause us
+            // to grow to fill the space. This could end up being wrong in some cases, but it is
+            // preferable to the alternative (sizing intrinsically and making the row end up too big).
+            RenderTableCell* cell = toRenderTableCell(cb);
+            if (scrollsOverflowY() && (!cell->style()->logicalHeight().isAuto() || !cell->table()->style()->logicalHeight().isAuto()))
+                return 0;
+            return -1;
         }
+        availableHeight = cb->overrideLogicalContentHeight();
+        includeBorderPadding = true;
     } else if (cbstyle->logicalHeight().isFixed()) {
-        // Otherwise we only use our percentage height if our containing block had a specified height.
         LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
         availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
     } else if (cbstyle->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) {

Modified: trunk/Source/WebCore/rendering/RenderBox.h (128632 => 128633)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-09-14 18:26:16 UTC (rev 128632)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-09-14 18:42:53 UTC (rev 128633)
@@ -583,6 +583,8 @@
 
     // Returns true if we did a full repaint
     bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground);
+
+    bool skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const;
    
     LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,
         LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to