WebCore:
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2006 18:40:03 +0000 (18:40 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Oct 2006 18:40:03 +0000 (18:40 +0000)
        Reviewed by Geoff.

        <rdar://problem/4478625> HTML Editing: Basic table editing and culling

        Initial implementaltion of table deletion user interface:
        * Interface shows up on the nearest table containing the entire selection.
        * Shows a Dashboard style close button in the top left corner.
        * Shows a 60% opaque black outline around the table.
        * Adds a new EditorClient function shouldShowDeleteInterface.

        Also adds a new constructor CachedImage and setter functions on
        HTMLImageElement and HTMLImageLoader allowing an Image object to be set
        and image element in the page. This change also paves the way to allow an
        NSImage setter on DOMHTMLImageElement.

        * Resources/deleteButton.tiff: Added.
        * Resources/deleteButtonPressed.tiff: Added.
        * WebCore.xcodeproj/project.pbxproj:
        * bridge/EditorClient.h:
        * editing/DeleteButton.cpp: Added.
        (WebCore::DeleteButton::DeleteButton):
        (WebCore::DeleteButton::defaultEventHandler): notify the controller to delete on click
        * editing/DeleteButton.h: Added.
        * editing/DeleteButtonController.cpp: Added.
        (WebCore::DeleteButtonController::DeleteButtonController):
        (WebCore::DeleteButtonController::respondToChangedSelection): move the interface to the new element, or hide
        (WebCore::DeleteButtonController::respondToChangedContents): call updateOutlineStyle
        (WebCore::DeleteButtonController::updateOutlineStyle): resize the outline if the table changed size
        (WebCore::DeleteButtonController::show): shows the interface on a new element
        (WebCore::DeleteButtonController::hide): hides the existing interface
        (WebCore::DeleteButtonController::deleteTarget): deletes the targeted element
        * editing/DeleteButtonController.h: Added.
        (WebCore::DeleteButtonController::target): getter for the current target
        * editing/Editor.cpp:
        (WebCore::Editor::shouldShowDeleteInterface): call the new shouldShowDeleteInterface client function
        (WebCore::Editor::Editor): remove the manual ref now that we use RefPtr for m_client
        (WebCore::Editor::~Editor): remove the manual deref now that we use RefPtr for m_client
        * editing/Editor.h:
        (WebCore::Editor::frame): new getter
        (WebCore::Editor::deleteButtonController): ditto
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::setSelection): notify the DeleteButtonController about the new selection
        * html/HTMLImageElement.h:
        (WebCore::HTMLImageElement::setCachedImage): new setter that replaces the CachedImage
        * html/HTMLImageLoader.cpp:
        (WebCore::HTMLImageLoader::setImage): ditto
        * html/HTMLImageLoader.h:
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::CachedImage): new constructor that takes an Image
        * loader/CachedImage.h: ditto
        * page/Frame.cpp:
        (WebCore::Frame::selectionController): cleanup coding style
        (WebCore::Frame::editor): ditto
        (WebCore::Frame::command): ditto
        (WebCore::Frame::appliedEditing): tell the delete button outline to update
        (WebCore::Frame::unappliedEditing): ditto
        (WebCore::Frame::reappliedEditing): ditto
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::addChild): workaround until bug 11363 is fixed

WebKit:

        Reviewed by Geoff.

        <rdar://problem/4478625> HTML Editing: Basic table editing and culling

        Initial implementaltion of table deletion user interface:
        * Adds a new editing delegate method, webView:shouldShowDeleteInterfaceForElement:.
        * The new delegate method is called from the new shouldShowDeleteInterface EditorClient function.

        * DefaultDelegates/WebDefaultEditingDelegate.m:
        (-[WebDefaultEditingDelegate webView:shouldShowDeleteInterfaceForElement:]):
        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::WebEditorClient):
        (WebEditorClient::shouldDeleteRange):
        (WebEditorClient::shouldShowDeleteInterface):
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebEditingDelegatePrivate.h: Added.

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

25 files changed:
WebCore/ChangeLog
WebCore/Resources/deleteButton.tiff [new file with mode: 0644]
WebCore/Resources/deleteButtonPressed.tiff [new file with mode: 0644]
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/EditorClient.h
WebCore/editing/DeleteButton.cpp [new file with mode: 0644]
WebCore/editing/DeleteButton.h [new file with mode: 0644]
WebCore/editing/DeleteButtonController.cpp [new file with mode: 0644]
WebCore/editing/DeleteButtonController.h [new file with mode: 0644]
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/editing/SelectionController.cpp
WebCore/html/HTMLImageElement.h
WebCore/html/HTMLImageLoader.cpp
WebCore/html/HTMLImageLoader.h
WebCore/loader/CachedImage.cpp
WebCore/loader/CachedImage.h
WebCore/page/Frame.cpp
WebCore/rendering/RenderTable.cpp
WebKit/ChangeLog
WebKit/DefaultDelegates/WebDefaultEditingDelegate.m
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebEditingDelegatePrivate.h [new file with mode: 0644]

