Title: [145391] trunk/Source/WebCore
Revision
145391
Author
hy...@apple.com
Date
2013-03-11 13:00:37 -0700 (Mon, 11 Mar 2013)

Log Message

Vertical writing doesn't work with form controls.
https://bugs.webkit.org/show_bug.cgi?id=70211

Reviewed by Simon Fraser.

This is just some basic plumbing work to make textfields and
textareas work with vertical writing modes. This patch leaves the
html.css override alone, so authors can't enable vertical
writing yet.
        
The changes consist of converting uses of x/y/width/height to
logicalLeft/Top/Width/Height.
      
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::paddingLogicalLeft):
(WebCore::RenderBoxModelObject::paddingLogicalRight):
(RenderBoxModelObject):
(WebCore::RenderBoxModelObject::marginLogicalHeight):
(WebCore::RenderBoxModelObject::marginLogicalWidth):
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::computeControlLogicalHeight):
(WebCore::RenderSearchField::computeLogicalHeightLimit):
(WebCore::RenderSearchField::centerContainerIfNeeded):
* rendering/RenderSearchField.h:
(RenderSearchField):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::textBlockLogicalHeight):
(WebCore::RenderTextControl::textBlockLogicalWidth):
(WebCore::RenderTextControl::computeLogicalHeight):
(WebCore::RenderTextControl::computeIntrinsicLogicalWidths):
(WebCore::RenderTextControl::computePreferredLogicalWidths):
* rendering/RenderTextControl.h:
(RenderTextControl):
* rendering/RenderTextControlMultiLine.cpp:
(WebCore::RenderTextControlMultiLine::preferredContentLogicalWidth):
(WebCore::RenderTextControlMultiLine::computeControlLogicalHeight):
(WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
* rendering/RenderTextControlMultiLine.h:
(RenderTextControlMultiLine):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::paint):
(WebCore::RenderTextControlSingleLine::computeLogicalHeightLimit):
(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::styleDidChange):
(WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
(WebCore::RenderTextControlSingleLine::computeControlLogicalHeight):
(WebCore::RenderTextControlSingleLine::createInnerTextStyle):
* rendering/RenderTextControlSingleLine.h:
(RenderTextControlSingleLine):
* rendering/style/RenderStyle.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145390 => 145391)


