WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 21:57:47 +0000 (21:57 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 21:57:47 +0000 (21:57 +0000)
        Reviewed by Oliver.

        Move methods from the bridge and frame into editor.

        * WebCore.exp:
        * bridge/EditorClient.h:
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        * editing/Editor.cpp:
        (WebCore::Editor::removeFormattingAndStyle):
        (WebCore::Editor::applyStyle):
        (WebCore::Editor::applyParagraphStyle):
        (WebCore::Editor::applyStyleToSelection):
        (WebCore::Editor::applyParagraphStyleToSelection):
        (WebCore::Editor::toggleBold):
        (WebCore::Editor::toggleItalic):
        (WebCore::Editor::selectionStartHasStyle):
        * editing/Editor.h:
        * editing/JSEditor.cpp:
        * page/Frame.cpp:
        * page/Frame.h:

WebKit:

        Reviewed by Oliver.

        Call into the WebCore editor object directly.

        * MigrateHeaders.make:
        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::shouldDeleteRange):
        (WebEditorClient::shouldShowDeleteInterface):
        (WebEditorClient::shouldApplyStyle):
        * WebView/WebFrame.mm:
        (core):
        (kit):
        * WebView/WebFrameInternal.h:
        * WebView/WebHTMLView.m:
        (-[NSArray _applyStyleToSelection:withUndoAction:]):
        (-[NSArray _applyParagraphStyleToSelection:withUndoAction:]):
        (-[NSArray _toggleBold]):
        (-[NSArray _toggleItalic]):
        (-[NSArray _changeCSSColorUsingSelector:inRange:]):
        (-[NSArray underline:]):
        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
        * WebView/WebView.mm:
        (-[WebView applyStyle:]):

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

18 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/bridge/EditorClient.h
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/editing/JSEditor.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/ChangeLog
WebKit/MigrateHeaders.make
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebView/WebFrame.mm
WebKit/WebView/WebFrameInternal.h
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebView.mm

index 3d7542b7dfe7a5b956a9baaa9d85c538870b5ce2..c1d8ac3c3f4951e229a71aa9508b84949e80da9f 100644 (file)
@@ -1,3 +1,27 @@
+2006-11-08  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Oliver.
+        
+        Move methods from the bridge and frame into editor.
+        
+        * WebCore.exp:
+        * bridge/EditorClient.h:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        * editing/Editor.cpp:
+        (WebCore::Editor::removeFormattingAndStyle):
+        (WebCore::Editor::applyStyle):
+        (WebCore::Editor::applyParagraphStyle):
+        (WebCore::Editor::applyStyleToSelection):
+        (WebCore::Editor::applyParagraphStyleToSelection):
+        (WebCore::Editor::toggleBold):
+        (WebCore::Editor::toggleItalic):
+        (WebCore::Editor::selectionStartHasStyle):
+        * editing/Editor.h:
+        * editing/JSEditor.cpp:
+        * page/Frame.cpp:
+        * page/Frame.h:
+
 2006-11-08  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Beth.
index c17f6f68d661713bae59c04d499918d7662b0397..b45c7d90c4335ef629fad6f15441793b82928061 100644 (file)
@@ -221,6 +221,13 @@ __ZN7WebCore5Image10getNSImageEv
 __ZN7WebCore5Image21getTIFFRepresentationEv
 __ZN7WebCore5RangeC1EPNS_8DocumentEPNS_4NodeEiS4_i
 __ZN7WebCore5RangeD1Ev
+__ZN7WebCore6Editor10applyStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
+__ZN7WebCore6Editor10toggleBoldEv
+__ZN7WebCore6Editor12toggleItalicEv
+__ZN7WebCore6Editor19applyParagraphStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
+__ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
+__ZNK7WebCore6Editor22selectionStartHasStyleEPNS_19CSSStyleDeclarationE
+__ZN7WebCore6Editor30applyParagraphStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
 __ZN7WebCore6Editor30deleteSelectionWithSmartDeleteEb
 __ZN7WebCore6StringC1EP8NSString
 __ZN7WebCore6StringC1EPKc