index e44ac44bc460f0db30ac723f7c9d59e70402852e..99abf10ecefd0ea84379e1b5479bc3e4d74dea6c 100644 (file)
@@ -1,3 +1,65 @@
+2006-10-21  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Geoff.
+
+        <rdar://problem/4478625> HTML Editing: Basic table editing and culling
+
+        Initial implementaltion of table deletion user interface:
+        * Interface shows up on the nearest table containing the entire selection.
+        * Shows a Dashboard style close button in the top left corner.
+        * Shows a 60% opaque black outline around the table.
+        * Adds a new EditorClient function shouldShowDeleteInterface.
+
+        Also adds a new constructor CachedImage and setter functions on
+        HTMLImageElement and HTMLImageLoader allowing an Image object to be set
+        and image element in the page. This change also paves the way to allow an
+        NSImage setter on DOMHTMLImageElement. 
+
+        * Resources/deleteButton.tiff: Added.
+        * Resources/deleteButtonPressed.tiff: Added.
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/EditorClient.h:
+        * editing/DeleteButton.cpp: Added.
+        (WebCore::DeleteButton::DeleteButton):
+        (WebCore::DeleteButton::defaultEventHandler): notify the controller to delete on click
+        * editing/DeleteButton.h: Added.
+        * editing/DeleteButtonController.cpp: Added.
+        (WebCore::DeleteButtonController::DeleteButtonController):
+        (WebCore::DeleteButtonController::respondToChangedSelection): move the interface to the new element, or hide
+        (WebCore::DeleteButtonController::respondToChangedContents): call updateOutlineStyle
+        (WebCore::DeleteButtonController::updateOutlineStyle): resize the outline if the table changed size
+        (WebCore::DeleteButtonController::show): shows the interface on a new element
+        (WebCore::DeleteButtonController::hide): hides the existing interface
+        (WebCore::DeleteButtonController::deleteTarget): deletes the targeted element
+        * editing/DeleteButtonController.h: Added.
+        (WebCore::DeleteButtonController::target): getter for the current target
+        * editing/Editor.cpp:
+        (WebCore::Editor::shouldShowDeleteInterface): call the new shouldShowDeleteInterface client function
+        (WebCore::Editor::Editor): remove the manual ref now that we use RefPtr for m_client
+        (WebCore::Editor::~Editor): remove the manual deref now that we use RefPtr for m_client
+        * editing/Editor.h:
+        (WebCore::Editor::frame): new getter
+        (WebCore::Editor::deleteButtonController): ditto
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::setSelection): notify the DeleteButtonController about the new selection
+        * html/HTMLImageElement.h:
+        (WebCore::HTMLImageElement::setCachedImage): new setter that replaces the CachedImage
+        * html/HTMLImageLoader.cpp:
+        (WebCore::HTMLImageLoader::setImage): ditto
+        * html/HTMLImageLoader.h:
+        * loader/CachedImage.cpp:
+        (WebCore::CachedImage::CachedImage): new constructor that takes an Image
+        * loader/CachedImage.h: ditto
+        * page/Frame.cpp:
+        (WebCore::Frame::selectionController): cleanup coding style
+        (WebCore::Frame::editor): ditto
+        (WebCore::Frame::command): ditto
+        (WebCore::Frame::appliedEditing): tell the delete button outline to update
+        (WebCore::Frame::unappliedEditing): ditto
+        (WebCore::Frame::reappliedEditing): ditto
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::addChild): workaround until bug 11363 is fixed
+
 2006-10-21  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Tim H.
diff --git a/WebCore/Resources/deleteButton.tiff b/WebCore/Resources/deleteButton.tiff
new file mode 100644 (file)
index 0000000..1749156
Binary files /dev/null and b/WebCore/Resources/deleteButton.tiff differ
diff --git a/WebCore/Resources/deleteButtonPressed.tiff b/WebCore/Resources/deleteButtonPressed.tiff
new file mode 100644 (file)
index 0000000..e99aa87
Binary files /dev/null and b/WebCore/Resources/deleteButtonPressed.tiff differ
index 536545aa0d0076529ff7b80851f3997b83861917..a1a95dc8cc8713e7aacf9c288edb495c2e77d013 100644 (file)
                1C11CCC60AA6093700DADB20 /* DOMDocumentFragment.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85089CD30A98C42800A275AA /* DOMDocumentFragment.h */; };
                1C11CCC70AA6093700DADB20 /* DOMCDATASection.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85089CCF0A98C42700A275AA /* DOMCDATASection.h */; };
                1C11CCC80AA6093700DADB20 /* DOMHTMLElement.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 85DF2EEB0AA387CB00AD64C5 /* DOMHTMLElement.h */; };
+               1C14E76B0AD8C81C00B6158B /* deleteButtonPressed.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1C14E7690AD8C81C00B6158B /* deleteButtonPressed.tiff */; };
+               1C14E76C0AD8C81C00B6158B /* deleteButton.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1C14E76A0AD8C81C00B6158B /* deleteButton.tiff */; };
+               1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; };
+               1C4C8F660AD8655D009475CE /* DeleteButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F640AD8655D009475CE /* DeleteButton.h */; };
                1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF347E0A6C405200ABE06E /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */; };
                1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */; };
                1CD4418E0A4CE76F00A007AB /* northEastSouthWestResizeCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1CD4418A0A4CE76F00A007AB /* northEastSouthWestResizeCursor.tiff */; };
                1CD4418F0A4CE76F00A007AB /* northSouthResizeCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1CD4418B0A4CE76F00A007AB /* northSouthResizeCursor.tiff */; };
                1CD441900A4CE76F00A007AB /* northWestSouthEastResizeCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1CD4418C0A4CE76F00A007AB /* northWestSouthEastResizeCursor.tiff */; };
+               1CE83AC30ADAFFD7009354F6 /* DeleteButtonController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4C8EFF0AD85D87009475CE /* DeleteButtonController.cpp */; };
+               1CE83AC40ADAFFD8009354F6 /* DeleteButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C4C8F630AD8655D009475CE /* DeleteButton.cpp */; };
                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
                1CFCEE960AACC40100348750 /* DOMHTMLBodyElementPrivate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1CFCEE8D0AACC3CD00348750 /* DOMHTMLBodyElementPrivate.h */; };
                1CFCEE970AACC40100348750 /* DOMHTMLButtonElementPrivate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1CFCEE8E0AACC3CD00348750 /* DOMHTMLButtonElementPrivate.h */; };
                85E711A40AC5D5350053270F /* DOMHTMLDivElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711550AC5D5340053270F /* DOMHTMLDivElementInternal.h */; };
                85E711A50AC5D5350053270F /* DOMHTMLDListElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711560AC5D5340053270F /* DOMHTMLDListElementInternal.h */; };
                85E711A60AC5D5350053270F /* DOMHTMLDocumentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711570AC5D5340053270F /* DOMHTMLDocumentInternal.h */; };
