Commit 8aa63105 authored by hyatt's avatar hyatt

Land box-sizing support and change button to work correctly

	with it.

	Also stop honoring of font properties on <input> if
	Aqua is enabled.  If you allow bold, but don't honor size, then
	you end up with poorly rendered buttons on cnn.com (box-sizing
	made this apparent, since the buttons got smaller).

	Fix the clipping code for button content to actually work. :)
	Function needed to be designated virtual in order to get
	called.

        Reviewed by darin

	fast/box-sizing/box-sizing.html is the new test case.

        * ChangeLog:
        * WebCore.xcodeproj/project.pbxproj:
        * khtml/rendering/render_block.cpp:
        (khtml::RenderBlock::calcMinMaxWidth):
        * khtml/rendering/render_block.h:
        * khtml/rendering/render_box.cpp:
        (RenderBox::calcBorderBoxWidth):
        (RenderBox::calcBorderBoxHeight):
        (RenderBox::calcContentBoxWidth):
        (RenderBox::calcContentBoxHeight):
        (RenderBox::calcWidth):
        (RenderBox::calcWidthUsing):
        (RenderBox::calcHeight):
        (RenderBox::calcHeightUsing):
        (RenderBox::calcPercentageHeight):
        (RenderBox::calcReplacedWidth):
        (RenderBox::calcReplacedWidthUsing):
        (RenderBox::calcReplacedHeightUsing):
        (RenderBox::availableHeightUsing):
        (RenderBox::calcAbsoluteHorizontalValues):
        (RenderBox::calcAbsoluteVerticalValues):
        * khtml/rendering/render_box.h:
        * khtml/rendering/render_button.cpp:
        (khtml::RenderButton::paintObject):
        * khtml/rendering/render_button.h:
        * khtml/rendering/render_flexbox.cpp:
        (khtml::RenderFlexibleBox::calcMinMaxWidth):
        * khtml/rendering/render_theme_mac.mm:
        (khtml::RenderThemeMac::setFontFromControlSize):
        (khtml::RenderThemeMac::adjustButtonStyle):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a25eb10f