--- trunk/Source/WebCore/ChangeLog	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/ChangeLog	2013-03-11 20:00:37 UTC (rev 145391)
@@ -1,3 +1,57 @@
+2013-03-11  David Hyatt  <hy...@apple.com>
+
+        Vertical writing doesn't work with form controls.
+        https://bugs.webkit.org/show_bug.cgi?id=70211
+
+        Reviewed by Simon Fraser.
+
+        This is just some basic plumbing work to make textfields and
+        textareas work with vertical writing modes. This patch leaves the
+        html.css override alone, so authors can't enable vertical
+        writing yet.
+        
+        The changes consist of converting uses of x/y/width/height to
+        logicalLeft/Top/Width/Height.
+      
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::paddingLogicalLeft):
+        (WebCore::RenderBoxModelObject::paddingLogicalRight):
+        (RenderBoxModelObject):
+        (WebCore::RenderBoxModelObject::marginLogicalHeight):
+        (WebCore::RenderBoxModelObject::marginLogicalWidth):
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::computeControlLogicalHeight):
+        (WebCore::RenderSearchField::computeLogicalHeightLimit):
+        (WebCore::RenderSearchField::centerContainerIfNeeded):
+        * rendering/RenderSearchField.h:
+        (RenderSearchField):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::textBlockLogicalHeight):
+        (WebCore::RenderTextControl::textBlockLogicalWidth):
+        (WebCore::RenderTextControl::computeLogicalHeight):
+        (WebCore::RenderTextControl::computeIntrinsicLogicalWidths):
+        (WebCore::RenderTextControl::computePreferredLogicalWidths):
+        * rendering/RenderTextControl.h:
+        (RenderTextControl):
+        * rendering/RenderTextControlMultiLine.cpp:
+        (WebCore::RenderTextControlMultiLine::preferredContentLogicalWidth):
+        (WebCore::RenderTextControlMultiLine::computeControlLogicalHeight):
+        (WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
+        * rendering/RenderTextControlMultiLine.h:
+        (RenderTextControlMultiLine):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::paint):
+        (WebCore::RenderTextControlSingleLine::computeLogicalHeightLimit):
+        (WebCore::RenderTextControlSingleLine::layout):
+        (WebCore::RenderTextControlSingleLine::styleDidChange):
+        (WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
+        (WebCore::RenderTextControlSingleLine::computeControlLogicalHeight):
+        (WebCore::RenderTextControlSingleLine::createInnerTextStyle):
+        * rendering/RenderTextControlSingleLine.h:
+        (RenderTextControlSingleLine):
+        * rendering/style/RenderStyle.h:
+
 2013-03-11  Tim Horton  <timothy_hor...@apple.com>
 
         TiledBacking scrolling coverage can be unfairly limited for clients who do scrolling outside the web view

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -133,6 +133,9 @@
     LayoutUnit borderLogicalLeft() const { return style()->isHorizontalWritingMode() ? borderLeft() : borderTop(); }
     LayoutUnit borderLogicalRight() const { return style()->isHorizontalWritingMode() ? borderRight() : borderBottom(); }
 
+    LayoutUnit paddingLogicalLeft() const { return style()->isHorizontalWritingMode() ? paddingLeft() : paddingTop(); }
+    LayoutUnit paddingLogicalRight() const { return style()->isHorizontalWritingMode() ? paddingRight() : paddingBottom(); }
+    
     virtual LayoutUnit marginTop() const = 0;
     virtual LayoutUnit marginBottom() const = 0;
     virtual LayoutUnit marginLeft() const = 0;
@@ -143,6 +146,8 @@
     virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const = 0;
     LayoutUnit marginHeight() const { return marginTop() + marginBottom(); }
     LayoutUnit marginWidth() const { return marginLeft() + marginRight(); }
+    LayoutUnit marginLogicalHeight() const { return marginBefore() + marginAfter(); }
+    LayoutUnit marginLogicalWidth() const { return marginStart() + marginEnd(); }
 
     bool hasInlineDirectionBordersPaddingOrMargin() const { return hasInlineDirectionBordersOrPadding() || marginStart()|| marginEnd(); }
     bool hasInlineDirectionBordersOrPadding() const { return borderStart() || borderEnd() || paddingStart()|| paddingEnd(); }

Modified: trunk/Source/WebCore/rendering/RenderSearchField.cpp (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderSearchField.cpp	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderSearchField.cpp	2013-03-11 20:00:37 UTC (rev 145391)
@@ -147,19 +147,19 @@
         m_searchPopup->popupMenu()->hide();
 }
 
-LayoutUnit RenderSearchField::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
+LayoutUnit RenderSearchField::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
     HTMLElement* resultsButton = resultsButtonElement();
     if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) {
         resultsRenderer->updateLogicalHeight();
-        nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingHeight() + resultsRenderer->marginHeight());
-        lineHeight = max(lineHeight, resultsRenderer->height());
+        nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingLogicalHeight() + resultsRenderer->marginLogicalHeight());
+        lineHeight = max(lineHeight, resultsRenderer->logicalHeight());
     }
     HTMLElement* cancelButton = cancelButtonElement();
     if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0) {
         cancelRenderer->updateLogicalHeight();
-        nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingHeight() + cancelRenderer->marginHeight());
-        lineHeight = max(lineHeight, cancelRenderer->height());
+        nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingLogicalHeight() + cancelRenderer->marginLogicalHeight());
+        lineHeight = max(lineHeight, cancelRenderer->logicalHeight());
     }
 
     return lineHeight + nonContentHeight;
@@ -363,9 +363,9 @@
     return widget.release();
 }
 
-LayoutUnit RenderSearchField::computeHeightLimit() const
+LayoutUnit RenderSearchField::computeLogicalHeightLimit() const
 {
-    return height();
+    return logicalHeight();
 }
 
 void RenderSearchField::centerContainerIfNeeded(RenderBox* containerRenderer) const
@@ -373,13 +373,13 @@
     if (!containerRenderer)
         return;
 
-    if (containerRenderer->height() <= contentHeight())
+    if (containerRenderer->logicalHeight() <= contentLogicalHeight())
         return;
 
     // A quirk for find-in-page box on Safari Windows.
     // http://webkit.org/b/63157
-    LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
-    containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    LayoutUnit logicalHeightDiff = containerRenderer->logicalHeight() - contentLogicalHeight();
+    containerRenderer->setLogicalTop(containerRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
 }
 
 }

