Source/WebCore/ChangeLog

 12011-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
1142011-02-23 Martin Robinson <mrobinson@igalia.com>
215
316 Reviewed by Xan Lopez.
79496

Source/WebCore/rendering/RenderBox.cpp

@@void RenderBox::computePositionedLogical
24162416 }
24172417 }
24182418
 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
24192422 // Use computed values to calculate the horizontal position.
24202423
24212424 // FIXME: This hack is needed to calculate the logical left position for a 'rtl' relatively

@@void RenderBox::computePositionedLogical
25492552 setLogicalHeight(logicalHeightResult + bordersPlusPadding);
25502553}
25512554
2552 void RenderBox::computePositionedLogicalHeightUsing(Length h, const RenderBoxModelObject* containerBlock,
2553  const int containerHeight, const int bordersPlusPadding,
2554  const Length top, const Length bottom, const Length marginTop, const Length marginBottom,
2555  int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos)
 2555void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength, const RenderBoxModelObject* containerBlock,
 2556 int containerLogicalHeight, int bordersPlusPadding,
 2557 Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
 2558 int& logicalHeightValue, int& marginLogicalTopValue, int& marginLogicalBottomValue, int& logicalTopPos)
25562559{
25572560 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
25582561 // converted to the static position in computePositionedLogicalHeight()
2559  ASSERT(!(top.isAuto() && bottom.isAuto()));
 2562 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto()));
25602563
2561  int contentHeight = height() - bordersPlusPadding;
 2564 int contentLogicalHeight = logicalHeight() - bordersPlusPadding;
25622565
2563  int topValue = 0;
 2566 int logicalTopValue = 0;
25642567
2565  bool heightIsAuto = h.isAuto();
2566  bool topIsAuto = top.isAuto();
2567  bool bottomIsAuto = bottom.isAuto();
 2568 bool logicalHeightIsAuto = logicalHeightLength.isAuto();
 2569 bool logicalTopIsAuto = logicalTop.isAuto();
 2570 bool logicalBottomIsAuto = logicalBottom.isAuto();
25682571
25692572 // Height is never unsolved for tables.
25702573 if (isTable()) {
2571  h.setValue(Fixed, contentHeight);
2572  heightIsAuto = false;
 2574 logicalHeightLength.setValue(Fixed, contentLogicalHeight);
 2575 logicalHeightIsAuto = false;
25732576 }
25742577
2575  if (!topIsAuto && !heightIsAuto && !bottomIsAuto) {
 2578 if (!logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) {
25762579 /*-----------------------------------------------------------------------*\
25772580 * If none of the three are 'auto': If both 'margin-top' and 'margin-
25782581 * bottom' are 'auto', solve the equation under the extra constraint that

@@void RenderBox::computePositionedLogical
25842587 // NOTE: It is not necessary to solve for 'bottom' in the over constrained
25852588 // case because the value is not used for any further calculations.
25862589
2587  heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2588  topValue = top.calcValue(containerHeight);
 2590 logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
 2591 logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
25892592
2590  const int availableSpace = containerHeight - (topValue + heightValue + bottom.calcValue(containerHeight) + bordersPlusPadding);
 2593 const int availableSpace = containerLogicalHeight - (logicalTopValue + logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight) + bordersPlusPadding);
25912594
25922595 // Margins are now the only unknown
2593  if (marginTop.isAuto() && marginBottom.isAuto()) {
 2596 if (marginLogicalTop.isAuto() && marginLogicalBottom.isAuto()) {
25942597 // Both margins auto, solve for equality
25952598 // NOTE: This may result in negative values.
2596  marginTopValue = availableSpace / 2; // split the difference
2597  marginBottomValue = availableSpace - marginTopValue; // account for odd valued differences
2598  } else if (marginTop.isAuto()) {
 2599 marginLogicalTopValue = availableSpace / 2; // split the difference
 2600 marginLogicalBottomValue = availableSpace - marginLogicalTopValue; // account for odd valued differences
 2601 } else if (marginLogicalTop.isAuto()) {
25992602 // Solve for top margin
2600  marginBottomValue = marginBottom.calcValue(containerHeight);
2601  marginTopValue = availableSpace - marginBottomValue;
2602  } else if (marginBottom.isAuto()) {
 2603 marginLogicalBottomValue = marginLogicalBottom.calcValue(containerLogicalHeight);
 2604 marginLogicalTopValue = availableSpace - marginLogicalBottomValue;
 2605 } else if (marginLogicalBottom.isAuto()) {
26032606 // Solve for bottom margin
2604  marginTopValue = marginTop.calcValue(containerHeight);
2605  marginBottomValue = availableSpace - marginTopValue;
 2607 marginLogicalTopValue = marginLogicalTop.calcValue(containerLogicalHeight);
 2608 marginLogicalBottomValue = availableSpace - marginLogicalTopValue;
26062609 } else {
26072610 // Over-constrained, (no need solve for bottom)
2608  marginTopValue = marginTop.calcValue(containerHeight);
2609  marginBottomValue = marginBottom.calcValue(containerHeight);
 2611 marginLogicalTopValue = marginLogicalTop.calcValue(containerLogicalHeight);
 2612 marginLogicalBottomValue = marginLogicalBottom.calcValue(containerLogicalHeight);
26102613 }
26112614 } else {
26122615 /*--------------------------------------------------------------------*\

@@void RenderBox::computePositionedLogical
26352638 // because the value is not used for any further calculations.
26362639
26372640 // Calculate margins, 'auto' margins are ignored.
2638  marginTopValue = marginTop.calcMinValue(containerHeight);
2639  marginBottomValue = marginBottom.calcMinValue(containerHeight);
 2641 marginLogicalTopValue = marginLogicalTop.calcMinValue(containerLogicalHeight);
 2642 marginLogicalBottomValue = marginLogicalBottom.calcMinValue(containerLogicalHeight);
26402643
2641  const int availableSpace = containerHeight - (marginTopValue + marginBottomValue + bordersPlusPadding);
 2644 const int availableSpace = containerLogicalHeight - (marginLogicalTopValue + marginLogicalBottomValue + bordersPlusPadding);
26422645
26432646 // Use rule/case that applies.
2644  if (topIsAuto && heightIsAuto && !bottomIsAuto) {
 2647 if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
26452648 // RULE 1: (height is content based, solve of top)
2646  heightValue = contentHeight;
2647  topValue = availableSpace - (heightValue + bottom.calcValue(containerHeight));
2648  } else if (!topIsAuto && heightIsAuto && bottomIsAuto) {
 2649 logicalHeightValue = contentLogicalHeight;
 2650 logicalTopValue = availableSpace - (logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight));
 2651 } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAuto) {
26492652 // RULE 3: (height is content based, no need solve of bottom)
2650  topValue = top.calcValue(containerHeight);
2651  heightValue = contentHeight;
2652  } else if (topIsAuto && !heightIsAuto && !bottomIsAuto) {
 2653 logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
 2654 logicalHeightValue = contentLogicalHeight;
 2655 } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) {
26532656 // RULE 4: (solve of top)
2654  heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2655  topValue = availableSpace - (heightValue + bottom.calcValue(containerHeight));
2656  } else if (!topIsAuto && heightIsAuto && !bottomIsAuto) {
 2657 logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
 2658 logicalTopValue = availableSpace - (logicalHeightValue + logicalBottom.calcValue(containerLogicalHeight));
 2659 } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
26572660 // RULE 5: (solve of height)
2658  topValue = top.calcValue(containerHeight);
2659  heightValue = max(0, availableSpace - (topValue + bottom.calcValue(containerHeight)));
2660  } else if (!topIsAuto && !heightIsAuto && bottomIsAuto) {
 2661 logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
 2662 logicalHeightValue = max(0, availableSpace - (logicalTopValue + logicalBottom.calcValue(containerLogicalHeight)));
 2663 } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsAuto) {
26612664 // RULE 6: (no need solve of bottom)
2662  heightValue = computeContentBoxLogicalHeight(h.calcValue(containerHeight));
2663  topValue = top.calcValue(containerHeight);
 2665 logicalHeightValue = computeContentBoxLogicalHeight(logicalHeightLength.calcValue(containerLogicalHeight));
 2666 logicalTopValue = logicalTop.calcValue(containerLogicalHeight);
26642667 }
26652668 }
26662669
 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
26672673 // 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 }
26692690}
26702691
26712692void RenderBox::computePositionedLogicalWidthReplaced()
79493

Source/WebCore/rendering/RenderBox.h

@@private:
434434 int containerLogicalWidth, int bordersPlusPadding,
435435 Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight,
436436 int& logicalWidthValue, int& marginLogicalLeftValue, int& marginLogicalRightValue, int& logicalLeftPos);
437  void computePositionedLogicalHeightUsing(Length height, const RenderBoxModelObject* cb,
438  int containerHeight, int bordersPlusPadding,
439  Length top, Length bottom, Length marginTop, Length marginBottom,
440  int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos);
 437 void computePositionedLogicalHeightUsing(Length logicalHeight, const RenderBoxModelObject* containerBlock,
 438 int containerLogicalHeight, int bordersPlusPadding,
 439 Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
 440 int& logicalHeightValue, int& marginLogicalTopValue, int& marginLogicalBottomValue, int& logicalTopPos);
441441
442442 void computePositionedLogicalHeightReplaced();
443443 void computePositionedLogicalWidthReplaced();
79490