diff options
Diffstat (limited to 'WebCore/html/parser/HTMLTreeBuilder.cpp')
-rw-r--r-- | WebCore/html/parser/HTMLTreeBuilder.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/WebCore/html/parser/HTMLTreeBuilder.cpp b/WebCore/html/parser/HTMLTreeBuilder.cpp index 6134607..3d39131 100644 --- a/WebCore/html/parser/HTMLTreeBuilder.cpp +++ b/WebCore/html/parser/HTMLTreeBuilder.cpp @@ -56,6 +56,11 @@ using namespace HTMLNames; static const int uninitializedLineNumberValue = -1; +static TextPosition1 uninitializedPositionValue1() +{ + return TextPosition1(WTF::OneBasedNumber::fromOneBasedInt(-1), WTF::OneBasedNumber::base()); +} + namespace { inline bool isHTMLSpaceOrReplacementCharacter(UChar character) @@ -225,7 +230,7 @@ HTMLFormElement* closestFormAncestor(Element* element) while (element) { if (element->hasTagName(formTag)) return static_cast<HTMLFormElement*>(element); - Node* parent = element->parent(); + ContainerNode* parent = element->parentNode(); if (!parent || !parent->isElementNode()) return 0; element = static_cast<Element*>(parent); @@ -340,8 +345,8 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLDocument* documen , m_insertionMode(InitialMode) , m_originalInsertionMode(InitialMode) , m_tokenizer(tokenizer) - , m_scriptToProcessStartLine(uninitializedLineNumberValue) - , m_lastScriptElementStartLine(uninitializedLineNumberValue) + , m_scriptToProcessStartPosition(uninitializedPositionValue1()) + , m_lastScriptElementStartPosition(TextPosition0::belowRangePosition()) , m_usePreHTML5ParserQuirks(usePreHTML5ParserQuirks) , m_hasPendingForeignInsertionModeSteps(false) { @@ -359,8 +364,8 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fra , m_insertionMode(InitialMode) , m_originalInsertionMode(InitialMode) , m_tokenizer(tokenizer) - , m_scriptToProcessStartLine(uninitializedLineNumberValue) - , m_lastScriptElementStartLine(uninitializedLineNumberValue) + , m_scriptToProcessStartPosition(uninitializedPositionValue1()) + , m_lastScriptElementStartPosition(TextPosition0::belowRangePosition()) , m_usePreHTML5ParserQuirks(usePreHTML5ParserQuirks) , m_hasPendingForeignInsertionModeSteps(false) { @@ -423,15 +428,15 @@ HTMLTreeBuilder::FragmentParsingContext::~FragmentParsingContext() { } -PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(int& scriptStartLine) +PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(TextPosition1& scriptStartPosition) { // Unpause ourselves, callers may pause us again when processing the script. // The HTML5 spec is written as though scripts are executed inside the tree // builder. We pause the parser to exit the tree builder, and then resume // before running scripts. m_isPaused = false; - scriptStartLine = m_scriptToProcessStartLine; - m_scriptToProcessStartLine = uninitializedLineNumberValue; + scriptStartPosition = m_scriptToProcessStartPosition; + m_scriptToProcessStartPosition = uninitializedPositionValue1(); return m_scriptToProcess.release(); } @@ -549,14 +554,14 @@ void HTMLTreeBuilder::processIsindexStartTagForInBody(AtomicHTMLToken& token) return; notImplemented(); // Acknowledge self-closing flag processFakeStartTag(formTag); - Attribute* actionAttribute = token.getAttributeItem(actionAttr); + RefPtr<Attribute> actionAttribute = token.getAttributeItem(actionAttr); if (actionAttribute) { ASSERT(m_tree.currentElement()->hasTagName(formTag)); m_tree.currentElement()->setAttribute(actionAttr, actionAttribute->value()); } processFakeStartTag(hrTag); processFakeStartTag(labelTag); - Attribute* promptAttribute = token.getAttributeItem(promptAttr); + RefPtr<Attribute> promptAttribute = token.getAttributeItem(promptAttr); if (promptAttribute) processFakeCharacters(promptAttribute->value()); else @@ -2190,7 +2195,7 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token) m_isPaused = true; ASSERT(m_tree.currentElement()->hasTagName(scriptTag)); m_scriptToProcess = m_tree.currentElement(); - m_scriptToProcessStartLine = m_lastScriptElementStartLine + 1; + m_scriptToProcessStartPosition = WTF::toOneBasedTextPosition(m_lastScriptElementStartPosition); m_tree.openElements()->pop(); if (isParsingFragment() && m_fragmentContext.scriptingPermission() == FragmentScriptingNotAllowed) m_scriptToProcess->removeAllChildren(); @@ -2770,7 +2775,10 @@ void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken& token) m_tree.insertScriptElement(token); m_tokenizer->setState(HTMLTokenizer::ScriptDataState); m_originalInsertionMode = m_insertionMode; - m_lastScriptElementStartLine = m_tokenizer->lineNumber(); + + TextPosition0 position = TextPosition0(WTF::ZeroBasedNumber::fromZeroBasedInt(m_tokenizer->lineNumber()), WTF::ZeroBasedNumber::base()); + m_lastScriptElementStartPosition = position; + setInsertionMode(TextMode); } |