Modified: trunk/Source/WebCore/rendering/RenderSearchField.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderSearchField.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderSearchField.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -47,8 +47,8 @@
 
 private:
     virtual void centerContainerIfNeeded(RenderBox*) const OVERRIDE;
-    virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
-    virtual LayoutUnit computeHeightLimit() const OVERRIDE;
+    virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
+    virtual LayoutUnit computeLogicalHeightLimit() const OVERRIDE;
     virtual void updateFromElement() OVERRIDE;
     EVisibility visibilityForCancelButton() const;
     const AtomicString& autosaveName() const;

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-03-11 20:00:37 UTC (rev 145391)
@@ -101,19 +101,19 @@
         textBlockStyle->setColor(theme()->disabledTextColor(textBlockStyle->visitedDependentColor(CSSPropertyColor), startStyle->visitedDependentColor(CSSPropertyBackgroundColor)));
 }
 
-int RenderTextControl::textBlockHeight() const
+int RenderTextControl::textBlockLogicalHeight() const
 {
-    return height() - borderAndPaddingHeight();
+    return logicalHeight() - borderAndPaddingLogicalHeight();
 }
 
-int RenderTextControl::textBlockWidth() const
+int RenderTextControl::textBlockLogicalWidth() const
 {
     Element* innerText = innerTextElement();
     ASSERT(innerText);
 
-    LayoutUnit unitWidth = width() - borderAndPaddingWidth();
+    LayoutUnit unitWidth = logicalWidth() - borderAndPaddingLogicalWidth();
     if (innerText->renderer())
-        unitWidth -= innerText->renderBox()->paddingLeft() + innerText->renderBox()->paddingRight();
+        unitWidth -= innerText->renderBox()->paddingStart() + innerText->renderBox()->paddingEnd();
 
     return unitWidth;
 }
@@ -148,10 +148,11 @@
     ASSERT(innerText);
     if (RenderBox* innerTextBox = innerText->renderBox()) {
         LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
-        logicalHeight = computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight();
+        logicalHeight = computeControlLogicalHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight();
 
         // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
-        if (style()->overflowX() == OSCROLL ||  (style()->overflowX() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap))
+        if ((isHorizontalWritingMode() && (style()->overflowX() == OSCROLL ||  (style()->overflowX() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap)))
+            || (!isHorizontalWritingMode() && (style()->overflowY() == OSCROLL ||  (style()->overflowY() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap))))
             logicalHeight += scrollbarThickness();
     }
 
@@ -256,10 +257,10 @@
 {
     // Use average character width. Matches IE.
     AtomicString family = style()->font().family().family();
-    maxLogicalWidth = preferredContentWidth(const_cast<RenderTextControl*>(this)->getAvgCharWidth(family));
+    maxLogicalWidth = preferredContentLogicalWidth(const_cast<RenderTextControl*>(this)->getAvgCharWidth(family));
     if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
-        maxLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
-    if (!style()->width().isPercent())
+        maxLogicalWidth += innerTextRenderBox->paddingStart() + innerTextRenderBox->paddingEnd();
+    if (!style()->logicalWidth().isPercent())
         minLogicalWidth = maxLogicalWidth;
 }
 
@@ -270,22 +271,22 @@
     m_minPreferredLogicalWidth = 0;
     m_maxPreferredLogicalWidth = 0;
 
-    if (style()->width().isFixed() && style()->width().value() >= 0)
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
+    if (style()->logicalWidth().isFixed() && style()->logicalWidth().value() >= 0)
+        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->logicalWidth().value());
     else
         computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
 
-    if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
-        m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
-        m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
+    if (style()->logicalMinWidth().isFixed() && style()->logicalMinWidth().value() > 0) {
+        m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMinWidth().value()));
+        m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMinWidth().value()));
     }
 
-    if (style()->maxWidth().isFixed()) {
-        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
-        m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
+    if (style()->logicalMaxWidth().isFixed()) {
+        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMaxWidth().value()));
+        m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMaxWidth().value()));
     }
 
-    LayoutUnit toAdd = borderAndPaddingWidth();
+    LayoutUnit toAdd = borderAndPaddingLogicalWidth();
 
     m_minPreferredLogicalWidth += toAdd;
     m_maxPreferredLogicalWidth += toAdd;

Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControl.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -50,15 +50,15 @@
 
     void hitInnerTextElement(HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
 
-    int textBlockWidth() const;
-    int textBlockHeight() const;
+    int textBlockLogicalWidth() const;
+    int textBlockLogicalHeight() const;
 
     float scaleEmToUnits(int x) const;
 
     static bool hasValidAvgCharWidth(AtomicString family);
     virtual float getAvgCharWidth(AtomicString family);
-    virtual LayoutUnit preferredContentWidth(float charWidth) const = 0;
-    virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const = 0;
+    virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const = 0;
+    virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const = 0;
     virtual RenderStyle* textBaseStyle() const = 0;
 
     virtual void updateFromElement();

Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2013-03-11 20:00:37 UTC (rev 145391)
@@ -65,13 +65,13 @@
     return RenderTextControl::getAvgCharWidth(family);
 }
 
-LayoutUnit RenderTextControlMultiLine::preferredContentWidth(float charWidth) const
+LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWidth) const
 {
     int factor = static_cast<HTMLTextAreaElement*>(node())->cols();
     return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
 }
 
-LayoutUnit RenderTextControlMultiLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
+LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
     return lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows() + nonContentHeight;
 }
@@ -104,7 +104,7 @@
     if (!placeholderRenderer->isBox())
         return placeholderRenderer;
     RenderBox* placeholderBox = toRenderBox(placeholderRenderer);
-    placeholderBox->style()->setWidth(Length(contentWidth() - placeholderBox->borderAndPaddingWidth(), Fixed));
+    placeholderBox->style()->setLogicalWidth(Length(contentLogicalWidth() - placeholderBox->borderAndPaddingLogicalWidth(), Fixed));
     placeholderBox->layoutIfNeeded();
     placeholderBox->setX(borderLeft() + paddingLeft());
     placeholderBox->setY(borderTop() + paddingTop());

Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -37,8 +37,8 @@
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
 
     virtual float getAvgCharWidth(AtomicString family);
-    virtual LayoutUnit preferredContentWidth(float charWidth) const;
-    virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
+    virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const;
+    virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
 
     virtual RenderStyle* textBaseStyle() const;

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2013-03-11 20:00:37 UTC (rev 145391)
@@ -52,7 +52,7 @@
 RenderTextControlSingleLine::RenderTextControlSingleLine(Element* element)
     : RenderTextControl(element)
     , m_shouldDrawCapsLockIndicator(false)
-    , m_desiredInnerTextHeight(-1)
+    , m_desiredInnerTextLogicalHeight(-1)
 {
     ASSERT(element->isHTMLElement());
     ASSERT(element->toInputElement());
@@ -80,8 +80,11 @@
     if (paintInfo.phase == PaintPhaseBlockBackground && m_shouldDrawCapsLockIndicator) {
         LayoutRect contentsRect = contentBoxRect();
 
-        // Center vertically like the text.
-        contentsRect.setY((height() - contentsRect.height()) / 2);
+        // Center in the block progression direction.
+        if (isHorizontalWritingMode())
+            contentsRect.setY((height() - contentsRect.height()) / 2);
+        else
+            contentsRect.setX((width() - contentsRect.width()) / 2);
 
         // Convert the rect into the coords used for painting the content
         contentsRect.moveBy(paintOffset + location());
@@ -89,9 +92,9 @@
     }
 }
 
-LayoutUnit RenderTextControlSingleLine::computeHeightLimit() const
+LayoutUnit RenderTextControlSingleLine::computeLogicalHeightLimit() const
 {
-    return containerElement() ? contentHeight() : height();
+    return containerElement() ? contentLogicalHeight() : logicalHeight();
 }
 
 void RenderTextControlSingleLine::layout()
@@ -114,9 +117,9 @@
 
     // To ensure consistency between layouts, we need to reset any conditionally overriden height.
     if (innerTextRenderer)
-        innerTextRenderer->style()->setHeight(Length(Auto));
+        innerTextRenderer->style()->setLogicalHeight(Length(Auto));
     if (innerBlockRenderer)
-        innerBlockRenderer->style()->setHeight(Length(Auto));
+        innerBlockRenderer->style()->setLogicalHeight(Length(Auto));
 
     RenderBlock::layoutBlock(false);
 
@@ -124,40 +127,41 @@
     RenderBox* containerRenderer = container ? container->renderBox() : 0;
 
     // Set the text block height
