WebCore:
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 01:50:21 +0000 (01:50 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 01:50:21 +0000 (01:50 +0000)
Pass dashboard regions up to WebKit.

Don't collect regions from RenderTexts.

Made more args and return types references to avoid
copying value lists.

        Reviewed by Hyatt.

        * WebCore.pbproj/project.pbxproj:
        * khtml/khtmlview.cpp:
        (KHTMLView::layout):
        * khtml/rendering/render_object.cpp:
        (RenderObject::collectDashboardRegions):
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::dashboardRegions):
        (DocumentImpl::setDashboardRegions):
        * khtml/xml/dom_docimpl.h:
        * kwq/KWQKHTMLPart.h:
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::didFirstLayout):
        (KWQKHTMLPart::dashboardRegionsChanged):
        * kwq/WebCoreBridge.h:
        * kwq/WebDashboardRegion.h: Added.
        * kwq/WebDashboardRegion.m: Added.
        (-[WebDashboardRegion initWithRect:type:]):
        (-[WebDashboardRegion copyWithZone:]):
        (-[WebDashboardRegion dashboardRegionRect]):
        (-[WebDashboardRegion dashboardRegionType]):
        (-[WebDashboardRegion description]):

WebKit:
Pass dashboard regions to UI delegate.

        Reviewed by Hyatt.

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge dashboardRegionsChanged:]):
        * WebView.subproj/WebUIDelegatePrivate.h:
        * copy-webcore-files-to-webkit:

WebBrowser:
Debug only code to display dashboard regions.

        Reviewed by Hyatt.

        * BrowserWebController.m:
        (-[BrowserWebView webView:dashboardRegionsChanged:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7640 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/khtmlview.cpp
WebCore/khtml/rendering/render_object.cpp
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_docimpl.h
WebCore/kwq/KWQKHTMLPart.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebDashboardRegion.h [new file with mode: 0644]
WebCore/kwq/WebDashboardRegion.m [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebView.subproj/WebUIDelegatePrivate.h
WebKit/copy-webcore-files-to-webkit

index 8dcf5b3ebb36194300e02bf73cb8951fd1fd34b1..70bc0491a006f2332e6d3e7ed1d91cea464bc2c5 100644 (file)
@@ -1,3 +1,36 @@
+2004-09-22  Richard Williamson   <rjw@apple.com>
+       
+       Pass dashboard regions up to WebKit.
+       
+       Don't collect regions from RenderTexts.
+
+       Made more args and return types references to avoid
+       copying value lists.
+
+        Reviewed by Hyatt.
+
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/khtmlview.cpp:
+        (KHTMLView::layout):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::collectDashboardRegions):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::dashboardRegions):
+        (DocumentImpl::setDashboardRegions):
+        * khtml/xml/dom_docimpl.h:
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::didFirstLayout):
+        (KWQKHTMLPart::dashboardRegionsChanged):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebDashboardRegion.h: Added.
+        * kwq/WebDashboardRegion.m: Added.
+        (-[WebDashboardRegion initWithRect:type:]):
+        (-[WebDashboardRegion copyWithZone:]):
+        (-[WebDashboardRegion dashboardRegionRect]):
+        (-[WebDashboardRegion dashboardRegionType]):
+        (-[WebDashboardRegion description]):
+
 2004-09-22  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Hyatt
index 3b9f77d2b5f6fdee13eea93c55bc433aca25b1ee..ea3036c9c0e3f3980979989277c458b048d4bf2e 100644 (file)
                                93B641F406E28C5C0055F610,
                                BEF3442706F1123C000A65D3,
                                BE855F800701E83500239769,
+                               5150C2A20702629000AF642C,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                93B641F306E28C5C0055F610,
                                BEF3442606F1123C000A65D3,
                                BE8560520701F91100239769,
+                               5150C2A60702629800AF642C,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
 //512
 //513
 //514
