Commit 17ed70ca authored by eric@webkit.org's avatar eric@webkit.org

2010-05-27 Nico Weber <thakis@chromium.org>

        Reviewed by Eric Seidel

        https://bugs.webkit.org/show_bug.cgi?id=39092

        Add Yank support to chromium mac. Do this by moving WebKit Mac's
        implementation of Editor::yankFromKillRing() into its own class and
        then using that.

        * editing/Editor.cpp:
          Use new KillRing class.
        * editing/Editor.h:
        (WebCore::Editor::killRing):
          Use new KillRing class.
        * editing/EditorCommand.cpp:
        (WebCore::executeYankAndSelect):
          Use new KillRing class.
        * platform/KillRing.h:
          Add new KillRing class, which acts as null object.
        (WebCore::KillRing::~KillRing):
        * platform/mac/KillRingMac.h:
          Add new KillRingMac class, which writes to the mac's kill ring.
        * platform/mac/KillRingMac.mm:
          Add new KillRingMac class, which writes to the mac's kill ring.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7a43c4a2
2010-05-27 Nico Weber <thakis@chromium.org>
Reviewed by Eric Seidel
https://bugs.webkit.org/show_bug.cgi?id=39092
Add Yank support to chromium mac. Do this by moving WebKit Mac's
implementation of Editor::yankFromKillRing() into its own class and
then using that.
* editing/Editor.cpp:
Use new KillRing class.
* editing/Editor.h:
(WebCore::Editor::killRing):
Use new KillRing class.
* editing/EditorCommand.cpp:
(WebCore::executeYankAndSelect):
Use new KillRing class.
* platform/KillRing.h:
Add new KillRing class, which acts as null object.
(WebCore::KillRing::~KillRing):
* platform/mac/KillRingMac.h:
Add new KillRingMac class, which writes to the mac's kill ring.
* platform/mac/KillRingMac.mm:
Add new KillRingMac class, which writes to the mac's kill ring.
2010-05-27 Ben Murdoch <benm@google.com>
Reviewed by Jian Li.
......
......@@ -1578,6 +1578,8 @@ webcore_sources += \
WebCore/platform/GeolocationService.cpp \
WebCore/platform/GeolocationService.h \
WebCore/platform/HostWindow.h \
WebCore/platform/KillRing.h \
WebCore/platform/KillRingNone.cpp \
WebCore/platform/KURL.cpp \
WebCore/platform/KURL.h \
WebCore/platform/KURLHash.h \
......
......@@ -1010,6 +1010,7 @@
['include', 'platform/graphics/mac/GraphicsContextMac\\.mm$'],
['include', 'platform/graphics/mac/IntRectMac\\.mm$'],
['include', 'platform/mac/BlockExceptions\\.mm$'],
['include', 'platform/mac/KillRingMac\\.mm$'],
['include', 'platform/mac/LocalCurrentGraphicsContext\\.mm$'],
['include', 'platform/mac/PurgeableBufferMac\\.cpp$'],
['include', 'platform/mac/WebCoreSystemInterface\\.mm$'],
......@@ -1022,6 +1023,10 @@
['include', 'WebKit/mac/WebCoreSupport/WebSystemInterface\\.m$'],
],
'sources!': [
# The Mac uses platform/mac/KillRingMac.mm instead of the dummy
# implementation.
'../platform/KillRingNone.cpp',
# The Mac currently uses FontCustomPlatformData.cpp from
# platform/graphics/mac, included by regex above, instead.
'../platform/graphics/chromium/FontCustomPlatformData.cpp',
......
......@@ -2516,6 +2516,7 @@
'platform/mac/FoundationExtras.h',
'platform/mac/KURLMac.mm',
'platform/mac/KeyEventMac.mm',
'platform/mac/KillRingMac.mm',
'platform/mac/Language.mm',
'platform/mac/LocalCurrentGraphicsContext.h',
'platform/mac/LocalCurrentGraphicsContext.mm',
......@@ -2900,6 +2901,8 @@
'platform/GeolocationService.cpp',
'platform/GeolocationService.h',
'platform/HostWindow.h',
'platform/KillRing.h',
'platform/KillRingNone.cpp',
'platform/KURL.cpp',
'platform/KURL.h',
'platform/KURLGoogle.cpp',
......
......@@ -861,6 +861,7 @@ SOURCES += \
platform/graphics/transforms/SkewTransformOperation.cpp \
platform/graphics/transforms/TransformOperations.cpp \
platform/graphics/transforms/TranslateTransformOperation.cpp \
platform/KillRingNone.cpp \
platform/KURL.cpp \
platform/Length.cpp \
platform/LinkHash.cpp \
......@@ -1620,6 +1621,7 @@ HEADERS += \
platform/graphics/transforms/TransformationMatrix.h \
platform/graphics/transforms/TransformOperations.h \
platform/graphics/transforms/TranslateTransformOperation.h \
platform/KillRing.h \
platform/KURL.h \
platform/Length.h \
platform/LinkHash.h \
......
......@@ -22408,6 +22408,14 @@
RelativePath="..\platform\HostWindow.h"
>
</File>
<File
RelativePath="..\platform\KillRing.h"
>
</File>
<File
RelativePath="..\platform\KillRingNone.cpp"
>
</File>
<File
RelativePath="..\platform\KURL.cpp"
>
......@@ -1159,6 +1159,8 @@
51EC92590CE90DB400F90308 /* SQLError.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EC92570CE90DB400F90308 /* SQLError.h */; settings = {ATTRIBUTES = (Private, ); }; };
51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */; };
51FAFE340CECBF2D00BB3F24 /* DatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FAFE330CECBF2D00BB3F24 /* DatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
521D46F611AEC98100514613 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 521D46F511AEC98100514613 /* KillRingMac.mm */; };
521D46F811AEC9B100514613 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = 521D46F711AEC9B100514613 /* KillRing.h */; };
54C50F7B0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */; };
550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -6786,6 +6788,8 @@
51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51FAFE330CECBF2D00BB3F24 /* DatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseTrackerClient.h; sourceTree = "<group>"; };
521D46F511AEC98100514613 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KillRingMac.mm; sourceTree = "<group>"; };
521D46F711AEC9B100514613 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerLibxml2.cpp; sourceTree = "<group>"; };
550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -11916,6 +11920,7 @@
BCE494A90F4F5E9E0084E319 /* GeolocationServiceMac.h */,
BCE494AA0F4F5E9E0084E319 /* GeolocationServiceMac.mm */,
935C476E09AC4D7300A6AAB4 /* KeyEventMac.mm */,
521D46F511AEC98100514613 /* KillRingMac.mm */,
6593923909AE435C002C531F /* KURLMac.mm */,
9352084409BD43B900F2038D /* Language.mm */,
06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
......@@ -15847,6 +15852,7 @@
FEAB90100EA51B9C006348C3 /* GeolocationService.cpp */,
FEAB90110EA51B9C006348C3 /* GeolocationService.h */,
BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
521D46F711AEC9B100514613 /* KillRing.h */,
6593923509AE4346002C531F /* KURL.cpp */,
6593923609AE4346002C531F /* KURL.h */,
BCBD21AA0E417AD400A070F2 /* KURLHash.h */,
......@@ -19370,6 +19376,7 @@
B6693EEE11AD63E6003F2770 /* IDBObjectStoreRequest.h in Headers */,
B6693EF311AD6486003F2770 /* JSIDBObjectStoreRequest.h in Headers */,
A83B3AF111ADEFF500458809 /* HTML5ScriptRunner.h in Headers */,
521D46F811AEC9B100514613 /* KillRing.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -21665,6 +21672,7 @@
B6693EF211AD6486003F2770 /* JSIDBObjectStoreRequest.cpp in Sources */,
B627FB2D11AD743500E97B72 /* IDBDatabaseImpl.cpp in Sources */,
A83B3AF011ADEFF500458809 /* HTML5ScriptRunner.cpp in Sources */,
521D46F611AEC98100514613 /* KillRingMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -55,6 +55,7 @@
#include "IndentOutdentCommand.h"
#include "InsertListCommand.h"
#include "KeyboardEvent.h"
#include "KillRing.h"
#include "ModifySelectionListLevel.h"
#include "Page.h"
#include "Pasteboard.h"
......@@ -928,6 +929,7 @@ Editor::Editor(Frame* frame)
, m_shouldStartNewKillRingSequence(false)
// This is off by default, since most editors want this behavior (this matches IE but not FF).
, m_shouldStyleWithCSS(false)
, m_killRing(new KillRing)
{
}
......@@ -2707,41 +2709,16 @@ void Editor::transpose()
void Editor::addToKillRing(Range* range, bool prepend)
{
if (m_shouldStartNewKillRingSequence)
startNewKillRingSequence();
killRing()->startNewSequence();
String text = plainText(range);
if (prepend)
prependToKillRing(text);
killRing()->prepend(text);
else
appendToKillRing(text);
killRing()->append(text);
m_shouldStartNewKillRingSequence = false;
}
#if !PLATFORM(MAC)
void Editor::appendToKillRing(const String&)
{
}
void Editor::prependToKillRing(const String&)
{
}
String Editor::yankFromKillRing()
{
return String();
}
void Editor::startNewKillRingSequence()
{
}
void Editor::setKillRingToYankedState()
{
}
#endif
bool Editor::insideVisibleArea(const IntPoint& point) const
{
if (m_frame->excludeFromTextSearch())
......
......@@ -43,6 +43,7 @@ class EditorClient;
class EditorInternalCommand;
class HTMLElement;
class HitTestResult;
class KillRing;
class Pasteboard;
class SimpleFontData;
class Text;
......@@ -278,11 +279,7 @@ public:
VisibleSelection selectionForCommand(Event*);
void appendToKillRing(const String&);
void prependToKillRing(const String&);
String yankFromKillRing();
void startNewKillRingSequence();
void setKillRingToYankedState();
KillRing* killRing() const { return m_killRing.get(); }
PassRefPtr<Range> selectedRange();
......@@ -305,6 +302,7 @@ private:
bool m_ignoreCompositionSelectionChange;
bool m_shouldStartNewKillRingSequence;
bool m_shouldStyleWithCSS;
OwnPtr<KillRing> m_killRing;
bool canDeleteRange(Range*) const;
bool canSmartReplaceWithPasteboard(Pasteboard*);
......
......@@ -47,6 +47,7 @@
#include "HTMLImageElement.h"
#include "IndentOutdentCommand.h"
#include "InsertListCommand.h"
#include "KillRing.h"
#include "Page.h"
#include "ReplaceSelectionCommand.h"
#include "Scrollbar.h"
......@@ -1046,15 +1047,15 @@ static bool executeUnselect(Frame* frame, Event*, EditorCommandSource, const Str
static bool executeYank(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->editor()->insertTextWithoutSendingTextEvent(frame->editor()->yankFromKillRing(), false, 0);
frame->editor()->setKillRingToYankedState();
frame->editor()->insertTextWithoutSendingTextEvent(frame->editor()->killRing()->yank(), false, 0);
frame->editor()->killRing()->setToYankedState();
return true;
}
static bool executeYankAndSelect(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->editor()->insertTextWithoutSendingTextEvent(frame->editor()->yankFromKillRing(), true, 0);
frame->editor()->setKillRingToYankedState();
frame->editor()->insertTextWithoutSendingTextEvent(frame->editor()->killRing()->yank(), true, 0);
frame->editor()->killRing()->setToYankedState();
return true;
}
......
......@@ -33,63 +33,11 @@
namespace WebCore {
extern "C" {
// Kill ring calls. Would be better to use NSKillRing.h, but that's not available as API or SPI.
void _NSInitializeKillRing();
void _NSAppendToKillRing(NSString *);
void _NSPrependToKillRing(NSString *);
NSString *_NSYankFromKillRing();
void _NSNewKillRingSequence();
void _NSSetKillRingToYankedState();
}
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
{
return ClipboardMac::create(false, [NSPasteboard generalPasteboard], policy, 0);
}
static void initializeKillRingIfNeeded()
{
static bool initializedKillRing = false;
if (!initializedKillRing) {
initializedKillRing = true;
_NSInitializeKillRing();
}
}
void Editor::appendToKillRing(const String& string)
{
initializeKillRingIfNeeded();
_NSAppendToKillRing(string);
}
void Editor::prependToKillRing(const String& string)
{
initializeKillRingIfNeeded();
_NSPrependToKillRing(string);
}
String Editor::yankFromKillRing()
{
initializeKillRingIfNeeded();
return _NSYankFromKillRing();
}
void Editor::startNewKillRingSequence()
{
initializeKillRingIfNeeded();
_NSNewKillRingSequence();
}
void Editor::setKillRingToYankedState()
{
initializeKillRingIfNeeded();
_NSSetKillRingToYankedState();
}
void Editor::showFontPanel()
{
[[NSFontManager sharedFontManager] orderFrontFontPanel:nil];
......
/*
* Copyright (C) 2010 Google 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 KillRing_h
#define KillRing_h
#include "PlatformString.h"
namespace WebCore {
class KillRing {
public:
void append(const String&);
void prepend(const String&);
String yank();
void startNewSequence();
void setToYankedState();
};
} // namespace WebCore
#endif // KillRing_h
/*
* Copyright (C) 2010 Google 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 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 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 "KillRing.h"
namespace WebCore {
void KillRing::append(const String& string)
{
}
void KillRing::prepend(const String& string)
{
}
String KillRing::yank()
{
return String();
}
void KillRing::startNewSequence()
{
}
void KillRing::setToYankedState()
{
}
} // namespace WebCore
/*
* Copyright (C) 2010 Google 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 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 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 "config.h"
#import "KillRing.h"
namespace WebCore {
extern "C" {
// Kill ring calls. Would be better to use NSKillRing.h, but that's not available as API or SPI.
void _NSInitializeKillRing();
void _NSAppendToKillRing(NSString *);
void _NSPrependToKillRing(NSString *);
NSString *_NSYankFromKillRing();
void _NSNewKillRingSequence();
void _NSSetKillRingToYankedState();
}
static void initializeKillRingIfNeeded()
{
static bool initializedKillRing = false;
if (!initializedKillRing) {
initializedKillRing = true;
_NSInitializeKillRing();
}
}
void KillRing::append(const String& string)
{
initializeKillRingIfNeeded();
_NSAppendToKillRing(string);
}
void KillRing::prepend(const String& string)
{
initializeKillRingIfNeeded();
_NSPrependToKillRing(string);
}
String KillRing::yank()
{
initializeKillRingIfNeeded();
return _NSYankFromKillRing();
}
void KillRing::startNewSequence()
{
initializeKillRingIfNeeded();
_NSNewKillRingSequence();
}
void KillRing::setToYankedState()
{
initializeKillRingIfNeeded();
_NSSetKillRingToYankedState();
}
} // namespace WebCore
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment