1 /** 2 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 21 #include "config.h" 22 23 #if ENABLE(WML) 24 #include "WMLFieldSetElement.h" 25 26 #include "Attribute.h" 27 #include "HTMLNames.h" 28 #include "RenderFieldset.h" 29 #include "Text.h" 30 #include "WMLElementFactory.h" 31 #include "WMLNames.h" 32 33 namespace WebCore { 34 35 using namespace WMLNames; 36 37 WMLFieldSetElement::WMLFieldSetElement(const QualifiedName& tagName, Document* doc) 38 : WMLElement(tagName, doc) 39 { 40 } 41 42 PassRefPtr<WMLFieldSetElement> WMLFieldSetElement::create(const QualifiedName& tagName, Document* document) 43 { 44 return adoptRef(new WMLFieldSetElement(tagName, document)); 45 } 46 47 WMLFieldSetElement::~WMLFieldSetElement() 48 { 49 } 50 51 void WMLFieldSetElement::insertedIntoDocument() 52 { 53 WMLElement::insertedIntoDocument(); 54 55 String title = parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::titleAttr)); 56 if (title.isEmpty()) 57 return; 58 59 m_insertedLegendElement = WMLElementFactory::createWMLElement(insertedLegendTag, document()); 60 61 // Insert <dummyLegend> element, as RenderFieldset expect it to be present 62 // to layout it's child text content, when rendering <fieldset> elements 63 ExceptionCode ec = 0; 64 appendChild(m_insertedLegendElement, ec); 65 ASSERT(ec == 0); 66 67 // Create text node holding the 'title' attribute value 68 m_insertedLegendElement->appendChild(document()->createTextNode(title), ec); 69 ASSERT(ec == 0); 70 } 71 72 void WMLFieldSetElement::removedFromDocument() 73 { 74 m_insertedLegendElement.clear(); 75 WMLElement::removedFromDocument(); 76 } 77 78 RenderObject* WMLFieldSetElement::createRenderer(RenderArena* arena, RenderStyle*) 79 { 80 return new (arena) RenderFieldset(this); 81 } 82 83 } 84 85 #endif 86