-               85E711A70AC5D5350053270F /* DOMHTMLElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711580AC5D5340053270F /* DOMHTMLElementInternal.h */; };
+               85E711A70AC5D5350053270F /* DOMHTMLElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711580AC5D5340053270F /* DOMHTMLElementInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                85E711A80AC5D5350053270F /* DOMHTMLFieldSetElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711590AC5D5340053270F /* DOMHTMLFieldSetElementInternal.h */; };
                85E711A90AC5D5350053270F /* DOMHTMLFontElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115A0AC5D5340053270F /* DOMHTMLFontElementInternal.h */; };
                85E711AA0AC5D5350053270F /* DOMHTMLFormElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E7115B0AC5D5340053270F /* DOMHTMLFormElementInternal.h */; };
                1AE2AEE50A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLBlockquoteElement.h; sourceTree = "<group>"; };
                1AE42F680AA4B8CB00C8612D /* StringCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StringCF.cpp; sourceTree = "<group>"; };
                1AE42F690AA4B8CB00C8612D /* StringImplCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StringImplCF.cpp; sourceTree = "<group>"; };
+               1C14E7690AD8C81C00B6158B /* deleteButtonPressed.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = deleteButtonPressed.tiff; sourceTree = "<group>"; };
+               1C14E76A0AD8C81C00B6158B /* deleteButton.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = deleteButton.tiff; sourceTree = "<group>"; };
+               1C4C8EFF0AD85D87009475CE /* DeleteButtonController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteButtonController.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               1C4C8F000AD85D87009475CE /* DeleteButtonController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeleteButtonController.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               1C4C8F630AD8655D009475CE /* DeleteButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteButton.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               1C4C8F640AD8655D009475CE /* DeleteButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeleteButton.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; };
                1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptObject.mm; sourceTree = "<group>"; };
                1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObjectPrivate.h; sourceTree = "<group>"; };
                089C1665FE841158C02AAC07 /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               1C14E76A0AD8C81C00B6158B /* deleteButton.tiff */,
+                               1C14E7690AD8C81C00B6158B /* deleteButtonPressed.tiff */,
                                5115095B0A9CE04600901013 /* urlIcon.tiff */,
                                AB4261D70A2F6C9700BDD17D /* missingImage.tiff */,
                                84C0FA24052B966D000440A1 /* eastResizeCursor.tiff */,
                                D0B0556609C6700100307E43 /* CreateLinkCommand.h */,
                                93309D8F099E64910056E581 /* DeleteFromTextNodeCommand.cpp */,
                                93309D90099E64910056E581 /* DeleteFromTextNodeCommand.h */,
+                               1C4C8EFF0AD85D87009475CE /* DeleteButtonController.cpp */,
+                               1C4C8F000AD85D87009475CE /* DeleteButtonController.h */,
+                               1C4C8F630AD8655D009475CE /* DeleteButton.cpp */,
+                               1C4C8F640AD8655D009475CE /* DeleteButton.h */,
                                93309D91099E64910056E581 /* DeleteSelectionCommand.cpp */,
                                93309D92099E64910056E581 /* DeleteSelectionCommand.h */,
                                93309D93099E64910056E581 /* EditAction.h */,
                                BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
                                BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
                                BCEA484B097D93020094C9E4 /* RenderTheme.h */,
-                               BCEA4848097D93020094C9E4 /* RenderThemeMac.h */,
                                BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */,
+                               BCEA4848097D93020094C9E4 /* RenderThemeMac.h */,
                                93955A4203D72932008635CE /* RenderTreeAsText.cpp */,
                                93955A4103D72932008635CE /* RenderTreeAsText.h */,
                                A871DFE10A15376B00B12A68 /* RenderWidget.cpp */,
                                8538F05D0AD722F1006A81D1 /* DOMRangeInternal.h in Headers */,
                                8538F0850AD72CB6006A81D1 /* DOMRanges.h in Headers */,
                                85C320790AD7401500BC15C4 /* DOMRangePrivate.h in Headers */,
+                               1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */,
+                               1C4C8F660AD8655D009475CE /* DeleteButton.h in Headers */,
                                85C9A2F00AD7E90300FBFF1E /* DOMSVGFilterElement.h in Headers */,
                                85C9A2F20AD7E90300FBFF1E /* DOMSVGFitToViewBox.h in Headers */,
                                85C9A2F30AD7E90300FBFF1E /* DOMSVGForeignObjectElement.h in Headers */,
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
+                       shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
                                1CD4418F0A4CE76F00A007AB /* northSouthResizeCursor.tiff in Resources */,
                                1CD441900A4CE76F00A007AB /* northWestSouthEastResizeCursor.tiff in Resources */,
                                5115095C0A9CE04700901013 /* urlIcon.tiff in Resources */,
+                               1C14E76B0AD8C81C00B6158B /* deleteButtonPressed.tiff in Resources */,
+                               1C14E76C0AD8C81C00B6158B /* deleteButton.tiff in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                859D62C10AD888EF00012995 /* DOMSVGUseElement.mm in Sources */,
                                859D62C30AD888EF00012995 /* DOMSVGViewElement.mm in Sources */,
                                859D62C60AD888EF00012995 /* DOMSVGZoomEvent.mm in Sources */,
+                               1CE83AC30ADAFFD7009354F6 /* DeleteButtonController.cpp in Sources */,
+                               1CE83AC40ADAFFD8009354F6 /* DeleteButton.cpp in Sources */,
                                850120520ADABC9200267125 /* DOMSVGPathSegArcAbs.mm in Sources */,
                                850120540ADABC9200267125 /* DOMSVGPathSegArcRel.mm in Sources */,
                                85CE1A3E0ADAC473003BBDEA /* DOMSVGPathSegCurvetoCubicAbs.mm in Sources */,