+               5150C2A10702629000AF642C = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = WebDashboardRegion.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               5150C2A20702629000AF642C = {
+                       fileRef = 5150C2A10702629000AF642C;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               5150C2A50702629800AF642C = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = WebDashboardRegion.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               5150C2A60702629800AF642C = {
+                       fileRef = 5150C2A50702629800AF642C;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                517FA6B20370BD6100CA2D3A = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
                                BE8560510701F91100239769,
                                F587855402DE375901EA4122,
                                F587855502DE375901EA4122,
+                               5150C2A10702629000AF642C,
+                               5150C2A50702629800AF642C,
                                F58EF58E02DFDFB7018635CA,
                                F58EF58D02DFDFB7018635CA,
                        );
index fe4c211a340bd6af4ddd34d02be4bc60255654a4..b59b9ed3a6b8ccfc044e70f94f67664234949f19 100644 (file)
@@ -707,7 +707,7 @@ void KHTMLView::layout()
         QValueList<DashboardRegionValue> currentRegions = document->dashboardRegions();
         if (!(newRegions == currentRegions)) {
             document->setDashboardRegions(newRegions);
-            // FIXME:  Pass the regions on up to webkit.
+            KWQ(m_part)->dashboardRegionsChanged(newRegions);
         }
     }
 #endif
