1 /* 2 * Copyright (C) 1999 Antti Koivisto (koivisto (at) kde.org) 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 * 20 */ 21 22 #include "config.h" 23 #include "ContentData.h" 24 25 #include "StyleImage.h" 26 #include <wtf/text/StringImpl.h> 27 28 namespace WebCore { 29 30 void ContentData::clear() 31 { 32 deleteContent(); 33 34 // Delete the singly-linked list without recursing. 35 for (OwnPtr<ContentData> next = m_next.release(); next; next = next->m_next.release()) { } 36 } 37 38 // FIXME: Why isn't this just operator==? 39 // FIXME: This is not a good name for a boolean-returning function. 40 bool ContentData::dataEquivalent(const ContentData& other) const 41 { 42 if (type() != other.type()) 43 return false; 44 45 switch (type()) { 46 case CONTENT_NONE: 47 return true; 48 case CONTENT_TEXT: 49 return equal(text(), other.text()); 50 case CONTENT_OBJECT: 51 return StyleImage::imagesEquivalent(image(), other.image()); 52 case CONTENT_COUNTER: 53 return *counter() == *other.counter(); 54 case CONTENT_QUOTE: 55 return quote() == other.quote(); 56 } 57 58 ASSERT_NOT_REACHED(); 59 return false; 60 } 61 62 void ContentData::deleteContent() 63 { 64 switch (m_type) { 65 case CONTENT_NONE: 66 break; 67 case CONTENT_OBJECT: 68 m_content.m_image->deref(); 69 break; 70 case CONTENT_TEXT: 71 m_content.m_text->deref(); 72 break; 73 case CONTENT_COUNTER: 74 delete m_content.m_counter; 75 break; 76 case CONTENT_QUOTE: 77 break; 78 } 79 80 m_type = CONTENT_NONE; 81 } 82 83 } // namespace WebCore 84