| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "core/html/parser/HTMLTreeBuilder.h" | 28 #include "core/html/parser/HTMLTreeBuilder.h" |
| 29 | 29 |
| 30 #include "HTMLNames.h" | 30 #include "HTMLNames.h" |
| 31 #include "MathMLNames.h" | 31 #include "MathMLNames.h" |
| 32 #include "SVGNames.h" | 32 #include "SVGNames.h" |
| 33 #include "XLinkNames.h" | 33 #include "XLinkNames.h" |
| 34 #include "XMLNSNames.h" | 34 #include "XMLNSNames.h" |
| 35 #include "XMLNames.h" | 35 #include "XMLNames.h" |
| 36 #include "bindings/v8/ExceptionStatePlaceholder.h" | 36 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 37 #include "core/dom/DocumentFragment.h" | 37 #include "core/dom/DocumentFragment.h" |
| 38 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/html/HTMLDocument.h" | 39 #include "core/html/HTMLDocument.h" |
| 39 #include "core/html/HTMLFormElement.h" | 40 #include "core/html/HTMLFormElement.h" |
| 40 #include "core/html/parser/AtomicHTMLToken.h" | 41 #include "core/html/parser/AtomicHTMLToken.h" |
| 41 #include "core/html/parser/HTMLDocumentParser.h" | 42 #include "core/html/parser/HTMLDocumentParser.h" |
| 42 #include "core/html/parser/HTMLParserIdioms.h" | 43 #include "core/html/parser/HTMLParserIdioms.h" |
| 43 #include "core/html/parser/HTMLStackItem.h" | 44 #include "core/html/parser/HTMLStackItem.h" |
| 44 #include "core/html/parser/HTMLToken.h" | 45 #include "core/html/parser/HTMLToken.h" |
| 45 #include "core/html/parser/HTMLTokenizer.h" | 46 #include "core/html/parser/HTMLTokenizer.h" |
| 46 #include "platform/NotImplemented.h" | 47 #include "platform/NotImplemented.h" |
| 47 #include "platform/text/PlatformLocale.h" | 48 #include "platform/text/PlatformLocale.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return tagName == nobrTag | 127 return tagName == nobrTag |
| 127 || isNonAnchorNonNobrFormattingTag(tagName); | 128 || isNonAnchorNonNobrFormattingTag(tagName); |
| 128 } | 129 } |
| 129 | 130 |
| 130 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#form
atting | 131 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#form
atting |
| 131 static bool isFormattingTag(const AtomicString& tagName) | 132 static bool isFormattingTag(const AtomicString& tagName) |
| 132 { | 133 { |
| 133 return tagName == aTag || isNonAnchorFormattingTag(tagName); | 134 return tagName == aTag || isNonAnchorFormattingTag(tagName); |
| 134 } | 135 } |
| 135 | 136 |
| 136 static HTMLFormElement* closestFormAncestor(Element* element) | 137 static HTMLFormElement* closestFormAncestor(Element& element) |
| 137 { | 138 { |
| 138 ASSERT(isMainThread()); | 139 ASSERT(isMainThread()); |
| 139 while (element) { | 140 return Traversal<HTMLFormElement>::firstAncestorOrSelf(element); |
| 140 if (isHTMLFormElement(*element)) | |
| 141 return toHTMLFormElement(element); | |
| 142 ContainerNode* parent = element->parentNode(); | |
| 143 if (!parent || !parent->isElementNode()) | |
| 144 return 0; | |
| 145 element = toElement(parent); | |
| 146 } | |
| 147 return 0; | |
| 148 } | 141 } |
| 149 | 142 |
| 150 class HTMLTreeBuilder::CharacterTokenBuffer { | 143 class HTMLTreeBuilder::CharacterTokenBuffer { |
| 151 WTF_MAKE_NONCOPYABLE(CharacterTokenBuffer); | 144 WTF_MAKE_NONCOPYABLE(CharacterTokenBuffer); |
| 152 public: | 145 public: |
| 153 explicit CharacterTokenBuffer(AtomicHTMLToken* token) | 146 explicit CharacterTokenBuffer(AtomicHTMLToken* token) |
| 154 : m_characters(token->characters().impl()) | 147 : m_characters(token->characters().impl()) |
| 155 , m_current(0) | 148 , m_current(0) |
| 156 , m_end(token->characters().length()) | 149 , m_end(token->characters().length()) |
| 157 { | 150 { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: | 301 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: |
| 309 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.h
tml#fragment-case | 302 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.h
tml#fragment-case |
| 310 // For efficiency, we skip step 4.2 ("Let root be a new html element wit
h no attributes") | 303 // For efficiency, we skip step 4.2 ("Let root be a new html element wit
h no attributes") |
| 311 // and instead use the DocumentFragment as a root node. | 304 // and instead use the DocumentFragment as a root node. |
| 312 m_tree.openElements()->pushRootNode(HTMLStackItem::create(fragment, HTML
StackItem::ItemForDocumentFragmentNode)); | 305 m_tree.openElements()->pushRootNode(HTMLStackItem::create(fragment, HTML
StackItem::ItemForDocumentFragmentNode)); |
| 313 | 306 |
| 314 if (isHTMLTemplateElement(*contextElement)) | 307 if (isHTMLTemplateElement(*contextElement)) |
| 315 m_templateInsertionModes.append(TemplateContentsMode); | 308 m_templateInsertionModes.append(TemplateContentsMode); |
| 316 | 309 |
| 317 resetInsertionModeAppropriately(); | 310 resetInsertionModeAppropriately(); |
| 318 m_tree.setForm(closestFormAncestor(contextElement)); | 311 m_tree.setForm(closestFormAncestor(*contextElement)); |
| 319 } | 312 } |
| 320 } | 313 } |
| 321 | 314 |
| 322 HTMLTreeBuilder::~HTMLTreeBuilder() | 315 HTMLTreeBuilder::~HTMLTreeBuilder() |
| 323 { | 316 { |
| 324 } | 317 } |
| 325 | 318 |
| 326 void HTMLTreeBuilder::detach() | 319 void HTMLTreeBuilder::detach() |
| 327 { | 320 { |
| 328 #ifndef NDEBUG | 321 #ifndef NDEBUG |
| (...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 ASSERT(m_isAttached); | 2782 ASSERT(m_isAttached); |
| 2790 // Warning, this may detach the parser. Do not do anything else after this. | 2783 // Warning, this may detach the parser. Do not do anything else after this. |
| 2791 m_tree.finishedParsing(); | 2784 m_tree.finishedParsing(); |
| 2792 } | 2785 } |
| 2793 | 2786 |
| 2794 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 2787 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) |
| 2795 { | 2788 { |
| 2796 } | 2789 } |
| 2797 | 2790 |
| 2798 } // namespace WebCore | 2791 } // namespace WebCore |
| OLD | NEW |