index 2a6257d401e67d6a43c739e1cc223ca1a6689c1a..370700278cac49ccb1d53c30d433649c55e3acfb 100644 (file)
@@ -2188,6 +2188,11 @@ void RenderObject::addDashboardRegions (QValueList<DashboardRegionValue>& region
 
 void RenderObject::collectDashboardRegions (QValueList<DashboardRegionValue>& regions)
 {
+    // RenderTexts don't have their own style, they just use their parent's style,
+    // so we don't want to include them.
+    if (isText())
+        return;
+        
     addDashboardRegions (regions);
     for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
         curr->collectDashboardRegions(regions);
index 450752bdbb40153ae0c08f9deb71a8f1d9399177..83964e538cd19442daefe3cb8a928d4b859bdc83 100644 (file)
@@ -2357,12 +2357,12 @@ bool DocumentImpl::acceptsEditingFocus(NodeImpl *node)
     return part()->shouldBeginEditing(range);
 }
 
-QValueList<DashboardRegionValue> DocumentImpl::dashboardRegions() const
+const QValueList<DashboardRegionValue> & DocumentImpl::dashboardRegions() const
 {
     return m_dashboardRegions;
 }
 
-void DocumentImpl::setDashboardRegions (QValueList<DashboardRegionValue>& regions)
+void DocumentImpl::setDashboardRegions (const QValueList<DashboardRegionValue>& regions)
 {
     m_dashboardRegions = regions;
 }
index 396274ef0219d09c3f3c03c53dc424582fdd482f..39e929efc4dd760c7489655e11af29545da768e3 100644 (file)
@@ -714,8 +714,8 @@ public:
 
     bool hasDashboardRegions () const { return m_hasDashboardRegions; }
     void setHasDashboardRegions (bool f) { m_hasDashboardRegions = f; }
-    QValueList<khtml::DashboardRegionValue> dashboardRegions() const;
-    void setDashboardRegions (QValueList<khtml::DashboardRegionValue>& regions);
+    const QValueList<khtml::DashboardRegionValue> & dashboardRegions() const;
+    void setDashboardRegions (const QValueList<khtml::DashboardRegionValue>& regions);
     
 private:
     JSEditor *jsEditor();
index 3368fc994bb1c2b1e2954c5ef6078eee23f7cba1..4fac0713ca08343204f8bf3dcf11c3476b7df8e9 100644 (file)
@@ -51,6 +51,7 @@ class KWQWindowWidget;
 
 namespace khtml {
     class RenderObject;
+    struct DashboardRegionValue;
 }
 
 namespace KJS {
@@ -341,6 +342,8 @@ public:
 
     void didFirstLayout();
     
+    void dashboardRegionsChanged(const QValueList<khtml::DashboardRegionValue> &regions);
+    
 private:
     virtual void khtmlMousePressEvent(khtml::MousePressEvent *);
     virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *);
index 9a5c3028525b2bee5fde33f2a33159f0f976d88d..69cdbccdf491453b19a65e096dab3230e4b5f21b 100644 (file)
@@ -70,6 +70,8 @@
 #import <JavaScriptCore/runtime_root.h>
 #import <JavaScriptCore/WebScriptObjectPrivate.h>
 
+#import "WebDashboardRegion.h"
+
 #undef _KWQ_TIMING
 
 using DOM::AtomicString;
@@ -102,6 +104,7 @@ using khtml::Cache;
 using khtml::CharacterIterator;
 using khtml::ChildFrame;
 using khtml::Decoder;
+using khtml::DashboardRegionValue;
 using khtml::findPlainText;
 using khtml::InlineTextBox;
 using khtml::MouseDoubleClickEvent;
@@ -3926,3 +3929,35 @@ void KWQKHTMLPart::didFirstLayout()
 {
     [_bridge didFirstLayout];
 }
+
+void KWQKHTMLPart::dashboardRegionsChanged(const QValueList<DashboardRegionValue>& regions)
+{
+    uint i, count = regions.count();
+
+    // Convert the QValueList<DashboardRegionValue> into a NSDictionary of WebDashboardRegions
+    NSMutableDictionary *webRegions = [[NSMutableDictionary alloc] initWithCapacity:count];
+    for (i = 0; i < count; i++) {
+        DashboardRegionValue region = regions[i];
+        NSRect rect;
+        rect.origin.x = region.bounds.x();
+        rect.origin.y = region.bounds.y();
+        rect.size.width = region.bounds.width();
+        rect.size.height = region.bounds.height();
+        NSString *label = region.label.getNSString();
+        WebDashboardRegionType type = WebDashboardRegionTypeNone;
+        if (region.type == khtml::StyleDashboardRegion::Circle)
+            type = WebDashboardRegionTypeCircle;
+        else if (region.type == khtml::StyleDashboardRegion::Rectangle)
+            type = WebDashboardRegionTypeRectangle;
+        NSMutableArray *regionValues = [webRegions objectForKey:label];
+        if (!regionValues) {
+            regionValues = [NSMutableArray array];
+            [webRegions setObject:regionValues forKey:label];
+        }
+        
+        WebDashboardRegion *webRegion = [[[WebDashboardRegion alloc] initWithRect:rect type:type] autorelease];
+        [regionValues addObject:webRegion];
+    }
+    
+    [_bridge dashboardRegionsChanged:webRegions];
+}
index bd3d25102d640a0f5cb73b5bd4eeecf4c437bf65..05c10140b405b32d71fee4b6cf23ea0483080abd 100644 (file)
@@ -515,6 +515,8 @@ typedef enum {
 
 - (void)didFirstLayout;
 
+- (void)dashboardRegionsChanged:(NSDictionary *)regions;
+
 @end
 
 // This interface definition allows those who hold a WebCoreBridge * to call all the methods
diff --git a/WebCore/kwq/WebDashboardRegion.h b/WebCore/kwq/WebDashboardRegion.h
new file mode 100644 (file)
index 0000000..bcec247
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#import <Foundation/Foundation.h>
+
+typedef enum {
+    WebDashboardRegionTypeNone,
+    WebDashboardRegionTypeCircle,
+    WebDashboardRegionTypeRectangle
+} WebDashboardRegionType;
+
+@interface WebDashboardRegion : NSObject <NSCopying>
+{
+    NSRect rect;
+    WebDashboardRegionType type;
+}
+- initWithRect:(NSRect)rect type:(WebDashboardRegionType)type;
+- (NSRect)dashboardRegionRect;
+- (WebDashboardRegionType)dashboardRegionType;
+@end
diff --git a/WebCore/kwq/WebDashboardRegion.m b/WebCore/kwq/WebDashboardRegion.m
new file mode 100644 (file)
index 0000000..cd421ca
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#import "WebDashboardRegion.h"
+
+@implementation WebDashboardRegion
+- initWithRect:(NSRect)r type:(WebDashboardRegionType)t
+{
+    self = [super init];
+    rect = r;
+    type = t;
+    return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    return [self retain];
+}
+
+- (NSRect)dashboardRegionRect
+{
+    return rect;
+}
+- (WebDashboardRegionType)dashboardRegionType
+{
+    return type;
+}
+- (NSString *)description
+{
+    return [NSString stringWithFormat:@"rect:%@ type:%s",
+        NSStringFromRect(rect),
+        type == WebDashboardRegionTypeNone ? "None" :
+            (type == WebDashboardRegionTypeCircle ? "Circle" :
+                (type == WebDashboardRegionTypeRectangle ? "Rectangle" :
+                    "Unknown"))];
+}
+
+@end
\ No newline at end of file
index a443f6e46284d492dd56ba585a11e40698deb39b..a5bf82e2b88aa2194539008239451806c2860792 100644 (file)
@@ -1,3 +1,14 @@
+2004-09-22  Richard Williamson   <rjw@apple.com>
+
+       Pass dashboard regions to UI delegate.
+
+        Reviewed by Hyatt.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge dashboardRegionsChanged:]):
+        * WebView.subproj/WebUIDelegatePrivate.h:
+        * copy-webcore-files-to-webkit:
+
 2004-09-22  Chris Blumenberg  <cblu@apple.com>
 
        Fixed build that I just broke.
