#include "core/dom/TreeScope.h"
#include "core/HTMLNames.h"
+#include "core/css/resolver/ScopedStyleResolver.h"
#include "core/dom/ContainerNode.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/dom/TreeScopeAdopter.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/ShadowRoot.h"
+#include "core/editing/DOMSelection.h"
#include "core/events/EventPath.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/html/HTMLLabelElement.h"
#include "core/html/HTMLMapElement.h"
-#include "core/page/DOMSelection.h"
#include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/RenderView.h"
#include "wtf/Vector.h"
-namespace WebCore {
+namespace blink {
using namespace HTMLNames;
setDocument(newParentScope.document());
}
+ScopedStyleResolver& TreeScope::ensureScopedStyleResolver()
+{
+ RELEASE_ASSERT(this);
+ if (!m_scopedStyleResolver)
+ m_scopedStyleResolver = ScopedStyleResolver::create(*this);
+ return *m_scopedStyleResolver;
+}
+
+void TreeScope::clearScopedStyleResolver()
+{
+ m_scopedStyleResolver.clear();
+}
+
Element* TreeScope::getElementById(const AtomicString& elementId) const
{
if (elementId.isEmpty())
return 0;
if (!m_elementsById)
return 0;
- return m_elementsById->getElementById(elementId.impl(), this);
+ return m_elementsById->getElementById(elementId, this);
}
-const Vector<Element*>& TreeScope::getAllElementsById(const AtomicString& elementId) const
+const WillBeHeapVector<RawPtrWillBeMember<Element> >& TreeScope::getAllElementsById(const AtomicString& elementId) const
{
- DEFINE_STATIC_LOCAL(Vector<Element*>, emptyVector, ());
+ DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMember<Element> > >, emptyVector, (adoptPtrWillBeNoop(new WillBeHeapVector<RawPtrWillBeMember<Element> >())));
if (elementId.isEmpty())
- return emptyVector;
+ return *emptyVector;
if (!m_elementsById)
- return emptyVector;
- return m_elementsById->getAllElementsById(elementId.impl(), this);
+ return *emptyVector;
+ return m_elementsById->getAllElementsById(elementId, this);
}
void TreeScope::addElementById(const AtomicString& elementId, Element* element)
{
if (!m_elementsById)
- m_elementsById = adoptPtr(new DocumentOrderedMap);
- m_elementsById->add(elementId.impl(), element);
+ m_elementsById = DocumentOrderedMap::create();
+ m_elementsById->add(elementId, element);
m_idTargetObserverRegistry->notifyObservers(elementId);
}
{
if (!m_elementsById)
return;
- m_elementsById->remove(elementId.impl(), element);
+ m_elementsById->remove(elementId, element);
m_idTargetObserverRegistry->notifyObservers(elementId);
}
void TreeScope::addImageMap(HTMLMapElement* imageMap)
{
- StringImpl* name = imageMap->getName().impl();
+ const AtomicString& name = imageMap->getName();
if (!name)
return;
if (!m_imageMapsByName)
- m_imageMapsByName = adoptPtr(new DocumentOrderedMap);
+ m_imageMapsByName = DocumentOrderedMap::create();
m_imageMapsByName->add(name, imageMap);
}
{
if (!m_imageMapsByName)
return;
- StringImpl* name = imageMap->getName().impl();
+ const AtomicString& name = imageMap->getName();
if (!name)
return;
m_imageMapsByName->remove(name, imageMap);
if (!m_imageMapsByName)
return 0;
size_t hashPos = url.find('#');
- String name = (hashPos == kNotFound ? url : url.substring(hashPos + 1)).impl();
+ String name = hashPos == kNotFound ? url : url.substring(hashPos + 1);
if (rootNode().document().isHTMLDocument())
- return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
- return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
+ return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()), this));
+ return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name), this));
}
HitTestResult hitTestInDocument(const Document* document, int x, int y)
if (!frameView->visibleContentRect().contains(point))
return HitTestResult();
- HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
+ HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(point);
document->renderView()->hitTest(request, result);
return result;
void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element)
{
ASSERT(m_labelsByForAttribute);
- m_labelsByForAttribute->add(forAttributeValue.impl(), element);
+ m_labelsByForAttribute->add(forAttributeValue, element);
}
void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element)
{
ASSERT(m_labelsByForAttribute);
- m_labelsByForAttribute->remove(forAttributeValue.impl(), element);
+ m_labelsByForAttribute->remove(forAttributeValue, element);
}
HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeValue)
if (!m_labelsByForAttribute) {
// Populate the map on first access.
- m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
+ m_labelsByForAttribute = DocumentOrderedMap::create();
for (HTMLLabelElement* label = Traversal<HTMLLabelElement>::firstWithin(rootNode()); label; label = Traversal<HTMLLabelElement>::next(*label)) {
const AtomicString& forValue = label->fastGetAttribute(forAttr);
if (!forValue.isEmpty())
}
}
- return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue.impl(), this));
+ return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue, this));
}
DOMSelection* TreeScope::getSelection() const
Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode();
Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode();
if (shadowHost1 != shadowHost2)
- return shadowHost1->compareDocumentPositionInternal(shadowHost2, Node::TreatShadowTreesAsDisconnected);
+ return shadowHost1->compareDocumentPosition(shadowHost2, Node::TreatShadowTreesAsDisconnected);
for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olderShadowRoot(); child; child = child->olderShadowRoot())
if (child == child1)
return treeScopesA[indexA] == treeScopesB[indexB] ? treeScopesA[indexA] : 0;
}
-#if SECURITY_ASSERT_ENABLED && !ENABLE(OILPAN)
+#if ENABLE(SECURITY_ASSERT) && !ENABLE(OILPAN)
bool TreeScope::deletionHasBegun()
{
return rootNode().m_deletionHasBegun;
visitor->trace(m_parentTreeScope);
visitor->trace(m_idTargetObserverRegistry);
visitor->trace(m_selection);
+ visitor->trace(m_elementsById);
+ visitor->trace(m_imageMapsByName);
+ visitor->trace(m_labelsByForAttribute);
+ visitor->trace(m_scopedStyleResolver);
}
-} // namespace WebCore
+} // namespace blink