Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
| diff --git a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
| index 1d366dd242374e8f133a1cd2c1aaf046061144fb..80995d678988900bcfe764ffc03f2917176901e0 100644 |
| --- a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
| +++ b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp |
| @@ -354,8 +354,8 @@ class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
| struct InspectorCSSAgent::VectorStringHashTraits |
| : public WTF::GenericHashTraits<Vector<String>> { |
| static unsigned hash(const Vector<String>& vec) { |
| - unsigned h = DefaultHash<String>::Hash::hash(vec[0]); |
| - for (size_t i = 1; i < vec.size(); i++) { |
| + unsigned h = DefaultHash<size_t>::Hash::hash(vec.size()); |
| + for (size_t i = 0; i < vec.size(); i++) { |
| h = WTF::hashInts(h, DefaultHash<String>::Hash::hash(vec[i])); |
| } |
| return h; |
| @@ -2375,9 +2375,16 @@ int InspectorCSSAgent::getStyleIndexForNode( |
| Vector<String> style; |
| for (const auto& pair : cssPropertyWhitelist) { |
| - style.append(computedStyleInfo->getPropertyValue(pair.second)); |
| + String value = computedStyleInfo->getPropertyValue(pair.second); |
| + if (value.isEmpty()) |
| + continue; |
| + style.append(value); |
| } |
| + // -1 means an empty style. |
| + if (style.isEmpty()) |
| + return -1; |
| + |
| ComputedStylesMap::iterator it = styleToIndexMap.find(style); |
| if (it != styleToIndexMap.end()) |
| return it->value; |
| @@ -2386,6 +2393,7 @@ int InspectorCSSAgent::getStyleIndexForNode( |
| std::unique_ptr<protocol::Array<protocol::CSS::CSSComputedStyleProperty>> |
| styleProperties = |
| protocol::Array<protocol::CSS::CSSComputedStyleProperty>::create(); |
| + |
| for (size_t i = 0; i < style.size(); i++) { |
| styleProperties->addItem(protocol::CSS::CSSComputedStyleProperty::create() |
| .setName(cssPropertyWhitelist[i].first) |
|
dgozman
2016/10/27 19:16:05
Aren't these two out of sync, since we skip items
alex clarke (OOO till 29th)
2016/10/27 20:51:19
Uh wow yes! Fixed now.
|
| @@ -2433,17 +2441,22 @@ void InspectorCSSAgent::visitLayoutTreeNodes( |
| if (!layoutObject) |
| continue; |
| - int backendNodeId = DOMNodeIds::idForNode(node); |
| + int nodeId = m_domAgent->boundNodeId(node); |
| + if (!nodeId) |
| + continue; |
| + |
| std::unique_ptr<protocol::CSS::LayoutTreeNode> layoutTreeNode = |
| protocol::CSS::LayoutTreeNode::create() |
| - .setBackendNodeId(backendNodeId) |
| - .setStyleIndex(getStyleIndexForNode( |
| - node, cssPropertyWhitelist, styleToIndexMap, computedStyles)) |
| + .setNodeId(nodeId) |
| .setBoundingBox(buildRectForFloatRect( |
| node->isElementNode() |
| ? FloatRect(toElement(node)->boundsInViewport()) |
| : layoutObject->absoluteBoundingBoxRect())) |
| .build(); |
| + int styleIndex = getStyleIndexForNode(node, cssPropertyWhitelist, |
| + styleToIndexMap, computedStyles); |
| + if (styleIndex != -1) |
| + layoutTreeNode->setStyleIndex(styleIndex); |
| if (layoutObject->isText()) { |
| LayoutText* layoutText = toLayoutText(layoutObject); |