index e7503399a9f8cb573869e9eb78f5c9ae9ed73f50..317f027d17acca058af6c5ef6eefa1d2b03571c6 100644 (file)
@@ -1382,6 +1382,14 @@ static id <WebFormDelegate> formDelegate(WebBridge *self)
     [[wv _frameLoadDelegateForwarder] webView:wv didFirstLayoutInFrame:_frame];
 }
 
+- (void)dashboardRegionsChanged:(NSDictionary *)regions
+{
+    WebView *wv = [_frame webView];
+    id wd = [wv UIDelegate];
+    if ([wd respondsToSelector: @selector(webView:dashboardRegionsChanged:)])
+        [wd webView:wv dashboardRegionsChanged:regions];
+}
+
 // This method exists to hold localizable strings for action names for the Undo menu item. It contains
 // all of the names used in NSTextView. We will wire some or all of these up eventually; for now we are
 // just putting them here to get them localized before the localization freeze for Tiger.
index 9e2c322352c342a87081c6df162b99cad9b40cf2..2e16f6d39ec1ae171f56b6d37f33b673fcfb899b 100644 (file)
@@ -17,4 +17,7 @@
 - (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect;
 - (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message;
 
+// regions is an dictionary whose keys are regions label and values are arrays of WebDashboardRegions.
+- (void)webView:(WebView *)webView dashboardRegionsChanged:(NSDictionary *)regions;
+
 @end
index 2930b6a71ba3b24a38649ef43e75e24b0036b430..e2cb5b35c434dbe034ed61e522eee6fbd1b03e79 100755 (executable)
@@ -19,6 +19,7 @@ my %WebCoreFiles = (
     'kwq/DOMStylesheets.h' => 'DOM.subproj/DOMStylesheets.h',
     'kwq/DOMTraversal.h' => 'DOM.subproj/DOMTraversal.h',
     'kwq/DOMViews.h' => 'DOM.subproj/DOMViews.h',
+    'kwq/WebDashboardRegion.h' => 'WebCoreSupport.subproj/WebDashboardRegion.h',
 );
 
 my %JavaScriptCoreFiles = (