2008-10-03 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Dave Hyatt

        Make setStyle() take a const RenderStyle, to ensure that an
        earlier RenderStyle::diff() remains valid.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 938a55f4
2008-10-03 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dave Hyatt
Make setStyle() take a const RenderStyle, to ensure that an
earlier RenderStyle::diff() remains valid.
* rendering/RenderBR.cpp:
* rendering/RenderBR.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBox.cpp:
* rendering/RenderBox.h:
* rendering/RenderButton.cpp:
* rendering/RenderButton.h:
* rendering/RenderFieldset.cpp:
* rendering/RenderFieldset.h:
* rendering/RenderFileUploadControl.cpp:
* rendering/RenderFileUploadControl.h:
* rendering/RenderInline.cpp:
* rendering/RenderInline.h:
* rendering/RenderListBox.cpp:
* rendering/RenderListBox.h:
* rendering/RenderListItem.cpp:
* rendering/RenderListItem.h:
* rendering/RenderListMarker.cpp:
* rendering/RenderListMarker.h:
* rendering/RenderMenuList.cpp:
* rendering/RenderMenuList.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setStyle):
* rendering/RenderObject.h:
* rendering/RenderReplaced.cpp:
* rendering/RenderReplaced.h:
* rendering/RenderSVGBlock.cpp:
(WebCore::RenderSVGBlock::setStyle):
* rendering/RenderSVGBlock.h:
* rendering/RenderSVGGradientStop.cpp:
* rendering/RenderSVGGradientStop.h:
* rendering/RenderSlider.cpp:
* rendering/RenderSlider.h:
* rendering/RenderTable.cpp:
* rendering/RenderTable.h:
* rendering/RenderTableCell.cpp:
* rendering/RenderTableCell.h:
* rendering/RenderTableRow.cpp:
* rendering/RenderTableRow.h:
* rendering/RenderText.cpp:
* rendering/RenderText.h:
* rendering/RenderTextControl.cpp:
* rendering/RenderTextControl.h:
* rendering/RenderWidget.cpp:
* rendering/RenderWidget.h:
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::isDisplayReplacedType):
(WebCore::RenderStyle::isDisplayInlineType):
2008-10-03 David Hyatt <hyatt@apple.com>
Preparation for enabling scrollbars to hit test properly inside transforms. Clean up the scrollbar
......
......@@ -82,7 +82,7 @@ int RenderBR::lineHeight(bool firstLine, bool isRootLineBox) const
return m_lineHeight;
}
void RenderBR::setStyle(RenderStyle* newStyle)
void RenderBR::setStyle(const RenderStyle* newStyle)
{
RenderText::setStyle(newStyle);
m_lineHeight = -1;
......
......@@ -47,7 +47,7 @@ public:
virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const;
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
// overrides
virtual InlineBox* createInlineBox(bool, bool, bool isOnlyRun = false);
......
......@@ -146,7 +146,7 @@ RenderBlock::~RenderBlock()
}
}
void RenderBlock::setStyle(RenderStyle* newStyle)
void RenderBlock::setStyle(const RenderStyle* newStyle)
{
setReplaced(newStyle->isDisplayReplacedType());
......
......@@ -106,7 +106,7 @@ public:
virtual void repaintOverhangingFloats(bool paintAllDescendants);
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void layout();
virtual void layoutBlock(bool relayoutChildren);
......
......@@ -72,7 +72,7 @@ RenderBox::RenderBox(Node* node)
{
}
void RenderBox::setStyle(RenderStyle* newStyle)
void RenderBox::setStyle(const RenderStyle* newStyle)
{
bool wasFloating = isFloating();
bool hadOverflowClip = hasOverflowClip();
......
......@@ -36,7 +36,7 @@ public:
virtual const char* renderName() const { return "RenderBox"; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void paint(PaintInfo&, int tx, int ty);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
......
......@@ -64,7 +64,7 @@ void RenderButton::removeChild(RenderObject* oldChild)
m_inner->removeChild(oldChild);
}
void RenderButton::setStyle(RenderStyle* style)
void RenderButton::setStyle(const RenderStyle* style)
{
if (m_inner) {
// RenderBlock::setStyle is going to apply a new style to the inner block, which
......
......@@ -45,7 +45,7 @@ public:
virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
virtual bool createsAnonymousWrapper() const { return true; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void updateFromElement();
virtual void updateBeforeAfterContent(RenderStyle::PseudoId);
......
......@@ -260,7 +260,7 @@ void RenderFieldset::paintBorderMinusLegend(GraphicsContext* graphicsContext, in
}
}
void RenderFieldset::setStyle(RenderStyle* newStyle)
void RenderFieldset::setStyle(const RenderStyle* newStyle)
{
RenderBlock::setStyle(newStyle);
......
......@@ -41,7 +41,7 @@ public:
virtual RenderObject* layoutLegend(bool relayoutChildren);
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void calcPrefWidths();
virtual bool avoidsFloats() const { return true; }
......
......@@ -71,7 +71,7 @@ RenderFileUploadControl::~RenderFileUploadControl()
m_fileChooser->disconnectClient();
}
void RenderFileUploadControl::setStyle(RenderStyle* newStyle)
void RenderFileUploadControl::setStyle(const RenderStyle* newStyle)
{
RenderBlock::setStyle(newStyle);
if (m_button)
......@@ -134,7 +134,7 @@ int RenderFileUploadControl::maxFilenameWidth() const
- (m_fileChooser->icon() ? iconWidth + iconFilenameSpacing : 0));
}
RenderStyle* RenderFileUploadControl::createButtonStyle(RenderStyle* parentStyle) const
RenderStyle* RenderFileUploadControl::createButtonStyle(const RenderStyle* parentStyle) const
{
RenderStyle* style = getPseudoStyle(RenderStyle::FILE_UPLOAD_BUTTON);
if (!style) {
......
......@@ -39,7 +39,7 @@ public:
virtual const char* renderName() const { return "RenderFileUploadControl"; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void updateFromElement();
virtual void calcPrefWidths();
virtual void paintObject(PaintInfo&, int tx, int ty);
......@@ -55,7 +55,7 @@ public:
private:
int maxFilenameWidth() const;
RenderStyle* createButtonStyle(RenderStyle* parentStyle) const;
RenderStyle* createButtonStyle(const RenderStyle* parentStyle) const;
RefPtr<HTMLInputElement> m_button;
RefPtr<FileChooser> m_fileChooser;
......
......@@ -41,7 +41,7 @@ RenderInline::~RenderInline()
{
}
void RenderInline::setStyle(RenderStyle* newStyle)
void RenderInline::setStyle(const RenderStyle* newStyle)
{
RenderFlow::setStyle(newStyle);
setInline(true);
......
......@@ -50,7 +50,7 @@ public:
void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
RenderObject* newChild, RenderFlow* oldCont);
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void layout() { } // Do nothing for layout()
......
......@@ -90,7 +90,7 @@ RenderListBox::~RenderListBox()
}
}
void RenderListBox::setStyle(RenderStyle* style)
void RenderListBox::setStyle(const RenderStyle* style)
{
RenderBlock::setStyle(style);
setReplaced(isInline());
......
......@@ -47,7 +47,7 @@ public:
virtual bool isListBox() const { return true; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void updateFromElement();
virtual bool canHaveChildren() const { return false; }
......
......@@ -48,7 +48,7 @@ RenderListItem::RenderListItem(Node* node)
setInline(false);
}
void RenderListItem::setStyle(RenderStyle* newStyle)
void RenderListItem::setStyle(const RenderStyle* newStyle)
{
RenderBlock::setStyle(newStyle);
......
......@@ -39,7 +39,7 @@ public:
virtual void destroy();
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
int value() const { if (!m_isValueUpToDate) updateValueNow(); return m_value; }
void updateValue();
......
......@@ -485,7 +485,7 @@ RenderListMarker::~RenderListMarker()
m_image->removeClient(this);
}
void RenderListMarker::setStyle(RenderStyle* s)
void RenderListMarker::setStyle(const RenderStyle* s)
{
if (style() && (s->listStylePosition() != style()->listStylePosition() || s->listStyleType() != style()->listStyleType()))
setNeedsLayoutAndPrefWidthsRecalc();
......
......@@ -42,7 +42,7 @@ public:
virtual bool isListMarker() const { return true; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void paint(PaintInfo&, int tx, int ty);
......
......@@ -117,7 +117,7 @@ void RenderMenuList::removeChild(RenderObject* oldChild)
m_innerBlock->removeChild(oldChild);
}
void RenderMenuList::setStyle(RenderStyle* newStyle)
void RenderMenuList::setStyle(const RenderStyle* newStyle)
{
bool fontChanged = !style() || style()->font() != newStyle->font();
......
......@@ -51,7 +51,7 @@ public:
virtual bool createsAnonymousWrapper() const { return true; }
virtual bool canHaveChildren() const { return false; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void updateFromElement();
virtual bool hasControlClip() const { return true; }
......
......@@ -2160,7 +2160,7 @@ void RenderObject::setAnimatableStyle(RenderStyle* style)
setStyle(style);
}
void RenderObject::setStyle(RenderStyle* style)
void RenderObject::setStyle(const RenderStyle* style)
{
if (m_style == style)
return;
......@@ -2301,7 +2301,9 @@ void RenderObject::setStyle(RenderStyle* style)
}
RenderStyle* oldStyle = m_style;
m_style = style;
m_style = const_cast<RenderStyle*>(style);
if (m_style)
m_style->ref();
updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_style->backgroundLayers() : 0);
updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->maskLayers() : 0);
......@@ -2309,11 +2311,10 @@ void RenderObject::setStyle(RenderStyle* style)
updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style ? m_style->borderImage().image() : 0);
updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style ? m_style->maskBoxImage().image() : 0);
if (m_style)
m_style->ref();
if (oldStyle)
if (oldStyle) {
oldStyle->deref(renderArena());
oldStyle = 0;
}
setHasBoxDecorations(m_style->hasBorder() || m_style->hasBackground() || m_style->hasAppearance() || m_style->boxShadow());
......
......@@ -555,7 +555,7 @@ public:
void setAnimatableStyle(RenderStyle*);
// Set the style of the object and update the state of the object accordingly.
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
// Updates only the local style ptr of the object. Does not update the state of the object,
// and so only should be called when the style is known not to have changed (or from setStyle).
......
......@@ -61,7 +61,7 @@ RenderReplaced::~RenderReplaced()
gOverflowRectMap->remove(this);
}
void RenderReplaced::setStyle(RenderStyle* newStyle)
void RenderReplaced::setStyle(const RenderStyle* newStyle)
{
bool hadStyle = style();
float oldZoom = hadStyle ? style()->effectiveZoom() : RenderStyle::initialZoom();
......
......@@ -42,7 +42,7 @@ public:
virtual void layout();
virtual int minimumReplacedHeight() const { return 0; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void paint(PaintInfo&, int tx, int ty);
virtual void paintReplaced(PaintInfo&, int tx, int ty) { }
......
......@@ -35,17 +35,18 @@ RenderSVGBlock::RenderSVGBlock(SVGElement* node)
{
}
void RenderSVGBlock::setStyle(RenderStyle* style)
void RenderSVGBlock::setStyle(const RenderStyle* style)
{
RenderStyle* useStyle = style;
const RenderStyle* useStyle = style;
// SVG text layout code expects us to be a block-level style element.
if (useStyle->display() == NONE)
setChildrenInline(false);
else if (useStyle->isDisplayInlineType()) {
useStyle = new (renderArena()) RenderStyle();
useStyle->inheritFrom(style);
useStyle->setDisplay(BLOCK);
RenderStyle* newStyle = new (renderArena()) RenderStyle();
newStyle->inheritFrom(style);
newStyle->setDisplay(BLOCK);
useStyle = newStyle;
}
RenderBlock::setStyle(useStyle);
......
......@@ -33,7 +33,7 @@ class SVGElement;
class RenderSVGBlock : public RenderBlock {
public:
RenderSVGBlock(SVGElement*);
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
};
}
......
......@@ -42,7 +42,7 @@ RenderSVGGradientStop::~RenderSVGGradientStop()
{
}
void RenderSVGGradientStop::setStyle(RenderStyle* style)
void RenderSVGGradientStop::setStyle(const RenderStyle* style)
{
RenderObject::setStyle(style);
......
......@@ -40,7 +40,7 @@ namespace WebCore {
virtual const char* renderName() const { return "RenderSVGGradientStop"; }
virtual void layout();
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
private:
SVGGradientElement* gradientElement() const;
......
......@@ -164,7 +164,7 @@ void RenderSlider::calcPrefWidths()
setPrefWidthsDirty(false);
}
void RenderSlider::setStyle(RenderStyle* newStyle)
void RenderSlider::setStyle(const RenderStyle* newStyle)
{
RenderBlock::setStyle(newStyle);
......@@ -176,7 +176,7 @@ void RenderSlider::setStyle(RenderStyle* newStyle)
setReplaced(isInline());
}
RenderStyle* RenderSlider::createThumbStyle(RenderStyle* parentStyle, RenderStyle* oldStyle)
RenderStyle* RenderSlider::createThumbStyle(const RenderStyle* parentStyle, const RenderStyle* oldStyle)
{
RenderStyle* style;
......
......@@ -41,7 +41,7 @@ namespace WebCore {
virtual int baselinePosition( bool, bool ) const;
virtual void calcPrefWidths();
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void layout();
virtual void updateFromElement();
......@@ -60,7 +60,7 @@ namespace WebCore {
bool inDragMode() const;
private:
RenderStyle* createThumbStyle(RenderStyle* parentStyle, RenderStyle* oldStyle = 0);
RenderStyle* createThumbStyle(const RenderStyle* parentStyle, const RenderStyle* oldStyle = 0);
int trackSize();
RefPtr<HTMLSliderThumbElement> m_thumb;
......
......@@ -70,7 +70,7 @@ RenderTable::~RenderTable()
delete m_tableLayout;
}
void RenderTable::setStyle(RenderStyle* newStyle)
void RenderTable::setStyle(const RenderStyle* newStyle)
{
ETableLayout oldTableLayout = style() ? style()->tableLayout() : TAUTO;
RenderBlock::setStyle(newStyle);
......
......@@ -66,7 +66,7 @@ public:
virtual bool isTable() const { return true; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual bool avoidsFloats() const { return true; }
......
......@@ -220,7 +220,7 @@ int RenderTableCell::baselinePosition(bool /*firstLine*/, bool /*isRootLineBox*/
return paddingTop() + borderTop() + contentHeight();
}
void RenderTableCell::setStyle(RenderStyle* newStyle)
void RenderTableCell::setStyle(const RenderStyle* newStyle)
{
if (parent() && section() && style() && style()->height() != newStyle->height())
section()->setNeedsCellRecalc();
......
......@@ -64,7 +64,7 @@ public:
virtual void calcPrefWidths();
virtual void calcWidth();
virtual void setWidth(int);
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual bool expandsToEncloseOverhangingFloats() const { return true; }
......
......@@ -54,7 +54,7 @@ void RenderTableRow::destroy()
recalcSection->setNeedsCellRecalc();
}
void RenderTableRow::setStyle(RenderStyle* newStyle)
void RenderTableRow::setStyle(const RenderStyle* newStyle)
{
if (section() && style() && style()->height() != newStyle->height())
section()->setNeedsCellRecalc();
......
......@@ -44,7 +44,7 @@ public:
RenderTableSection* section() const { return static_cast<RenderTableSection*>(parent()); }
RenderTable* table() const { return static_cast<RenderTable*>(parent()->parent()); }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const { return 0; }
virtual void position(InlineBox*) { }
......
......@@ -91,7 +91,7 @@ bool RenderText::isWordBreak() const
return false;
}
void RenderText::setStyle(RenderStyle* newStyle)
void RenderText::setStyle(const RenderStyle* newStyle)
{
RenderStyle* oldStyle = style();
if (oldStyle == newStyle)
......
......@@ -44,7 +44,7 @@ public:
virtual PassRefPtr<StringImpl> originalText() const;
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
void extractTextBox(InlineTextBox*);
void attachTextBox(InlineTextBox*);
......
......@@ -108,7 +108,7 @@ RenderTextControl::~RenderTextControl()
m_innerText->detach();
}
void RenderTextControl::setStyle(RenderStyle* style)
void RenderTextControl::setStyle(const RenderStyle* style)
{
RenderBlock::setStyle(style);
if (m_innerBlock) {
......@@ -142,7 +142,7 @@ void RenderTextControl::setStyle(RenderStyle* style)
setReplaced(isInline());
}
RenderStyle* RenderTextControl::createInnerBlockStyle(RenderStyle* startStyle)
RenderStyle* RenderTextControl::createInnerBlockStyle(const RenderStyle* startStyle)
{
RenderStyle* innerBlockStyle = new (renderArena()) RenderStyle();
......@@ -155,7 +155,7 @@ RenderStyle* RenderTextControl::createInnerBlockStyle(RenderStyle* startStyle)
return innerBlockStyle;
}
RenderStyle* RenderTextControl::createInnerTextStyle(RenderStyle* startStyle)
RenderStyle* RenderTextControl::createInnerTextStyle(const RenderStyle* startStyle)
{
HTMLFormControlElement* element = static_cast<HTMLFormControlElement*>(node());
bool placeholderShouldBeVisible = !m_multiLine && static_cast<HTMLInputElement*>(element)->placeholderShouldBeVisible();
......@@ -225,7 +225,7 @@ RenderStyle* RenderTextControl::createInnerTextStyle(RenderStyle* startStyle)
return textBlockStyle;
}
RenderStyle* RenderTextControl::createResultsButtonStyle(RenderStyle* startStyle)
RenderStyle* RenderTextControl::createResultsButtonStyle(const RenderStyle* startStyle)
{
ASSERT(!m_multiLine);
HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
......@@ -246,7 +246,7 @@ RenderStyle* RenderTextControl::createResultsButtonStyle(RenderStyle* startStyle
return resultsBlockStyle;
}
RenderStyle* RenderTextControl::createCancelButtonStyle(RenderStyle* startStyle)
RenderStyle* RenderTextControl::createCancelButtonStyle(const RenderStyle* startStyle)
{
RenderStyle* cancelBlockStyle;
......
......@@ -47,7 +47,7 @@ public:
virtual void calcHeight();
virtual void calcPrefWidths();
virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void updateFromElement();
virtual bool canHaveChildren() const { return false; }
virtual int baselinePosition(bool firstLine, bool isRootLineBox) const;
......@@ -130,10 +130,10 @@ private:
virtual bool valueShouldChangeOnHotTrack() const { return false; }
virtual FontSelector* fontSelector() const;
RenderStyle* createInnerBlockStyle(RenderStyle* startStyle);
RenderStyle* createInnerTextStyle(RenderStyle* startStyle);
RenderStyle* createCancelButtonStyle(RenderStyle* startStyle);
RenderStyle* createResultsButtonStyle(RenderStyle* startStyle);
RenderStyle* createInnerBlockStyle(const RenderStyle* startStyle);
RenderStyle* createInnerTextStyle(const RenderStyle* startStyle);
RenderStyle* createCancelButtonStyle(const RenderStyle* startStyle);
RenderStyle* createResultsButtonStyle(const RenderStyle* startStyle);
void createSubtreeIfNeeded();
void updateCancelButtonVisibility(RenderStyle*);
......
......@@ -156,7 +156,7 @@ void RenderWidget::layout()
setNeedsLayout(false);
}
void RenderWidget::setStyle(RenderStyle* newStyle)
void RenderWidget::setStyle(const RenderStyle* newStyle)
{
RenderReplaced::setStyle(newStyle);
if (m_widget) {
......
......@@ -37,7 +37,7 @@ public:
virtual bool isWidget() const { return true; }
virtual void setStyle(RenderStyle*);
virtual void setStyle(const RenderStyle*);
virtual void paint(PaintInfo&, int tx, int ty);
......
......@@ -437,8 +437,8 @@ public:
EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); }
ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); }
const Font& font() { return inherited->font; }
const FontDescription& fontDescription() { return inherited->font.fontDescription(); }