Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/InspectorDOMAgent.h" | 32 #include "core/inspector/InspectorDOMAgent.h" |
| 33 | 33 |
| 34 #include "HTMLNames.h" | 34 #include "HTMLNames.h" |
| 35 #include "InspectorFrontend.h" | 35 #include "InspectorFrontend.h" |
| 36 #include "SkTypeface.h" | |
| 36 #include "bindings/v8/ExceptionState.h" | 37 #include "bindings/v8/ExceptionState.h" |
| 37 #include "bindings/v8/ScriptEventListener.h" | 38 #include "bindings/v8/ScriptEventListener.h" |
| 38 #include "core/dom/Attr.h" | 39 #include "core/dom/Attr.h" |
| 39 #include "core/dom/CharacterData.h" | 40 #include "core/dom/CharacterData.h" |
| 40 #include "core/dom/ContainerNode.h" | 41 #include "core/dom/ContainerNode.h" |
| 41 #include "core/dom/DOMException.h" | 42 #include "core/dom/DOMException.h" |
| 42 #include "core/dom/Document.h" | 43 #include "core/dom/Document.h" |
| 43 #include "core/dom/DocumentFragment.h" | 44 #include "core/dom/DocumentFragment.h" |
| 44 #include "core/dom/DocumentType.h" | 45 #include "core/dom/DocumentType.h" |
| 45 #include "core/dom/Element.h" | 46 #include "core/dom/Element.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 66 #include "core/inspector/InspectorPageAgent.h" | 67 #include "core/inspector/InspectorPageAgent.h" |
| 67 #include "core/inspector/InspectorState.h" | 68 #include "core/inspector/InspectorState.h" |
| 68 #include "core/inspector/InstrumentingAgents.h" | 69 #include "core/inspector/InstrumentingAgents.h" |
| 69 #include "core/loader/DocumentLoader.h" | 70 #include "core/loader/DocumentLoader.h" |
| 70 #include "core/page/Frame.h" | 71 #include "core/page/Frame.h" |
| 71 #include "core/page/FrameTree.h" | 72 #include "core/page/FrameTree.h" |
| 72 #include "core/page/Page.h" | 73 #include "core/page/Page.h" |
| 73 #include "core/platform/PlatformGestureEvent.h" | 74 #include "core/platform/PlatformGestureEvent.h" |
| 74 #include "core/platform/PlatformMouseEvent.h" | 75 #include "core/platform/PlatformMouseEvent.h" |
| 75 #include "core/platform/PlatformTouchEvent.h" | 76 #include "core/platform/PlatformTouchEvent.h" |
| 77 #include "core/platform/graphics/Font.h" | |
| 78 #include "core/platform/graphics/GlyphBuffer.h" | |
| 79 #include "core/platform/graphics/TextRun.h" | |
| 80 #include "core/platform/graphics/WidthIterator.h" | |
| 76 #include "core/rendering/HitTestResult.h" | 81 #include "core/rendering/HitTestResult.h" |
| 82 #include "core/rendering/InlineTextBox.h" | |
| 83 #include "core/rendering/RenderObject.h" | |
| 84 #include "core/rendering/RenderText.h" | |
| 85 #include "core/rendering/RenderTextFragment.h" | |
| 77 #include "core/rendering/RenderView.h" | 86 #include "core/rendering/RenderView.h" |
| 87 #include "core/rendering/style/RenderStyle.h" | |
| 78 #include "core/xml/DocumentXPathEvaluator.h" | 88 #include "core/xml/DocumentXPathEvaluator.h" |
| 79 #include "core/xml/XPathResult.h" | 89 #include "core/xml/XPathResult.h" |
| 80 #include "wtf/HashSet.h" | 90 #include "wtf/HashSet.h" |
| 81 #include "wtf/ListHashSet.h" | 91 #include "wtf/ListHashSet.h" |
| 82 #include "wtf/OwnPtr.h" | 92 #include "wtf/OwnPtr.h" |
| 83 #include "wtf/Vector.h" | 93 #include "wtf/Vector.h" |
| 84 #include "wtf/text/CString.h" | 94 #include "wtf/text/CString.h" |
| 85 #include "wtf/text/WTFString.h" | 95 #include "wtf/text/WTFString.h" |
| 86 | 96 |
| 87 namespace WebCore { | 97 namespace WebCore { |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1218 Frame* frame = m_pageAgent->frameForId(frameId); | 1228 Frame* frame = m_pageAgent->frameForId(frameId); |
| 1219 if (frame && frame->ownerElement()) { | 1229 if (frame && frame->ownerElement()) { |
| 1220 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig() ); | 1230 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig() ); |
| 1221 highlightConfig->showInfo = true; // Always show tooltips for frames. | 1231 highlightConfig->showInfo = true; // Always show tooltips for frames. |
| 1222 highlightConfig->content = parseColor(color); | 1232 highlightConfig->content = parseColor(color); |
| 1223 highlightConfig->contentOutline = parseColor(outlineColor); | 1233 highlightConfig->contentOutline = parseColor(outlineColor); |
| 1224 m_overlay->highlightNode(frame->ownerElement(), 0 /* eventTarget */, *hi ghlightConfig); | 1234 m_overlay->highlightNode(frame->ownerElement(), 0 /* eventTarget */, *hi ghlightConfig); |
| 1225 } | 1235 } |
| 1226 } | 1236 } |
| 1227 | 1237 |
| 1238 String InspectorDOMAgent::familyNameFromSimpleFontData(const SimpleFontData* fon tData) | |
|
pfeldman
2013/08/16 08:16:48
make it static
| |
| 1239 { | |
| 1240 FontPlatformData platformData = fontData->platformData(); | |
| 1241 SkTypeface::LocalizedStrings* fontFamilyIterator = platformData.typeface()-> createFamilyNameIterator(); | |
|
pfeldman
2013/08/16 08:16:48
No, you can't use Sk here.
| |
| 1242 SkTypeface::LocalizedString localizedString; | |
| 1243 while (fontFamilyIterator->next(&localizedString) && !localizedString.fStrin g.size()) { } | |
| 1244 fontFamilyIterator->unref(); | |
| 1245 return String(localizedString.fString.c_str()); | |
| 1246 } | |
| 1247 | |
| 1248 void InspectorDOMAgent::platformFontsForRenderer(RenderText* renderer, StringBui lder& fontChars, RefPtr<TypeBuilder::Array<String> >& fonts) | |
| 1249 { | |
| 1250 for (InlineTextBox* box = renderer->firstTextBox(); box; box = box->nextText Box()) { | |
| 1251 RenderStyle* style = renderer->style(box->isFirstLineStyle()); | |
| 1252 const Font& font = style->font(); | |
| 1253 TextRun run = box->constructTextRunForInspector(style, font); | |
| 1254 WidthIterator it(&font, run, 0, false); | |
| 1255 GlyphBuffer glyphBuffer; | |
| 1256 it.advance(run.length(), &glyphBuffer); | |
| 1257 for (int i = 0; i < glyphBuffer.size(); ++i) { | |
| 1258 fonts->addItem(familyNameFromSimpleFontData(glyphBuffer.fontDataAt(i ))); | |
| 1259 fontChars.append(run[i]); | |
| 1260 } | |
| 1261 } | |
| 1262 } | |
| 1263 | |
| 1264 void InspectorDOMAgent::getPlatformFontsForNode(WebCore::ErrorString* errorStrin g, int nodeId, | |
| 1265 WTF::RefPtr<WebCore::TypeBuilder::Array<WebCore::TypeBuilder::DOM::TextNodeP latformFonts> >& textNodeList) | |
| 1266 { | |
| 1267 Node* node = assertNode(errorString, nodeId); | |
| 1268 if (!node) | |
| 1269 return; | |
| 1270 Vector<Node*> textNodes; | |
| 1271 if (node->nodeType() == Node::TEXT_NODE) { | |
| 1272 if (node->renderer()) | |
| 1273 textNodes.append(node); | |
| 1274 } else { | |
| 1275 for (Node* child = node->firstChild(); child; child = child->nextSibling ()) { | |
| 1276 if (child->nodeType() == Node::TEXT_NODE && child->renderer()) | |
| 1277 textNodes.append(child); | |
| 1278 } | |
| 1279 } | |
| 1280 | |
| 1281 textNodeList = TypeBuilder::Array<WebCore::TypeBuilder::DOM::TextNodePlatfor mFonts>::create(); | |
| 1282 for (int i = 0; i < textNodes.size(); ++i) { | |
| 1283 StringBuilder fontChars; | |
| 1284 RefPtr<TypeBuilder::Array<String> > fonts = TypeBuilder::Array<String>:: create(); | |
| 1285 RenderText* renderer = static_cast<RenderText*>(textNodes[i]->renderer() ); | |
|
pfeldman
2013/08/16 08:16:48
toRenderText
| |
| 1286 if (renderer->isTextFragment()) { | |
| 1287 RenderTextFragment* textFragment = static_cast<RenderTextFragment*>( renderer); | |
|
pfeldman
2013/08/16 08:16:48
ditto
| |
| 1288 if (textFragment->firstLetter()) { | |
| 1289 RenderObject* firstLetter = textFragment->firstLetter(); | |
| 1290 for (RenderObject* current = firstLetter->firstChild(); current; current = current->nextSibling()) { | |
| 1291 if (current->isText()) | |
| 1292 platformFontsForRenderer(static_cast<RenderText*>(curren t), fontChars, fonts); | |
|
pfeldman
2013/08/16 08:16:48
collectFontsForRenderer
| |
| 1293 } | |
| 1294 } | |
| 1295 } | |
| 1296 platformFontsForRenderer(renderer, fontChars, fonts); | |
|
pfeldman
2013/08/16 08:16:48
drop fontChars
| |
| 1297 if (!fonts->length()) | |
| 1298 continue; | |
| 1299 RefPtr<TypeBuilder::DOM::TextNodePlatformFonts> textNodePlatformFonts = TypeBuilder::DOM::TextNodePlatformFonts::create() | |
| 1300 .setText(fontChars.toString()) | |
| 1301 .setFonts(fonts); | |
| 1302 textNodeList->addItem(textNodePlatformFonts); | |
| 1303 } | |
| 1304 } | |
| 1305 | |
| 1228 void InspectorDOMAgent::hideHighlight(ErrorString*) | 1306 void InspectorDOMAgent::hideHighlight(ErrorString*) |
| 1229 { | 1307 { |
| 1230 m_overlay->hideHighlight(); | 1308 m_overlay->hideHighlight(); |
| 1231 } | 1309 } |
| 1232 | 1310 |
| 1233 void InspectorDOMAgent::moveTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId) | 1311 void InspectorDOMAgent::moveTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId) |
| 1234 { | 1312 { |
| 1235 Node* node = assertEditableNode(errorString, nodeId); | 1313 Node* node = assertEditableNode(errorString, nodeId); |
| 1236 if (!node) | 1314 if (!node) |
| 1237 return; | 1315 return; |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1850 | 1928 |
| 1851 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m ainWorldScriptState(frame)); | 1929 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m ainWorldScriptState(frame)); |
| 1852 if (injectedScript.hasNoValue()) | 1930 if (injectedScript.hasNoValue()) |
| 1853 return 0; | 1931 return 0; |
| 1854 | 1932 |
| 1855 return injectedScript.wrapNode(node, objectGroup); | 1933 return injectedScript.wrapNode(node, objectGroup); |
| 1856 } | 1934 } |
| 1857 | 1935 |
| 1858 } // namespace WebCore | 1936 } // namespace WebCore |
| 1859 | 1937 |
| OLD | NEW |