Changeset 85617 in webkit


Ignore:
Timestamp:
May 3, 2011 10:17:44 AM (13 years ago)
Author:
rolandsteiner@chromium.org
Message:

2011-05-02 Roland Steiner <rolandsteiner@chromium.org>

Reviewed by Dimitri Glazkov.

Bug 59966 - Update ID hash on the containing TreeScope rather than the Document
https://bugs.webkit.org/show_bug.cgi?id=59966

No new tests. (refactoring)

  • accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::elementsFromAttribute): (WebCore::AccessibilityRenderObject::activeDescendant):
  • accessibility/AccessibilityRenderObject.h: (WebCore::AccessibilityRenderObject::isAccessibilityRenderObject):
  • css/CSSCursorImageValue.cpp: (WebCore::resourceReferencedByCursorElement): (WebCore::CSSCursorImageValue::~CSSCursorImageValue): (WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed): (WebCore::CSSCursorImageValue::cachedImage):
  • dom/DynamicNodeList.cpp: (WebCore::DynamicNodeList::itemWithName):
  • dom/Element.h: (WebCore::Element::updateId):
  • dom/Node.cpp: (WebCore::Node::querySelector):
  • html/FormAssociatedElement.cpp: (WebCore::FormAssociatedElement::insertedIntoTree): (WebCore::FormAssociatedElement::resetFormOwner):
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::dataList):
  • html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::control):
  • rendering/svg/RenderSVGTextPath.cpp: (WebCore::RenderSVGTextPath::layoutPath):
  • svg/SVGAElement.cpp: (WebCore::SVGAElement::defaultEventHandler):
  • svg/SVGAltGlyphElement.cpp: (WebCore::SVGAltGlyphElement::glyphElement):
  • svg/SVGFEImageElement.cpp: (WebCore::SVGFEImageElement::requestImageResource): (WebCore::SVGFEImageElement::build):
  • svg/SVGLinearGradientElement.cpp: (WebCore::SVGLinearGradientElement::collectGradientAttributes):
  • svg/SVGMPathElement.cpp: (WebCore::SVGMPathElement::pathElement):
  • svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::collectPatternAttributes):
  • svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::collectGradientAttributes):
  • svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::getElementById):
  • svg/SVGTRefElement.cpp: (WebCore::SVGTRefElement::updateReferencedText):
  • svg/SVGTextPathElement.cpp: (WebCore::SVGTextPathElement::insertedIntoDocument):
  • svg/SVGUseElement.cpp: (WebCore::SVGUseElement::buildPendingResource): (WebCore::SVGUseElement::hasCycleUseReferencing): (WebCore::SVGUseElement::expandUseElementsInShadowTree):
  • svg/SVGViewSpec.cpp: (WebCore::SVGViewSpec::viewTarget):
  • svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::eventBaseFor): (WebCore::SVGSMILElement::connectConditions): (WebCore::SVGSMILElement::targetElement):
  • xml/XPathFunctions.cpp: (WebCore::XPath::FunId::evaluate):
