[webkit-changes] cvs commit: WebCore/khtml/rendering
render_block.cpp render_block.h render_box.cpp render_box.h
render_button.cpp render_button.h render_flexbox.cpp
render_theme_mac.mm
David
hyatt at opensource.apple.com
Tue Oct 25 13:54:30 PDT 2005
hyatt 05/10/25 13:54:29
Modified: . ChangeLog
WebCore.xcodeproj project.pbxproj
khtml/rendering render_block.cpp render_block.h
render_box.cpp render_box.h render_button.cpp
render_button.h render_flexbox.cpp
render_theme_mac.mm
Log:
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):
Revision Changes Path
1.284 +49 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.283
retrieving revision 1.284
diff -u -r1.283 -r1.284
--- ChangeLog 25 Oct 2005 20:49:28 -0000 1.283
+++ ChangeLog 25 Oct 2005 20:54:22 -0000 1.284
@@ -1,3 +1,52 @@
+2005-10-25 David Hyatt <hyatt at 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 at apple.com>
Reviewed by Hyatt.
1.38 +0 -1 WebCore/WebCore.xcodeproj/project.pbxproj
Index: project.pbxproj
===================================================================
RCS file: /cvs/root/WebCore/WebCore.xcodeproj/project.pbxproj,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- project.pbxproj 24 Oct 2005 06:31:22 -0000 1.37
+++ project.pbxproj 25 Oct 2005 20:54:24 -0000 1.38
@@ -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 */
1.212 +6 -6 WebCore/khtml/rendering/render_block.cpp
Index: render_block.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_block.cpp,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -r1.211 -r1.212
--- render_block.cpp 21 Oct 2005 22:49:21 -0000 1.211
+++ render_block.cpp 25 Oct 2005 20:54:27 -0000 1.212
@@ -2678,19 +2678,19 @@
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;
1.70 +1 -1 WebCore/khtml/rendering/render_block.h
Index: render_block.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_block.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- render_block.h 9 Aug 2005 20:58:27 -0000 1.69
+++ render_block.h 25 Oct 2005 20:54:27 -0000 1.70
@@ -140,7 +140,7 @@
// 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);
1.173 +57 -42 WebCore/khtml/rendering/render_box.cpp
Index: render_box.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_box.cpp,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -r1.172 -r1.173
--- render_box.cpp 22 Oct 2005 18:19:26 -0000 1.172
+++ render_box.cpp 25 Oct 2005 20:54:27 -0000 1.173
@@ -212,6 +212,36 @@
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 @@
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 @@
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 @@
}
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 @@
else if (h.isPercent())
height = calcPercentageHeight(h);
if (height != -1) {
- height += borderTop() + paddingTop() + borderBottom() + paddingBottom();
+ height = calcBorderBoxHeight(height);
return height;
}
}
@@ -1175,7 +1197,7 @@
// 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 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 @@
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 @@
case Percent:
return availableHeightUsing(h);
case Fixed:
- return h.value;
+ return calcContentBoxHeight(h.value);
default:
return intrinsicHeight();
};
@@ -1284,7 +1300,7 @@
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 @@
// 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 @@
width = style()->maxWidth();
if (!width.isAuto())
- w = width.width(cw);
+ w = calcContentBoxWidth(width.width(cw));
else if (isReplaced())
w = intrinsicWidth();
@@ -1597,7 +1612,7 @@
h = ourHeight - pab;
else if (!height.isAuto())
{
- h = height.width(ch);
+ h = calcContentBoxHeight(height.width(ch));
if (ourHeight - pab > h)
ourHeight = h + pab;
}
1.60 +5 -0 WebCore/khtml/rendering/render_box.h
Index: render_box.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_box.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- render_box.h 6 Oct 2005 00:53:56 -0000 1.59
+++ render_box.h 25 Oct 2005 20:54:28 -0000 1.60
@@ -83,6 +83,11 @@
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
1.4 +3 -1 WebCore/khtml/rendering/render_button.cpp
Index: render_button.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_button.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- render_button.cpp 24 Oct 2005 22:43:49 -0000 1.3
+++ render_button.cpp 25 Oct 2005 20:54:28 -0000 1.4
@@ -97,7 +97,9 @@
{
// 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);
1.3 +1 -1 WebCore/khtml/rendering/render_button.h
Index: render_button.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_button.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- render_button.h 22 Oct 2005 18:19:27 -0000 1.2
+++ render_button.h 25 Oct 2005 20:54:28 -0000 1.3
@@ -43,7 +43,7 @@
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"; }
1.28 +5 -5 WebCore/khtml/rendering/render_flexbox.cpp
Index: render_flexbox.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_flexbox.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- render_flexbox.cpp 3 Oct 2005 21:12:38 -0000 1.27
+++ render_flexbox.cpp 25 Oct 2005 20:54:28 -0000 1.28
@@ -220,16 +220,16 @@
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();
1.12 +3 -6 WebCore/khtml/rendering/render_theme_mac.mm
Index: render_theme_mac.mm
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_theme_mac.mm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- render_theme_mac.mm 22 Oct 2005 18:19:27 -0000 1.11
+++ render_theme_mac.mm 25 Oct 2005 20:54:28 -0000 1.12
@@ -204,7 +204,7 @@
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 @@
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 @@
// 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));
}
}
More information about the webkit-changes
mailing list