- a/WebCore/ChangeLog +26 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2010-01-13  Kelly Norton  <knorton@google.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Web Inspector does not update the DOM tree when attributes change.
6
        https://bugs.webkit.org/show_bug.cgi?id=20162
7
8
        * dom/Element.cpp: Moves callbacks to InspectorController directly into setAttribute
9
        and removeAttribute and removes the existing call sites. This makes it possible to
10
        see attribute modifications.
11
        (WebCore::Element::setAttribute):
12
        (WebCore::Element::dispatchAttrRemovalEvent):
13
        (WebCore::Element::dispatchAttrAdditionEvent):
14
        (WebCore::Element::removeAttribute):
15
        * inspector/front-end/DOMAgent.js:
16
        (WebInspector.DOMNode.prototype._setAttributesPayload): Clear existing attributes.
17
        (WebInspector.DOMAgent.prototype._didApplyDomChange): Updated call site and fixed style.
18
        (WebInspector.DOMAgent.prototype._attributesUpdated): Added.
19
        * inspector/front-end/ElementsPanel.js:
20
        (WebInspector.ElementsPanel.prototype._attributesUpdated): Added.
21
        (WebInspector.ElementsPanel.prototype.updateModifiedNodes): Updated call site.
22
        * inspector/front-end/ElementsTreeOutline.js: Renamed _updateTitle to updateTitle.
23
        (WebInspector.ElementsTreeElement.prototype.onattach): Updated updateTitle call site.
24
        (WebInspector.ElementsTreeElement.prototype._textNodeEditingCommitted): Ditto.
25
        (WebInspector.ElementsTreeElement.prototype._editingCancelled): Ditto.
26
1
2010-01-12  Jon Honeycutt  <jhoneycutt@apple.com>
27
2010-01-12  Jon Honeycutt  <jhoneycutt@apple.com>
2
28
3
        MSAA: selected, selectable, extended selectable, and multiple
29
        MSAA: selected, selectable, extended selectable, and multiple
- a/WebCore/dom/Element.cpp -16 / +24 lines
Lines 535-541 void Element::setAttribute(const AtomicString& name, const AtomicString& value, a/WebCore/dom/Element.cpp_sec1
535
535
536
    if (localName == idAttributeName().localName())
536
    if (localName == idAttributeName().localName())
537
        updateId(old ? old->value() : nullAtom, value);
537
        updateId(old ? old->value() : nullAtom, value);
538
    
538
539
    if (old && value.isNull())
539
    if (old && value.isNull())
540
        namedAttrMap->removeAttribute(old->name());
540
        namedAttrMap->removeAttribute(old->name());
541
    else if (!old && !value.isNull())
541
    else if (!old && !value.isNull())
Lines 544-549 void Element::setAttribute(const AtomicString& name, const AtomicString& value, a/WebCore/dom/Element.cpp_sec2
544
        old->setValue(value);
544
        old->setValue(value);
545
        attributeChanged(old);
545
        attributeChanged(old);
546
    }
546
    }
547
548
#if ENABLE(INSPECTOR)
549
    if (Page* page = document()->page()) {
550
        if (InspectorController* inspectorController = page->inspectorController())
551
            inspectorController->didModifyDOMAttr(this);
552
    }
553
#endif
547
}
554
}
548
555
549
void Element::setAttribute(const QualifiedName& name, const AtomicString& value, ExceptionCode&)
556
void Element::setAttribute(const QualifiedName& name, const AtomicString& value, ExceptionCode&)
Lines 555-561 void Element::setAttribute(const QualifiedName& name, const AtomicString& value, a/WebCore/dom/Element.cpp_sec3
555
562
556
    if (name == idAttributeName())
563
    if (name == idAttributeName())
557
        updateId(old ? old->value() : nullAtom, value);
564
        updateId(old ? old->value() : nullAtom, value);
558
    
565
559
    if (old && value.isNull())
566
    if (old && value.isNull())
560
        namedAttrMap->removeAttribute(name);
567
        namedAttrMap->removeAttribute(name);
561
    else if (!old && !value.isNull())
568
    else if (!old && !value.isNull())
Lines 564-569 void Element::setAttribute(const QualifiedName& name, const AtomicString& value, a/WebCore/dom/Element.cpp_sec4
564
        old->setValue(value);
571
        old->setValue(value);
565
        attributeChanged(old);
572
        attributeChanged(old);
566
    }
573
    }
574
575
#if ENABLE(INSPECTOR)
576
    if (Page* page = document()->page()) {
577
        if (InspectorController* inspectorController = page->inspectorController())
578
            inspectorController->didModifyDOMAttr(this);
579
    }