index 3c8aa72655d58dc7b848032a239e9c811177ead9..53ae84e69d8702d80594861741cfdbe001fc4e9f 100644 (file)
 namespace WebCore {
 
 class Range;
+class HTMLElement;
 
 class EditorClient : public Shared<EditorClient>{
 public:
     virtual ~EditorClient() { }
 
     virtual bool shouldDeleteRange(Range *range) = 0;
+    virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
+
 //    virtual bool shouldBeginEditingInRange(Range *range) = 0;
 //    virtual bool shouldEndEditingInRange(Range *range) = 0;
 //    virtual bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) = 0;
diff --git a/WebCore/editing/DeleteButton.cpp b/WebCore/editing/DeleteButton.cpp
new file mode 100644 (file)
index 0000000..6d64fd1
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2006 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. 
+ */
+
+#include "config.h"
+#include "DeleteButton.h"
+
+#include "DeleteButtonController.h"
+#include "Document.h"
+#include "Editor.h"
+#include "Event.h"
+#include "EventNames.h"
+#include "Frame.h"
+
+namespace WebCore {
+
+using namespace EventNames;
+
+DeleteButton::DeleteButton(Document* document)
+    : HTMLImageElement(document)
+{
+}
+
+void DeleteButton::defaultEventHandler(Event* event)
+{
+    if (event->isMouseEvent()) {
+        if (event->type() == clickEvent) {
+            document()->frame()->editor()->deleteButtonController()->deleteTarget();
+            event->setDefaultHandled();
+        }
+    }
+
+    HTMLImageElement::defaultEventHandler(event);
+}
+
+} // namespace
diff --git a/WebCore/editing/DeleteButton.h b/WebCore/editing/DeleteButton.h
new file mode 100644 (file)
index 0000000..cdfb5d0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2006 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. 
+ */
+
+#ifndef DELETE_BUTTON_H
+#define DELETE_BUTTON_H
+
+#include "HTMLImageElement.h"
+
+namespace WebCore {
+
+class DeleteButton : public HTMLImageElement {
+public:
+    DeleteButton(Document*);
+
+    virtual void defaultEventHandler(Event*);
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/editing/DeleteButtonController.cpp b/WebCore/editing/DeleteButtonController.cpp
new file mode 100644 (file)
index 0000000..f521141
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2006 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. 
+ */
+
+#include "config.h"
+#include "DeleteButtonController.h"
+
+#include "CachedImage.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSPropertyNames.h"
+#include "CSSValueKeywords.h"
+#include "DeleteButton.h"
+#include "Document.h"
+#include "Editor.h"
+#include "Frame.h"
+#include "htmlediting.h"
+#include "HTMLDivElement.h"
+#include "HTMLNames.h"
+#include "Image.h"
+#include "Node.h"
+#include "Range.h"
+#include "RemoveNodeCommand.h"
+#include "RenderObject.h"
+#include "SelectionController.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+const char* const DeleteButtonController::containerElementIdentifier = "WebKit-Editing-Delete-Container";
+const char* const DeleteButtonController::buttonElementIdentifier = "WebKit-Editing-Delete-Button";
+const char* const DeleteButtonController::outlineElementIdentifier = "WebKit-Editing-Delete-Outline";
+
+DeleteButtonController::DeleteButtonController(Editor* editor)
+    : m_editor(editor)
+    , m_wasStaticPositioned(false)
+    , m_wasAutoZIndex(false)
+{
+}
+
+void DeleteButtonController::respondToChangedSelection(const Selection& oldSelection)
+{
+    ExceptionCode ec = 0;
+    Node* oldTableNode = 0;
+    Node* newTableNode = 0;
+
+    RefPtr<Range> range = oldSelection.toRange();
+    if (oldSelection.isContentEditable() && range.get())
+        oldTableNode = enclosingNodeWithTag(range->commonAncestorContainer(ec), tableTag);
+    ASSERT(ec == 0);
+
+    range = m_editor->frame()->selectionController()->toRange();
+    if (m_editor->frame()->selectionController()->isContentEditable() && range.get())
+        newTableNode = enclosingNodeWithTag(range->commonAncestorContainer(ec), tableTag);
+    ASSERT(ec == 0);
+
+    if (oldTableNode != newTableNode) {
+        // If the base is inside an editable table, give the table a close widget.
+        if (newTableNode)
+            show(static_cast<HTMLElement*>(newTableNode));
+        else if (oldTableNode)
+            hide();
+    }
+}
+    
+void DeleteButtonController::respondToChangedContents(const Selection& endingSelection)
+{
+    updateOutlineStyle();
+}
+
+void DeleteButtonController::updateOutlineStyle()
+{
+    if (!m_element || !m_element->renderer() || !m_outlineElement)
+        return;
+
+    CSSMutableStyleDeclaration* style = m_outlineElement->getInlineStyleDecl();
+    style->setProperty(CSS_PROP_WIDTH, String::number(m_element->renderer()->offsetWidth()) + "px");
+    style->setProperty(CSS_PROP_HEIGHT, String::number(m_element->renderer()->offsetHeight()) + "px");
+}
+
+void DeleteButtonController::show(HTMLElement* element)
+{
+    hide();
+
+    if (!(element->renderer() && element->renderer()->isRenderBlock()))
+        return;
+
+    if (!m_editor->shouldShowDeleteInterface(static_cast<HTMLElement*>(element)))
+        return;
+
+    m_element = element;
+
+    m_containerElement = new HTMLDivElement(m_element->document());
+    m_containerElement->setId(containerElementIdentifier);
+
+    CSSMutableStyleDeclaration* style = m_containerElement->getInlineStyleDecl();
+    style->setProperty(CSS_PROP_POSITION, CSS_VAL_ABSOLUTE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_DRAG, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_SELECT, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_MODIFY, CSS_VAL_NONE);
+
+    m_outlineElement = new HTMLDivElement(m_element->document());
+    m_outlineElement->setId(outlineElementIdentifier);
+
+    const int borderWidth = 4;
+    const int borderRadius = 6;
+
+    style = m_outlineElement->getInlineStyleDecl();
+    style->setProperty(CSS_PROP_POSITION, CSS_VAL_ABSOLUTE);
+    style->setProperty(CSS_PROP_CURSOR, CSS_VAL_DEFAULT);
+    style->setProperty(CSS_PROP__WEBKIT_USER_DRAG, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_SELECT, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_MODIFY, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP_Z_INDEX, String::number(-1));
+    style->setProperty(CSS_PROP_TOP, String::number(-borderWidth) + "px");
+    style->setProperty(CSS_PROP_LEFT, String::number(-borderWidth) + "px");
+    style->setProperty(CSS_PROP_BORDER, String::number(borderWidth) + "px solid rgba(0, 0, 0, 0.6)");
+    style->setProperty(CSS_PROP__WEBKIT_BORDER_RADIUS, String::number(borderRadius) + "px");
+
+    updateOutlineStyle();
+
+    ExceptionCode ec = 0;
+    m_containerElement->appendChild(m_outlineElement.get(), ec);
+    ASSERT(ec == 0);
+    if (ec) {
+        hide();
+        return;
+    }
+
+    m_buttonElement = new DeleteButton(m_element->document());
+    m_buttonElement->setId(buttonElementIdentifier);
+
+    const int buttonWidth = 30;
+    const int buttonHeight = 30;
+
+    style = m_buttonElement->getInlineStyleDecl();
+    style->setProperty(CSS_PROP_POSITION, CSS_VAL_ABSOLUTE);
+    style->setProperty(CSS_PROP_CURSOR, CSS_VAL_DEFAULT);
+    style->setProperty(CSS_PROP__WEBKIT_USER_DRAG, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_SELECT, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP__WEBKIT_USER_MODIFY, CSS_VAL_NONE);
+    style->setProperty(CSS_PROP_LEFT, String::number(-buttonWidth / 2) + "px");
+    style->setProperty(CSS_PROP_TOP, String::number(-buttonHeight / 2) + "px");
+    style->setProperty(CSS_PROP_WIDTH, String::number(buttonWidth) + "px");
+    style->setProperty(CSS_PROP_HEIGHT, String::number(buttonHeight) + "px");
+
+    m_buttonElement->setCachedImage(new CachedImage(Image::loadPlatformResource("deleteButton")));
+
+    m_containerElement->appendChild(m_buttonElement.get(), ec);
+    ASSERT(ec == 0);
+    if (ec) {
+        hide();
+        return;
+    }
+
+    m_element->appendChild(m_containerElement.get(), ec);
+    ASSERT(ec == 0);
+    if (ec) {
+        hide();
+        return;
+    }
+
+    if (m_element->renderer()) {
+        if (m_element->renderer()->style()->position() == StaticPosition) {
+            m_element->getInlineStyleDecl()->setProperty(CSS_PROP_POSITION, CSS_VAL_RELATIVE);
+            m_wasStaticPositioned = true;
+        }
+
+        if (m_element->renderer()->style()->hasAutoZIndex()) {
+            m_element->getInlineStyleDecl()->setProperty(CSS_PROP_Z_INDEX, "0");
+            m_wasAutoZIndex = true;
+        }
+
+        m_element->renderer()->repaint(true);
+    }
+}
+
+void DeleteButtonController::hide()
+{
+    ExceptionCode ec = 0;
+    if (m_containerElement)
+        m_containerElement->parentNode()->removeChild(m_containerElement.get(), ec);
+
+    if (m_element && m_wasStaticPositioned)
+        m_element->getInlineStyleDecl()->setProperty(CSS_PROP_POSITION, CSS_VAL_STATIC);
+
+    if (m_element && m_wasAutoZIndex)
+        m_element->getInlineStyleDecl()->setProperty(CSS_PROP_Z_INDEX, CSS_VAL_AUTO);
+
+    m_wasStaticPositioned = false;
+    m_wasAutoZIndex = false;
+    m_element = 0;
+    m_outlineElement = 0;
+    m_buttonElement = 0;
+    m_containerElement = 0;
+}
+
+void DeleteButtonController::deleteTarget()
+{
+    if (!m_element)
+        return;
+
+    RefPtr<Node> element = m_element;
+    hide();
+
+    RefPtr<RemoveNodeCommand> command = new RemoveNodeCommand(element.get());
+    command->apply();
+}
+
+} // namespace WebCore
diff --git a/WebCore/editing/DeleteButtonController.h b/WebCore/editing/DeleteButtonController.h
new file mode 100644 (file)
index 0000000..69d7d10
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2006 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. 
+ */
+
+#ifndef DELETE_BUTTON_CONTROLLER_H
+#define DELETE_BUTTON_CONTROLLER_H
+
+#include "DeleteButton.h"
+
+namespace WebCore {
+
+class DeleteButton;
+class Editor;
+class HTMLElement;
+class RenderObject;
+class Selection;
+
+class DeleteButtonController {
+public:
+    DeleteButtonController(Editor*);
+
+    static const char* const containerElementIdentifier;
+    static const char* const buttonElementIdentifier;
+    static const char* const outlineElementIdentifier;
+
+    HTMLElement* target() const { return m_element.get(); };
+
+    void respondToChangedSelection(const Selection& oldSelection);
+    void respondToChangedContents(const Selection& endingSelection);
+
+    void show(HTMLElement*);
+    void hide();
+
+    void deleteTarget();
+
+private:
+    void updateOutlineStyle();
+
+    Editor* m_editor;
+    RefPtr<HTMLElement> m_element;
+    RefPtr<HTMLElement> m_containerElement;
+    RefPtr<HTMLElement> m_outlineElement;
+    RefPtr<DeleteButton> m_buttonElement;
+    bool m_wasStaticPositioned;
+    bool m_wasAutoZIndex;
+};
+
+} // namespace WebCore
+
+#endif
index c6da53470a246d68392b0475d8d98db709b4da12..1d6067918039f82442268125b98bd13da7da6312 100644 (file)
 #include "config.h"
 #include "Editor.h"
 
+#include "EditorClient.h"
 #include "Frame.h"
+#include "HTMLElement.h"
 #include "Range.h"
 #include "Sound.h"
-#include "EditorClient.h"
 
 namespace WebCore {
 
@@ -126,6 +127,11 @@ bool Editor::tryDHTMLPaste()
 void Editor::writeSelectionToPasteboard(Pasteboard pasteboard)
 {}
 
+bool Editor::shouldShowDeleteInterface(HTMLElement* element)
+{
+    return m_client->shouldShowDeleteInterface(element);
+}
+
 // =============================================================================
 //
 // public editing commands
@@ -135,13 +141,12 @@ void Editor::writeSelectionToPasteboard(Pasteboard pasteboard)
 Editor::Editor(Frame* frame, EditorClient* client)
     : m_frame(frame)
     , m_client(client)
+    , m_deleteButtonController(this)
 { 
-    m_client->ref();
 }
 
 Editor::~Editor()
 {
-    m_client->deref();
 }
 
 void Editor::cut()
index 469b66650b7ee1c4672393a92d4fb80811a51ec3..640ecb1680c98391f0c5310a4ee9243209af27cc 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef editor_h__
-#define editor_h__
+#ifndef EDITOR_H
+#define EDITOR_H
+
+#include "DeleteButtonController.h"
 
 namespace WebCore {
 
+class EditorClient;
 class Frame;
 class Range;
-class EditorClient;
 
 // make platform-specific and implement - this is temporary placeholder
 typedef int Pasteboard;
 
 class Editor {
 public:
-    Editor(Frame* frame, EditorClient* client);
+    Editor(Frame*, EditorClient*);
     ~Editor();
 
     void cut();
@@ -45,30 +47,36 @@ public:
     void paste();
     void performDelete();
 
+    bool shouldShowDeleteInterface(HTMLElement*);
+
+    Frame* frame() const { return m_frame; }
+    DeleteButtonController* deleteButtonController() { return &m_deleteButtonController; }
+
 private:
     Frame* m_frame;
-    EditorClient* m_client;
-    
+    RefPtr<EditorClient> m_client;
+    DeleteButtonController m_deleteButtonController;
+
     bool canCopy();
     bool canCut();
     bool canDelete();
-    bool canDeleteRange(Range* range);
+    bool canDeleteRange(Range*);
     bool canPaste();
     bool canSmartCopyOrDelete();
     bool isSelectionRichlyEditable();
     Range* selectedRange();
-    bool shouldDeleteRange(Range* range);
+    bool shouldDeleteRange(Range*);
     bool tryDHTMLCopy();
     bool tryDHTMLCut();
     bool tryDHTMLPaste();
     void deleteSelection();
     void deleteSelectionWithSmartDelete(bool enabled);
-    void pasteAsPlainTextWithPasteboard(Pasteboard pasteboard);
-    void pasteWithPasteboard(Pasteboard pasteboard, bool allowPlainText);
-    void writeSelectionToPasteboard(Pasteboard pasteboard);
+    void pasteAsPlainTextWithPasteboard(Pasteboard);
+    void pasteWithPasteboard(Pasteboard, bool allowPlainText);
+    void writeSelectionToPasteboard(Pasteboard);
 
 };
 
 } // namespace WebCore
 
-#endif // editor_h__
+#endif // EDITOR_H
index 5bbabdc8eb78bdc37f2ab3be81725e51ed779529..e6c82add50001bc58e963d5f4fdb1e958e5800c5 100644 (file)
@@ -26,7 +26,9 @@
 #include "config.h"
 #include "SelectionController.h"
 
+#include "DeleteButtonController.h"
 #include "Document.h"
+#include "Editor.h"
 #include "Element.h"
 #include "EventNames.h"
 #include "Frame.h"
@@ -119,6 +121,7 @@ void SelectionController::setSelection(const Selection& s, bool closeTyping, boo
     m_frame->selectFrameElementInParentIfFullySelected();
     m_frame->notifyRendererOfSelectionChange(userTriggered);
     m_frame->respondToChangedSelection(oldSelection, closeTyping);
+    m_frame->editor()->deleteButtonController()->respondToChangedSelection(oldSelection);
     if (userTriggered)
         m_frame->revealCaret(RenderLayer::gAlignToEdgeIfNeeded);
 }
index afdf1d248066510a039ad2ab363836043aa79919..abc289383016b0bc094fb560cd3ef16498e373ef 100644 (file)
@@ -64,7 +64,8 @@ public:
     CompositeOperator compositeOperator() const { return m_compositeOperator; }
 
     CachedImage* cachedImage() const { return m_imageLoader.image(); }
-    
+    void setCachedImage(CachedImage* i) { m_imageLoader.setImage(i); };
+
     void setLoadManually (bool loadManually) { m_imageLoader.setLoadManually(loadManually); }
 
     String name() const;
index 842926ce10a0bf0b58290ed77b6ff69731cf39bf..301ea9d3eb75d58c6396ed4b7938dbba2f447e5d 100644 (file)
@@ -55,6 +55,23 @@ HTMLImageLoader::~HTMLImageLoader()
     m_element->document()->removeImage(this);
 }
 
+void HTMLImageLoader::setImage(CachedImage *newImage)
+{
+    CachedImage *oldImage = m_image;
+    if (newImage != oldImage) {
+        setLoadingImage(newImage);
+        m_firedLoad = true;
+        m_imageComplete = true;
+        if (newImage)
+            newImage->ref(this);
+        if (oldImage)
+            oldImage->deref(this);
+    }
+
+    if (RenderImage* renderer = static_cast<RenderImage*>(element()->renderer()))
+        renderer->resetAnimation();
+}
+
 void HTMLImageLoader::setLoadingImage(CachedImage *loadingImage)
 {
     m_firedLoad = false;
index 21811d0f47a54428b54bc1142848aa36b70e4d7a..223c07198201432724fa96d0abe13e8a0ce7b70a 100644 (file)
@@ -42,7 +42,9 @@ public:
 
     Element* element() const { return m_element; }
     bool imageComplete() const { return m_imageComplete; }
+
     CachedImage* image() const { return m_image; }
+    void setImage(CachedImage*);
 
     void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
 
index 0badd3cb4ccba2d0e86a96e7699a6afda5df1665..02d86f07d375afbb50742df000b00653ec304008 100644 (file)
@@ -56,6 +56,16 @@ CachedImage::CachedImage(DocLoader* docLoader, const String& url, CachePolicy ca
         m_loading = false;
 }
 
+CachedImage::CachedImage(Image* image)
+    : CachedResource(String(), ImageResource, CachePolicyCache, 0)
+    , m_dataSize(0)
+{
+    m_image = image;
+    m_errorOccurred = false;
+    m_status = Cached;
+    m_loading = false;
+}
+
 CachedImage::~CachedImage()
 {
     delete m_image;
index 7985295dac63f94b11c2336d44af601ba0ab681d..f4bb7ae3b17f96cc7b0ac7fcc0480511a723040c 100644 (file)
@@ -42,6 +42,7 @@ class Image;
 class CachedImage : public CachedResource, public ImageAnimationObserver {
 public:
     CachedImage(DocLoader*, const String& url, CachePolicy, time_t expireDate);
+    CachedImage(Image*);
     virtual ~CachedImage();
 
     Image* image() const;
index 9703e877d3754387caaf455089167c1ed8379146..d43758b740b8bd6dbf1dc34ebcfd7408984a66b2 100644 (file)
@@ -1235,17 +1235,17 @@ bool Frame::hasSelection() const
 
 SelectionController* Frame::selectionController() const
 {
-    return &(d->m_selectionController);
+    return &d->m_selectionController;
 }
 
 Editor* Frame::editor() const
 {
-    return &(d->m_editor);
+    return &d->m_editor;
 }
 
 CommandByName* Frame::command() const
 {
-    return &(d->m_command);
+    return &d->m_command;
 }
 
 TextGranularity Frame::selectionGranularity() const
@@ -2156,6 +2156,7 @@ void Frame::appliedEditing(PassRefPtr<EditCommand> cmd)
         registerCommandForUndo(cmd);
     }
     respondToChangedContents(newSelection);
+    editor()->deleteButtonController()->respondToChangedContents(newSelection);
 }
 
 void Frame::unappliedEditing(PassRefPtr<EditCommand> cmd)
@@ -2169,6 +2170,7 @@ void Frame::unappliedEditing(PassRefPtr<EditCommand> cmd)
     d->m_lastEditCommand = 0;
     registerCommandForRedo(cmd);
     respondToChangedContents(newSelection);
+    editor()->deleteButtonController()->respondToChangedContents(newSelection);
 }
 
 void Frame::reappliedEditing(PassRefPtr<EditCommand> cmd)
@@ -2182,6 +2184,7 @@ void Frame::reappliedEditing(PassRefPtr<EditCommand> cmd)
     d->m_lastEditCommand = 0;
     registerCommandForUndo(cmd);
     respondToChangedContents(newSelection);
+    editor()->deleteButtonController()->respondToChangedContents(newSelection);
 }
 
 CSSMutableStyleDeclaration *Frame::typingStyle() const
index 7fc6a947acbaa56e18f2255305e43105843206f0..8296fc1af691cecae1aa58178d7a7fcfbb35ccef 100644 (file)
@@ -29,6 +29,7 @@
 #include "RenderTable.h"
 
 #include "AutoTableLayout.h"
+#include "DeleteButtonController.h"
 #include "Document.h"
 #include "FixedTableLayout.h"
 #include "HTMLNames.h"
@@ -154,6 +155,10 @@ void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild)
         case TABLE:
             // Allow a form to just sit at the top level.
             wrapInAnonymousSection = !isTableElement || !child->element() || !(child->element()->hasTagName(formTag) && document()->isHTMLDocument());
+
+            // FIXME: Allow the delete button container element to sit at the top level. This is needed until http://bugs.webkit.org/show_bug.cgi?id=11363 is fixed.
+            if (wrapInAnonymousSection && child->element() && child->element()->isHTMLElement() && static_cast<HTMLElement*>(child->element())->id() == DeleteButtonController::containerElementIdentifier)
+                wrapInAnonymousSection = false;
             break;
         }
 
