| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 635 } |
| 636 | 636 |
| 637 bool Document::isInMainFrame() const { | 637 bool Document::isInMainFrame() const { |
| 638 return frame() && frame()->isMainFrame(); | 638 return frame() && frame()->isMainFrame(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 AtomicString Document::convertLocalName(const AtomicString& name) { | 641 AtomicString Document::convertLocalName(const AtomicString& name) { |
| 642 return isHTMLDocument() ? name.lower() : name; | 642 return isHTMLDocument() ? name.lower() : name; |
| 643 } | 643 } |
| 644 | 644 |
| 645 // https://dom.spec.whatwg.org/#dom-document-createelement |
| 645 Element* Document::createElement(const AtomicString& name, | 646 Element* Document::createElement(const AtomicString& name, |
| 646 ExceptionState& exceptionState) { | 647 ExceptionState& exceptionState) { |
| 647 if (!isValidName(name)) { | 648 if (!isValidName(name)) { |
| 648 exceptionState.throwDOMException( | 649 exceptionState.throwDOMException( |
| 649 InvalidCharacterError, | 650 InvalidCharacterError, |
| 650 "The tag name provided ('" + name + "') is not a valid name."); | 651 "The tag name provided ('" + name + "') is not a valid name."); |
| 651 return nullptr; | 652 return nullptr; |
| 652 } | 653 } |
| 653 | 654 |
| 654 if (isXHTMLDocument() || isHTMLDocument()) { | 655 if (isXHTMLDocument() || isHTMLDocument()) { |
| 655 if (CustomElement::shouldCreateCustomElement(name)) | 656 // 2. If the context object is an HTML document, let localName be |
| 656 return CustomElement::createCustomElementSync(*this, name, | 657 // converted to ASCII lowercase. |
| 658 AtomicString localName = convertLocalName(name); |
| 659 if (CustomElement::shouldCreateCustomElement(localName)) |
| 660 return CustomElement::createCustomElementSync(*this, localName, |
| 657 exceptionState); | 661 exceptionState); |
| 658 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *this, | 662 return HTMLElementFactory::createHTMLElement(localName, *this, 0, |
| 659 0, CreatedByCreateElement); | 663 CreatedByCreateElement); |
| 660 } | 664 } |
| 661 | 665 |
| 662 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); | 666 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); |
| 663 } | 667 } |
| 664 | 668 |
| 665 Element* Document::createElement(const AtomicString& localName, | 669 Element* Document::createElement(const AtomicString& localName, |
| 666 const AtomicString& typeExtension, | 670 const AtomicString& typeExtension, |
| 667 ExceptionState& exceptionState) { | 671 ExceptionState& exceptionState) { |
| 668 if (!isValidName(localName)) { | 672 if (!isValidName(localName)) { |
| 669 exceptionState.throwDOMException( | 673 exceptionState.throwDOMException( |
| 670 InvalidCharacterError, | 674 InvalidCharacterError, |
| 671 "The tag name provided ('" + localName + "') is not a valid name."); | 675 "The tag name provided ('" + localName + "') is not a valid name."); |
| 672 return nullptr; | 676 return nullptr; |
| 673 } | 677 } |
| 674 | 678 |
| 675 Element* element; | 679 Element* element; |
| 676 | 680 |
| 677 if (CustomElement::shouldCreateCustomElement(localName)) { | 681 if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) { |
| 678 element = CustomElement::createCustomElementSync(*this, localName, | 682 element = CustomElement::createCustomElementSync( |
| 679 exceptionState); | 683 *this, convertLocalName(localName), exceptionState); |
| 680 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { | 684 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { |
| 681 element = registrationContext()->createCustomTagElement( | 685 element = registrationContext()->createCustomTagElement( |
| 682 *this, QualifiedName(nullAtom, convertLocalName(localName), | 686 *this, QualifiedName(nullAtom, convertLocalName(localName), |
| 683 xhtmlNamespaceURI)); | 687 xhtmlNamespaceURI)); |
| 684 } else { | 688 } else { |
| 685 element = createElement(localName, exceptionState); | 689 element = createElement(localName, exceptionState); |
| 686 if (exceptionState.hadException()) | 690 if (exceptionState.hadException()) |
| 687 return nullptr; | 691 return nullptr; |
| 688 } | 692 } |
| 689 | 693 |
| (...skipping 5701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6391 } | 6395 } |
| 6392 | 6396 |
| 6393 void showLiveDocumentInstances() { | 6397 void showLiveDocumentInstances() { |
| 6394 WeakDocumentSet& set = liveDocumentSet(); | 6398 WeakDocumentSet& set = liveDocumentSet(); |
| 6395 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6399 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6396 for (Document* document : set) | 6400 for (Document* document : set) |
| 6397 fprintf(stderr, "- Document %p URL: %s\n", document, | 6401 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6398 document->url().getString().utf8().data()); | 6402 document->url().getString().utf8().data()); |
| 6399 } | 6403 } |
| 6400 #endif | 6404 #endif |
| OLD | NEW |