Commit 55fe6bdd authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-22 David Hyatt <hyatt@apple.com>

        Move the border and padding methods from RenderObject to RenderBox.

        Reviewed by Oliver Hunt

        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * editing/DeleteButtonController.cpp:
        (WebCore::DeleteButtonController::createDeletionUI):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::hitTestResultAtPoint):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::placeBoxesVertically):
        * rendering/InlineFlowBox.h:
        (WebCore::InlineFlowBox::borderLeft):
        (WebCore::InlineFlowBox::borderRight):
        (WebCore::InlineFlowBox::paddingLeft):
        (WebCore::InlineFlowBox::paddingRight):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::clearFloats):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paddingTop):
        (WebCore::RenderBox::paddingBottom):
        (WebCore::RenderBox::paddingLeft):
        (WebCore::RenderBox::paddingRight):
        (WebCore::RenderBox::calcHeight):
        (WebCore::RenderBox::containingBlockWidthForPositioned):
        (WebCore::RenderBox::containingBlockHeightForPositioned):
        (WebCore::RenderBox::calcAbsoluteHorizontal):
        (WebCore::RenderBox::calcAbsoluteHorizontalValues):
        (WebCore::RenderBox::calcAbsoluteVertical):
        (WebCore::RenderBox::calcAbsoluteVerticalValues):
        (WebCore::RenderBox::calcAbsoluteHorizontalReplaced):
        (WebCore::RenderBox::calcAbsoluteVerticalReplaced):
        * rendering/RenderBox.h:
        (WebCore::RenderBox::borderTop):
        (WebCore::RenderBox::borderBottom):
        (WebCore::RenderBox::borderLeft):
        (WebCore::RenderBox::borderRight):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::repaintAfterLayoutIfNeeded):
        * rendering/RenderObject.h:
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::textBlockWidth):
        (WebCore::RenderTextControl::calcHeight):
        (WebCore::RenderTextControl::calcPrefWidths):
        * rendering/RenderTextControlSingleLine.cpp:
        (WebCore::RenderTextControlSingleLine::preferredContentWidth):
        * rendering/RenderTreeAsText.cpp:
        (WebCore::operator<<):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::repaintViewRectangle):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 774bbed5