index a8a55f540a7f2e2f81e3fb533b00dac0f43caf00..7c5d4f0055e6de81b9d0efa93058997a968a5caa 100644 (file)
@@ -1,3 +1,23 @@
+2006-10-21  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Geoff.
+
+        <rdar://problem/4478625> HTML Editing: Basic table editing and culling
+
+        Initial implementaltion of table deletion user interface:
+        * Adds a new editing delegate method, webView:shouldShowDeleteInterfaceForElement:.
+        * The new delegate method is called from the new shouldShowDeleteInterface EditorClient function.
+
+        * DefaultDelegates/WebDefaultEditingDelegate.m:
+        (-[WebDefaultEditingDelegate webView:shouldShowDeleteInterfaceForElement:]):
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::WebEditorClient):
+        (WebEditorClient::shouldDeleteRange):
+        (WebEditorClient::shouldShowDeleteInterface):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebEditingDelegatePrivate.h: Added.
+
 2006-10-21  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Maciej.
index 7de99cbaed20788ff0fd15843de92df9bc8547ed..e95f4a2d824204cd5613cc82268ec6f52e0b60dd 100644 (file)
@@ -32,6 +32,7 @@
 
 #import <WebKit/DOM.h>
 #import <WebKit/WebEditingDelegate.h>
