Chromium Code Reviews| 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 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "sky/engine/core/dom/ElementRareData.h" | 49 #include "sky/engine/core/dom/ElementRareData.h" |
| 50 #include "sky/engine/core/dom/ElementTraversal.h" | 50 #include "sky/engine/core/dom/ElementTraversal.h" |
| 51 #include "sky/engine/core/dom/ExceptionCode.h" | 51 #include "sky/engine/core/dom/ExceptionCode.h" |
| 52 #include "sky/engine/core/dom/MutationObserverInterestGroup.h" | 52 #include "sky/engine/core/dom/MutationObserverInterestGroup.h" |
| 53 #include "sky/engine/core/dom/MutationRecord.h" | 53 #include "sky/engine/core/dom/MutationRecord.h" |
| 54 #include "sky/engine/core/dom/NodeRenderStyle.h" | 54 #include "sky/engine/core/dom/NodeRenderStyle.h" |
| 55 #include "sky/engine/core/dom/RenderTreeBuilder.h" | 55 #include "sky/engine/core/dom/RenderTreeBuilder.h" |
| 56 #include "sky/engine/core/dom/SelectorQuery.h" | 56 #include "sky/engine/core/dom/SelectorQuery.h" |
| 57 #include "sky/engine/core/dom/StyleEngine.h" | 57 #include "sky/engine/core/dom/StyleEngine.h" |
| 58 #include "sky/engine/core/dom/Text.h" | 58 #include "sky/engine/core/dom/Text.h" |
| 59 #include "sky/engine/core/dom/custom/CustomElement.h" | 59 #include "sky/engine/core/dom/custom2/new_custom_element.h" |
| 60 #include "sky/engine/core/dom/custom/CustomElementRegistrationContext.h" | |
| 61 #include "sky/engine/core/dom/shadow/InsertionPoint.h" | 60 #include "sky/engine/core/dom/shadow/InsertionPoint.h" |
| 62 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 61 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 63 #include "sky/engine/core/editing/FrameSelection.h" | 62 #include "sky/engine/core/editing/FrameSelection.h" |
| 64 #include "sky/engine/core/editing/TextIterator.h" | 63 #include "sky/engine/core/editing/TextIterator.h" |
| 65 #include "sky/engine/core/editing/htmlediting.h" | 64 #include "sky/engine/core/editing/htmlediting.h" |
| 66 #include "sky/engine/core/events/EventDispatcher.h" | 65 #include "sky/engine/core/events/EventDispatcher.h" |
| 67 #include "sky/engine/core/events/FocusEvent.h" | 66 #include "sky/engine/core/events/FocusEvent.h" |
| 68 #include "sky/engine/core/frame/FrameView.h" | 67 #include "sky/engine/core/frame/FrameView.h" |
| 69 #include "sky/engine/core/frame/LocalFrame.h" | 68 #include "sky/engine/core/frame/LocalFrame.h" |
| 70 #include "sky/engine/core/frame/Settings.h" | 69 #include "sky/engine/core/frame/Settings.h" |
| 71 #include "sky/engine/core/html/HTMLCanvasElement.h" | 70 #include "sky/engine/core/html/HTMLCanvasElement.h" |
| 72 #include "sky/engine/core/html/HTMLElement.h" | 71 #include "sky/engine/core/html/HTMLElement.h" |
| 73 #include "sky/engine/core/html/HTMLTemplateElement.h" | 72 #include "sky/engine/core/html/HTMLTemplateElement.h" |
| 74 #include "sky/engine/core/html/parser/HTMLDocumentParser.h" | 73 #include "sky/engine/core/html/parser/HTMLDocumentParser.h" |
| 75 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" | 74 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" |
| 76 #include "sky/engine/core/page/ChromeClient.h" | 75 #include "sky/engine/core/page/ChromeClient.h" |
| 77 #include "sky/engine/core/page/FocusController.h" | 76 #include "sky/engine/core/page/FocusController.h" |
| 78 #include "sky/engine/core/page/Page.h" | 77 #include "sky/engine/core/page/Page.h" |
| 79 #include "sky/engine/core/rendering/RenderLayer.h" | 78 #include "sky/engine/core/rendering/RenderLayer.h" |
| 80 #include "sky/engine/core/rendering/RenderView.h" | 79 #include "sky/engine/core/rendering/RenderView.h" |
| 81 #include "sky/engine/platform/EventDispatchForbiddenScope.h" | 80 #include "sky/engine/platform/EventDispatchForbiddenScope.h" |
| 81 #include "sky/engine/tonic/dart_state.h" | |
| 82 #include "sky/engine/wtf/BitVector.h" | 82 #include "sky/engine/wtf/BitVector.h" |
| 83 #include "sky/engine/wtf/HashFunctions.h" | 83 #include "sky/engine/wtf/HashFunctions.h" |
| 84 #include "sky/engine/wtf/text/CString.h" | 84 #include "sky/engine/wtf/text/CString.h" |
| 85 #include "sky/engine/wtf/text/StringBuilder.h" | 85 #include "sky/engine/wtf/text/StringBuilder.h" |
| 86 #include "sky/engine/wtf/text/TextPosition.h" | 86 #include "sky/engine/wtf/text/TextPosition.h" |
| 87 | 87 |
| 88 namespace blink { | 88 namespace blink { |
| 89 | 89 |
| 90 PassRefPtr<Element> Element::create(Document& document, const AtomicString& tagN ame) | |
| 91 { | |
| 92 DCHECK(DartState::Current()) << "This function should be used only by the bi ndings"; | |
| 93 RefPtr<Element> element = create(QualifiedName(tagName), &document); | |
| 94 element->setCustomElementState(Element::WaitingForUpgrade); | |
| 95 element->setCustomElementState(Element::Upgraded); | |
|
ojan
2015/02/20 23:09:34
Presumablye we should add a TODO to get rid of the
abarth-chromium
2015/02/21 00:00:45
Done.
| |
| 96 return element.release(); | |
| 97 } | |
| 98 | |
| 90 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment) | 99 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment) |
| 91 { | 100 { |
| 92 return adoptRef(new Element(tagName, document, CreateElement)); | 101 return adoptRef(new Element(tagName, document, CreateElement)); |
| 93 } | 102 } |
| 94 | 103 |
| 95 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT ype type) | 104 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT ype type) |
| 96 : ContainerNode(document, type) | 105 : ContainerNode(document, type) |
| 97 , m_tagName(tagName) | 106 , m_tagName(tagName) |
| 98 { | 107 { |
| 99 } | 108 } |
| 100 | 109 |
| 101 Element::~Element() | 110 Element::~Element() |
| 102 { | 111 { |
| 103 ASSERT(needsAttach()); | 112 ASSERT(needsAttach()); |
| 104 | 113 |
| 105 #if !ENABLE(OILPAN) | 114 #if !ENABLE(OILPAN) |
| 106 if (hasRareData()) | 115 if (hasRareData()) |
| 107 elementRareData()->clearShadow(); | 116 elementRareData()->clearShadow(); |
| 108 | |
| 109 if (isCustomElement()) | |
| 110 CustomElement::wasDestroyed(this); | |
| 111 #endif | 117 #endif |
| 112 } | 118 } |
| 113 | 119 |
| 114 inline ElementRareData* Element::elementRareData() const | 120 inline ElementRareData* Element::elementRareData() const |
| 115 { | 121 { |
| 116 ASSERT(hasRareData()); | 122 ASSERT(hasRareData()); |
| 117 return static_cast<ElementRareData*>(rareData()); | 123 return static_cast<ElementRareData*>(rareData()); |
| 118 } | 124 } |
| 119 | 125 |
| 120 inline ElementRareData& Element::ensureElementRareData() | 126 inline ElementRareData& Element::ensureElementRareData() |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 void Element::insertedInto(ContainerNode* insertionPoint) | 638 void Element::insertedInto(ContainerNode* insertionPoint) |
| 633 { | 639 { |
| 634 // need to do superclass processing first so inDocument() is true | 640 // need to do superclass processing first so inDocument() is true |
| 635 // by the time we reach updateId | 641 // by the time we reach updateId |
| 636 ContainerNode::insertedInto(insertionPoint); | 642 ContainerNode::insertedInto(insertionPoint); |
| 637 | 643 |
| 638 if (!insertionPoint->isInTreeScope()) | 644 if (!insertionPoint->isInTreeScope()) |
| 639 return; | 645 return; |
| 640 | 646 |
| 641 if (isUpgradedCustomElement() && inDocument()) | 647 if (isUpgradedCustomElement() && inDocument()) |
| 642 CustomElement::didAttach(this, document()); | 648 NewCustomElement::DidAttach(this, document()); |
| 643 | 649 |
| 644 TreeScope& scope = insertionPoint->treeScope(); | 650 TreeScope& scope = insertionPoint->treeScope(); |
| 645 if (scope != treeScope()) | 651 if (scope != treeScope()) |
| 646 return; | 652 return; |
| 647 | 653 |
| 648 const AtomicString& idValue = getIdAttribute(); | 654 const AtomicString& idValue = getIdAttribute(); |
| 649 if (!idValue.isNull()) | 655 if (!idValue.isNull()) |
| 650 updateId(scope, nullAtom, idValue); | 656 updateId(scope, nullAtom, idValue); |
| 651 } | 657 } |
| 652 | 658 |
| 653 void Element::removedFrom(ContainerNode* insertionPoint) | 659 void Element::removedFrom(ContainerNode* insertionPoint) |
| 654 { | 660 { |
| 655 bool wasInDocument = insertionPoint->inDocument(); | 661 bool wasInDocument = insertionPoint->inDocument(); |
| 656 | 662 |
| 657 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | 663 if (insertionPoint->isInTreeScope() && treeScope() == document()) { |
| 658 const AtomicString& idValue = getIdAttribute(); | 664 const AtomicString& idValue = getIdAttribute(); |
| 659 if (!idValue.isNull()) | 665 if (!idValue.isNull()) |
| 660 updateId(insertionPoint->treeScope(), idValue, nullAtom); | 666 updateId(insertionPoint->treeScope(), idValue, nullAtom); |
| 661 } | 667 } |
| 662 | 668 |
| 663 ContainerNode::removedFrom(insertionPoint); | 669 ContainerNode::removedFrom(insertionPoint); |
| 664 if (wasInDocument) { | 670 if (wasInDocument) { |
| 665 if (isUpgradedCustomElement()) | 671 if (isUpgradedCustomElement()) |
| 666 CustomElement::didDetach(this, insertionPoint->document()); | 672 NewCustomElement::DidDetach(this, insertionPoint->document()); |
| 667 } | 673 } |
| 668 } | 674 } |
| 669 | 675 |
| 670 void Element::attach(const AttachContext& context) | 676 void Element::attach(const AttachContext& context) |
| 671 { | 677 { |
| 672 ASSERT(document().inStyleRecalc()); | 678 ASSERT(document().inStyleRecalc()); |
| 673 | 679 |
| 674 if (isInsertionPoint()) | 680 if (isInsertionPoint()) |
| 675 toInsertionPoint(this)->attachDistribution(context); | 681 toInsertionPoint(this)->attachDistribution(context); |
| 676 | 682 |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1294 | 1300 |
| 1295 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) | 1301 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) |
| 1296 { | 1302 { |
| 1297 if (name == HTMLNames::idAttr) | 1303 if (name == HTMLNames::idAttr) |
| 1298 updateId(oldValue, newValue); | 1304 updateId(oldValue, newValue); |
| 1299 | 1305 |
| 1300 if (inActiveDocument() && styleChangeType() < SubtreeStyleChange && affected ByAttributeSelector(name.localName())) | 1306 if (inActiveDocument() && styleChangeType() < SubtreeStyleChange && affected ByAttributeSelector(name.localName())) |
| 1301 setNeedsStyleRecalc(LocalStyleChange); | 1307 setNeedsStyleRecalc(LocalStyleChange); |
| 1302 | 1308 |
| 1303 if (isUpgradedCustomElement()) | 1309 if (isUpgradedCustomElement()) |
| 1304 CustomElement::attributeDidChange(this, name.localName(), oldValue, newV alue); | 1310 NewCustomElement::AttributeDidChange(this, name.localName(), oldValue, n ewValue); |
| 1305 | 1311 |
| 1306 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(*this, name)) | 1312 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(*this, name)) |
| 1307 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); | 1313 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); |
| 1308 } | 1314 } |
| 1309 | 1315 |
| 1310 static bool needsURLResolutionForInlineStyle(const Element& element, const Docum ent& oldDocument, const Document& newDocument) | 1316 static bool needsURLResolutionForInlineStyle(const Element& element, const Docum ent& oldDocument, const Document& newDocument) |
| 1311 { | 1317 { |
| 1312 if (oldDocument == newDocument) | 1318 if (oldDocument == newDocument) |
| 1313 return false; | 1319 return false; |
| 1314 if (oldDocument.baseURL() == newDocument.baseURL()) | 1320 if (oldDocument.baseURL() == newDocument.baseURL()) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 return false; | 1576 return false; |
| 1571 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) | 1577 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) |
| 1572 return true; | 1578 return true; |
| 1573 // Host rules could also have effects. | 1579 // Host rules could also have effects. |
| 1574 if (ShadowRoot* shadowRoot = this->shadowRoot()) | 1580 if (ShadowRoot* shadowRoot = this->shadowRoot()) |
| 1575 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); | 1581 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); |
| 1576 return false; | 1582 return false; |
| 1577 } | 1583 } |
| 1578 | 1584 |
| 1579 } // namespace blink | 1585 } // namespace blink |
| OLD | NEW |