| Differences between
and this patch
- Source/WebCore/ChangeLog +13 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2011-02-23  David Hyatt  <hyatt@apple.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=46500, make positioned elements work with vertical text.
6
7
        Patch computePositionedLogicalHeightUsing to be writing-mode-aware. 
8
9
        * rendering/RenderBox.cpp:
10
        (WebCore::RenderBox::computePositionedLogicalWidthUsing):
11
        (WebCore::RenderBox::computePositionedLogicalHeightUsing):
12
        * rendering/RenderBox.h:
13
1
2011-02-23  Martin Robinson  <mrobinson@igalia.com>
14
2011-02-23  Martin Robinson  <mrobinson@igalia.com>
2
15
3
        Reviewed by Xan Lopez.
16
        Reviewed by Xan Lopez.
- Source/WebCore/rendering/RenderBox.cpp -46 / +67 lines
Lines 2416-2421 void RenderBox::computePositionedLogical Source/WebCore/rendering/RenderBox.cpp_sec1
2416
        }
2416
        }
2417
    }
2417
    }
2418
2418
2419
    // FIXME: Deal with differing writing modes here.  Our offset needs to be in the containing block's coordinate space, so that
2420
    // can make the result here rather complicated to compute.
2421
    
2419
    // Use computed values to calculate the horizontal position.
2422
    // Use computed values to calculate the horizontal position.
2420
2423
2421
    // FIXME: This hack is needed to calculate the  logical left position for a 'rtl' relatively
2424
    // FIXME: This hack is needed to calculate the  logical left position for a 'rtl' relatively
Lines 2549-2578 void RenderBox::computePositionedLogical Source/WebCore/rendering/RenderBox.cpp_sec2
2549
    setLogicalHeight(logicalHeightResult + bordersPlusPadding);
2552
    setLogicalHeight(logicalHeightResult + bordersPlusPadding);
2550
}
2553
}
2551
2554
2552
void RenderBox::computePositionedLogicalHeightUsing(Length h, const RenderBoxModelObject* containerBlock,
2555
void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength, const RenderBoxModelObject* containerBlock,
2553
                                           const int containerHeight, const int bordersPlusPadding,
2556
                                                    int containerLogicalHeight, int bordersPlusPadding,
2554
                                           const Length top, const Length bottom, const Length marginTop, const Length marginBottom,
2557
                                                    Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
2555
                                           int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos)
2558
                                                    int& logicalHeightValue, int& marginLogicalTopValue, int& marginLogicalBottomValue, int& logicalTopPos)
2556
{
2559
{
2557
    // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
2560
    // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
2558
    // converted to the static position in computePositionedLogicalHeight()
2561
    // converted to the static position in computePositionedLogicalHeight()
2559
    ASSERT(!(top.isAuto() && bottom.isAuto()));
2562
    ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto()));
2560
2563
2561
    int contentHeight = height() - bordersPlusPadding;
2564
    int contentLogicalHeight = logicalHeight() - bordersPlusPadding;
2562
2565
2563
    int topValue = 0;
2566
    int logicalTopValue = 0;
2564
2567
2565
    bool heightIsAuto = h.isAuto();
2568
    bool logicalHeightIsAuto = logicalHeightLength.isAuto();
2566
    bool topIsAuto = top.isAuto();
2569
    bool logicalTopIsAuto = logicalTop.isAuto();
2567
    bool bottomIsAuto = bottom.isAuto();
2570
    bool logicalBottomIsAuto = logicalBottom.isAuto();
2568
2571
2569
    // Height is never unsolved for tables.
2572
    // Height is never unsolved for tables.
2570
    if (isTable()) {
2573
    if (isTable()) {
2571
        h.setValue(Fixed, contentHeight);
2574
        logicalHeightLength.setValue(Fixed, contentLogicalHeight);
2572
        heightIsAuto = false;
2575
        logicalHeightIsAuto = false;
2573
    }
2576
    }
