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 r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 | 1671 |
1672 HitTestResult result(documentPoint); | 1672 HitTestResult result(documentPoint); |
1673 renderView()->hitTest(request, result); | 1673 renderView()->hitTest(request, result); |
1674 | 1674 |
1675 if (!request.readOnly()) | 1675 if (!request.readOnly()) |
1676 updateHoverActiveState(request, result.innerElement(), &event); | 1676 updateHoverActiveState(request, result.innerElement(), &event); |
1677 | 1677 |
1678 return MouseEventWithHitTestResults(event, result); | 1678 return MouseEventWithHitTestResults(event, result); |
1679 } | 1679 } |
1680 | 1680 |
1681 // DOM Section 1.1.1 | |
1682 bool Document::childTypeAllowed(NodeType type) const | |
1683 { | |
1684 switch (type) { | |
1685 case DOCUMENT_FRAGMENT_NODE: | |
1686 case DOCUMENT_NODE: | |
1687 case TEXT_NODE: | |
1688 return false; | |
1689 case ELEMENT_NODE: | |
1690 // Documents may contain no more than one of each of these. | |
1691 // (One Element and one DocumentType.) | |
1692 for (Node* c = firstChild(); c; c = c->nextSibling()) | |
1693 if (c->nodeType() == type) | |
1694 return false; | |
1695 return true; | |
1696 } | |
1697 return false; | |
1698 } | |
1699 | |
1700 bool Document::canReplaceChild(const Node& newChild, const Node& oldChild) const | |
1701 { | |
1702 if (oldChild.nodeType() == newChild.nodeType()) | |
1703 return true; | |
1704 | |
1705 int numElements = 0; | |
1706 | |
1707 // First, check how many doctypes and elements we have, not counting | |
1708 // the child we're about to remove. | |
1709 for (Node* c = firstChild(); c; c = c->nextSibling()) { | |
1710 if (c == oldChild) | |
1711 continue; | |
1712 | |
1713 switch (c->nodeType()) { | |
1714 case ELEMENT_NODE: | |
1715 numElements++; | |
1716 break; | |
1717 default: | |
1718 break; | |
1719 } | |
1720 } | |
1721 | |
1722 // Then, see how many doctypes and elements might be added by the new child. | |
1723 if (newChild.isDocumentFragment()) { | |
1724 for (Node* c = toDocumentFragment(newChild).firstChild(); c; c = c->next
Sibling()) { | |
1725 switch (c->nodeType()) { | |
1726 case DOCUMENT_FRAGMENT_NODE: | |
1727 case DOCUMENT_NODE: | |
1728 case TEXT_NODE: | |
1729 return false; | |
1730 case ELEMENT_NODE: | |
1731 numElements++; | |
1732 break; | |
1733 } | |
1734 } | |
1735 } else { | |
1736 switch (newChild.nodeType()) { | |
1737 case DOCUMENT_FRAGMENT_NODE: | |
1738 case DOCUMENT_NODE: | |
1739 case TEXT_NODE: | |
1740 return false; | |
1741 case ELEMENT_NODE: | |
1742 numElements++; | |
1743 break; | |
1744 } | |
1745 } | |
1746 | |
1747 if (numElements > 1) | |
1748 return false; | |
1749 | |
1750 return true; | |
1751 } | |
1752 | |
1753 PassRefPtr<Node> Document::cloneNode(bool deep) | 1681 PassRefPtr<Node> Document::cloneNode(bool deep) |
1754 { | 1682 { |
1755 RefPtr<Document> clone = cloneDocumentWithoutChildren(); | 1683 RefPtr<Document> clone = cloneDocumentWithoutChildren(); |
1756 if (deep) | 1684 if (deep) |
1757 cloneChildNodes(clone.get()); | 1685 cloneChildNodes(clone.get()); |
1758 return clone.release(); | 1686 return clone.release(); |
1759 } | 1687 } |
1760 | 1688 |
1761 PassRefPtr<Document> Document::cloneDocumentWithoutChildren() | 1689 PassRefPtr<Document> Document::cloneDocumentWithoutChildren() |
1762 { | 1690 { |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2905 using namespace blink; | 2833 using namespace blink; |
2906 void showLiveDocumentInstances() | 2834 void showLiveDocumentInstances() |
2907 { | 2835 { |
2908 WeakDocumentSet& set = liveDocumentSet(); | 2836 WeakDocumentSet& set = liveDocumentSet(); |
2909 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 2837 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
2910 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 2838 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
2911 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 2839 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
2912 } | 2840 } |
2913 } | 2841 } |
2914 #endif | 2842 #endif |
OLD | NEW |