summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom')
-rw-r--r--Source/WebCore/dom/Document.cpp33
-rw-r--r--Source/WebCore/dom/Document.h4
-rw-r--r--Source/WebCore/dom/Element.cpp2
-rw-r--r--Source/WebCore/dom/Node.cpp59
-rw-r--r--Source/WebCore/dom/Node.h3
5 files changed, 19 insertions, 82 deletions
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 5fe400c82..c7d87bb6c 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -343,19 +343,6 @@ static inline bool isValidNamePart(UChar32 c)
return true;
}
-static bool shouldInheritSecurityOriginFromOwner(const URL& url)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/#origin-0
- //
- // If a Document has the address "about:blank"
- // The origin of the Document is the origin it was assigned when its browsing context was created.
- //
- // Note: We generalize this to all "blank" URLs and invalid URLs because we
- // treat all of these URLs as about:blank.
- //
- return url.isEmpty() || url.isBlankURL();
-}
-
static Widget* widgetForElement(Element* focusedElement)
{
if (!focusedElement)
@@ -546,8 +533,6 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
, m_cookieCacheExpiryTimer(*this, &Document::invalidateDOMCookieCache)
, m_disabledFieldsetElementsCount(0)
, m_hasInjectedPlugInsScript(false)
- , m_renderTreeBeingDestroyed(false)
- , m_hasPreparedForDestruction(false)
, m_hasStyleWithViewportUnits(false)
{
allDocuments().add(this);
@@ -680,6 +665,7 @@ void Document::removedLastRef()
// until after removeDetachedChildren returns, so we protect ourselves.
incrementReferencingNodeCount();
+ prepareForDestruction();
// We must make sure not to be retaining any of our children through
// these extra pointers or we will create a reference cycle.
m_focusedElement = nullptr;
@@ -2575,12 +2561,11 @@ void Document::cancelParsing()
void Document::implicitOpen()
{
- cancelParsing();
-
removeChildren();
setCompatibilityMode(DocumentCompatibilityMode::NoQuirksMode);
+ cancelParsing();
m_parser = createParser();
setParsing(true);
setReadyState(Loading);
@@ -5080,6 +5065,20 @@ RefPtr<XPathResult> Document::evaluate(const String& expression, Node* contextNo
return m_xpathEvaluator->evaluate(expression, contextNode, resolver, type, result, ec);
}
+static bool shouldInheritSecurityOriginFromOwner(const URL& url)
+{
+ // Paraphrased from <https://html.spec.whatwg.org/multipage/browsers.html#origin> (8 July 2016)
+ //
+ // If a Document has the address "about:blank"
+ // The origin of the document is the origin it was assigned when its browsing context was created.
+ // If a Document has the address "about:srcdoc"
+ // The origin of the document is the origin of its parent document.
+ //
+ // Note: We generalize this to invalid URLs because we treat such URLs as about:blank.
+ //
+ return url.isEmpty() || equalIgnoringASCIICase(url.string(), blankURL()) || equalLettersIgnoringASCIICase(url.string(), "about:srcdoc");
+}
+
void Document::initSecurityContext()
{
if (haveInitializedSecurityOrigin()) {
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 1472b0bdc..cd35b20e6 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -1759,8 +1759,8 @@ private:
unsigned m_disabledFieldsetElementsCount;
bool m_hasInjectedPlugInsScript;
- bool m_renderTreeBeingDestroyed;
- bool m_hasPreparedForDestruction;
+ bool m_renderTreeBeingDestroyed { false };
+ bool m_hasPreparedForDestruction { false };
bool m_hasStyleWithViewportUnits;
bool m_isTimerThrottlingEnabled { false };
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 84ccf5666..cd85ae496 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -2489,7 +2489,7 @@ bool Element::needsStyleInvalidation() const
return false;
if (styleChangeType() >= FullStyleChange)
return false;
- if (!document().styleResolverIfExists())
+ if (document().hasPendingForcedStyleRecalc())
return false;
return true;
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index ba9886615..34495b5c7 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -938,65 +938,6 @@ bool Node::containsIncludingHostElements(const Node* node) const
#endif
}
-static inline Node* ancestor(Node* node, unsigned depth)
-{
- for (unsigned i = 0; i < depth; ++i)
- node = node->parentNode();
- return node;
-}
-
-Node* commonAncestor(Node& thisNode, Node& otherNode)
-{
- unsigned thisDepth = 0;
- for (auto node = &thisNode; node; node = node->parentNode()) {
- if (node == &otherNode)
- return node;
- thisDepth++;
- }
- unsigned otherDepth = 0;
- for (auto node = &otherNode; node; node = node->parentNode()) {
- if (node == &thisNode)
- return &thisNode;
- otherDepth++;
- }
-
- Node* thisAncestor = &thisNode;
- Node* otherAncestor = &otherNode;
- if (thisDepth > otherDepth)
- thisAncestor = ancestor(thisAncestor, thisDepth - otherDepth);
- else if (otherDepth > thisDepth)
- otherAncestor = ancestor(otherAncestor, otherDepth - thisDepth);
-
- for (; thisAncestor; thisAncestor = thisAncestor->parentNode()) {
- if (thisAncestor == otherAncestor)
- return thisAncestor;
- otherAncestor = otherAncestor->parentNode();
- }
- ASSERT(!otherAncestor);
- return nullptr;
-}
-
-Node* commonAncestorCrossingShadowBoundary(Node& node, Node& other)
-{
- if (&node == &other)
- return &node;
-
- Element* shadowHost = node.shadowHost();
- // FIXME: This test might be wrong for user-authored shadow trees.
- if (shadowHost && shadowHost == other.shadowHost())
- return shadowHost;
-
- TreeScope* scope = commonTreeScope(&node, &other);
- if (!scope)
- return nullptr;
-
- Node* parentNode = scope->ancestorInThisScope(&node);
- ASSERT(parentNode);
- Node* parentOther = scope->ancestorInThisScope(&other);
- ASSERT(parentOther);
- return commonAncestor(*parentNode, *parentOther);
-}
-
Node* Node::pseudoAwarePreviousSibling() const
{
Element* parentOrHost = is<PseudoElement>(*this) ? downcast<PseudoElement>(*this).hostElement() : parentElement();
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index ec24e2163..842bd8775 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -791,9 +791,6 @@ inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
return parentNode();
}
-Node* commonAncestor(Node&, Node&);
-Node* commonAncestorCrossingShadowBoundary(Node&, Node&);
-
} // namespace WebCore
#if ENABLE(TREE_DEBUGGING)