Commit 1e3a190f authored by ddkilzer@apple.com's avatar ddkilzer@apple.com

Bug 23741: StyleRareNonInheritedData::operator==() should not compare...

        Bug 23741: StyleRareNonInheritedData::operator==() should not compare ContentData objects by pointer

        <https://bugs.webkit.org/show_bug.cgi?id=23741>

        Reviewed by Darin Adler.

        * rendering/style/RenderStyle.cpp:
        (WebCore::RenderStyle::contentDataEquivalent): Moved method to
        WebCore::StyleRareNonInheritedData class.
        * rendering/style/RenderStyle.h:
        (WebCore::InheritedFlags::contentDataEquivalent): Replaced declaration
        with inline method that calls contentDataEquivalent() on
        WebCore::StyleRareNonInheritedData instead.
        * rendering/style/StyleRareNonInheritedData.cpp:
        (WebCore::StyleRareNonInheritedData::operator==): This is the bug fix!
        Replaced pointer comparison of ContentData objects with call to
        StyleRareNonInheritedData::contentDataEquivalent().
        (WebCore::StyleRareNonInheritedData::contentDataEquivalent): Added.
        * rendering/style/StyleRareNonInheritedData.h:
        (WebCore::StyleRareNonInheritedData::contentDataEquivalent): Added
        declaration.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f1fd1c90
2009-02-06 David Kilzer <ddkilzer@apple.com>
Bug 23741: StyleRareNonInheritedData::operator==() should not compare ContentData objects by pointer
<https://bugs.webkit.org/show_bug.cgi?id=23741>
Reviewed by Darin Adler.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::contentDataEquivalent): Moved method to
WebCore::StyleRareNonInheritedData class.
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::contentDataEquivalent): Replaced declaration
with inline method that calls contentDataEquivalent() on
WebCore::StyleRareNonInheritedData instead.
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::operator==): This is the bug fix!
Replaced pointer comparison of ContentData objects with call to
StyleRareNonInheritedData::contentDataEquivalent().
(WebCore::StyleRareNonInheritedData::contentDataEquivalent): Added.
* rendering/style/StyleRareNonInheritedData.h:
(WebCore::StyleRareNonInheritedData::contentDataEquivalent): Added
declaration.
2009-02-06 Simon Fraser <simon.fraser@apple.com>
Reviewed by Eric Seidel
......@@ -503,39 +503,6 @@ void RenderStyle::clearCursorList()
inherited.access()->cursorData = 0;
}
bool RenderStyle::contentDataEquivalent(const RenderStyle* otherStyle) const
{
ContentData* c1 = rareNonInheritedData->m_content.get();
ContentData* c2 = otherStyle->rareNonInheritedData->m_content.get();
while (c1 && c2) {
if (c1->m_type != c2->m_type)
return false;
switch (c1->m_type) {
case CONTENT_NONE:
break;
case CONTENT_TEXT:
if (!equal(c1->m_content.m_text, c2->m_content.m_text))
return false;
break;
case CONTENT_OBJECT:
if (!StyleImage::imagesEquivalent(c1->m_content.m_image, c2->m_content.m_image))
return false;
break;
case CONTENT_COUNTER:
if (*c1->m_content.m_counter != *c2->m_content.m_counter)
return false;
break;
}
c1 = c1->m_next;
c2 = c2->m_next;
}
return !c1 && !c2;
}
void RenderStyle::clearContent()
{
if (rareNonInheritedData->m_content)
......
......@@ -971,7 +971,7 @@ public:
#endif
const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
bool contentDataEquivalent(const RenderStyle* otherStyle) const;
bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast<RenderStyle*>(this)->rareNonInheritedData->contentDataEquivalent(*const_cast<RenderStyle*>(otherStyle)->rareNonInheritedData); }
void clearContent();
void setContent(StringImpl*, bool add = false);
void setContent(PassRefPtr<StyleImage>, bool add = false);
......
......@@ -23,7 +23,10 @@
#include "StyleRareNonInheritedData.h"
#include "CSSStyleSelector.h"
#include "ContentData.h"
#include "RenderCounter.h"
#include "RenderStyle.h"
#include "StyleImage.h"
namespace WebCore {
......@@ -105,7 +108,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& marquee == o.marquee
&& m_multiCol == o.m_multiCol
&& m_transform == o.m_transform
&& m_content == o.m_content
&& contentDataEquivalent(o)
&& m_counterDirectives == o.m_counterDirectives
&& userDrag == o.userDrag
&& textOverflow == o.textOverflow
......@@ -126,6 +129,39 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
;
}
bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const
{
ContentData* c1 = m_content.get();
ContentData* c2 = o.m_content.get();
while (c1 && c2) {
if (c1->m_type != c2->m_type)
return false;
switch (c1->m_type) {
case CONTENT_NONE:
break;
case CONTENT_TEXT:
if (!equal(c1->m_content.m_text, c2->m_content.m_text))
return false;
break;
case CONTENT_OBJECT:
if (!StyleImage::imagesEquivalent(c1->m_content.m_image, c2->m_content.m_image))
return false;
break;
case CONTENT_COUNTER:
if (*c1->m_content.m_counter != *c2->m_content.m_counter)
return false;
break;
}
c1 = c1->m_next;
c2 = c2->m_next;
}
return !c1 && !c2;
}
bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const
{
if (!m_boxShadow && o.m_boxShadow || m_boxShadow && !o.m_boxShadow)
......
......@@ -69,7 +69,8 @@ public:
bool operator==(const StyleRareNonInheritedData&) const;
bool operator!=(const StyleRareNonInheritedData& o) const { return !(*this == o); }
bool contentDataEquivalent(const StyleRareNonInheritedData& o) const;
bool shadowDataEquivalent(const StyleRareNonInheritedData& o) const;
bool reflectionDataEquivalent(const StyleRareNonInheritedData& o) const;
bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
......
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