[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

apavlov at chromium.org apavlov at chromium.org
Wed Dec 22 13:30:02 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 50d411151c05ecc721e64343d66fdaeee46d17dc
Author: apavlov at chromium.org <apavlov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 17 13:36:59 2010 +0000

    2010-09-17  Alexander Pavlov  <apavlov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: Show node description in inspector highlight
            https://bugs.webkit.org/show_bug.cgi?id=20930
    
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::drawNodeHighlight):
            (WebCore::InspectorController::drawElementTitle):
            * inspector/InspectorController.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67703 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e13807d..9bae248 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-09-17  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Show node description in inspector highlight
+        https://bugs.webkit.org/show_bug.cgi?id=20930
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::drawNodeHighlight):
+        (WebCore::InspectorController::drawElementTitle):
+        * inspector/InspectorController.h:
+
 2010-09-16  takano takumi  <takano1 at asia.apple.com>
 
         Reviewed by Kent Tamura.
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index a9ef261..d76ea12 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -71,6 +71,7 @@
 #include "InspectorTimelineAgent.h"
 #include "InspectorValues.h"
 #include "InspectorWorkerResource.h"
+#include "IntRect.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "Range.h"
@@ -1814,6 +1815,84 @@ void InspectorController::drawNodeHighlight(GraphicsContext& context) const
 
         drawHighlightForLineBoxesOrSVGRenderer(context, lineBoxQuads);
     }
+
+    // Draw node title if necessary.
+
+    if (!m_highlightedNode->isElementNode())
+        return;
+
+    WebCore::Settings* settings = containingFrame->settings();
+    drawElementTitle(context, boundingBox, overlayRect, settings);
+}
+
+void InspectorController::drawElementTitle(GraphicsContext& context, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings* settings) const
+{
+    static const int rectInflatePx = 4;
+    static const int fontHeightPx = 12;
+    static const int borderWidthPx = 1;
+    static const Color tooltipBackgroundColor(255, 255, 194, 255);
+    static const Color tooltipBorderColor(Color::black);
+    static const Color tooltipFontColor(Color::black);
+
+    Element* element = static_cast<Element*>(m_highlightedNode.get());
+    bool isXHTML = element->document()->isXHTMLDocument();
+    String nodeTitle = isXHTML ? element->nodeName() : element->nodeName().lower();
+    const AtomicString& idValue = element->getIdAttribute();
+    if (!idValue.isNull() && !idValue.isEmpty()) {
+        nodeTitle += "#";
+        nodeTitle += idValue;
+    }
+    if (element->hasClass() && element->isStyledElement()) {
+        const SpaceSplitString& classNamesString = static_cast<StyledElement*>(element)->classNames();
+        size_t classNameCount = classNamesString.size();
+        if (classNameCount) {
+            HashSet<AtomicString> usedClassNames;
+            for (size_t i = 0; i < classNameCount; ++i) {
+                const AtomicString& className = classNamesString[i];
+                if (usedClassNames.contains(className))
+                    continue;
+                usedClassNames.add(className);
+                nodeTitle += ".";
+                nodeTitle += className;
+            }
+        }
+    }
+    nodeTitle += " [";
+    nodeTitle += String::number(boundingBox.width());
+    nodeTitle.append(static_cast<UChar>(0x00D7)); // &times;
+    nodeTitle += String::number(boundingBox.height());
+    nodeTitle += "]";
+
+    FontDescription desc;
+    FontFamily family;
+    family.setFamily(settings->fixedFontFamily());
+    desc.setFamily(family);
+    desc.setComputedSize(fontHeightPx);
+    Font font = Font(desc, 0, 0);
+    font.update(0);
+
+    TextRun nodeTitleRun(nodeTitle);
+    IntPoint titleBasePoint = boundingBox.bottomLeft();
+    titleBasePoint.move(rectInflatePx, rectInflatePx);
+    IntRect titleRect = enclosingIntRect(font.selectionRectForText(nodeTitleRun, titleBasePoint, fontHeightPx));
+    titleRect.inflate(rectInflatePx);
+
+    // The initial offsets needed to compensate for a 1px-thick border stroke (which is not a part of the rectangle).
+    int dx = -borderWidthPx;
+    int dy = borderWidthPx;
+    if (titleRect.right() > overlayRect.right())
+        dx += overlayRect.right() - titleRect.right();
+    if (titleRect.x() + dx < overlayRect.x())
+        dx = overlayRect.x() - titleRect.x();
+    if (titleRect.bottom() > overlayRect.bottom())
+        dy += overlayRect.bottom() - titleRect.bottom() - borderWidthPx;
+    titleRect.move(dx, dy);
+    context.setStrokeColor(tooltipBorderColor, DeviceColorSpace);
+    context.setStrokeThickness(borderWidthPx);
+    context.setFillColor(tooltipBackgroundColor, DeviceColorSpace);
+    context.drawRect(titleRect);
+    context.setFillColor(tooltipFontColor, DeviceColorSpace);
+    context.drawText(font, nodeTitleRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + font.height()));
 }
 
 void InspectorController::openInInspectedWindow(const String& url)
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 35aae89..fda8c24 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -50,6 +50,7 @@ class Database;
 class Document;
 class DocumentLoader;
 class Element;
+class FloatRect;
 class GraphicsContext;
 class HitTestResult;
 class InjectedScript;
@@ -72,6 +73,7 @@ class InspectorStorageAgent;
 class InspectorTimelineAgent;
 class InspectorValue;
 class InspectorWorkerResource;
+class IntRect;
 class KURL;
 class Node;
 class Page;
@@ -228,6 +230,7 @@ public:
 
     void drawNodeHighlight(GraphicsContext&) const;
     void openInInspectedWindow(const String& url);
+    void drawElementTitle(GraphicsContext&, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings*) const;
 
     void count(const String& title, unsigned lineNumber, const String& sourceID);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list