2574
2577
2575
    if (!topIsAuto && !heightIsAuto && !bottomIsAuto) {
2578
    if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) {
2576
        /*-----------------------------------------------------------------------*\
2579
        /*-----------------------------------------------------------------------*\
2577
         * If none of the three are 'auto': If both 'margin-top' and 'margin-
2580
         * If none of the three are 'auto': If both 'margin-top' and 'margin-
2578
         * bottom' are 'auto', solve the equation under the extra constraint that
2581
         * bottom' are 'auto', solve the equation under the extra constraint that
Lines 2584-2612 void RenderBox::computePositionedLogical Source/WebCore/rendering/RenderBox.cpp_sec3
2584
        // NOTE:  It is not necessary to solve for 'bottom' in the over constrained
2587
        // NOTE:  It is not necessary to solve for 'bottom' in the over constrained
2585
        // case because the value is not used for any further calculations.
2588
        // case because the value is not used for any further calculations.
2586
2589
2587
        heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2590
        logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
2588
        topValue = top.calcValue(containerHeight);
2591
        logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
2589
2592
2590
        const int availableSpace = containerHeight - (topValue + heightValue + bottom.calcValue(containerHeight) + bordersPlusPadding);
2593
        const int availableSpace = containerLogicalHeight - (logicalTopValue + logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight) + bordersPlusPadding);
2591
2594
2592
        // Margins are now the only unknown
2595
        // Margins are now the only unknown
2593
        if (marginTop.isAuto() && marginBottom.isAuto()) {
2596
        if (marginLogicalTop.isAuto() && marginLogicalBottom.isAuto()) {
2594
            // Both margins auto, solve for equality
2597
            // Both margins auto, solve for equality
2595
            // NOTE: This may result in negative values.
2598
            // NOTE: This may result in negative values.
2596
            marginTopValue = availableSpace / 2; // split the difference
2599
            marginLogicalTopValue = availableSpace / 2; // split the difference
2597
            marginBottomValue = availableSpace - marginTopValue; // account for odd valued differences
2600
            marginLogicalBottomValue = availableSpace - marginLogicalTopValue; // account for odd valued differences
2598
        } else if (marginTop.isAuto()) {
2601
        } else if (marginLogicalTop.isAuto()) {
2599
            // Solve for top margin
2602
            // Solve for top margin
2600
            marginBottomValue = marginBottom.calcValue(containerHeight);
2603
            marginLogicalBottomValue = marginLogicalBottom.calcValue(containerLogicalHeight);
2601
            marginTopValue = availableSpace - marginBottomValue;
2604
            marginLogicalTopValue = availableSpace - marginLogicalBottomValue;
2602
        } else if (marginBottom.isAuto()) {
2605
        } else if (marginLogicalBottom.isAuto()) {
2603
            // Solve for bottom margin
2606
            // Solve for bottom margin
2604
            marginTopValue = marginTop.calcValue(containerHeight);
2607
            marginLogicalTopValue = marginLogicalTop.calcValue(containerLogicalHeight);
2605
            marginBottomValue = availableSpace - marginTopValue;
2608
            marginLogicalBottomValue = availableSpace - marginLogicalTopValue;
2606
        } else {
2609
        } else {
2607
            // Over-constrained, (no need solve for bottom)
2610
            // Over-constrained, (no need solve for bottom)
2608
            marginTopValue = marginTop.calcValue(containerHeight);
2611
            marginLogicalTopValue = marginLogicalTop.calcValue(containerLogicalHeight);
2609
            marginBottomValue = marginBottom.calcValue(containerHeight);
2612
            marginLogicalBottomValue = marginLogicalBottom.calcValue(containerLogicalHeight);
2610
        }
2613
        }
2611
    } else {
2614
    } else {
2612
        /*--------------------------------------------------------------------*\
2615
        /*--------------------------------------------------------------------*\
Lines 2635-2671 void RenderBox::computePositionedLogical Source/WebCore/rendering/RenderBox.cpp_sec4
2635
        // because the value is not used for any further calculations.
2638
        // because the value is not used for any further calculations.
2636
2639
2637
        // Calculate margins, 'auto' margins are ignored.
2640
        // Calculate margins, 'auto' margins are ignored.
2638
        marginTopValue = marginTop.calcMinValue(containerHeight);
2641
        marginLogicalTopValue = marginLogicalTop.calcMinValue(containerLogicalHeight);
2639
        marginBottomValue = marginBottom.calcMinValue(containerHeight);
2642
        marginLogicalBottomValue = marginLogicalBottom.calcMinValue(containerLogicalHeight);
2640
2643
2641
        const int availableSpace = containerHeight - (marginTopValue + marginBottomValue + bordersPlusPadding);
2644
        const int availableSpace = containerLogicalHeight - (marginLogicalTopValue + marginLogicalBottomValue + bordersPlusPadding);
2642
2645
2643
        // Use rule/case that applies.
2646
        // Use rule/case that applies.
2644
        if (topIsAuto && heightIsAuto && !bottomIsAuto) {
2647
        if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
2645
            // RULE 1: (height is content based, solve of top)
2648
            // RULE 1: (height is content based, solve of top)
2646
            heightValue = contentHeight;
2649
            logicalHeightValue = contentLogicalHeight;
2647
            topValue = availableSpace - (heightValue + bottom.calcValue(containerHeight));
2650
            logicalTopValue = availableSpace - (logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight));
2648
        } else if (!topIsAuto && heightIsAuto && bottomIsAuto) {
2651
        } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAuto) {
2649
            // RULE 3: (height is content based, no need solve of bottom)
2652
            // RULE 3: (height is content based, no need solve of bottom)
2650
            topValue = top.calcValue(containerHeight);
2653
            logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
2651
            heightValue = contentHeight;
2654
            logicalHeightValue = contentLogicalHeight;
2652
        } else if (topIsAuto && !heightIsAuto && !bottomIsAuto) {
2655
        } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) {
2653
            // RULE 4: (solve of top)
2656
            // RULE 4: (solve of top)
2654
            heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2657
            logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
2655
            topValue = availableSpace - (heightValue + bottom.calcValue(containerHeight));
2658
            logicalTopValue = availableSpace - (logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight));
2656
        } else if (!topIsAuto && heightIsAuto && !bottomIsAuto) {
2659
        } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
2657
            // RULE 5: (solve of height)
2660
            // RULE 5: (solve of height)
2658
            topValue = top.calcValue(containerHeight);
2661
            logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
2659
            heightValue = max(0, availableSpace - (topValue + bottom.calcValue(containerHeight)));
2662
            logicalHeightValue = max(0, availableSpace - (logicalTopValue + logicalBottom.calcValue(containerLogicalHeight)));
2660
        } else if (!topIsAuto && !heightIsAuto && bottomIsAuto) {
2663
        } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsAuto) {
2661
            // RULE 6: (no need solve of bottom)
2664
            // RULE 6: (no need solve of bottom)
2662
            heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2665
            logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
2663
            topValue = top.calcValue(containerHeight);
2666
            logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
2664
        }
2667
        }
2665
    }
2668
    }
2666
2669
2670
    // FIXME: Deal with differing writing modes here.  Our offset needs to be in the containing block's coordinate space, so that
2671
    // can make the result here rather complicated to compute.
2672
2667
    // Use computed values to calculate the vertical position.
2673
    // Use computed values to calculate the vertical position.
2668
    yPos = topValue + marginTopValue + containerBlock->borderTop();
2674
    logicalTopPos = logicalTopValue;
2675
    
2676
    // Our offset is from the logical bottom edge in a flipped environment, e.g., right for vertical-rl and bottom for horizontal-bt.
2677
    if (style()->isFlippedBlocksWritingMode()) {
2678
        logicalTopPos += marginLogicalBottomValue;
2679
        if (style()->isHorizontalWritingMode())
2680
            logicalTopPos += containerBlock->borderBottom();
2681
        else
2682
            logicalTopPos += containerBlock->borderRight();
2683
    } else {
2684
        logicalTopPos += marginLogicalTopValue;
2685
        if (style()->isHorizontalWritingMode())
2686
            logicalTopPos += containerBlock->borderTop();
2687
        else
2688
            logicalTopPos += containerBlock->borderLeft();
2689
    }
2669
}
2690
}
2670
2691
2671
void RenderBox::computePositionedLogicalWidthReplaced()
2692
void RenderBox::computePositionedLogicalWidthReplaced()
- Source/WebCore/rendering/RenderBox.h -4 / +4 lines
Lines 434-443 private: Source/WebCore/rendering/RenderBox.h_sec1
434
                                            int containerLogicalWidth, int bordersPlusPadding,
434
                                            int containerLogicalWidth, int bordersPlusPadding,
435
                                            Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight,
435
                                            Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight,
436
                                            int& logicalWidthValue, int& marginLogicalLeftValue, int& marginLogicalRightValue, int& logicalLeftPos);
436
                                            int& logicalWidthValue, int& marginLogicalLeftValue, int& marginLogicalRightValue, int& logicalLeftPos);
437
    void computePositionedLogicalHeightUsing(Length height, const RenderBoxModelObject* cb,
437
    void computePositionedLogicalHeightUsing(Length logicalHeight, const RenderBoxModelObject* containerBlock,
438
                                    int containerHeight, int bordersPlusPadding,
438
                                             int containerLogicalHeight, int bordersPlusPadding,
439
                                    Length top, Length bottom, Length marginTop, Length marginBottom,
439
                                             Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
440
                                    int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos);
440
                                             int& logicalHeightValue, int& marginLogicalTopValue, int& marginLogicalBottomValue, int& logicalTopPos);
441
441
442
    void computePositionedLogicalHeightReplaced();
442
    void computePositionedLogicalHeightReplaced();
443
    void computePositionedLogicalWidthReplaced();
443
    void computePositionedLogicalWidthReplaced();

Return to Bug 46500