Bug 111551

Summary: Web Inspector: identify layers for CSS generated content in LayerTreeAgent
Product: WebKit Reporter: Antoine Quint <graouts>
Component: Web Inspector (Deprecated)Assignee: Antoine Quint <graouts>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, esprehn+autocc, joepeck, keishi, loislo, ojan.autocc, pfeldman, pmuellr, timothy, vsevik, web-inspector-bugs, webkit-bug-importer, webkit.review.bot, yurys
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Antoine Quint 2013-03-06 02:54:39 PST
Some layers are created for pseudo elements, content created by CSS via the ::before or ::after pseudo-classes. Since these layers' renderer are not directly associated to a Node in the DOM tree, we'll probably want to identify as such in the UI, we should clearly identify such layers as generated content.
Comment 1 Radar WebKit Bug Importer 2013-03-06 02:55:05 PST
<rdar://problem/13356715>
Comment 2 Antoine Quint 2013-03-06 03:14:47 PST
Created attachment 191703 [details]
Patch
Comment 3 Simon Fraser (smfr) 2013-03-06 14:30:45 PST
Comment on attachment 191703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=191703&action=review

> Source/WebCore/inspector/InspectorLayerTreeAgent.cpp:250
> +        return "";

It's better to use emptyString().

> Source/WebCore/inspector/InspectorLayerTreeAgent.cpp:268
> +    String identifier = m_pseudoElementToIdMap.get(pseudoElement);
> +    if (identifier.isNull())
> +        return;
> +
> +    m_pseudoElementToIdMap.remove(pseudoElement);
> +    m_idToPseudoElement.remove(identifier);

get() and remove() both do hash lookups. It would be better to find(), compare with != .end() to know if you found anything, then use remove(iterator);
Comment 4 Antoine Quint 2013-03-07 01:58:59 PST
Created attachment 191952 [details]
Patch for landing
Comment 5 Antoine Quint 2013-03-07 01:59:55 PST
(In reply to comment #3)
> (From update of attachment 191703 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=191703&action=review
> 
> > Source/WebCore/inspector/InspectorLayerTreeAgent.cpp:250
> > +        return "";
> 
> It's better to use emptyString().

Will fix in landing patch.

> > Source/WebCore/inspector/InspectorLayerTreeAgent.cpp:268
> > +    String identifier = m_pseudoElementToIdMap.get(pseudoElement);
> > +    if (identifier.isNull())
> > +        return;
> > +
> > +    m_pseudoElementToIdMap.remove(pseudoElement);
> > +    m_idToPseudoElement.remove(identifier);
> 
> get() and remove() both do hash lookups. It would be better to find(), compare with != .end() to know if you found anything, then use remove(iterator);

Good point. I rewrote the method as follows for landing:

void InspectorLayerTreeAgent::unbindPseudoElement(PseudoElement* pseudoElement)
{
    HashMap<PseudoElement*, String>::iterator iterator = m_pseudoElementToIdMap.find(pseudoElement);
    if (iterator == m_pseudoElementToIdMap.end())
        return;
    m_idToPseudoElement.remove(iterator->value);
    m_pseudoElementToIdMap.remove(iterator);
}
Comment 6 WebKit Review Bot 2013-03-07 02:41:23 PST
Comment on attachment 191952 [details]
Patch for landing

Clearing flags on attachment: 191952

Committed r145057: <http://trac.webkit.org/changeset/145057>
Comment 7 WebKit Review Bot 2013-03-07 02:41:27 PST
All reviewed patches have been landed.  Closing bug.