580
#endif
567
}
581
}
568
582
569
PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const AtomicString& value)
583
PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const AtomicString& value)
Lines 1007-1019 void Element::dispatchAttrRemovalEvent(Attribute*) a/WebCore/dom/Element.cpp_sec5
1007
{
1021
{
1008
    ASSERT(!eventDispatchForbidden());
1022
    ASSERT(!eventDispatchForbidden());
1009
1023
1010
#if ENABLE(INSPECTOR)
1011
    if (Page* page = document()->page()) {
1012
      if (InspectorController* inspectorController = page->inspectorController())
1013
          inspectorController->didModifyDOMAttr(this);
1014
    }
1015
#endif
1016
1017
#if 0
1024
#if 0
1018
    if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER))
1025
    if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER))
1019
        return;
1026
        return;
Lines 1027-1039 void Element::dispatchAttrAdditionEvent(Attribute*) a/WebCore/dom/Element.cpp_sec6
1027
{
1034
{
1028
    ASSERT(!eventDispatchForbidden());
1035
    ASSERT(!eventDispatchForbidden());
1029
1036
1030
#if ENABLE(INSPECTOR)
1031
    if (Page* page = document()->page()) {
1032
      if (InspectorController* inspectorController = page->inspectorController())
1033
          inspectorController->didModifyDOMAttr(this);
1034
    }
1035
#endif
1036
1037
#if 0
1037
#if 0
1038
    if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER))
1038
    if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER))
1039
        return;
1039
        return;
Lines 1173-1178 void Element::removeAttribute(const String& name, ExceptionCode& ec) a/WebCore/dom/Element.cpp_sec7
1173
        if (ec == NOT_FOUND_ERR)
1173
        if (ec == NOT_FOUND_ERR)
1174
            ec = 0;
1174
            ec = 0;
1175
    }
1175
    }
1176
    
1177
#if ENABLE(INSPECTOR)
1178
    if (Page* page = document()->page()) {
1179
        if (InspectorController* inspectorController = page->inspectorController())
1180
            inspectorController->didModifyDOMAttr(this);
1181
    }
1182
#endif
1183
    
1176
}
1184
}
1177
1185
1178
void Element::removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
1186
void Element::removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
- a/WebCore/inspector/front-end/DOMAgent.js -3 / +6 lines
Lines 140-145 WebInspector.DOMNode.prototype = { a/WebCore/inspector/front-end/DOMAgent.js_sec1
140
140
141
    _setAttributesPayload: function(attrs)
141
    _setAttributesPayload: function(attrs)
142
    {
142
    {
143
        this.attributes = [];
144
        this._attributesMap = {};
143
        for (var i = 0; i < attrs.length; i += 2)
145
        for (var i = 0; i < attrs.length; i += 2)
144
            this._addAttribute(attrs[i], attrs[i + 1]);
146
            this._addAttribute(attrs[i], attrs[i + 1]);
145
    },
147
    },
Lines 363-377 WebInspector.DOMAgent.prototype = { a/WebCore/inspector/front-end/DOMAgent.js_sec2
363
        callback();
365
        callback();
364
        // TODO(pfeldman): Fix this hack.
366
        // TODO(pfeldman): Fix this hack.
365
        var elem = WebInspector.panels.elements.treeOutline.findTreeElement(node);
367
        var elem = WebInspector.panels.elements.treeOutline.findTreeElement(node);
366
        if (elem) {
368
        if (elem)
367
            elem._updateTitle();
369
            elem.updateTitle();
368
        }
369
    },
370
    },
370
371
371
    _attributesUpdated: function(nodeId, attrsArray)
372
    _attributesUpdated: function(nodeId, attrsArray)
372
    {
373
    {
373
        var node = this._idToDOMNode[nodeId];
374
        var node = this._idToDOMNode[nodeId];
374
        node._setAttributesPayload(attrsArray);
375
        node._setAttributesPayload(attrsArray);
376
        var event = { target : node };
377
        this.document._fireDomEvent("DOMAttrModified", event);
375
    },
378
    },
