| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 namespace blink { | 123 namespace blink { |
| 124 | 124 |
| 125 using namespace HTMLNames; | 125 using namespace HTMLNames; |
| 126 using namespace XMLNames; | 126 using namespace XMLNames; |
| 127 | 127 |
| 128 typedef WillBeHeapVector<RefPtrWillBeMember<Attr> > AttrNodeList; | 128 typedef WillBeHeapVector<RefPtrWillBeMember<Attr> > AttrNodeList; |
| 129 | 129 |
| 130 static Attr* findAttrNodeInList(const AttrNodeList& attrNodeList, const Qualifie
dName& name) | 130 static Attr* findAttrNodeInList(const AttrNodeList& attrNodeList, const Qualifie
dName& name) |
| 131 { | 131 { |
| 132 AttrNodeList::const_iterator end = attrNodeList.end(); | 132 for (const auto& attr : attrNodeList) { |
| 133 for (AttrNodeList::const_iterator it = attrNodeList.begin(); it != end; ++it
) { | 133 if (attr->qualifiedName() == name) |
| 134 if ((*it)->qualifiedName() == name) | 134 return attr.get(); |
| 135 return it->get(); | |
| 136 } | 135 } |
| 137 return 0; | 136 return nullptr; |
| 138 } | 137 } |
| 139 | 138 |
| 140 PassRefPtrWillBeRawPtr<Element> Element::create(const QualifiedName& tagName, Do
cument* document) | 139 PassRefPtrWillBeRawPtr<Element> Element::create(const QualifiedName& tagName, Do
cument* document) |
| 141 { | 140 { |
| 142 return adoptRefWillBeNoop(new Element(tagName, document, CreateElement)); | 141 return adoptRefWillBeNoop(new Element(tagName, document, CreateElement)); |
| 143 } | 142 } |
| 144 | 143 |
| 145 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT
ype type) | 144 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT
ype type) |
| 146 : ContainerNode(document, type) | 145 : ContainerNode(document, type) |
| 147 , m_tagName(tagName) | 146 , m_tagName(tagName) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 return attributeMap; | 334 return attributeMap; |
| 336 | 335 |
| 337 rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); | 336 rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); |
| 338 return rareData.attributeMap(); | 337 return rareData.attributeMap(); |
| 339 } | 338 } |
| 340 | 339 |
| 341 ActiveAnimations* Element::activeAnimations() const | 340 ActiveAnimations* Element::activeAnimations() const |
| 342 { | 341 { |
| 343 if (hasRareData()) | 342 if (hasRareData()) |
| 344 return elementRareData()->activeAnimations(); | 343 return elementRareData()->activeAnimations(); |
| 345 return 0; | 344 return nullptr; |
| 346 } | 345 } |
| 347 | 346 |
| 348 ActiveAnimations& Element::ensureActiveAnimations() | 347 ActiveAnimations& Element::ensureActiveAnimations() |
| 349 { | 348 { |
| 350 ElementRareData& rareData = ensureElementRareData(); | 349 ElementRareData& rareData = ensureElementRareData(); |
| 351 if (!rareData.activeAnimations()) | 350 if (!rareData.activeAnimations()) |
| 352 rareData.setActiveAnimations(adoptPtrWillBeNoop(new ActiveAnimations()))
; | 351 rareData.setActiveAnimations(adoptPtrWillBeNoop(new ActiveAnimations()))
; |
| 353 return *rareData.activeAnimations(); | 352 return *rareData.activeAnimations(); |
| 354 } | 353 } |
| 355 | 354 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 537 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
| 539 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), *renderer).round(); | 538 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), *renderer).round(); |
| 540 return 0; | 539 return 0; |
| 541 } | 540 } |
| 542 | 541 |
| 543 Element* Element::offsetParentForBindings() | 542 Element* Element::offsetParentForBindings() |
| 544 { | 543 { |
| 545 Element* element = offsetParent(); | 544 Element* element = offsetParent(); |
| 546 if (!element || !element->isInShadowTree()) | 545 if (!element || !element->isInShadowTree()) |
| 547 return element; | 546 return element; |
| 548 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; | 547 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
nullptr; |
| 549 } | 548 } |
| 550 | 549 |
| 551 Element* Element::offsetParent() | 550 Element* Element::offsetParent() |
| 552 { | 551 { |
| 553 document().updateLayoutIgnorePendingStylesheets(); | 552 document().updateLayoutIgnorePendingStylesheets(); |
| 554 if (RenderObject* renderer = this->renderer()) | 553 if (RenderObject* renderer = this->renderer()) |
| 555 return renderer->offsetParent(); | 554 return renderer->offsetParent(); |
| 556 return 0; | 555 return nullptr; |
| 557 } | 556 } |
| 558 | 557 |
| 559 int Element::clientLeft() | 558 int Element::clientLeft() |
| 560 { | 559 { |
| 561 document().updateLayoutIgnorePendingStylesheets(); | 560 document().updateLayoutIgnorePendingStylesheets(); |
| 562 | 561 |
| 563 if (RenderBox* renderer = renderBox()) | 562 if (RenderBox* renderer = renderBox()) |
| 564 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft()
), *renderer); | 563 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft()
), *renderer); |
| 565 return 0; | 564 return 0; |
| 566 } | 565 } |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 updateCallbackSelectors(0, renderStyle()); | 1598 updateCallbackSelectors(0, renderStyle()); |
| 1600 } | 1599 } |
| 1601 | 1600 |
| 1602 void Element::removeCallbackSelectors() | 1601 void Element::removeCallbackSelectors() |
| 1603 { | 1602 { |
| 1604 updateCallbackSelectors(renderStyle(), 0); | 1603 updateCallbackSelectors(renderStyle(), 0); |
| 1605 } | 1604 } |
| 1606 | 1605 |
| 1607 ElementShadow* Element::shadow() const | 1606 ElementShadow* Element::shadow() const |
| 1608 { | 1607 { |
| 1609 return hasRareData() ? elementRareData()->shadow() : 0; | 1608 return hasRareData() ? elementRareData()->shadow() : nullptr; |
| 1610 } | 1609 } |
| 1611 | 1610 |
| 1612 ElementShadow& Element::ensureShadow() | 1611 ElementShadow& Element::ensureShadow() |
| 1613 { | 1612 { |
| 1614 return ensureElementRareData().ensureShadow(); | 1613 return ensureElementRareData().ensureShadow(); |
| 1615 } | 1614 } |
| 1616 | 1615 |
| 1617 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo) | 1616 void Element::pseudoStateChanged(CSSSelector::PseudoType pseudo) |
| 1618 { | 1617 { |
| 1619 StyleResolver* styleResolver = document().styleResolver(); | 1618 StyleResolver* styleResolver = document().styleResolver(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 if (!hasRareData() && !definition) | 1658 if (!hasRareData() && !definition) |
| 1660 return; | 1659 return; |
| 1661 ASSERT(!customElementDefinition()); | 1660 ASSERT(!customElementDefinition()); |
| 1662 ensureElementRareData().setCustomElementDefinition(definition); | 1661 ensureElementRareData().setCustomElementDefinition(definition); |
| 1663 } | 1662 } |
| 1664 | 1663 |
| 1665 CustomElementDefinition* Element::customElementDefinition() const | 1664 CustomElementDefinition* Element::customElementDefinition() const |
| 1666 { | 1665 { |
| 1667 if (hasRareData()) | 1666 if (hasRareData()) |
| 1668 return elementRareData()->customElementDefinition(); | 1667 return elementRareData()->customElementDefinition(); |
| 1669 return 0; | 1668 return nullptr; |
| 1670 } | 1669 } |
| 1671 | 1670 |
| 1672 PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exc
eptionState) | 1671 PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exc
eptionState) |
| 1673 { | 1672 { |
| 1674 if (alwaysCreateUserAgentShadowRoot()) | 1673 if (alwaysCreateUserAgentShadowRoot()) |
| 1675 ensureUserAgentShadowRoot(); | 1674 ensureUserAgentShadowRoot(); |
| 1676 | 1675 |
| 1677 // Some elements make assumptions about what kind of renderers they allow | 1676 // Some elements make assumptions about what kind of renderers they allow |
| 1678 // as children so we can't allow author shadows on them for now. An override | 1677 // as children so we can't allow author shadows on them for now. An override |
| 1679 // flag is provided for testing how author shadows interact on these element
s. | 1678 // flag is provided for testing how author shadows interact on these element
s. |
| 1680 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo
rAnyElementEnabled()) { | 1679 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo
rAnyElementEnabled()) { |
| 1681 exceptionState.throwDOMException(HierarchyRequestError, "Author-created
shadow roots are disabled for this element."); | 1680 exceptionState.throwDOMException(HierarchyRequestError, "Author-created
shadow roots are disabled for this element."); |
| 1682 return nullptr; | 1681 return nullptr; |
| 1683 } | 1682 } |
| 1684 | 1683 |
| 1685 return PassRefPtrWillBeRawPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this
, ShadowRoot::AuthorShadowRoot)); | 1684 return PassRefPtrWillBeRawPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this
, ShadowRoot::AuthorShadowRoot)); |
| 1686 } | 1685 } |
| 1687 | 1686 |
| 1688 ShadowRoot* Element::shadowRoot() const | 1687 ShadowRoot* Element::shadowRoot() const |
| 1689 { | 1688 { |
| 1690 ElementShadow* elementShadow = shadow(); | 1689 ElementShadow* elementShadow = shadow(); |
| 1691 if (!elementShadow) | 1690 if (!elementShadow) |
| 1692 return 0; | 1691 return nullptr; |
| 1693 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); | 1692 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); |
| 1694 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) | 1693 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) |
| 1695 return shadowRoot; | 1694 return shadowRoot; |
| 1696 return 0; | 1695 return nullptr; |
| 1697 } | 1696 } |
| 1698 | 1697 |
| 1699 ShadowRoot* Element::userAgentShadowRoot() const | 1698 ShadowRoot* Element::userAgentShadowRoot() const |
| 1700 { | 1699 { |
| 1701 if (ElementShadow* elementShadow = shadow()) { | 1700 if (ElementShadow* elementShadow = shadow()) { |
| 1702 if (ShadowRoot* shadowRoot = elementShadow->oldestShadowRoot()) { | 1701 if (ShadowRoot* shadowRoot = elementShadow->oldestShadowRoot()) { |
| 1703 ASSERT(shadowRoot->type() == ShadowRoot::UserAgentShadowRoot); | 1702 ASSERT(shadowRoot->type() == ShadowRoot::UserAgentShadowRoot); |
| 1704 return shadowRoot; | 1703 return shadowRoot; |
| 1705 } | 1704 } |
| 1706 } | 1705 } |
| 1707 | 1706 |
| 1708 return 0; | 1707 return nullptr; |
| 1709 } | 1708 } |
| 1710 | 1709 |
| 1711 ShadowRoot& Element::ensureUserAgentShadowRoot() | 1710 ShadowRoot& Element::ensureUserAgentShadowRoot() |
| 1712 { | 1711 { |
| 1713 if (ShadowRoot* shadowRoot = userAgentShadowRoot()) | 1712 if (ShadowRoot* shadowRoot = userAgentShadowRoot()) |
| 1714 return *shadowRoot; | 1713 return *shadowRoot; |
| 1715 ShadowRoot& shadowRoot = ensureShadow().addShadowRoot(*this, ShadowRoot::Use
rAgentShadowRoot); | 1714 ShadowRoot& shadowRoot = ensureShadow().addShadowRoot(*this, ShadowRoot::Use
rAgentShadowRoot); |
| 1716 didAddUserAgentShadowRoot(shadowRoot); | 1715 didAddUserAgentShadowRoot(shadowRoot); |
| 1717 return shadowRoot; | 1716 return shadowRoot; |
| 1718 } | 1717 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 if (result.length() > 0) | 1788 if (result.length() > 0) |
| 1790 result.appendLiteral("; "); | 1789 result.appendLiteral("; "); |
| 1791 result.appendLiteral("class="); | 1790 result.appendLiteral("class="); |
| 1792 result.append(s); | 1791 result.append(s); |
| 1793 } | 1792 } |
| 1794 | 1793 |
| 1795 strncpy(buffer, result.toString().utf8().data(), length - 1); | 1794 strncpy(buffer, result.toString().utf8().data(), length - 1); |
| 1796 } | 1795 } |
| 1797 #endif | 1796 #endif |
| 1798 | 1797 |
| 1799 WillBeHeapVector<RefPtrWillBeMember<Attr> >* Element::attrNodeList() | 1798 WillBeHeapVector<RefPtrWillBeMember<Attr>>* Element::attrNodeList() |
| 1800 { | 1799 { |
| 1801 return hasRareData() ? elementRareData()->attrNodeList() : 0; | 1800 return hasRareData() ? elementRareData()->attrNodeList() : nullptr; |
| 1802 } | 1801 } |
| 1803 | 1802 |
| 1804 WillBeHeapVector<RefPtrWillBeMember<Attr> >& Element::ensureAttrNodeList() | 1803 WillBeHeapVector<RefPtrWillBeMember<Attr> >& Element::ensureAttrNodeList() |
| 1805 { | 1804 { |
| 1806 setHasSyntheticAttrChildNodes(true); | 1805 setHasSyntheticAttrChildNodes(true); |
| 1807 return ensureElementRareData().ensureAttrNodeList(); | 1806 return ensureElementRareData().ensureAttrNodeList(); |
| 1808 } | 1807 } |
| 1809 | 1808 |
| 1810 void Element::removeAttrNodeList() | 1809 void Element::removeAttrNodeList() |
| 1811 { | 1810 { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 | 2214 |
| 2216 RefPtrWillBeRawPtr<Element> parent = toElement(p); | 2215 RefPtrWillBeRawPtr<Element> parent = toElement(p); |
| 2217 RefPtrWillBeRawPtr<Node> prev = previousSibling(); | 2216 RefPtrWillBeRawPtr<Node> prev = previousSibling(); |
| 2218 RefPtrWillBeRawPtr<Node> next = nextSibling(); | 2217 RefPtrWillBeRawPtr<Node> next = nextSibling(); |
| 2219 | 2218 |
| 2220 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(html, parent.get(), AllowScriptingContent, "outerHTML", exceptionState); | 2219 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(html, parent.get(), AllowScriptingContent, "outerHTML", exceptionState); |
| 2221 if (exceptionState.hadException()) | 2220 if (exceptionState.hadException()) |
| 2222 return; | 2221 return; |
| 2223 | 2222 |
| 2224 parent->replaceChild(fragment.release(), this, exceptionState); | 2223 parent->replaceChild(fragment.release(), this, exceptionState); |
| 2225 RefPtrWillBeRawPtr<Node> node = next ? next->previousSibling() : 0; | 2224 RefPtrWillBeRawPtr<Node> node = next ? next->previousSibling() : nullptr; |
| 2226 if (!exceptionState.hadException() && node && node->isTextNode()) | 2225 if (!exceptionState.hadException() && node && node->isTextNode()) |
| 2227 mergeWithNextTextNode(toText(node.get()), exceptionState); | 2226 mergeWithNextTextNode(toText(node.get()), exceptionState); |
| 2228 | 2227 |
| 2229 if (!exceptionState.hadException() && prev && prev->isTextNode()) | 2228 if (!exceptionState.hadException() && prev && prev->isTextNode()) |
| 2230 mergeWithNextTextNode(toText(prev.get()), exceptionState); | 2229 mergeWithNextTextNode(toText(prev.get()), exceptionState); |
| 2231 } | 2230 } |
| 2232 | 2231 |
| 2233 Node* Element::insertAdjacent(const String& where, Node* newChild, ExceptionStat
e& exceptionState) | 2232 Node* Element::insertAdjacent(const String& where, Node* newChild, ExceptionStat
e& exceptionState) |
| 2234 { | 2233 { |
| 2235 if (equalIgnoringCase(where, "beforeBegin")) { | 2234 if (equalIgnoringCase(where, "beforeBegin")) { |
| 2236 if (ContainerNode* parent = this->parentNode()) { | 2235 if (ContainerNode* parent = this->parentNode()) { |
| 2237 parent->insertBefore(newChild, this, exceptionState); | 2236 parent->insertBefore(newChild, this, exceptionState); |
| 2238 if (!exceptionState.hadException()) | 2237 if (!exceptionState.hadException()) |
| 2239 return newChild; | 2238 return newChild; |
| 2240 } | 2239 } |
| 2241 return 0; | 2240 return nullptr; |
| 2242 } | 2241 } |
| 2243 | 2242 |
| 2244 if (equalIgnoringCase(where, "afterBegin")) { | 2243 if (equalIgnoringCase(where, "afterBegin")) { |
| 2245 insertBefore(newChild, firstChild(), exceptionState); | 2244 insertBefore(newChild, firstChild(), exceptionState); |
| 2246 return exceptionState.hadException() ? 0 : newChild; | 2245 return exceptionState.hadException() ? nullptr : newChild; |
| 2247 } | 2246 } |
| 2248 | 2247 |
| 2249 if (equalIgnoringCase(where, "beforeEnd")) { | 2248 if (equalIgnoringCase(where, "beforeEnd")) { |
| 2250 appendChild(newChild, exceptionState); | 2249 appendChild(newChild, exceptionState); |
| 2251 return exceptionState.hadException() ? 0 : newChild; | 2250 return exceptionState.hadException() ? nullptr : newChild; |
| 2252 } | 2251 } |
| 2253 | 2252 |
| 2254 if (equalIgnoringCase(where, "afterEnd")) { | 2253 if (equalIgnoringCase(where, "afterEnd")) { |
| 2255 if (ContainerNode* parent = this->parentNode()) { | 2254 if (ContainerNode* parent = this->parentNode()) { |
| 2256 parent->insertBefore(newChild, nextSibling(), exceptionState); | 2255 parent->insertBefore(newChild, nextSibling(), exceptionState); |
| 2257 if (!exceptionState.hadException()) | 2256 if (!exceptionState.hadException()) |
| 2258 return newChild; | 2257 return newChild; |
| 2259 } | 2258 } |
| 2260 return 0; | 2259 return nullptr; |
| 2261 } | 2260 } |
| 2262 | 2261 |
| 2263 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher
e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.")
; | 2262 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher
e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.")
; |
| 2264 return 0; | 2263 return nullptr; |
| 2265 } | 2264 } |
| 2266 | 2265 |
| 2267 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() | 2266 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() |
| 2268 static Element* contextElementForInsertion(const String& where, Element* element
, ExceptionState& exceptionState) | 2267 static Element* contextElementForInsertion(const String& where, Element* element
, ExceptionState& exceptionState) |
| 2269 { | 2268 { |
| 2270 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft
erEnd")) { | 2269 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft
erEnd")) { |
| 2271 Element* parent = element->parentElement(); | 2270 Element* parent = element->parentElement(); |
| 2272 if (!parent) { | 2271 if (!parent) { |
| 2273 exceptionState.throwDOMException(NoModificationAllowedError, "The el
ement has no parent."); | 2272 exceptionState.throwDOMException(NoModificationAllowedError, "The el
ement has no parent."); |
| 2274 return 0; | 2273 return nullptr; |
| 2275 } | 2274 } |
| 2276 return parent; | 2275 return parent; |
| 2277 } | 2276 } |
| 2278 if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "befo
reEnd")) | 2277 if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "befo
reEnd")) |
| 2279 return element; | 2278 return element; |
| 2280 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher
e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.")
; | 2279 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher
e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.")
; |
| 2281 return 0; | 2280 return nullptr; |
| 2282 } | 2281 } |
| 2283 | 2282 |
| 2284 Element* Element::insertAdjacentElement(const String& where, Element* newChild,
ExceptionState& exceptionState) | 2283 Element* Element::insertAdjacentElement(const String& where, Element* newChild,
ExceptionState& exceptionState) |
| 2285 { | 2284 { |
| 2286 if (!newChild) { | 2285 if (!newChild) { |
| 2287 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception
alternative. | 2286 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception
alternative. |
| 2288 exceptionState.throwTypeError("The node provided is null."); | 2287 exceptionState.throwTypeError("The node provided is null."); |
| 2289 return 0; | 2288 return nullptr; |
| 2290 } | 2289 } |
| 2291 | 2290 |
| 2292 Node* returnValue = insertAdjacent(where, newChild, exceptionState); | 2291 Node* returnValue = insertAdjacent(where, newChild, exceptionState); |
| 2293 return toElement(returnValue); | 2292 return toElement(returnValue); |
| 2294 } | 2293 } |
| 2295 | 2294 |
| 2296 void Element::insertAdjacentText(const String& where, const String& text, Except
ionState& exceptionState) | 2295 void Element::insertAdjacentText(const String& where, const String& text, Except
ionState& exceptionState) |
| 2297 { | 2296 { |
| 2298 insertAdjacent(where, document().createTextNode(text).get(), exceptionState)
; | 2297 insertAdjacent(where, document().createTextNode(text).get(), exceptionState)
; |
| 2299 } | 2298 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 } | 2413 } |
| 2415 | 2414 |
| 2416 RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) | 2415 RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) |
| 2417 { | 2416 { |
| 2418 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) | 2417 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) |
| 2419 return element->computedStyle(); | 2418 return element->computedStyle(); |
| 2420 | 2419 |
| 2421 if (!inActiveDocument()) { | 2420 if (!inActiveDocument()) { |
| 2422 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the | 2421 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the |
| 2423 // document tree and figure out when to destroy the computed style for s
uch elements. | 2422 // document tree and figure out when to destroy the computed style for s
uch elements. |
| 2424 return 0; | 2423 return nullptr; |
| 2425 } | 2424 } |
| 2426 | 2425 |
| 2427 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' | 2426 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' |
| 2428 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the | 2427 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the |
| 2429 // values returned for the ":selection" pseudo-element will be correct. | 2428 // values returned for the ":selection" pseudo-element will be correct. |
| 2430 RenderStyle* elementStyle = renderStyle(); | 2429 RenderStyle* elementStyle = renderStyle(); |
| 2431 if (!elementStyle) { | 2430 if (!elementStyle) { |
| 2432 ElementRareData& rareData = ensureElementRareData(); | 2431 ElementRareData& rareData = ensureElementRareData(); |
| 2433 if (!rareData.computedStyle()) | 2432 if (!rareData.computedStyle()) |
| 2434 rareData.setComputedStyle(document().styleForElementIgnoringPendingS
tylesheets(this)); | 2433 rareData.setComputedStyle(document().styleForElementIgnoringPendingS
tylesheets(this)); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2571 element->insertedInto(this); | 2570 element->insertedInto(this); |
| 2572 element->attach(); | 2571 element->attach(); |
| 2573 | 2572 |
| 2574 InspectorInstrumentation::pseudoElementCreated(element.get()); | 2573 InspectorInstrumentation::pseudoElementCreated(element.get()); |
| 2575 | 2574 |
| 2576 ensureElementRareData().setPseudoElement(pseudoId, element.release()); | 2575 ensureElementRareData().setPseudoElement(pseudoId, element.release()); |
| 2577 } | 2576 } |
| 2578 | 2577 |
| 2579 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2578 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
| 2580 { | 2579 { |
| 2581 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; | 2580 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; |
| 2582 } | 2581 } |
| 2583 | 2582 |
| 2584 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const | 2583 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const |
| 2585 { | 2584 { |
| 2586 if (PseudoElement* element = pseudoElement(pseudoId)) | 2585 if (PseudoElement* element = pseudoElement(pseudoId)) |
| 2587 return element->renderer(); | 2586 return element->renderer(); |
| 2588 return 0; | 2587 return nullptr; |
| 2589 } | 2588 } |
| 2590 | 2589 |
| 2591 bool Element::matches(const String& selectors, ExceptionState& exceptionState) | 2590 bool Element::matches(const String& selectors, ExceptionState& exceptionState) |
| 2592 { | 2591 { |
| 2593 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr
ing(selectors), document(), exceptionState); | 2592 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr
ing(selectors), document(), exceptionState); |
| 2594 if (!selectorQuery) | 2593 if (!selectorQuery) |
| 2595 return false; | 2594 return false; |
| 2596 return selectorQuery->matches(*this); | 2595 return selectorQuery->matches(*this); |
| 2597 } | 2596 } |
| 2598 | 2597 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3078 ASSERT(elementData()->m_styleAttributeIsDirty); | 3077 ASSERT(elementData()->m_styleAttributeIsDirty); |
| 3079 elementData()->m_styleAttributeIsDirty = false; | 3078 elementData()->m_styleAttributeIsDirty = false; |
| 3080 const StylePropertySet* inlineStyle = this->inlineStyle(); | 3079 const StylePropertySet* inlineStyle = this->inlineStyle(); |
| 3081 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr, | 3080 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr, |
| 3082 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); | 3081 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); |
| 3083 } | 3082 } |
| 3084 | 3083 |
| 3085 CSSStyleDeclaration* Element::style() | 3084 CSSStyleDeclaration* Element::style() |
| 3086 { | 3085 { |
| 3087 if (!isStyledElement()) | 3086 if (!isStyledElement()) |
| 3088 return 0; | 3087 return nullptr; |
| 3089 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); | 3088 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); |
| 3090 } | 3089 } |
| 3091 | 3090 |
| 3092 MutableStylePropertySet& Element::ensureMutableInlineStyle() | 3091 MutableStylePropertySet& Element::ensureMutableInlineStyle() |
| 3093 { | 3092 { |
| 3094 ASSERT(isStyledElement()); | 3093 ASSERT(isStyledElement()); |
| 3095 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData(
).m_inlineStyle; | 3094 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData(
).m_inlineStyle; |
| 3096 if (!inlineStyle) { | 3095 if (!inlineStyle) { |
| 3097 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H
TMLQuirksMode : HTMLStandardMode; | 3096 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H
TMLQuirksMode : HTMLStandardMode; |
| 3098 inlineStyle = MutableStylePropertySet::create(mode); | 3097 inlineStyle = MutableStylePropertySet::create(mode); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3308 return wrapper; | 3307 return wrapper; |
| 3309 | 3308 |
| 3310 CustomElementBinding* binding = perContextData->customElementBinding(customE
lementDefinition()); | 3309 CustomElementBinding* binding = perContextData->customElementBinding(customE
lementDefinition()); |
| 3311 | 3310 |
| 3312 wrapper->SetPrototype(binding->prototype()); | 3311 wrapper->SetPrototype(binding->prototype()); |
| 3313 | 3312 |
| 3314 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType
, wrapper, isolate); | 3313 return V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType
, wrapper, isolate); |
| 3315 } | 3314 } |
| 3316 | 3315 |
| 3317 } // namespace blink | 3316 } // namespace blink |
| OLD | NEW |