2005-10-25 David Hyatt <hyatt@apple.com>
Land box-sizing support and change button to work correctly
with it.
Also stop honoring of font properties on <input> if
Aqua is enabled. If you allow bold, but don't honor size, then
you end up with poorly rendered buttons on cnn.com (box-sizing
made this apparent, since the buttons got smaller).
Fix the clipping code for button content to actually work. :)
Function needed to be designated virtual in order to get
called.
Reviewed by darin
fast/box-sizing/box-sizing.html is the new test case.
* ChangeLog:
* WebCore.xcodeproj/project.pbxproj:
* khtml/rendering/render_block.cpp:
(khtml::RenderBlock::calcMinMaxWidth):
* khtml/rendering/render_block.h:
* khtml/rendering/render_box.cpp:
(RenderBox::calcBorderBoxWidth):
(RenderBox::calcBorderBoxHeight):
(RenderBox::calcContentBoxWidth):
(RenderBox::calcContentBoxHeight):
(RenderBox::calcWidth):
(RenderBox::calcWidthUsing):
(RenderBox::calcHeight):
(RenderBox::calcHeightUsing):
(RenderBox::calcPercentageHeight):
(RenderBox::calcReplacedWidth):
(RenderBox::calcReplacedWidthUsing):
(RenderBox::calcReplacedHeightUsing):
(RenderBox::availableHeightUsing):
(RenderBox::calcAbsoluteHorizontalValues):
(RenderBox::calcAbsoluteVerticalValues):
* khtml/rendering/render_box.h:
* khtml/rendering/render_button.cpp:
(khtml::RenderButton::paintObject):
* khtml/rendering/render_button.h:
* khtml/rendering/render_flexbox.cpp:
(khtml::RenderFlexibleBox::calcMinMaxWidth):
* khtml/rendering/render_theme_mac.mm:
(khtml::RenderThemeMac::setFontFromControlSize):
(khtml::RenderThemeMac::adjustButtonStyle):
2005-10-25 Vicki Murley <vicki@apple.com>
Reviewed by Hyatt.
......@@ -2293,7 +2293,6 @@
E1EE773908F1086C00166870 /* WebCoreTextDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1EE773A08F1086C00166870 /* WebCoreTextDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */; };
ED048ABC0833F132006E1E67 /* textAreaResizeCorner.tiff in Resources */ = {isa = PBXBuildFile; fileRef = ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */; };
F99FC1D0090473A700712A54 /* SharedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = F9A7A992090467BE00BD59C9 /* SharedPtr.h */; };
/* End PBXBuildFile section */
/* Begin PBXBuildRule section */
......@@ -2678,19 +2678,19 @@ void RenderBlock::calcMinMaxWidth()
if (style()->width().isFixed() && style()->width().value > 0) {
if (isTableCell())
m_maxWidth = kMax(m_minWidth, style()->width().value);
m_maxWidth = kMax(m_minWidth, calcContentBoxWidth(style()->width().value));
else
m_minWidth = m_maxWidth = style()->width().value;
m_minWidth = m_maxWidth = calcContentBoxWidth(style()->width().value);
}
if (style()->minWidth().isFixed() && style()->minWidth().value > 0) {
m_maxWidth = kMax(m_maxWidth, style()->minWidth().value);
m_minWidth = kMax(m_minWidth, style()->minWidth().value);
m_maxWidth = kMax(m_maxWidth, calcContentBoxWidth(style()->minWidth().value));
m_minWidth = kMax(m_minWidth, calcContentBoxWidth(style()->minWidth().value));
}
if (style()->maxWidth().isFixed() && style()->maxWidth().value != UNDEFINED) {
m_maxWidth = kMin(m_maxWidth, style()->maxWidth().value);
m_minWidth = kMin(m_minWidth, style()->maxWidth().value);
m_maxWidth = kMin(m_maxWidth, calcContentBoxWidth(style()->maxWidth().value));
m_minWidth = kMin(m_minWidth, calcContentBoxWidth(style()->maxWidth().value));
}
int toAdd = 0;
......
......@@ -140,7 +140,7 @@ public:
// end bidi.cpp functions
virtual void paint(PaintInfo& i, int tx, int ty);
void paintObject(PaintInfo& i, int tx, int ty);
virtual void paintObject(PaintInfo& i, int tx, int ty);
void paintFloats(PaintInfo& i, int _tx, int _ty, bool paintSelection = false);
void paintChildren(PaintInfo& i, int _tx, int _ty);
void paintEllipsisBoxes(PaintInfo& i, int _tx, int _ty);
......
......@@ -212,6 +212,36 @@ int RenderBox::height() const
return m_height;
}
int RenderBox::calcBorderBoxWidth(int w) const
{
int toAdd = borderLeft() + borderRight() + paddingLeft() + paddingRight();
if (style()->boxSizing() == CONTENT_BOX)
return w + toAdd;
return kMax(w, toAdd);
}
int RenderBox::calcBorderBoxHeight(int h) const
{
int toAdd = borderTop() + borderBottom() + paddingTop() + paddingBottom();
if (style()->boxSizing() == CONTENT_BOX)
return h + toAdd;
return kMax(h, toAdd);
}
int RenderBox::calcContentBoxWidth(int w) const
{
if (style()->boxSizing() == BORDER_BOX)
w -= (borderLeft() + borderRight() + paddingLeft() + paddingRight());
return kMax(0, w);
}
int RenderBox::calcContentBoxHeight(int h) const
{
if (style()->boxSizing() == BORDER_BOX)
h -= (borderTop() + borderBottom() + paddingTop() + paddingBottom());
return kMax(0, h);
}
// Hit Testing
bool RenderBox::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
HitTestAction hitTestAction)
......@@ -861,25 +891,20 @@ void RenderBox::calcWidth()
m_marginLeft = 0;
m_marginRight = 0;
if (isInline() && !isInlineBlockOrInlineTable())
{
if (isInline() && !isInlineBlockOrInlineTable()) {
// just calculate margins
m_marginLeft = ml.minWidth(cw);
m_marginRight = mr.minWidth(cw);
if (treatAsReplaced)
{
m_width = w.width(cw);
m_width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
if(m_width < m_minWidth) m_width = m_minWidth;
if (treatAsReplaced) {
m_width = w.width(cw) + borderLeft() + borderRight() + paddingLeft() + paddingRight();
m_width = kMax(m_width, m_minWidth);
}
return;
}
else {
LengthType widthType, minWidthType, maxWidthType;
if (treatAsReplaced) {
m_width = w.width(cw);
m_width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
m_width = w.width(cw) + borderLeft() + borderRight() + paddingLeft() + paddingRight();
widthType = w.type;
} else {
m_width = calcWidthUsing(Width, cw, widthType);
......@@ -944,17 +969,12 @@ int RenderBox::calcWidthUsing(WidthType widthType, int cw, LengthType& lengthTyp
if (cw) width = cw - marginLeft - marginRight;
if (sizesToIntrinsicWidth(widthType)) {
if (width < m_minWidth)
width = m_minWidth;
if (width > m_maxWidth)
width = m_maxWidth;
width = kMax(width, m_minWidth);
width = kMin(width, m_maxWidth);
}
}
else
{
width = w.width(cw);
width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
}
width = calcBorderBoxWidth(w.width(cw));
return width;
}
......@@ -1091,8 +1111,10 @@ void RenderBox::calcHeight()
}
else
// The only times we don't check min/max height are when a fixed length has
// been given as an override. Just use that.
height = h.value + borderTop() + paddingTop() + borderBottom() + paddingBottom();
// been given as an override. Just use that. The value has already been adjusted
// for box-sizing.
height = h.value + borderTop() + borderBottom() + paddingTop() + paddingBottom();
m_height = height;
}
......@@ -1129,7 +1151,7 @@ int RenderBox::calcHeightUsing(const Length& h)
else if (h.isPercent())
height = calcPercentageHeight(h);
if (height != -1) {
height += borderTop() + paddingTop() + borderBottom() + paddingBottom();
height = calcBorderBoxHeight(height);
return height;
}
}
......@@ -1175,7 +1197,7 @@ int RenderBox::calcPercentageHeight(const Length& height)
// Otherwise we only use our percentage height if our containing block had a specified
// height.
else if (cb->style()->height().isFixed())
result = cb->style()->height().value;
result = cb->calcContentBoxHeight(cb->style()->height().value);
else if (cb->style()->height().isPercent())
// We need to recur and compute the percentage height for our containing block.
result = cb->calcPercentageHeight(cb->style()->height());
......@@ -1206,11 +1228,8 @@ int RenderBox::calcReplacedWidth() const
int minW = calcReplacedWidthUsing(MinWidth);
int maxW = style()->maxWidth().value == UNDEFINED ? width : calcReplacedWidthUsing(MaxWidth);
if (width > maxW)
width = maxW;
if (width < minW)
width = minW;
width = kMin(width, maxW);
width = kMax(width, minW);
return width;
}
......@@ -1227,14 +1246,11 @@ int RenderBox::calcReplacedWidthUsing(WidthType widthType) const
switch (w.type) {
case Fixed:
return w.value;
case Percent:
{
return calcContentBoxWidth(w.value);
case Percent: {
const int cw = containingBlockWidth();
if (cw > 0) {
int result = w.minWidth(cw);
return result;
}
if (cw > 0)
return calcContentBoxWidth(w.minWidth(cw));
}
// fall through
default:
......@@ -1270,7 +1286,7 @@ int RenderBox::calcReplacedHeightUsing(HeightType heightType) const
case Percent:
return availableHeightUsing(h);
case Fixed:
return h.value;
return calcContentBoxHeight(h.value);
default:
return intrinsicHeight();
};
......@@ -1284,7 +1300,7 @@ int RenderBox::availableHeight() const
int RenderBox::availableHeightUsing(const Length& h) const
{
if (h.isFixed())
return h.value;
return calcContentBoxHeight(h.value);
if (isCanvas())
return static_cast<const RenderCanvas*>(this)->viewportHeight();
......@@ -1292,12 +1308,11 @@ int RenderBox::availableHeightUsing(const Length& h) const
// We need to stop here, since we don't want to increase the height of the table
// artificially. We're going to rely on this cell getting expanded to some new
// height, and then when we lay out again we'll use the calculation below.
if (isTableCell() && (h.isAuto() || h.isPercent())) {
return overrideSize() - (borderLeft()+borderRight()+paddingLeft()+paddingRight());
}
if (isTableCell() && (h.isAuto() || h.isPercent()))
return overrideSize() - (borderLeft() + borderRight() + paddingLeft() + paddingRight());
if (h.isPercent())
return h.width(containingBlock()->availableHeight());
return calcContentBoxHeight(h.width(containingBlock()->availableHeight()));
return containingBlock()->availableHeight();
}
......@@ -1422,7 +1437,7 @@ void RenderBox::calcAbsoluteHorizontalValues(WidthType widthType, RenderObject*
width = style()->maxWidth();
if (!width.isAuto())
w = width.width(cw);
w = calcContentBoxWidth(width.width(cw));
else if (isReplaced())
w = intrinsicWidth();
......@@ -1597,7 +1612,7 @@ void RenderBox::calcAbsoluteVerticalValues(HeightType heightType, RenderObject*
h = ourHeight - pab;
else if (!height.isAuto())
{
h = height.width(ch);
h = calcContentBoxHeight(height.width(ch));
if (ourHeight - pab > h)
ourHeight = h + pab;
}
......
......@@ -83,6 +83,11 @@ public:
virtual QRect borderBox() const { return QRect(0, -borderTopExtra(), width(), height() + borderTopExtra() + borderBottomExtra()); }
int calcBorderBoxWidth(int w) const;
int calcBorderBoxHeight(int h) const;
int calcContentBoxWidth(int w) const;
int calcContentBoxHeight(int h) const;
// This method is now public so that centered objects like tables that are
// shifted right by left-aligned floats can recompute their left and
// right margins (so that they can remain centered after being
......
......@@ -97,7 +97,9 @@ void RenderButton::paintObject(PaintInfo& i, int _tx, int _ty)
{
// Push a clip.
if (m_inner && i.phase == PaintActionForeground) {
QRect clipRect(_tx + m_inner->xPos(), _ty + m_inner->yPos(), m_inner->width(), m_inner->height());
QRect clipRect(_tx + borderLeft() + paddingLeft(), _ty + borderTop() + paddingTop(), contentWidth(), contentHeight());
if (clipRect.width() == 0 || clipRect.height() == 0)
return;
clipRect = i.p->xForm(clipRect);
i.p->save();
i.p->addClip(clipRect);
......
......@@ -43,7 +43,7 @@ public:
virtual void setStyle(RenderStyle* style);
virtual void updateFromElement();
void paintObject(PaintInfo& i, int _tx, int _ty);
virtual void paintObject(PaintInfo& i, int _tx, int _ty);
virtual const char *renderName() const { return "RenderButton"; }
......
......@@ -220,16 +220,16 @@ void RenderFlexibleBox::calcMinMaxWidth()
if(m_maxWidth < m_minWidth) m_maxWidth = m_minWidth;
if (style()->width().isFixed() && style()->width().value > 0)
m_minWidth = m_maxWidth = style()->width().value;
m_minWidth = m_maxWidth = calcContentBoxWidth(style()->width().value);
if (style()->minWidth().isFixed() && style()->minWidth().value > 0) {
m_maxWidth = kMax(m_maxWidth, style()->minWidth().value);
m_minWidth = kMax(m_minWidth, style()->minWidth().value);
m_maxWidth = kMax(m_maxWidth, calcContentBoxWidth(style()->minWidth().value));
m_minWidth = kMax(m_minWidth, calcContentBoxWidth(style()->minWidth().value));
}
if (style()->maxWidth().isFixed() && style()->maxWidth().value != UNDEFINED) {
m_maxWidth = kMin(m_maxWidth, style()->maxWidth().value);
m_minWidth = kMin(m_minWidth, style()->maxWidth().value);
m_maxWidth = kMin(m_maxWidth, calcContentBoxWidth(style()->maxWidth().value));
m_minWidth = kMin(m_minWidth, calcContentBoxWidth(style()->maxWidth().value));
}
int toAdd = borderLeft() + borderRight() + paddingLeft() + paddingRight();
......
......@@ -204,7 +204,7 @@ void RenderThemeMac::setSizeFromFont(RenderStyle* style, const QSize* sizes) con
void RenderThemeMac::setFontFromControlSize(CSSStyleSelector* selector, RenderStyle* style, NSControlSize controlSize) const
{
FontDef fontDef(style->htmlFont().getFontDef());
FontDef fontDef;
fontDef.isAbsoluteSize = true;
fontDef.genericFamily = FontDef::eSansSerif;
......@@ -400,7 +400,6 @@ void RenderThemeMac::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle*
addIntrinsicMargins(style, controlSize);
// Whenever a button has a background or border specified, then appearance is disabled.
// FIXME: We need to support box-sizing properly on bordered buttons! They end up too big right now!
bool disableAppearance = style->hasBorder() || style->hasBackground();
if (!disableAppearance) {
if (style->appearance() == PushButtonAppearance) {
......@@ -420,11 +419,9 @@ void RenderThemeMac::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle*
// a reasonable control size, but once that control size is determined, we throw that font away and use the appropriate
// system font for the control size instead.
setFontFromControlSize(selector, style, controlSize);
} else {
} else
// Set a min-height so that we can't get smaller than the mini button.
// FIXME: Once we support box-sizing, we'll have to change this value to include the padding.
style->setMinHeight(Length(10, Fixed));
}
style->setMinHeight(Length(15, Fixed));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment