2 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
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.
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.
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.
24 #include "WMLTaskElement.h"
26 #include "WMLAnchorElement.h"
27 #include "WMLDoElement.h"
29 #include "WMLOnEventElement.h"
30 #include "WMLPageState.h"
31 #include "WMLSetvarElement.h"
35 using namespace WMLNames;
37 WMLTaskElement::WMLTaskElement(const QualifiedName& tagName, Document* doc)
38 : WMLElement(tagName, doc)
42 WMLTaskElement::~WMLTaskElement()
46 void WMLTaskElement::insertedIntoDocument()
48 WMLElement::insertedIntoDocument();
50 Node* parent = parentNode();
53 if (!parent || !parent->isWMLElement())
56 if (parent->hasTagName(anchorTag))
57 static_cast<WMLAnchorElement*>(parent)->registerTask(this);
58 else if (parent->hasTagName(doTag))
59 static_cast<WMLDoElement*>(parent)->registerTask(this);
60 else if (parent->hasTagName(oneventTag))
61 static_cast<WMLOnEventElement*>(parent)->registerTask(this);
64 void WMLTaskElement::registerVariableSetter(WMLSetvarElement* element)
67 m_variableSetterElements.add(element);
70 void WMLTaskElement::storeVariableState(WMLPageState* pageState)
72 if (!pageState || m_variableSetterElements.isEmpty())
75 WMLVariableMap variables;
76 HashSet<WMLSetvarElement*>::iterator it = m_variableSetterElements.begin();
77 HashSet<WMLSetvarElement*>::iterator end = m_variableSetterElements.end();
79 for (; it != end; ++it) {
80 WMLSetvarElement* setterElement = (*it);
81 if (setterElement->name().isEmpty())
84 variables.set(setterElement->name(), setterElement->value());
87 if (variables.isEmpty())
90 pageState->storeVariables(variables);