-    LayoutUnit desiredHeight = textBlockHeight();
-    LayoutUnit heightLimit = computeHeightLimit();
-    if (innerTextRenderer && innerTextRenderer->height() > heightLimit) {
-        if (desiredHeight != innerTextRenderer->height())
+    LayoutUnit desiredLogicalHeight = textBlockLogicalHeight();
+    LayoutUnit logicalHeightLimit = computeLogicalHeightLimit();
+    if (innerTextRenderer && innerTextRenderer->logicalHeight() > logicalHeightLimit) {
+        if (desiredLogicalHeight != innerTextRenderer->logicalHeight())
             setNeedsLayout(true, MarkOnlyThis);
 
-        m_desiredInnerTextHeight = desiredHeight;
+        m_desiredInnerTextLogicalHeight = desiredLogicalHeight;
+
         if (innerTextRenderer)
-            innerTextRenderer->style()->setHeight(Length(desiredHeight, Fixed));
+            innerTextRenderer->style()->setLogicalHeight(Length(desiredLogicalHeight, Fixed));
         if (innerBlockRenderer)
-            innerBlockRenderer->style()->setHeight(Length(desiredHeight, Fixed));
+            innerBlockRenderer->style()->setLogicalHeight(Length(desiredLogicalHeight, Fixed));
     }
     // The container might be taller because of decoration elements.
     if (containerRenderer) {
         containerRenderer->layoutIfNeeded();
-        LayoutUnit containerHeight = containerRenderer->height();
-        if (containerHeight > heightLimit) {
-            containerRenderer->style()->setHeight(Length(heightLimit, Fixed));
+        LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight();
+        if (containerLogicalHeight > logicalHeightLimit) {
+            containerRenderer->style()->setLogicalHeight(Length(logicalHeightLimit, Fixed));
             setNeedsLayout(true, MarkOnlyThis);
-        } else if (containerRenderer->height() < contentHeight()) {
-            containerRenderer->style()->setHeight(Length(contentHeight(), Fixed));
+        } else if (containerRenderer->logicalHeight() < contentLogicalHeight()) {
+            containerRenderer->style()->setLogicalHeight(Length(contentLogicalHeight(), Fixed));
             setNeedsLayout(true, MarkOnlyThis);
         } else
-            containerRenderer->style()->setHeight(Length(containerHeight, Fixed));
+            containerRenderer->style()->setLogicalHeight(Length(containerLogicalHeight, Fixed));
     }
 
     // If we need another layout pass, we have changed one of children's height so we need to relayout them.
     if (needsLayout())
         RenderBlock::layoutBlock(true);
 
-    // Center the child block vertically
-    if (!container && innerTextRenderer && innerTextRenderer->height() != contentHeight()) {
-        LayoutUnit heightDiff = innerTextRenderer->height() - contentHeight();
-        innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    // Center the child block in the block progression direction (vertical centering for horizontal text fields).
+    if (!container && innerTextRenderer && innerTextRenderer->height() != contentLogicalHeight()) {
+        LayoutUnit logicalHeightDiff = innerTextRenderer->logicalHeight() - contentLogicalHeight();
+        innerTextRenderer->setLogicalTop(innerTextRenderer->logicalTop() - (logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
     } else
         centerContainerIfNeeded(containerRenderer);
 
@@ -165,10 +169,10 @@
     if (RenderBox* innerSpinBox = innerSpinButtonElement() ? innerSpinButtonElement()->renderBox() : 0) {
         RenderBox* parentBox = innerSpinBox->parentBox();
         if (containerRenderer && !containerRenderer->style()->isLeftToRightDirection())
-            innerSpinBox->setLocation(LayoutPoint(-paddingLeft(), -paddingTop()));
+            innerSpinBox->setLogicalLocation(LayoutPoint(-paddingLogicalLeft(), -paddingBefore()));
         else
-            innerSpinBox->setLocation(LayoutPoint(parentBox->width() - innerSpinBox->width() + paddingRight(), -paddingTop()));
-        innerSpinBox->setHeight(height() - borderTop() - borderBottom());
+            innerSpinBox->setLogicalLocation(LayoutPoint(parentBox->logicalWidth() - innerSpinBox->logicalWidth() + paddingLogicalRight(), -paddingBefore()));
+        innerSpinBox->setLogicalHeight(logicalHeight() - borderBefore() - borderAfter());
     }
 
     HTMLElement* placeholderElement = inputElement()->placeholderElement();
@@ -223,7 +227,7 @@
 
 void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
-    m_desiredInnerTextHeight = -1;
+    m_desiredInnerTextLogicalHeight = -1;
     RenderTextControl::styleDidChange(diff, oldStyle);
 
     // We may have set the width and the height in the old style in layout().
@@ -295,7 +299,7 @@
     return RenderTextControl::getAvgCharWidth(family);
 }
 
-LayoutUnit RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
+LayoutUnit RenderTextControlSingleLine::preferredContentLogicalWidth(float charWidth) const
 {
     int factor;
     bool includesDecoration = inputElement()->sizeShouldIncludeDecoration(factor);
@@ -322,18 +326,17 @@
     if (includesDecoration) {
         HTMLElement* spinButton = innerSpinButtonElement();
         if (RenderBox* spinRenderer = spinButton ? spinButton->renderBox() : 0) {
-            result += spinRenderer->borderLeft() + spinRenderer->borderRight() +
-                  spinRenderer->paddingLeft() + spinRenderer->paddingRight();
-            // Since the width of spinRenderer is not calculated yet, spinRenderer->width() returns 0.
-            // So computedStyle()->width() is used instead.
-            result += spinButton->computedStyle()->width().value();
+            result += spinRenderer->borderAndPaddingLogicalWidth();
+            // Since the width of spinRenderer is not calculated yet, spinRenderer->logicalWidth() returns 0.
+            // So computedStyle()->logicalWidth() is used instead.
+            result += spinButton->computedStyle()->logicalWidth().value();
         }
     }
 
     return result;
 }
 
-LayoutUnit RenderTextControlSingleLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
+LayoutUnit RenderTextControlSingleLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
     return lineHeight + nonContentHeight;
 }
@@ -355,8 +358,8 @@
     textBlockStyle->setOverflowY(OHIDDEN);
     textBlockStyle->setTextOverflow(textShouldBeTruncated() ? TextOverflowEllipsis : TextOverflowClip);
 
-    if (m_desiredInnerTextHeight >= 0)
-        textBlockStyle->setHeight(Length(m_desiredInnerTextHeight, Fixed));
+    if (m_desiredInnerTextLogicalHeight >= 0)
+        textBlockStyle->setLogicalHeight(Length(m_desiredInnerTextLogicalHeight, Fixed));
     // Do not allow line-height to be smaller than our default.
     if (textBlockStyle->fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes))
         textBlockStyle->setLineHeight(RenderStyle::initialLineHeight());

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -42,7 +42,7 @@
 
 protected:
     virtual void centerContainerIfNeeded(RenderBox*) const { }
-    virtual LayoutUnit computeHeightLimit() const;
+    virtual LayoutUnit computeLogicalHeightLimit() const;
     HTMLElement* containerElement() const;
     HTMLElement* innerBlockElement() const;
     HTMLInputElement* inputElement() const;
@@ -72,8 +72,8 @@
 
     int textBlockWidth() const;
     virtual float getAvgCharWidth(AtomicString family);
-    virtual LayoutUnit preferredContentWidth(float charWidth) const;
-    virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
+    virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const;
+    virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
     
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
@@ -84,7 +84,7 @@
     HTMLElement* innerSpinButtonElement() const;
 
     bool m_shouldDrawCapsLockIndicator;
-    LayoutUnit m_desiredInnerTextHeight;
+    LayoutUnit m_desiredInnerTextLogicalHeight;
 };
 
 inline HTMLElement* RenderTextControlSingleLine::containerElement() const

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (145390 => 145391)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2013-03-11 19:59:07 UTC (rev 145390)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2013-03-11 20:00:37 UTC (rev 145391)
@@ -983,6 +983,24 @@
     void setWidth(Length v) { SET_VAR(m_box, m_width, v); }
     void setHeight(Length v) { SET_VAR(m_box, m_height, v); }
 
+    void setLogicalWidth(Length v)
+    {
+        if (isHorizontalWritingMode()) {
+            SET_VAR(m_box, m_width, v);
+        } else {
+            SET_VAR(m_box, m_height, v);
+        }
+    }
+
+    void setLogicalHeight(Length v)
+    {
+        if (isHorizontalWritingMode()) {
+            SET_VAR(m_box, m_height, v);
+        } else {
+            SET_VAR(m_box, m_width, v);
+        }
+    }
+
     void setMinWidth(Length v) { SET_VAR(m_box, m_minWidth, v); }
     void setMaxWidth(Length v) { SET_VAR(m_box, m_maxWidth, v); }
     void setMinHeight(Length v) { SET_VAR(m_box, m_minHeight, v); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to