376
379
377
    nodeForId: function(nodeId) {
380
    nodeForId: function(nodeId) {
- a/WebCore/inspector/front-end/ElementsPanel.js +16 lines
Lines 205-210 WebInspector.ElementsPanel.prototype = { a/WebCore/inspector/front-end/ElementsPanel.js_sec1
205
205
206
        inspectedRootDocument.addEventListener("DOMNodeInserted", this._nodeInserted.bind(this));
206
        inspectedRootDocument.addEventListener("DOMNodeInserted", this._nodeInserted.bind(this));
207
        inspectedRootDocument.addEventListener("DOMNodeRemoved", this._nodeRemoved.bind(this));
207
        inspectedRootDocument.addEventListener("DOMNodeRemoved", this._nodeRemoved.bind(this));
208
        inspectedRootDocument.addEventListener("DOMAttrModified", this._attributesUpdated.bind(this));
208
209
209
        this.treeOutline.suppressSelectHighlight = true;
210
        this.treeOutline.suppressSelectHighlight = true;
210
        this.rootDOMNode = inspectedRootDocument;
211
        this.rootDOMNode = inspectedRootDocument;
Lines 477-482 WebInspector.ElementsPanel.prototype = { a/WebCore/inspector/front-end/ElementsPanel.js_sec2
477
        this.treeOutline.focusedDOMNode = x;
478
        this.treeOutline.focusedDOMNode = x;
478
    },
479
    },
479
480
481
    _attributesUpdated : function(event)
482
    {
483
        this.recentlyModifiedNodes.push({node: event.target, updated: true});
484
        if (this.visible)
485
            this._updateModifiedNodesSoon();
486
    },
487
480
    _nodeInserted: function(event)
488
    _nodeInserted: function(event)
481
    {
489
    {
482
        this.recentlyModifiedNodes.push({node: event.target, parent: event.relatedNode, inserted: true});
490
        this.recentlyModifiedNodes.push({node: event.target, parent: event.relatedNode, inserted: true});
Lines 511-516 WebInspector.ElementsPanel.prototype = { a/WebCore/inspector/front-end/ElementsPanel.js_sec3
511
        for (var i = 0; i < this.recentlyModifiedNodes.length; ++i) {
519
        for (var i = 0; i < this.recentlyModifiedNodes.length; ++i) {
512
            var replaced = this.recentlyModifiedNodes[i].replaced;
520
            var replaced = this.recentlyModifiedNodes[i].replaced;
513
            var parent = this.recentlyModifiedNodes[i].parent;
521
            var parent = this.recentlyModifiedNodes[i].parent;
522
            var node = this.recentlyModifiedNodes[i].node;
523
524
            if (this.recentlyModifiedNodes[i].updated) {
525
                var nodeItem = this.treeOutline.findTreeElement(node);
526
                nodeItem.updateTitle();
527
                continue;
528
            }
529
            
514
            if (!parent)
530
            if (!parent)
515
                continue;
531
                continue;
516
532
- a/WebCore/inspector/front-end/ElementsTreeOutline.js -5 / +5 lines
Lines 394-400 WebInspector.ElementsTreeElement.prototype = { a/WebCore/inspector/front-end/ElementsTreeOutline.js_sec1
394
            this.listItemElement.addStyleClass("hovered");
394
            this.listItemElement.addStyleClass("hovered");
395
        }
395
        }
396
396
397
        this._updateTitle();
397
        this.updateTitle();
398
398
399
        this._preventFollowingLinksOnDoubleClick();
399
        this._preventFollowingLinksOnDoubleClick();
400
    },
400
    },
Lines 858-864 WebInspector.ElementsTreeElement.prototype = { a/WebCore/inspector/front-end/ElementsTreeOutline.js_sec2
858
        textNode.nodeValue = newText;
858
        textNode.nodeValue = newText;
859
859
860
        // Need to restore attributes / node structure.
860
        // Need to restore attributes / node structure.
861
        this._updateTitle();
861
        this.updateTitle();
862
    },
862
    },
863
863
864
    _editingCancelled: function(element, context)
864
    _editingCancelled: function(element, context)
Lines 866-878 WebInspector.ElementsTreeElement.prototype = { a/WebCore/inspector/front-end/ElementsTreeOutline.js_sec3
866
        delete this._editing;
866
        delete this._editing;
867
867
868
        // Need to restore attributes structure.
868
        // Need to restore attributes structure.
869
        this._updateTitle();
869
        this.updateTitle();
870
    },
870
    },
871
871
872
    _updateTitle: function()
872
    updateTitle: function()
873
    {
873
    {
874
        // If we are editing, return early to prevent canceling the edit.
874
        // If we are editing, return early to prevent canceling the edit.
875
        // After editing is committed _updateTitle will be called.
875
        // After editing is committed updateTitle will be called.
876
        if (this._editing)
876
        if (this._editing)
877
            return;
877
            return;
878
878

Return to Bug 20162