Location:
trunk/Source/WebCore
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85616 r85617  
     12011-05-02  Roland Steiner  <rolandsteiner@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Bug 59966 - Update ID hash on the containing TreeScope rather than the Document
     6        https://bugs.webkit.org/show_bug.cgi?id=59966
     7
     8        No new tests. (refactoring)
     9
     10        * accessibility/AccessibilityRenderObject.cpp:
     11        (WebCore::AccessibilityRenderObject::elementsFromAttribute):
     12        (WebCore::AccessibilityRenderObject::activeDescendant):
     13        * accessibility/AccessibilityRenderObject.h:
     14        (WebCore::AccessibilityRenderObject::isAccessibilityRenderObject):
     15        * css/CSSCursorImageValue.cpp:
     16        (WebCore::resourceReferencedByCursorElement):
     17        (WebCore::CSSCursorImageValue::~CSSCursorImageValue):
     18        (WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
     19        (WebCore::CSSCursorImageValue::cachedImage):
     20        * dom/DynamicNodeList.cpp:
     21        (WebCore::DynamicNodeList::itemWithName):
     22        * dom/Element.h:
     23        (WebCore::Element::updateId):
     24        * dom/Node.cpp:
     25        (WebCore::Node::querySelector):
     26        * html/FormAssociatedElement.cpp:
     27        (WebCore::FormAssociatedElement::insertedIntoTree):
     28        (WebCore::FormAssociatedElement::resetFormOwner):
     29        * html/HTMLInputElement.cpp:
     30        (WebCore::HTMLInputElement::dataList):
     31        * html/HTMLLabelElement.cpp:
     32        (WebCore::HTMLLabelElement::control):
     33        * rendering/svg/RenderSVGTextPath.cpp:
     34        (WebCore::RenderSVGTextPath::layoutPath):
     35        * svg/SVGAElement.cpp:
     36        (WebCore::SVGAElement::defaultEventHandler):
     37        * svg/SVGAltGlyphElement.cpp:
     38        (WebCore::SVGAltGlyphElement::glyphElement):
     39        * svg/SVGFEImageElement.cpp:
     40        (WebCore::SVGFEImageElement::requestImageResource):
     41        (WebCore::SVGFEImageElement::build):
     42        * svg/SVGLinearGradientElement.cpp:
     43        (WebCore::SVGLinearGradientElement::collectGradientAttributes):
     44        * svg/SVGMPathElement.cpp:
     45        (WebCore::SVGMPathElement::pathElement):
     46        * svg/SVGPatternElement.cpp:
     47        (WebCore::SVGPatternElement::collectPatternAttributes):
     48        * svg/SVGRadialGradientElement.cpp:
     49        (WebCore::SVGRadialGradientElement::collectGradientAttributes):
     50        * svg/SVGSVGElement.cpp:
     51        (WebCore::SVGSVGElement::getElementById):
     52        * svg/SVGTRefElement.cpp:
     53        (WebCore::SVGTRefElement::updateReferencedText):
     54        * svg/SVGTextPathElement.cpp:
     55        (WebCore::SVGTextPathElement::insertedIntoDocument):
     56        * svg/SVGUseElement.cpp:
     57        (WebCore::SVGUseElement::buildPendingResource):
     58        (WebCore::SVGUseElement::hasCycleUseReferencing):
     59        (WebCore::SVGUseElement::expandUseElementsInShadowTree):
     60        * svg/SVGViewSpec.cpp:
     61        (WebCore::SVGViewSpec::viewTarget):
     62        * svg/animation/SVGSMILElement.cpp:
     63        (WebCore::SVGSMILElement::eventBaseFor):
     64        (WebCore::SVGSMILElement::connectConditions):
     65        (WebCore::SVGSMILElement::targetElement):
     66        * xml/XPathFunctions.cpp:
     67        (WebCore::XPath::FunId::evaluate):
     68
    1692011-05-03  Sam Weinig  <sam@webkit.org>
    270
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r85414 r85617  
    12141214        return;
    12151215
    1216     Document* document = m_renderer->document();
    1217     if (!document)
     1216    TreeScope* scope = node->treeScope();
     1217    if (!scope)
    12181218        return;
    12191219   
     
    12291229    for (unsigned i = 0; i < size; ++i) {
    12301230        String idName = idVector[i];
    1231         Element* idElement = document->getElementById(idName);
     1231        Element* idElement = scope->getElementById(idName);
    12321232        if (idElement)
    12331233            elements.append(idElement);
     
    28382838        return 0;
    28392839   
    2840     Element* target = document()->getElementById(activeDescendantAttrStr);
     2840    Element* target = element->treeScope()->getElementById(activeDescendantAttrStr);
    28412841    if (!target)
    28422842        return 0;
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r84600 r85617  
    6363    virtual ~AccessibilityRenderObject();
    6464   
    65     bool isAccessibilityRenderObject() const { return true; }
     65    virtual bool isAccessibilityRenderObject() const { return true; }
    6666   
    6767    virtual bool isAnchor() const;
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r74574 r85617  
    2424
    2525#include "CachedResourceLoader.h"
    26 #include "Document.h"
     26#include "TreeScope.h"
    2727#include "PlatformString.h"
    2828#include <wtf/MathExtras.h>
     
    4444}
    4545
    46 static inline SVGCursorElement* resourceReferencedByCursorElement(const String& fragmentId, Document* document)
     46static inline SVGCursorElement* resourceReferencedByCursorElement(const String& fragmentId, TreeScope* scope)
    4747{
    48     Element* element = document->getElementById(SVGURIReference::getTarget(fragmentId));
     48    Element* element = scope->getElementById(SVGURIReference::getTarget(fragmentId));
    4949    if (element && element->hasTagName(SVGNames::cursorTag))
    5050        return static_cast<SVGCursorElement*>(element);
     
    7373        SVGElement* referencedElement = *it;
    7474        referencedElement->cursorImageValueRemoved();
    75         if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, referencedElement->document()))
     75        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, referencedElement->treeScope()))
    7676            cursorElement->removeClient(referencedElement);
    7777    }
     
    9191        return false;
    9292
    93     if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) {
     93    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->treeScope())) {
    9494        // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
    9595        float x = roundf(cursorElement->x().value(0));
     
    119119#if ENABLE(SVG)
    120120    if (isSVGCursorIdentifier(url) && loader && loader->document()) {
     121        // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
    121122        if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, loader->document()))
    122123            url = cursorElement->href();
  • trunk/Source/WebCore/dom/DynamicNodeList.cpp

    r84309 r85617  
    123123{
    124124    if (m_rootNode->isDocumentNode() || m_rootNode->inDocument()) {
    125         Element* node = m_rootNode->document()->getElementById(elementId);
     125        Element* node = m_rootNode->treeScope()->getElementById(elementId);
    126126        if (node && nodeMatches(node)) {
    127127            for (ContainerNode* p = node->parentNode(); p; p = p->parentNode()) {
  • trunk/Source/WebCore/dom/Element.h

    r84706 r85617  
    485485        return;
    486486
    487     Document* doc = document();
     487    TreeScope* scope = treeScope();
    488488    if (!oldId.isEmpty())
    489         doc->removeElementById(oldId, this);
     489        scope->removeElementById(oldId, this);
    490490    if (!newId.isEmpty())
    491         doc->addElementById(newId, this);
     491        scope->addElementById(newId, this);
    492492}
    493493
  • trunk/Source/WebCore/dom/Node.cpp

    r85572 r85617  
    18821882    // FIXME: we could also optimize for the the [id="foo"] case
    18831883    if (strictParsing && inDocument() && querySelectorList.hasOneSelector() && querySelectorList.first()->m_match == CSSSelector::Id) {
    1884         Element* element = document()->getElementById(querySelectorList.first()->value());
     1884        Element* element = treeScope()->getElementById(querySelectorList.first()->value());
    18851885        if (element && (isDocumentNode() || element->isDescendantOf(this)) && selectorChecker.checkSelector(querySelectorList.first(), element))
    18861886            return element;
  • trunk/Source/WebCore/html/FormAssociatedElement.cpp

    r80797 r85617  
    7878    HTMLElement* element = toHTMLElement(this);
    7979    if (element->fastHasAttribute(formAttr)) {
    80         Element* formElement = element->document()->getElementById(element->fastGetAttribute(formAttr));
     80        Element* formElement = element->treeScope()->getElementById(element->fastGetAttribute(formAttr));
    8181        if (formElement && formElement->hasTagName(formTag)) {
    8282            if (m_form)
     
    137137        // the first element in the document to have an ID that equal to
    138138        // the value of form attribute, so we put the result of
    139         // document()->getElementById() over the given element.
    140         Element* firstElement = element->document()->getElementById(formId);
     139        // treeScope()->getElementById() over the given element.
     140        Element* firstElement = element->treeScope()->getElementById(formId);
    141141        if (firstElement && firstElement->hasTagName(formTag))
    142142            m_form = static_cast<HTMLFormElement*>(firstElement);
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r84695 r85617  
    12921292        return 0;
    12931293
    1294     Element* element = document()->getElementById(fastGetAttribute(listAttr));
     1294    Element* element = treeScope()->getElementById(fastGetAttribute(listAttr));
    12951295    if (!element)
    12961296        return 0;
  • trunk/Source/WebCore/html/HTMLLabelElement.cpp

    r73270 r85617  
    8282    // Find the first element whose id is controlId. If it is found and it is a labelable form control,
    8383    // return it, otherwise return 0.
    84     return nodeAsLabelableFormControl(document()->getElementById(controlId));
     84    return nodeAsLabelableFormControl(treeScope()->getElementById(controlId));
    8585}
    8686
  • trunk/Source/WebCore/rendering/svg/RenderSVGTextPath.cpp

    r75325 r85617  
    4646    SVGTextPathElement* textPathElement = static_cast<SVGTextPathElement*>(node());
    4747        String pathId = SVGURIReference::getTarget(textPathElement->href());
    48     Element* targetElement = textPathElement->document()->getElementById(pathId);   
     48    Element* targetElement = textPathElement->treeScope()->getElementById(pathId);   
    4949    if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
    5050        return Path();
  • trunk/Source/WebCore/svg/SVGAElement.cpp

    r81965 r85617  
    165165#if ENABLE(SVG_ANIMATION)
    166166            if (url[0] == '#') {
    167                 Element* targetElement = document()->getElementById(url.substring(1));
     167                Element* targetElement = treeScope()->getElementById(url.substring(1));
    168168                if (SVGSMILElement::isSMILElement(targetElement)) {
    169169                    static_cast<SVGSMILElement*>(targetElement)->beginByLinkActivation();
  • trunk/Source/WebCore/svg/SVGAltGlyphElement.cpp

    r78345 r85617  
    103103SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
    104104{
    105     Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
     105    Element* elt = treeScope()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
    106106    if (!elt || !elt->hasTagName(SVGNames::glyphTag))
    107107        return 0;
  • trunk/Source/WebCore/svg/SVGFEImageElement.cpp

    r78345 r85617  
    6767    }
    6868
    69     Element* hrefElement = document()->getElementById(SVGURIReference::getTarget(href()));
     69    Element* hrefElement = treeScope()->getElementById(SVGURIReference::getTarget(href()));
    7070    if (hrefElement && hrefElement->isSVGElement() && hrefElement->renderer())
    7171        return;
     
    155155{
    156156    if (!m_cachedImage && !m_targetImage) {
    157         Element* hrefElement = document()->getElementById(SVGURIReference::getTarget(href()));
     157        Element* hrefElement = treeScope()->getElementById(SVGURIReference::getTarget(href()));
    158158        if (!hrefElement || !hrefElement->isSVGElement())
    159159            return 0;
  • trunk/Source/WebCore/svg/SVGLinearGradientElement.cpp

    r78345 r85617  
    182182
    183183        // Respect xlink:href, take attributes from referenced element
    184         Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
     184        Node* refNode = treeScope()->getElementById(SVGURIReference::getTarget(current->href()));
    185185        if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
    186186            current = static_cast<SVGGradientElement*>(refNode);
  • trunk/Source/WebCore/svg/SVGMPathElement.cpp

    r78249 r85617  
    7979SVGPathElement* SVGMPathElement::pathElement()
    8080{
    81     Element* target = document()->getElementById(getTarget(href()));
     81    Element* target = treeScope()->getElementById(getTarget(href()));
    8282    if (target && target->hasTagName(SVGNames::pathTag))
    8383        return static_cast<SVGPathElement*>(target);
  • trunk/Source/WebCore/svg/SVGPatternElement.cpp

    r78345 r85617  
    276276
    277277        // Respect xlink:href, take attributes from referenced element
    278         Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
     278        Node* refNode = treeScope()->getElementById(SVGURIReference::getTarget(current->href()));
    279279        if (refNode && refNode->hasTagName(SVGNames::patternTag)) {
    280280            current = static_cast<const SVGPatternElement*>(const_cast<const Node*>(refNode));
  • trunk/Source/WebCore/svg/SVGRadialGradientElement.cpp

    r78345 r85617  
    196196
    197197        // Respect xlink:href, take attributes from referenced element
    198         Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href()));
     198        Node* refNode = treeScope()->getElementById(SVGURIReference::getTarget(current->href()));
    199199        if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
    200200            current = static_cast<SVGGradientElement*>(refNode);
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r84851 r85617  
    642642Element* SVGSVGElement::getElementById(const AtomicString& id) const
    643643{
    644     Element* element = document()->getElementById(id);
     644    Element* element = treeScope()->getElementById(id);
    645645    if (element && element->isDescendantOf(this))
    646646        return element;
  • trunk/Source/WebCore/svg/SVGTRefElement.cpp

    r78345 r85617  
    4848void SVGTRefElement::updateReferencedText()
    4949{
    50     Element* target = document()->getElementById(SVGURIReference::getTarget(href()));
     50    Element* target = treeScope()->getElementById(SVGURIReference::getTarget(href()));
    5151    String textContent;
    5252    if (target && target->isSVGElement())
  • trunk/Source/WebCore/svg/SVGTextPathElement.cpp

    r83710 r85617  
    158158
    159159    String id = SVGURIReference::getTarget(href());
    160     Element* targetElement = ownerDocument()->getElementById(id);
     160    Element* targetElement = treeScope()->getElementById(id);
    161161    if (!targetElement) {
    162162        document()->accessSVGExtensions()->addPendingResource(id, this);
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r85413 r85617  
    474474    // Once the pending resource appears, it will call buildPendingResource(), so we're called a second time.
    475475    String id = SVGURIReference::getTarget(href());
    476     Element* targetElement = document()->getElementById(id);
     476    Element* targetElement = treeScope()->getElementById(id);
    477477    ASSERT(!m_targetElementInstance);
    478478
     
    519519
    520520    String id = SVGURIReference::getTarget(href());
    521     Element* targetElement = document()->getElementById(id);
     521    Element* targetElement = treeScope()->getElementById(id);
    522522    if (!targetElement) {
    523523        // The only time we should get here is when the use element has not been
     
    770770{
    771771    String id = SVGURIReference::getTarget(use->href());
    772     Element* targetElement = document()->getElementById(id);
     772    Element* targetElement = treeScope()->getElementById(id);
    773773    newTarget = 0;
    774774    if (targetElement && targetElement->isSVGElement())
     
    851851
    852852        String id = SVGURIReference::getTarget(use->href());
    853         Element* targetElement = document()->getElementById(id);
     853        Element* targetElement = treeScope()->getElementById(id);
    854854        SVGElement* target = 0;
    855855        if (targetElement && targetElement->isSVGElement())
  • trunk/Source/WebCore/svg/SVGViewSpec.cpp

    r74782 r85617  
    6767SVGElement* SVGViewSpec::viewTarget() const
    6868{
    69     return static_cast<SVGElement*>(m_contextElement->document()->getElementById(m_viewTargetString));
     69    return static_cast<SVGElement*>(m_contextElement->treeScope()->getElementById(m_viewTargetString));
    7070}
    7171
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp

    r84729 r85617  
    426426inline Element* SVGSMILElement::eventBaseFor(const Condition& condition) const
    427427{
    428     return condition.m_baseID.isEmpty() ? targetElement() : document()->getElementById(condition.m_baseID);
     428    return condition.m_baseID.isEmpty() ? targetElement() : treeScope()->getElementById(condition.m_baseID);
    429429}
    430430
     
    446446        } else if (condition.m_type == Condition::Syncbase) {
    447447            ASSERT(!condition.m_baseID.isEmpty());
    448             condition.m_syncbase = document()->getElementById(condition.m_baseID);
     448            condition.m_syncbase = treeScope()->getElementById(condition.m_baseID);
    449449            if (!isSMILElement(condition.m_syncbase.get())) {
    450450                condition.m_syncbase = 0;
     
    500500
    501501    String href = xlinkHref();
    502     ContainerNode* target = href.isEmpty() ? parentNode() : document()->getElementById(SVGURIReference::getTarget(href));
     502    ContainerNode* target = href.isEmpty() ? parentNode() : treeScope()->getElementById(SVGURIReference::getTarget(href));
    503503    if (!target || !target->isSVGElement())
    504504        return 0;
  • trunk/Source/WebCore/xml/XPathFunctions.cpp

    r72500 r85617  
    3131#if ENABLE(XPATH)
    3232
    33 #include "Document.h"
    3433#include "Element.h"
    3534#include "NamedNodeMap.h"
    3635#include "ProcessingInstruction.h"
     36#include "TreeScope.h"
    3737#include "XMLNames.h"
    3838#include "XPathUtil.h"
     
    333333    }
    334334   
    335     Document* contextDocument = evaluationContext().node->document();
     335    TreeScope* contextScope = evaluationContext().node->treeScope();
    336336    NodeSet result;
    337337    HashSet<Node*> resultSet;
     
    352352        // If there are several nodes with the same id, id() should return the first one.
    353353        // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
    354         Node* node = contextDocument->getElementById(String(&idList[startPos], endPos - startPos));
     354        Node* node = contextScope->getElementById(String(&idList[startPos], endPos - startPos));
    355355        if (node && resultSet.add(node).second)
    356356            result.append(node);
Note: See TracChangeset for help on using the changeset viewer.