+#import <WebKit/WebEditingDelegatePrivate.h>
 #import <WebKit/WebView.h>
 
 @implementation WebDefaultEditingDelegate
@@ -46,6 +47,11 @@ static WebDefaultEditingDelegate *sharedDelegate = nil;
     return sharedDelegate;
 }
 
+- (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element
+{
+    return NO;
+}
+
 - (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range
 {
     return YES;
index 5787be3d0e3a9367614644a3acbe6a08d7c8b7ff..542e7f6b838d4ee0a9468a128502f5e10c2159fa 100644 (file)
 
 @class WebView;
 
-class WebEditorClient : public WebCore::EditorClient
-{
+class WebEditorClient : public WebCore::EditorClient {
 public:
     WebEditorClient();
     WebEditorClient(WebView* webView);
     ~WebEditorClient();
 
     void setWebView(WebView* webView);
-    bool shouldDeleteRange(WebCore::Range *range);    
+
+    bool shouldDeleteRange(WebCore::Range*);    
+    bool shouldShowDeleteInterface(WebCore::HTMLElement*);
+
 //    bool shouldBeginEditingInRange(Range *range);
 //    bool shouldEndEditingInRange(Range *range);
 //    bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction);
index fdc7456a86e31daa111f5deb368f0abe7e186be3..a2fd00eef7f5ac1a54314e97f16e5b430eb4574a 100644 (file)
 
 #import "WebView.h"
 #import "WebViewInternal.h"
+#import <WebCore/DOMHTMLElementInternal.h>
 #import <WebCore/DOMRangeInternal.h>
 #import "WebEditingDelegate.h"
+#import "WebEditingDelegatePrivate.h"
 
 using namespace WebCore;
 
 WebEditorClient::WebEditorClient()
     : m_webView(NULL) 
-{ }
+{
+}
 
 WebEditorClient::WebEditorClient(WebView* webView)
     : m_webView(webView) 
@@ -59,11 +62,16 @@ void WebEditorClient::setWebView(WebView* webView)
     }
 }
 
-bool WebEditorClient::shouldDeleteRange(Range *range)
+bool WebEditorClient::shouldDeleteRange(Rangerange)
 {
     return [[m_webView _editingDelegateForwarder] webView:m_webView shouldDeleteDOMRange:[DOMRange _rangeWith:range]];
 }
 
+bool WebEditorClient::shouldShowDeleteInterface(HTMLElement* element)
+{
+    return [[m_webView _editingDelegateForwarder] webView:m_webView shouldShowDeleteInterfaceForElement:[DOMHTMLElement _HTMLElementWith:element]];
+}
+
 /*
 bool WebEditorClient::shouldBeginEditingInRange(Range *range) { return false; }
 bool WebEditorClient::shouldEndEditingInRange(Range *range) { return false; }
index 1bfe5ed57e8867f2eb4003c6da8f7cb3b98a1911..70607eba6f0bc637b30969cc6bf9afa6d0cb0382 100644 (file)
@@ -24,6 +24,7 @@
                1C68F670095B5FC100C2984E /* WebNodeHighlight.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C68F664095B5FC100C2984E /* WebNodeHighlight.m */; };
                1C68F671095B5FC100C2984E /* WebNodeHighlightView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */; };
                1C68F672095B5FC100C2984E /* WebNodeHighlightView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */; };