index e1451c3980b1dc5cb9f7c5d26d851b42f6fdebf6..da2cab594ba8f7bc73300c1cb55aa5d8a4293a38 100644 (file)
@@ -30,6 +30,7 @@
 
 namespace WebCore {
 
+class CSSStyleDeclaration;
 class Range;
 class HTMLElement;
 
@@ -49,7 +50,7 @@ public:
 //    virtual bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) = 0;
 //    virtual bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertAction givenAction) = 0;
 //    virtual bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) = 0;
-//    virtual bool shouldApplyStyle(CSSStyleDeclaration *style, Range *toElementsInDOMRange) = 0;
+    virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) = 0;
 //    virtual bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) = 0;
 //    virtual bool doCommandBySelector(SEL selector) = 0;
 //
index 207cc7ac701e07588333eb1c0d25499bae18f40d..b41dec464e9392f3a95316ff5c23e75c9ebc09c9 100644 (file)
@@ -282,9 +282,6 @@ typedef enum {
 
 - (DOMCSSStyleDeclaration *)typingStyle;
 - (void)setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
-- (void)applyParagraphStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction;
-- (BOOL)selectionStartHasStyle:(DOMCSSStyleDeclaration *)style;
 - (NSCellStateValue)selectionHasStyle:(DOMCSSStyleDeclaration *)style;
 
 - (NSDragOperation)dragOperationForDraggingInfo:(id <NSDraggingInfo>)info;
index dba710dae2139abd32f569ed42f3b9464355fce5..c0b53c1db5ee6445bbc8b1c18e36d7b219b67aaa 100644 (file)
@@ -1516,27 +1516,6 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     m_frame->computeAndSetTypingStyle([style _CSSStyleDeclaration], undoAction);
 }
 
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
-{
-    if (!m_frame)
-        return;
-    m_frame->applyStyle([style _CSSStyleDeclaration], undoAction);
-}
-
-- (void)applyParagraphStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
-{
-    if (!m_frame)
-        return;
-    m_frame->applyParagraphStyle([style _CSSStyleDeclaration], undoAction);
-}
-
-- (BOOL)selectionStartHasStyle:(DOMCSSStyleDeclaration *)style
-{
-    if (!m_frame)
-        return NO;
-    return m_frame->selectionStartHasStyle([style _CSSStyleDeclaration]);
-}
-
 - (NSCellStateValue)selectionHasStyle:(DOMCSSStyleDeclaration *)style
 {
     if (!m_frame)
index 0d1221a324b956ac6bba7e1ce0215ab8d08bb216..9aac165eb002fbac0037b95046b3f9f6eeca4877 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "ApplyStyleCommand.h"
 #include "CSSComputedStyleDeclaration.h"
+#include "CSSProperty.h"
+#include "CSSPropertyNames.h"
 #include "DeleteButtonController.h"
 #include "DeleteSelectionCommand.h"
 #include "Document.h"
@@ -229,10 +231,10 @@ Frame::TriState Editor::selectionOrderedListState() const
 
 void Editor::removeFormattingAndStyle()
 {
-    Document* document = frame()->document();
+    Document* document = m_frame->document();
     
     // Make a plain text string from the selection to remove formatting like tables and lists.
-    RefPtr<DocumentFragment> text = createFragmentFromText(frame()->selectionController()->toRange().get(), frame()->selectionController()->toString());
+    RefPtr<DocumentFragment> text = createFragmentFromText(m_frame->selectionController()->toRange().get(), m_frame->selectionController()->toString());
     
     // Put the fragment made from that string into a style span with the document's
     // default style to make sure that it is unstyled regardless of where it is inserted.
@@ -259,6 +261,105 @@ void Editor::setLastEditCommand(PassRefPtr<EditCommand> lastEditCommand)
     m_lastEditCommand = lastEditCommand;
 }
 
+void Editor::applyStyle(CSSStyleDeclaration *style, EditAction editingAction)
+{
+    switch (m_frame->selectionController()->state()) {
+        case Selection::NONE:
+            // do nothing
+            break;
+        case Selection::CARET: {
+            m_frame->computeAndSetTypingStyle(style, editingAction);
+            break;
+        }
+        case Selection::RANGE:
+            if (m_frame->document() && style)
+                applyCommand(new ApplyStyleCommand(m_frame->document(), style, editingAction));
+            break;
+    }
+}
+
+void Editor::applyParagraphStyle(CSSStyleDeclaration *style, EditAction editingAction)
+{
+    switch (m_frame->selectionController()->state()) {
+        case Selection::NONE:
+            // do nothing
+            break;
+        case Selection::CARET:
+        case Selection::RANGE:
+            if (m_frame->document() && style)
+                applyCommand(new ApplyStyleCommand(m_frame->document(), style, editingAction, ApplyStyleCommand::ForceBlockProperties));
+            break;
+    }
+}
+
+void Editor::applyStyleToSelection(CSSStyleDeclaration* style, EditAction editingAction)
+{
+    if (!style || style->length() == 0 || !canEditRichly())
+        return;
+
+    if (m_client->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
+        applyStyle(style, editingAction);
+}
+
+void Editor::applyParagraphStyleToSelection(CSSStyleDeclaration* style, EditAction editingAction)
+{
+    if (!style || style->length() == 0 || !canEditRichly())
+        return;
+    
+    if (m_client->shouldApplyStyle(style, m_frame->selectionController()->toRange().get()))
+        applyParagraphStyle(style, editingAction);
+}
+
+void Editor::toggleBold()
+{
+    ExceptionCode ec;
+    
+    RefPtr<CSSStyleDeclaration> style = m_frame->document()->createCSSStyleDeclaration();
+    style->setProperty(CSS_PROP_FONT_WEIGHT, "bold", false, ec);
+    if (selectionStartHasStyle(style.get()))
+        style->setProperty(CSS_PROP_FONT_WEIGHT, "normal", false, ec);
+    applyStyleToSelection(style.get(), EditActionSetFont);
+}
+
+void Editor::toggleItalic()
+{
+    ExceptionCode ec;
+    
+    RefPtr<CSSStyleDeclaration> style = m_frame->document()->createCSSStyleDeclaration();
+    style->setProperty(CSS_PROP_FONT_STYLE, "italic", false, ec);
+    if (selectionStartHasStyle(style.get()))
+        style->setProperty(CSS_PROP_FONT_STYLE, "normal", false, ec);
+    applyStyleToSelection(style.get(), EditActionSetFont);
+}
+
+bool Editor::selectionStartHasStyle(CSSStyleDeclaration* style) const
+{
+    Node* nodeToRemove;
+    RefPtr<CSSStyleDeclaration> selectionStyle = m_frame->selectionComputedStyle(nodeToRemove);
+    if (!selectionStyle)
+        return false;
+    
+    RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->makeMutable();
+    
+    bool match = true;
+    DeprecatedValueListConstIterator<CSSProperty> end;
+    for (DeprecatedValueListConstIterator<CSSProperty> it = mutableStyle->valuesIterator(); it != end; ++it) {
+        int propertyID = (*it).id();
+        if (!equalIgnoringCase(mutableStyle->getPropertyValue(propertyID), selectionStyle->getPropertyValue(propertyID))) {
+            match = false;
+            break;
+        }
+    }
+    
+    if (nodeToRemove) {
+        ExceptionCode ec = 0;
+        nodeToRemove->remove(ec);
+        assert(ec == 0);
+    }
+    
+    return match;
+}
+
 // =============================================================================
 //
 // public editing commands
index ed28e3ab03916316f5757e1f832b783f87fd9214..6cf26e07ec50efce49cd1e727f4217df4a0726c7 100644 (file)
@@ -84,6 +84,15 @@ public:
 
     void deleteSelectionWithSmartDelete(bool smartDelete);
 
+    void applyStyle(CSSStyleDeclaration*, EditAction = EditActionUnspecified);
+    void applyParagraphStyle(CSSStyleDeclaration*, EditAction = EditActionUnspecified);
+    void applyStyleToSelection(CSSStyleDeclaration*, EditAction);
+    void applyParagraphStyleToSelection(CSSStyleDeclaration*, EditAction);
+
+    void toggleBold();
+    void toggleItalic();
+    
+    bool selectionStartHasStyle(CSSStyleDeclaration*) const;
 private:
     Frame* m_frame;
     RefPtr<EditorClient> m_client;
index 450ad0840ff45cc2c84ecbcc96ddc8ef9376695b..e367b03891f76ec06f839dcc309df2427518928c 100644 (file)
@@ -155,7 +155,7 @@ bool execStyleChange(Frame* frame, int propertyID, const String& propertyValue)
 {
     RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
     style->setProperty(propertyID, propertyValue);
-    frame->applyStyle(style.get());
+    frame->editor()->applyStyle(style.get());
     return true;
 }
 
@@ -175,7 +175,7 @@ bool selectionStartHasStyle(Frame* frame, int propertyID, const char* desiredVal
 {
     RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
     style->setProperty(propertyID, desiredValue);
-    return frame->selectionStartHasStyle(style.get());
+    return frame->editor()->selectionStartHasStyle(style.get());
 }
 
 String valueStyle(Frame* frame, int propertyID)
index 5cc31019cb38162e70f02f72054142f2414770cf..e329e88d72e35d59f549b32014667c8799538bb0 100644 (file)
@@ -1020,37 +1020,6 @@ void Frame::computeAndSetTypingStyle(CSSStyleDeclaration *style, EditAction edit
     d->m_typingStyle = mutableStyle.release();
 }
 
-void Frame::applyStyle(CSSStyleDeclaration *style, EditAction editingAction)
-{
-    switch (selectionController()->state()) {
-        case Selection::NONE:
-            // do nothing
-            break;
-        case Selection::CARET: {
-            computeAndSetTypingStyle(style, editingAction);
-            break;
-        }
-        case Selection::RANGE:
-            if (document() && style)
-                applyCommand(new ApplyStyleCommand(document(), style, editingAction));
-            break;
-    }
-}
-
-void Frame::applyParagraphStyle(CSSStyleDeclaration *style, EditAction editingAction)
-{
-    switch (selectionController()->state()) {
-        case Selection::NONE:
-            // do nothing
-            break;
-        case Selection::CARET:
-        case Selection::RANGE:
-            if (document() && style)
-                applyCommand(new ApplyStyleCommand(document(), style, editingAction, ApplyStyleCommand::ForceBlockProperties));
-            break;
-    }
-}
-
 void Frame::indent()
 {
     applyCommand(new IndentOutdentCommand(document(), IndentOutdentCommand::Indent));
@@ -1113,34 +1082,6 @@ Frame::TriState Frame::selectionHasStyle(CSSStyleDeclaration *style) const
     return state;
 }
 
-bool Frame::selectionStartHasStyle(CSSStyleDeclaration *style) const
-{
-    Node* nodeToRemove;
-    RefPtr<CSSStyleDeclaration> selectionStyle = selectionComputedStyle(nodeToRemove);
-    if (!selectionStyle)
-        return false;
-
-    RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->makeMutable();
-
-    bool match = true;
-    DeprecatedValueListConstIterator<CSSProperty> end;
-    for (DeprecatedValueListConstIterator<CSSProperty> it = mutableStyle->valuesIterator(); it != end; ++it) {
-        int propertyID = (*it).id();
-        if (!equalIgnoringCase(mutableStyle->getPropertyValue(propertyID), selectionStyle->getPropertyValue(propertyID))) {
-            match = false;
-            break;
-        }
-    }
-
-    if (nodeToRemove) {
-        ExceptionCode ec = 0;
-        nodeToRemove->remove(ec);
-        assert(ec == 0);
-    }
-
-    return match;
-}
-
 String Frame::selectionStartStylePropertyValue(int stylePropertyID) const
 {
     Node *nodeToRemove;
index dc110c722b57e78c6da215650994d49538bc8284..a795db6435f1ae6bd46ee25d0043b965dd9e6ff9 100644 (file)
@@ -265,13 +265,10 @@ public:
     virtual bool canRedo() const = 0;
     virtual bool canUndo() const = 0;
     void computeAndSetTypingStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
-    void applyStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
-    void applyParagraphStyle(CSSStyleDeclaration* , EditAction = EditActionUnspecified);
     void indent();
     void outdent();
     enum TriState { falseTriState, trueTriState, mixedTriState };
     TriState selectionHasStyle(CSSStyleDeclaration*) const;
-    bool selectionStartHasStyle(CSSStyleDeclaration*) const;
     String selectionStartStylePropertyValue(int stylePropertyID) const;
     void applyEditingStyleToBodyElement() const;
     void removeEditingStyleFromBodyElement() const;
index 61b8344e8f2e00fba3812ac0c1ad25311dbd5111..b3242ae2ffa0e5714e6bf940ac9a3cb90921215c 100644 (file)
@@ -1,3 +1,30 @@
+2006-11-08  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Oliver.
+
+        Call into the WebCore editor object directly.
+        
+        * MigrateHeaders.make:
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::shouldDeleteRange):
+        (WebEditorClient::shouldShowDeleteInterface):
+        (WebEditorClient::shouldApplyStyle):
+        * WebView/WebFrame.mm:
+        (core):
+        (kit):
+        * WebView/WebFrameInternal.h:
+        * WebView/WebHTMLView.m:
+        (-[NSArray _applyStyleToSelection:withUndoAction:]):
+        (-[NSArray _applyParagraphStyleToSelection:withUndoAction:]):
+        (-[NSArray _toggleBold]):
+        (-[NSArray _toggleItalic]):
+        (-[NSArray _changeCSSColorUsingSelector:inRange:]):
+        (-[NSArray underline:]):
+        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
+        * WebView/WebView.mm:
+        (-[WebView applyStyle:]):
+
 2006-11-08  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Oliver.
index 26a85ab1409d8bffe948fb41e65128330fe0e673..b33767b5b61ebb4bb3de03e351112babc2fa3868 100644 (file)
@@ -47,6 +47,7 @@ all : \
     $(PUBLIC_HEADERS_DIR)/DOMCSSRule.h \
     $(PUBLIC_HEADERS_DIR)/DOMCSSRuleList.h \
     $(PUBLIC_HEADERS_DIR)/DOMCSSStyleDeclaration.h \
+    $(INTERNAL_HEADERS_DIR)/DOMCSSStyleDeclarationInternal.h \
     $(PUBLIC_HEADERS_DIR)/DOMCSSStyleRule.h \
     $(PUBLIC_HEADERS_DIR)/DOMCSSStyleSheet.h \
     $(PUBLIC_HEADERS_DIR)/DOMCSSUnknownRule.h \
index 6d05701c681514c73b2c23d5ceac3b226e7a7700..322f26b5da01325a1a164b62bca61ddabfea6856 100644 (file)
@@ -50,7 +50,7 @@ public:
 //    bool shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction);
 //    bool shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertActiongivenAction);
 //    bool shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting);
-//    bool shouldApplyStyle(CSSStyleDeclaration *style, Range *toElementsInDOMRange);
+    bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*);
 //    bool shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle);
 //    bool doCommandBySelector(SEL selector);
 
index aaeee3c08670b9f283ba0551cbc5da8395c60426..145e4ec297b14aa2e20bf203da6962db0ddeeec1 100644 (file)
@@ -32,6 +32,8 @@
 #import "WebViewInternal.h"
 #import "WebEditingDelegatePrivate.h"
 
+using namespace WebCore;
+
 WebEditorClient::WebEditorClient()
     : m_webView(nil) 
 {
@@ -70,25 +72,30 @@ int WebEditorClient::spellCheckerDocumentTag()
     return [m_webView spellCheckerDocumentTag];
 }
 
-bool WebEditorClient::shouldDeleteRange(WebCore::Range* range)
+bool WebEditorClient::shouldDeleteRange(Range* range)
 {
     return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldDeleteDOMRange:kit(range)];
 }
 
-bool WebEditorClient::shouldShowDeleteInterface(WebCore::HTMLElement* element)
+bool WebEditorClient::shouldShowDeleteInterface(HTMLElement* element)
 {
     return [[m_webView _editingDelegateForwarder] webView:m_webView
         shouldShowDeleteInterfaceForElement:kit(element)];
 }
 
+bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration* style, Range* range)
+{
+    return [[m_webView _editingDelegateForwarder] webView:m_webView
+        shouldApplyStyle:kit(style) toElementsInDOMRange:kit(range)];
+}
+
 /*
 bool WebEditorClient::shouldBeginEditingInRange(Range *range) { return false; }
 bool WebEditorClient::shouldEndEditingInRange(Range *range) { return false; }
 bool WebEditorClient::shouldInsertNode(Node *node, Range* replacingRange, WebViewInsertAction givenAction) { return false; }
 bool WebEditorClient::shouldInsertText(NSString *text, Range *replacingRange, WebViewInsertActiongivenAction) { return false; }
 bool WebEditorClient::shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, NSSelectionAffinity selectionAffinity, bool stillSelecting) { return false; }
-bool WebEditorClient::shouldApplyStyle(CSSStyleDeclaration *style, Range *toElementsInDOMRange) { return false; }
 bool WebEditorClient::shouldChangeTypingStyle(CSSStyleDeclaration *currentStyle, CSSStyleDeclaration *toProposedStyle) { return false; }
 bool WebEditorClient::doCommandBySelector(SEL selector) { return false; }
 
index 11da940e8fcad98016152286cbfb4ac8f289f2d6..dcb3989e3f1baf2d96b4e2f4e64d7da0411bee6c 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "WebFrameInternal.h"
 
+#import "DOMCSSStyleDeclarationInternal.h"
 #import "DOMDocumentInternal.h"
 #import "DOMElementInternal.h"
 #import "DOMHTMLElementInternal.h"
@@ -150,6 +151,16 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
 
 @end
 
+CSSStyleDeclaration* core(DOMCSSStyleDeclaration *declaration)
+{
+    return [declaration _CSSStyleDeclaration];
+}
+
+DOMCSSStyleDeclaration *kit(WebCore::CSSStyleDeclaration* declaration)
+{
+    return [DOMCSSStyleDeclaration _CSSStyleDeclarationWith:declaration];
+}
+
 Element* core(DOMElement *element)
 {
     return [element _element];
index 30bf296aa911e825f4fc16a9165ebe36112c01a4..aa941e94a6490c84efa347dd68a6110803f54f1c 100644 (file)
@@ -34,6 +34,7 @@
 #import <WebCore/FrameLoaderTypes.h>
 #endif
 
+@class DOMCSSStyleDeclaration;
 @class DOMElement;
 @class DOMNode;
 @class DOMRange;
@@ -46,6 +47,7 @@
 #ifdef __cplusplus
 
 namespace WebCore {
+    class CSSStyleDeclaration;
     class Document;
     class DocumentLoader;
     class Element;
@@ -58,6 +60,9 @@ namespace WebCore {
     class Range;
 }
 
+WebCore::CSSStyleDeclaration* core(DOMCSSStyleDeclaration *);
+DOMCSSStyleDeclaration *kit(WebCore::CSSStyleDeclaration*);
+
 WebCore::FrameMac* core(WebFrame *);
 WebFrame *kit(WebCore::Frame *);
 
index ba2ced1096b16ed4873d6c2a307ea6bbc86c9800..1232b05add27a7cffcd0b3194c09548d591f9e98 100644 (file)
@@ -3983,41 +3983,30 @@ done:
 
 - (void)_applyStyleToSelection:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
 {
-    if (style == nil || [style length] == 0 || ![self _canEditRichly])
-        return;
-    WebView *webView = [self _webView];
-    WebFrameBridge *bridge = [self _bridge];
-    if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:[self _selectedRange]]) {
-        [bridge applyStyle:style withUndoAction:undoAction];
-    }
+    Frame* coreFrame = core([self _frame]);
+    if (coreFrame)
+        coreFrame->editor()->applyStyleToSelection(core(style), undoAction);
 }
 
 - (void)_applyParagraphStyleToSelection:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
 {
-    if (style == nil || [style length] == 0 || ![self _canEditRichly])
-        return;
-    WebView *webView = [self _webView];
-    WebFrameBridge *bridge = [self _bridge];
-    if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:[self _selectedRange]])
-        [bridge applyParagraphStyle:style withUndoAction:undoAction];
+    Frame* coreFrame = core([self _frame]);
+    if (coreFrame)
+        coreFrame->editor()->applyParagraphStyleToSelection(core(style), undoAction);
 }
 
 - (void)_toggleBold
 {
-    DOMCSSStyleDeclaration *style = [self _emptyStyle];
-    [style setFontWeight:@"bold"];
-    if ([[self _bridge] selectionStartHasStyle:style])
-        [style setFontWeight:@"normal"];
-    [self _applyStyleToSelection:style withUndoAction:EditActionSetFont];
+    Frame* coreFrame = core([self _frame]);
+    if (coreFrame)
+        coreFrame->editor()->toggleBold();
 }
 
 - (void)_toggleItalic
 {
-    DOMCSSStyleDeclaration *style = [self _emptyStyle];
-    [style setFontStyle:@"italic"];
-    if ([[self _bridge] selectionStartHasStyle:style])
-        [style setFontStyle:@"normal"];
-    [self _applyStyleToSelection:style withUndoAction:EditActionSetFont];
+    Frame* coreFrame = core([self _frame]);
+    if (coreFrame)
+        coreFrame->editor()->toggleItalic();
 }
 
 - (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
@@ -4317,7 +4306,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     DOMCSSStyleDeclaration *style = [self _styleFromColorPanelWithSelector:selector];
     WebView *webView = [self _webView];
     if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:range])
-        [[self _bridge] applyStyle:style withUndoAction:[self _undoActionFromColorPanelWithSelector:selector]];
+        core([self _frame])->editor()->applyStyle(core(style), [self _undoActionFromColorPanelWithSelector:selector]);
 }
 
 - (void)changeDocumentBackgroundColor:(id)sender
@@ -4684,11 +4673,14 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
 - (void)underline:(id)sender
 {
+    Frame* coreFrame = core([self _frame]);
+    if (!coreFrame)
+        return;
     // Despite the name, this method is actually supposed to toggle underline.
     // FIXME: This currently clears overline, line-through, and blink as an unwanted side effect.
     DOMCSSStyleDeclaration *style = [self _emptyStyle];
     [style setProperty:@"-khtml-text-decorations-in-effect" value:@"underline" priority:@""];
-    if ([[self _bridge] selectionStartHasStyle:style])
+    if (coreFrame->editor()->selectionStartHasStyle(core(style)))
         [style setProperty:@"-khtml-text-decorations-in-effect" value:@"none" priority:@""];
     [self _applyStyleToSelection:style withUndoAction:EditActionUnderline];
 }
@@ -6068,7 +6060,7 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
         [[webView _UIDelegateForwarder] webView:webView
             willPerformDragDestinationAction:WebDragDestinationActionEdit
             forDraggingInfo:draggingInfo];
-        [innerBridge applyStyle:style withUndoAction:EditActionSetColor];
+        coreFrame->editor()->applyStyle(core(style), EditActionSetColor);
         return YES;
     }
 
index 9091e57738f78208a2b1c08c2757736b3f090d00..5d85c10fa2de00810809c16fbf361d66b611d5d5 100644 (file)
@@ -3396,7 +3396,10 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 {
     // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
     // change the API to allow this.
-    [[self _bridgeForSelectedOrMainFrame] applyStyle:style withUndoAction:EditActionUnspecified];
+    WebFrame *webFrame = [self _selectedOrMainFrame];
+    Frame* coreFrame = core(webFrame);
+    if (coreFrame)
+        coreFrame->editor()->applyStyle(core(style));
 }
 
 @end