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 "WMLDocument.h"
26 #include "BackForwardList.h"
29 #include "ScriptableDocumentParser.h"
30 #include "WMLCardElement.h"
31 #include "WMLErrorHandling.h"
32 #include "WMLPageState.h"
33 #include "WMLTemplateElement.h"
37 WMLDocument::WMLDocument(Frame* frame, const KURL& url)
38 : Document(frame, url, false, false)
44 WMLDocument::~WMLDocument()
48 void WMLDocument::finishedParsing()
50 if (ScriptableDocumentParser* parser = this->scriptableDocumentParser()) {
51 if (!parser->wellFormed()) {
52 Document::finishedParsing();
57 bool hasAccess = initialize(true);
58 Document::finishedParsing();
63 WMLPageState* wmlPageState = wmlPageStateForDocument(this);
67 Page* page = wmlPageState->page();
71 BackForwardList* list = page->backForwardList();
75 HistoryItem* item = list->backItem();
79 page->goToItem(item, FrameLoadTypeBackWMLDeckNotAccessible);
84 m_activeCard->handleIntrinsicEventIfNeeded();
87 bool WMLDocument::initialize(bool aboutToFinishParsing)
89 WMLPageState* wmlPageState = wmlPageStateForDocument(this);
90 if (!wmlPageState || !wmlPageState->canAccessDeck())
93 // Remember that we'e successfully entered the deck
94 wmlPageState->resetAccessControlData();
96 // Notify the existance of templates to all cards of the current deck
97 WMLTemplateElement::registerTemplatesInDocument(this);
99 // Set destination card
100 m_activeCard = WMLCardElement::determineActiveCard(this);
102 reportWMLError(this, WMLErrorNoCardInDocument);
106 // Handle deck-level task overrides
107 m_activeCard->handleDeckLevelTaskOverridesIfNeeded();
109 // Handle card-level intrinsic event
110 if (!aboutToFinishParsing)
111 m_activeCard->handleIntrinsicEventIfNeeded();
116 WMLPageState* wmlPageStateForDocument(Document* doc)
120 Page* page = doc->page();
123 return page->wmlPageState();