+               1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                220398770922D816009C3FFC /* WebBaseNetscapePluginViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2203984A0922D765009C3FFC /* WebBaseNetscapePluginViewInternal.h */; settings = {ATTRIBUTES = (); }; };
                224100F3091818D900D2D266 /* WebPluginsPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 224100F2091818D900D2D266 /* WebPluginsPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                224100F90918190100D2D266 /* WebPluginsPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 224100F80918190100D2D266 /* WebPluginsPrivate.m */; };
                1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNodeHighlightView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNodeHighlightView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                1C6CB03E0AA6391D00D23BFD /* MigrateHeaders.make */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MigrateHeaders.make; sourceTree = "<group>"; };
+               1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebEditingDelegatePrivate.h; sourceTree = "<group>"; };
                2203984A0922D765009C3FFC /* WebBaseNetscapePluginViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebBaseNetscapePluginViewInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                224100F2091818D900D2D266 /* WebPluginsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginsPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                224100F80918190100D2D266 /* WebPluginsPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebPluginsPrivate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                833987810543012D00EE146E /* WebDocumentPrivate.h */,
                                3944606B020F50ED0ECA1767 /* WebDynamicScrollBarsView.h */,
                                BE4FBECB0653DF47005EDE15 /* WebEditingDelegate.h */,
+                               1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */,
                                2D81DAB203EB0B2D00A80166 /* WebFormDelegate.h */,
                                2D36FD5E03F78F9E00A80166 /* WebFormDelegatePrivate.h */,
                                39446074020F50ED0ECA1767 /* WebFrame.h */,
                                65FFB7FC0AD0B7D30048CD05 /* WebDocumentLoaderMac.h in Headers */,
                                658BA6FC0ADB39DE00AEB387 /* WebPolicyDeciderMac.h in Headers */,
                                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
+                               1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */,
                                4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
+                       shouldCheckCompatibility = 1;
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );
diff --git a/WebKit/WebView/WebEditingDelegatePrivate.h b/WebKit/WebView/WebEditingDelegatePrivate.h
new file mode 100644 (file)
index 0000000..825cbda
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 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. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 <Cocoa/Cocoa.h>
+
+@class WebView;
+@class DOMHTMLElement;
+
+@interface NSObject (WebViewEditingDelegatePrivate)
+- (BOOL)webView:(WebView *)webView shouldShowDeleteInterfaceForElement:(DOMHTMLElement *)element;
+@end