2009-01-22 David Hyatt <hyatt@apple.com>
Move the border and padding methods from RenderObject to RenderBox.
Reviewed by Oliver Hunt
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* editing/DeleteButtonController.cpp:
(WebCore::DeleteButtonController::createDeletionUI):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxesVertically):
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::borderLeft):
(WebCore::InlineFlowBox::borderRight):
(WebCore::InlineFlowBox::paddingLeft):
(WebCore::InlineFlowBox::paddingRight):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::clearFloats):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paddingTop):
(WebCore::RenderBox::paddingBottom):
(WebCore::RenderBox::paddingLeft):
(WebCore::RenderBox::paddingRight):
(WebCore::RenderBox::calcHeight):
(WebCore::RenderBox::containingBlockWidthForPositioned):
(WebCore::RenderBox::containingBlockHeightForPositioned):
(WebCore::RenderBox::calcAbsoluteHorizontal):
(WebCore::RenderBox::calcAbsoluteHorizontalValues):
(WebCore::RenderBox::calcAbsoluteVertical):
(WebCore::RenderBox::calcAbsoluteVerticalValues):
(WebCore::RenderBox::calcAbsoluteHorizontalReplaced):
(WebCore::RenderBox::calcAbsoluteVerticalReplaced):
* rendering/RenderBox.h:
(WebCore::RenderBox::borderTop):
(WebCore::RenderBox::borderBottom):
(WebCore::RenderBox::borderLeft):
(WebCore::RenderBox::borderRight):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::repaintAfterLayoutIfNeeded):
* rendering/RenderObject.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::textBlockWidth):
(WebCore::RenderTextControl::calcHeight):
(WebCore::RenderTextControl::calcPrefWidths):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::preferredContentWidth):
* rendering/RenderTreeAsText.cpp:
(WebCore::operator<<):
* rendering/RenderView.cpp:
(WebCore::RenderView::repaintViewRectangle):
2009-01-22 David Hyatt <hyatt@apple.com>
Devirtualize the marginTop/Right/Left/Bottom functions and move them to RenderBox (along with some of the
......@@ -862,20 +862,20 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSSPropertyOverflowY:
return CSSPrimitiveValue::create(style->overflowY());
case CSSPropertyPaddingTop:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingTop(false), CSSPrimitiveValue::CSS_PX);
if (renderer && renderer->isBox())
return CSSPrimitiveValue::create(RenderBox::toRenderBox(renderer)->paddingTop(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingTop());
case CSSPropertyPaddingRight:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingRight(false), CSSPrimitiveValue::CSS_PX);
if (renderer && renderer->isBox())
return CSSPrimitiveValue::create(RenderBox::toRenderBox(renderer)->paddingRight(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingRight());
case CSSPropertyPaddingBottom:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingBottom(false), CSSPrimitiveValue::CSS_PX);
if (renderer && renderer->isBox())
return CSSPrimitiveValue::create(RenderBox::toRenderBox(renderer)->paddingBottom(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingBottom());
case CSSPropertyPaddingLeft:
if (renderer)
return CSSPrimitiveValue::create(renderer->paddingLeft(false), CSSPrimitiveValue::CSS_PX);
if (renderer && renderer->isBox())
return CSSPrimitiveValue::create(RenderBox::toRenderBox(renderer)->paddingLeft(false), CSSPrimitiveValue::CSS_PX);
return CSSPrimitiveValue::create(style->paddingLeft());
case CSSPropertyPageBreakAfter:
return CSSPrimitiveValue::create(style->pageBreakAfter());
......
......@@ -167,10 +167,10 @@ void DeleteButtonController::createDeletionUI()
style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
style->setProperty(CSSPropertyWebkitUserModify, CSSValueNone);
style->setProperty(CSSPropertyZIndex, String::number(-1000000));
style->setProperty(CSSPropertyTop, String::number(-borderWidth - m_target->renderer()->borderTop()) + "px");
style->setProperty(CSSPropertyRight, String::number(-borderWidth - m_target->renderer()->borderRight()) + "px");
style->setProperty(CSSPropertyBottom, String::number(-borderWidth - m_target->renderer()->borderBottom()) + "px");
style->setProperty(CSSPropertyLeft, String::number(-borderWidth - m_target->renderer()->borderLeft()) + "px");
style->setProperty(CSSPropertyTop, String::number(-borderWidth - m_target->renderBox()->borderTop()) + "px");
style->setProperty(CSSPropertyRight, String::number(-borderWidth - m_target->renderBox()->borderRight()) + "px");
style->setProperty(CSSPropertyBottom, String::number(-borderWidth - m_target->renderBox()->borderBottom()) + "px");
style->setProperty(CSSPropertyLeft, String::number(-borderWidth - m_target->renderBox()->borderLeft()) + "px");
style->setProperty(CSSPropertyBorder, String::number(borderWidth) + "px solid rgba(0, 0, 0, 0.6)");
style->setProperty(CSSPropertyWebkitBorderRadius, String::number(borderRadius) + "px");
......@@ -194,8 +194,8 @@ void DeleteButtonController::createDeletionUI()
style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone);
style->setProperty(CSSPropertyWebkitUserModify, CSSValueNone);
style->setProperty(CSSPropertyZIndex, String::number(1000000));
style->setProperty(CSSPropertyTop, String::number((-buttonHeight / 2) - m_target->renderer()->borderTop() - (borderWidth / 2) + buttonBottomShadowOffset) + "px");
style->setProperty(CSSPropertyLeft, String::number((-buttonWidth / 2) - m_target->renderer()->borderLeft() - (borderWidth / 2)) + "px");
style->setProperty(CSSPropertyTop, String::number((-buttonHeight / 2) - m_target->renderBox()->borderTop() - (borderWidth / 2) + buttonBottomShadowOffset) + "px");
style->setProperty(CSSPropertyLeft, String::number((-buttonWidth / 2) - m_target->renderBox()->borderLeft() - (borderWidth / 2)) + "px");
style->setProperty(CSSPropertyWidth, String::number(buttonWidth) + "px");
style->setProperty(CSSPropertyHeight, String::number(buttonHeight) + "px");
......
......@@ -698,15 +698,16 @@ HitTestResult EventHandler::hitTestResultAtPoint(const IntPoint& point, bool all
Node* n = result.innerNode();
if (!result.isOverWidget() || !n || !n->renderer() || !n->renderer()->isWidget())
break;
Widget* widget = static_cast<RenderWidget*>(n->renderer())->widget();
RenderWidget* renderWidget = static_cast<RenderWidget*>(n->renderer());
Widget* widget = renderWidget->widget();
if (!widget || !widget->isFrameView())
break;
Frame* frame = static_cast<HTMLFrameElementBase*>(n)->contentFrame();
if (!frame || !frame->contentRenderer())
break;
FrameView* view = static_cast<FrameView*>(widget);
IntPoint widgetPoint(result.localPoint().x() + view->scrollX() - n->renderer()->borderLeft() - n->renderer()->paddingLeft(),
result.localPoint().y() + view->scrollY() - n->renderer()->borderTop() - n->renderer()->paddingTop());
IntPoint widgetPoint(result.localPoint().x() + view->scrollX() - renderWidget->borderLeft() - renderWidget->paddingLeft(),
result.localPoint().y() + view->scrollY() - renderWidget->borderTop() - renderWidget->paddingTop());
HitTestResult widgetHitTestResult(widgetPoint);
frame->contentRenderer()->layer()->hitTest(HitTestRequest(true, true), widgetHitTestResult);
result = widgetHitTestResult;
......
......@@ -529,10 +529,10 @@ void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bo
}
if (curr->isInlineFlowBox()) {
newHeight += curr->object()->borderTop() + curr->object()->paddingTop() +
curr->object()->borderBottom() + curr->object()->paddingBottom();
newY -= curr->object()->borderTop() + curr->object()->paddingTop();
newBaseline += curr->object()->borderTop() + curr->object()->paddingTop();
newHeight += curr->renderBox()->borderTop() + curr->renderBox()->paddingTop() +
curr->renderBox()->borderBottom() + curr->renderBox()->paddingBottom();
newY -= curr->renderBox()->borderTop() + curr->renderBox()->paddingTop();
newBaseline += curr->renderBox()->borderTop() + curr->renderBox()->paddingTop();
}
} else if (!curr->object()->isBR()) {
newY += curr->renderBox()->marginTop();
......
......@@ -97,10 +97,10 @@ public:
int marginBorderPaddingRight();
int marginLeft();
int marginRight();
int borderLeft() { if (includeLeftEdge()) return object()->borderLeft(); return 0; }
int borderRight() { if (includeRightEdge()) return object()->borderRight(); return 0; }
int paddingLeft() { if (includeLeftEdge()) return object()->paddingLeft(); return 0; }
int paddingRight() { if (includeRightEdge()) return object()->paddingRight(); return 0; }
int borderLeft() { if (includeLeftEdge()) return renderBox()->borderLeft(); return 0; }
int borderRight() { if (includeRightEdge()) return renderBox()->borderRight(); return 0; }
int paddingLeft() { if (includeLeftEdge()) return renderBox()->paddingLeft(); return 0; }
int paddingRight() { if (includeRightEdge()) return renderBox()->paddingRight(); return 0; }
bool includeLeftEdge() { return m_includeLeftEdge; }
bool includeRightEdge() { return m_includeRightEdge; }
......
......@@ -2844,23 +2844,24 @@ void RenderBlock::clearFloats()
// First add in floats from the parent.
int offset = y();
if (parentHasFloats)
addIntrudingFloats(static_cast<RenderBlock *>(parent()),
parent()->borderLeft() + parent()->paddingLeft(), offset);
if (parentHasFloats) {
RenderBlock* parentBlock = static_cast<RenderBlock *>(parent());
addIntrudingFloats(parentBlock, parentBlock->borderLeft() + parentBlock->paddingLeft(), offset);
}
int xoffset = 0;
if (prev)
offset -= toRenderBox(prev)->y();
else {
else if (parent()->isBox()) {
prev = parent();
xoffset += prev->borderLeft() + prev->paddingLeft();
xoffset += RenderBox::toRenderBox(prev)->borderLeft() + RenderBox::toRenderBox(prev)->paddingLeft();
}
// Add overhanging floats from the previous RenderBlock, but only if it has a float that intrudes into our space.
if (!prev->isRenderBlock()) return;
if (!prev || !prev->isRenderBlock())
return;
RenderBlock* block = static_cast<RenderBlock *>(prev);
if (block->m_floatingObjects && block->floatBottom() > offset)
addIntrudingFloats(block, xoffset, offset);
......
......@@ -343,6 +343,42 @@ void RenderBox::setScrollTop(int newTop)
m_layer->scrollToYOffset(newTop);
}
int RenderBox::paddingTop(bool) const
{
int w = 0;
Length padding = style()->paddingTop();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderBox::paddingBottom(bool) const
{
int w = 0;
Length padding = style()->paddingBottom();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderBox::paddingLeft(bool) const
{
int w = 0;
Length padding = style()->paddingLeft();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderBox::paddingRight(bool) const
{
int w = 0;
Length padding = style()->paddingRight();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
void RenderBox::absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool topLevel)
{
// For blocks inside inlines, we go ahead and include margins so that we run right up to the
......@@ -1787,8 +1823,8 @@ void RenderBox::calcHeight()
setHeight(max(height(), visHeight - margins));
else {
int marginsBordersPadding = margins + parentBox()->marginTop() + parentBox()->marginBottom()
+ parent()->borderTop() + parent()->borderBottom()
+ parent()->paddingTop() + parent()->paddingBottom();
+ parentBox()->borderTop() + parentBox()->borderBottom()
+ parentBox()->paddingTop() + parentBox()->paddingBottom();
setHeight(max(height(), visHeight - marginsBordersPadding));
}
}
......@@ -2064,19 +2100,22 @@ int RenderBox::containingBlockWidthForPositioned(const RenderObject* containingB
return max(0, (fromRight - fromLeft));
}
return RenderBox::toConstRenderBox(containingBlock)->width() - containingBlock->borderLeft() - containingBlock->borderRight() - containingBlock->verticalScrollbarWidth();
const RenderBox* containingBlockBox = RenderBox::toConstRenderBox(containingBlock);
return containingBlockBox->width() - containingBlockBox->borderLeft() - containingBlockBox->borderRight() - containingBlockBox->verticalScrollbarWidth();
}
int RenderBox::containingBlockHeightForPositioned(const RenderObject* containingBlock) const
{
const RenderBox* containingBlockBox = RenderBox::toConstRenderBox(containingBlock);
int heightResult;
if (containingBlock->isRenderInline()) {
ASSERT(containingBlock->isRelPositioned());
heightResult = static_cast<const RenderInline*>(containingBlock)->boundingBoxHeight();
} else
heightResult = RenderBox::toConstRenderBox(containingBlock)->height();
heightResult = containingBlockBox->height();
return heightResult - containingBlock->borderTop() - containingBlock->borderBottom();
return heightResult - containingBlockBox->borderTop() - containingBlockBox->borderBottom();
}
void RenderBox::calcAbsoluteHorizontal()
......@@ -2113,8 +2152,8 @@ void RenderBox::calcAbsoluteHorizontal()
// We don't use containingBlock(), since we may be positioned by an enclosing
// relative positioned inline.
const RenderObject* containerBlock = container();
const RenderBox* containerBlock = RenderBox::toRenderBox(container());
const int containerWidth = containingBlockWidthForPositioned(containerBlock);
// To match WinIE, in quirks mode use the parent's 'direction' property
......@@ -2233,7 +2272,7 @@ void RenderBox::calcAbsoluteHorizontal()
setWidth(width() + bordersPlusPadding);
}
void RenderBox::calcAbsoluteHorizontalValues(Length width, const RenderObject* containerBlock, TextDirection containerDirection,
void RenderBox::calcAbsoluteHorizontalValues(Length width, const RenderBox* containerBlock, TextDirection containerDirection,
const int containerWidth, const int bordersPlusPadding,
const Length left, const Length right, const Length marginLeft, const Length marginRight,
int& widthValue, int& marginLeftValue, int& marginRightValue, int& xPos)
......@@ -2420,7 +2459,7 @@ void RenderBox::calcAbsoluteVertical()
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
const RenderObject* containerBlock = container();
const RenderBox* containerBlock = RenderBox::toConstRenderBox(container());
const int containerHeight = containingBlockHeightForPositioned(containerBlock);
......@@ -2514,7 +2553,7 @@ void RenderBox::calcAbsoluteVertical()
setHeight(h + bordersPlusPadding);
}
void RenderBox::calcAbsoluteVerticalValues(Length h, const RenderObject* containerBlock,
void RenderBox::calcAbsoluteVerticalValues(Length h, const RenderBox* containerBlock,
const int containerHeight, const int bordersPlusPadding,
const Length top, const Length bottom, const Length marginTop, const Length marginBottom,
int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos)
......@@ -2643,7 +2682,7 @@ void RenderBox::calcAbsoluteHorizontalReplaced()
// We don't use containingBlock(), since we may be positioned by an enclosing
// relative positioned inline.
const RenderObject* containerBlock = container();
const RenderBox* containerBlock = RenderBox::toConstRenderBox(container());
const int containerWidth = containingBlockWidthForPositioned(containerBlock);
......@@ -2816,7 +2855,7 @@ void RenderBox::calcAbsoluteVerticalReplaced()
// the numbers correspond to numbers in spec)
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
const RenderObject* containerBlock = container();
const RenderBox* containerBlock = RenderBox::toConstRenderBox(container());
const int containerHeight = containingBlockHeightForPositioned(containerBlock);
......
......@@ -128,6 +128,17 @@ public:
int marginLeft() const { return m_marginLeft; }
int marginRight() const { return m_marginRight; }
// Virtual since table cells override
virtual int paddingTop(bool includeIntrinsicPadding = true) const;
virtual int paddingBottom(bool includeIntrinsicPadding = true) const;
virtual int paddingLeft(bool includeIntrinsicPadding = true) const;
virtual int paddingRight(bool includeIntrinsicPadding = true) const;
virtual int borderTop() const { return style()->borderTopWidth(); }
virtual int borderBottom() const { return style()->borderBottomWidth(); }
virtual int borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }
// The following seven functions are used to implement collapsing margins.
// All objects know their maximal positive and negative margins. The
// formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
......@@ -308,11 +319,11 @@ private:
int containingBlockHeightForPositioned(const RenderObject* containingBlock) const;
void calcAbsoluteVertical();
void calcAbsoluteHorizontalValues(Length width, const RenderObject* cb, TextDirection containerDirection,
void calcAbsoluteHorizontalValues(Length width, const RenderBox* cb, TextDirection containerDirection,
int containerWidth, int bordersPlusPadding,
Length left, Length right, Length marginLeft, Length marginRight,
int& widthValue, int& marginLeftValue, int& marginRightValue, int& xPos);
void calcAbsoluteVerticalValues(Length height, const RenderObject* cb,
void calcAbsoluteVerticalValues(Length height, const RenderBox* cb,
int containerHeight, int bordersPlusPadding,
Length top, Length bottom, Length marginTop, Length marginBottom,
int& heightValue, int& marginTopValue, int& marginBottomValue, int& yPos);
......
......@@ -1792,7 +1792,8 @@ bool RenderObject::repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const In
for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next)
shadowRight = max(shadow->x + shadow->blur, shadowRight);
int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight(), max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + max(ow, shadowRight);
int borderRight = isBox() ? RenderBox::toRenderBox(this)->borderRight() : 0;
int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight, max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + max(ow, shadowRight);
IntRect rightRect(newOutlineBox.x() + min(newOutlineBox.width(), oldOutlineBox.width()) - borderWidth,
newOutlineBox.y(),
width + borderWidth,
......@@ -1809,7 +1810,8 @@ bool RenderObject::repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const In
for (ShadowData* shadow = boxShadow; shadow; shadow = shadow->next)
shadowBottom = max(shadow->y + shadow->blur, shadowBottom);
int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom(), max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + max(ow, shadowBottom);
int borderBottom = isBox() ? RenderBox::toRenderBox(this)->borderBottom() : 0;
int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom, max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + max(ow, shadowBottom);
IntRect bottomRect(newOutlineBox.x(),
min(newOutlineBox.bottom(), oldOutlineBox.bottom()) - borderHeight,
max(newOutlineBox.width(), oldOutlineBox.width()),
......@@ -2308,42 +2310,6 @@ IntRect RenderObject::localCaretRect(InlineBox*, int, int* extraWidthToEndOfLine
return IntRect();
}
int RenderObject::paddingTop(bool) const
{
int w = 0;
Length padding = m_style->paddingTop();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderObject::paddingBottom(bool) const
{
int w = 0;
Length padding = style()->paddingBottom();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderObject::paddingLeft(bool) const
{
int w = 0;
Length padding = style()->paddingLeft();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
int RenderObject::paddingRight(bool) const
{
int w = 0;
Length padding = style()->paddingRight();
if (padding.isPercent())
w = containingBlock()->availableWidth();
return padding.calcMinValue(w);
}
RenderView* RenderObject::view() const
{
return static_cast<RenderView*>(document()->renderer());
......
......@@ -579,17 +579,6 @@ public:
virtual bool isScrollable() const;
// Virtual since table cells override
virtual int paddingTop(bool includeIntrinsicPadding = true) const;
virtual int paddingBottom(bool includeIntrinsicPadding = true) const;
virtual int paddingLeft(bool includeIntrinsicPadding = true) const;
virtual int paddingRight(bool includeIntrinsicPadding = true) const;
virtual int borderTop() const { return style()->borderTopWidth(); }
virtual int borderBottom() const { return style()->borderBottomWidth(); }
virtual int borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }
virtual void addLineBoxRects(Vector<IntRect>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false);
virtual void absoluteRects(Vector<IntRect>&, int, int, bool = true) { }
......
......@@ -132,7 +132,7 @@ int RenderTextControl::textBlockHeight() const
int RenderTextControl::textBlockWidth() const
{
return width() - paddingLeft() - paddingRight() - borderLeft() - borderRight()
- m_innerText->renderer()->paddingLeft() - m_innerText->renderer()->paddingRight();
- m_innerText->renderBox()->paddingLeft() - m_innerText->renderBox()->paddingRight();
}
void RenderTextControl::updateFromElement()
......@@ -418,8 +418,8 @@ int RenderTextControl::scrollbarThickness() const
void RenderTextControl::calcHeight()
{
setHeight(m_innerText->renderer()->borderTop() + m_innerText->renderer()->borderBottom() +
m_innerText->renderer()->paddingTop() + m_innerText->renderer()->paddingBottom() +
setHeight(m_innerText->renderBox()->borderTop() + m_innerText->renderBox()->borderBottom() +
m_innerText->renderBox()->paddingTop() + m_innerText->renderBox()->paddingBottom() +
m_innerText->renderBox()->marginTop() + m_innerText->renderBox()->marginBottom());
adjustControlHeightBasedOnLineHeight(m_innerText->renderer()->lineHeight(true, true));
......@@ -467,7 +467,7 @@ void RenderTextControl::calcPrefWidths()
// (using "0" as the nominal character).
const UChar ch = '0';
float charWidth = style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
m_maxPrefWidth = preferredContentWidth(charWidth) + m_innerText->renderer()->paddingLeft() + m_innerText->renderer()->paddingRight();
m_maxPrefWidth = preferredContentWidth(charWidth) + m_innerText->renderBox()->paddingLeft() + m_innerText->renderBox()->paddingRight();
}
if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
......
......@@ -400,11 +400,11 @@ int RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
int result = static_cast<int>(ceilf(charWidth * factor));
if (RenderObject* resultsRenderer = m_resultsButton ? m_resultsButton->renderer() : 0)
if (RenderBox* resultsRenderer = m_resultsButton ? m_resultsButton->renderBox() : 0)
result += resultsRenderer->borderLeft() + resultsRenderer->borderRight() +
resultsRenderer->paddingLeft() + resultsRenderer->paddingRight();
if (RenderObject* cancelRenderer = m_cancelButton ? m_cancelButton->renderer() : 0)
if (RenderBox* cancelRenderer = m_cancelButton ? m_cancelButton->renderBox() : 0)
result += cancelRenderer->borderLeft() + cancelRenderer->borderRight() +
cancelRenderer->paddingLeft() + cancelRenderer->paddingRight();
......
......@@ -236,16 +236,20 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
o.style()->textStrokeWidth() > 0)
ts << " [textStrokeWidth=" << o.style()->textStrokeWidth() << "]";
if (o.borderTop() || o.borderRight() || o.borderBottom() || o.borderLeft()) {
if (!o.isBox())
return ts;
const RenderBox& box = static_cast<const RenderBox&>(o);
if (box.borderTop() || box.borderRight() || box.borderBottom() || box.borderLeft()) {
ts << " [border:";
BorderValue prevBorder;
if (o.style()->borderTop() != prevBorder) {
prevBorder = o.style()->borderTop();
if (!o.borderTop())
if (!box.borderTop())
ts << " none";
else {
ts << " (" << o.borderTop() << "px ";
ts << " (" << box.borderTop() << "px ";
printBorderStyle(ts, o.style()->borderTopStyle());
Color col = o.style()->borderTopColor();
if (!col.isValid())
......@@ -256,10 +260,10 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
if (o.style()->borderRight() != prevBorder) {
prevBorder = o.style()->borderRight();
if (!o.borderRight())
if (!box.borderRight())
ts << " none";
else {
ts << " (" << o.borderRight() << "px ";
ts << " (" << box.borderRight() << "px ";
printBorderStyle(ts, o.style()->borderRightStyle());
Color col = o.style()->borderRightColor();
if (!col.isValid())
......@@ -269,11 +273,11 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
}
if (o.style()->borderBottom() != prevBorder) {
prevBorder = o.style()->borderBottom();
if (!o.borderBottom())
prevBorder = box.style()->borderBottom();
if (!box.borderBottom())
ts << " none";
else {
ts << " (" << o.borderBottom() << "px ";
ts << " (" << box.borderBottom() << "px ";
printBorderStyle(ts, o.style()->borderBottomStyle());
Color col = o.style()->borderBottomColor();
if (!col.isValid())
......@@ -284,10 +288,10 @@ static TextStream &operator<<(TextStream& ts, const RenderObject& o)
if (o.style()->borderLeft() != prevBorder) {
prevBorder = o.style()->borderLeft();
if (!o.borderLeft())
if (!box.borderLeft())
ts << " none";
else {
ts << " (" << o.borderLeft() << "px ";
ts << " (" << box.borderLeft() << "px ";
printBorderStyle(ts, o.style()->borderLeftStyle());
Color col = o.style()->borderLeftColor();
if (!col.isValid())
......
......@@ -222,7 +222,7 @@ void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
Element* elt = document()->ownerElement();
if (!elt)
m_frameView->repaintContentRectangle(ur, immediate);
else if (RenderObject* obj = elt->renderer()) {
else if (RenderBox* obj = elt->renderBox()) {
IntRect vr = viewRect();
IntRect r = intersection(ur, vr);
......
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