|
Lines 39-44
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec1
|
| 39 |
#include "HTMLNames.h" |
39 |
#include "HTMLNames.h" |
| 40 |
#include "HTMLParserIdioms.h" |
40 |
#include "HTMLParserIdioms.h" |
| 41 |
#include "HTMLScriptElement.h" |
41 |
#include "HTMLScriptElement.h" |
|
|
42 |
#include "HTMLStackItem.h" |
| 42 |
#include "HTMLToken.h" |
43 |
#include "HTMLToken.h" |
| 43 |
#include "HTMLTokenizer.h" |
44 |
#include "HTMLTokenizer.h" |
| 44 |
#include "LocalizedStrings.h" |
45 |
#include "LocalizedStrings.h" |
|
Lines 197-203
void HTMLConstructionSite::insertHTMLHtmlStartTagBeforeHTML(AtomicHTMLToken* tok
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec2
|
| 197 |
RefPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(m_document); |
198 |
RefPtr<HTMLHtmlElement> element = HTMLHtmlElement::create(m_document); |
| 198 |
element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission); |
199 |
element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission); |
| 199 |
attachLater(m_attachmentRoot, element); |
200 |
attachLater(m_attachmentRoot, element); |
| 200 |
m_openElements.pushHTMLHtmlElement(element); |
201 |
m_openElements.pushHTMLHtmlElement(HTMLStackItem::create(element, token)); |
| 201 |
|
202 |
|
| 202 |
executeQueuedTasks(); |
203 |
executeQueuedTasks(); |
| 203 |
element->insertedByParser(); |
204 |
element->insertedByParser(); |
|
Lines 282-288
void HTMLConstructionSite::insertHTMLHeadElement(AtomicHTMLToken* token)
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec3
|
| 282 |
ASSERT(!shouldFosterParent()); |
283 |
ASSERT(!shouldFosterParent()); |
| 283 |
m_head = createHTMLElement(token); |
284 |
m_head = createHTMLElement(token); |
| 284 |
attachLater(currentNode(), m_head); |
285 |
attachLater(currentNode(), m_head); |
| 285 |
m_openElements.pushHTMLHeadElement(m_head); |
286 |
m_openElements.pushHTMLHeadElement(HTMLStackItem::create(m_head, token)); |
| 286 |
} |
287 |
} |
| 287 |
|
288 |
|
| 288 |
void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) |
289 |
void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token) |
|
Lines 290-296
void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken* token)
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec4
|
| 290 |
ASSERT(!shouldFosterParent()); |
291 |
ASSERT(!shouldFosterParent()); |
| 291 |
RefPtr<Element> body = createHTMLElement(token); |
292 |
RefPtr<Element> body = createHTMLElement(token); |
| 292 |
attachLater(currentNode(), body); |
293 |
attachLater(currentNode(), body); |
| 293 |
m_openElements.pushHTMLBodyElement(body.release()); |
294 |
m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), token)); |
| 294 |
} |
295 |
} |
| 295 |
|
296 |
|
| 296 |
void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool isDemoted) |
297 |
void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool isDemoted) |
|
Lines 300-313
void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool is
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec5
|
| 300 |
m_form = static_pointer_cast<HTMLFormElement>(element.release()); |
301 |
m_form = static_pointer_cast<HTMLFormElement>(element.release()); |
| 301 |
m_form->setDemoted(isDemoted); |
302 |
m_form->setDemoted(isDemoted); |
| 302 |
attachLater(currentNode(), m_form); |
303 |
attachLater(currentNode(), m_form); |
| 303 |
m_openElements.push(m_form); |
304 |
m_openElements.push(HTMLStackItem::create(m_form, token)); |
| 304 |
} |
305 |
} |
| 305 |
|
306 |
|
| 306 |
void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) |
307 |
void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) |
| 307 |
{ |
308 |
{ |
| 308 |
RefPtr<Element> element = createHTMLElement(token); |
309 |
RefPtr<Element> element = createHTMLElement(token); |
| 309 |
attachLater(currentNode(), element); |
310 |
attachLater(currentNode(), element); |
| 310 |
m_openElements.push(element.release()); |
311 |
m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 311 |
} |
312 |
} |
| 312 |
|
313 |
|
| 313 |
void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) |
314 |
void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken* token) |
|
Lines 327-333
void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken* token)
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec6
|
| 327 |
// Possible active formatting elements include: |
328 |
// Possible active formatting elements include: |
| 328 |
// a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, and u. |
329 |
// a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, and u. |
| 329 |
insertHTMLElement(token); |
330 |
insertHTMLElement(token); |
| 330 |
m_activeFormattingElements.append(currentElement()); |
331 |
m_activeFormattingElements.append(currentElementRecord()->stackItem()); |
| 331 |
} |
332 |
} |
| 332 |
|
333 |
|
| 333 |
void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) |
334 |
void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) |
|
Lines 343-349
void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token)
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec7
|
| 343 |
if (m_fragmentScriptingPermission != DisallowScriptingContent) |
344 |
if (m_fragmentScriptingPermission != DisallowScriptingContent) |
| 344 |
element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission); |
345 |
element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission); |
| 345 |
attachLater(currentNode(), element); |
346 |
attachLater(currentNode(), element); |
| 346 |
m_openElements.push(element.release()); |
347 |
m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 347 |
} |
348 |
} |
| 348 |
|
349 |
|
| 349 |
void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const AtomicString& namespaceURI) |
350 |
void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const AtomicString& namespaceURI) |
|
Lines 354-360
void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec8
|
| 354 |
RefPtr<Element> element = createElement(token, namespaceURI); |
355 |
RefPtr<Element> element = createElement(token, namespaceURI); |
| 355 |
attachLater(currentNode(), element, token->selfClosing()); |
356 |
attachLater(currentNode(), element, token->selfClosing()); |
| 356 |
if (!token->selfClosing()) |
357 |
if (!token->selfClosing()) |
| 357 |
m_openElements.push(element.release()); |
358 |
m_openElements.push(HTMLStackItem::create(element.release(), token, namespaceURI)); |
| 358 |
} |
359 |
} |
| 359 |
|
360 |
|
| 360 |
void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMode whitespaceMode) |
361 |
void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMode whitespaceMode) |
|
Lines 418-445
PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* tok
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec9
|
| 418 |
return element.release(); |
419 |
return element.release(); |
| 419 |
} |
420 |
} |
| 420 |
|
421 |
|
| 421 |
PassRefPtr<Element> HTMLConstructionSite::createHTMLElementFromElementRecord(HTMLElementStack::ElementRecord* record) |
422 |
PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem* item) |
| 422 |
{ |
423 |
{ |
| 423 |
return createHTMLElementFromSavedElement(record->element()); |
424 |
RefPtr<Element> element; |
| 424 |
} |
425 |
if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) |
| 425 |
|
426 |
element = createHTMLElement(item->token()); |
| 426 |
PassRefPtr<Element> HTMLConstructionSite::createHTMLElementFromSavedElement(Element* element) |
427 |
else |
| 427 |
{ |
428 |
element = createElement(item->token(), item->namespaceURI()); |
| 428 |
// FIXME: This method is wrong. We should be using the original token. |
429 |
return HTMLStackItem::create(element.release(), item->token(), item->namespaceURI()); |
| 429 |
// Using an Element* causes us to fail examples like this: |
|
|
| 430 |
// <b id="1"><p><script>document.getElementById("1").id = "2"</script></p>TEXT</b> |
| 431 |
// When reconstructTheActiveFormattingElements calls this method to open |
| 432 |
// a second <b> tag to wrap TEXT, it will have id "2", even though the HTML5 |
| 433 |
// spec implies it should be "1". Minefield matches the HTML5 spec here. |
| 434 |
|
| 435 |
ASSERT(element->isHTMLElement()); // otherwise localName() might be wrong. |
| 436 |
|
| 437 |
Vector<Attribute> clonedAttributes; |
| 438 |
if (ElementAttributeData* attributeData = element->updatedAttributeData()) |
| 439 |
clonedAttributes = attributeData->clonedAttributeVector(); |
| 440 |
|
| 441 |
RefPtr<AtomicHTMLToken> fakeToken = AtomicHTMLToken::create(HTMLTokenTypes::StartTag, element->localName(), clonedAttributes); |
| 442 |
return createHTMLElement(fakeToken.get()); |
| 443 |
} |
430 |
} |
| 444 |
|
431 |
|
| 445 |
bool HTMLConstructionSite::indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const |
432 |
bool HTMLConstructionSite::indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const |
|
Lines 469-478
void HTMLConstructionSite::reconstructTheActiveFormattingElements()
a/Source/WebCore/html/parser/HTMLConstructionSite.cpp_sec10
|
| 469 |
ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); |
456 |
ASSERT(unopenEntryIndex < m_activeFormattingElements.size()); |
| 470 |
for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIndex) { |
457 |
for (; unopenEntryIndex < m_activeFormattingElements.size(); ++unopenEntryIndex) { |
| 471 |
HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElements.at(unopenEntryIndex); |
458 |
HTMLFormattingElementList::Entry& unopenedEntry = m_activeFormattingElements.at(unopenEntryIndex); |
| 472 |
RefPtr<Element> reconstructed = createHTMLElementFromSavedElement(unopenedEntry.element()); |
459 |
RefPtr<HTMLStackItem> reconstructed = createElementFromSavedToken(unopenedEntry.stackItem().get()); |
| 473 |
attachLater(currentNode(), reconstructed); |
460 |
attachLater(currentNode(), reconstructed->node()); |
| 474 |
m_openElements.push(reconstructed.release()); |
461 |
m_openElements.push(reconstructed); |
| 475 |
unopenedEntry.replaceElement(currentElement()); |
462 |
unopenedEntry.replaceElement(reconstructed.release()); |
| 476 |
} |
463 |
} |
| 477 |
} |
464 |
} |
| 478 |
|
465 |
|