https://bugs.webkit.org/show_bug.cgi?id=144670
<rdar://problem/
3790443>
Reviewed by Darin Adler.
Source/WebCore:
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::EditingStyle): Added a variant that takes CSSStyleDeclaration.
* editing/EditingStyle.h:
(WebCore::EditingStyle::create): Ditto.
* editing/Editor.cpp:
(WebCore::Editor::applyStyleToSelection): Takes Ref<EditingStyle>&& instead of RefPtr<EditingStyle>&&.
* editing/Editor.h:
* editing/EditorCommand.cpp:
(WebCore::applyCommandToFrame): Ditto.
(WebCore::executeStrikethrough):
(WebCore::executeUnderline):
Source/WebKit/mac:
Use setStrikeThroughChange and setUnderlineChange added in r183770 to toggle underline and strike through.
* WebView/WebHTMLView.mm:
(-[WebHTMLView _applyEditingStyleToSelection:withUndoAction:]):
(-[WebHTMLView _styleForAttributeChange:]):
(-[WebHTMLView changeAttributes:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183871
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-05-06 Ryosuke Niwa <rniwa@webkit.org>
+
+ Toggling underline on font panel removes strike through
+ https://bugs.webkit.org/show_bug.cgi?id=144670
+ <rdar://problem/3790443>
+
+ Reviewed by Darin Adler.
+
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::EditingStyle): Added a variant that takes CSSStyleDeclaration.
+ * editing/EditingStyle.h:
+ (WebCore::EditingStyle::create): Ditto.
+ * editing/Editor.cpp:
+ (WebCore::Editor::applyStyleToSelection): Takes Ref<EditingStyle>&& instead of RefPtr<EditingStyle>&&.
+ * editing/Editor.h:
+ * editing/EditorCommand.cpp:
+ (WebCore::applyCommandToFrame): Ditto.
+ (WebCore::executeStrikethrough):
+ (WebCore::executeUnderline):
+
2015-05-06 Jessie Berlin <jberlin@webkit.org>
More build fixing.
init(position.deprecatedNode(), propertiesToInclude);
}
+EditingStyle::EditingStyle(const CSSStyleDeclaration* style)
+ : EditingStyle()
+{
+ if (style)
+ m_mutableStyle = style->copyProperties();
+ extractFontSizeDelta();
+}
+
EditingStyle::EditingStyle(const StyleProperties* style)
: EditingStyle()
{
return adoptRef(*new EditingStyle(style));
}
+ static Ref<EditingStyle> create(const CSSStyleDeclaration* style)
+ {
+ return adoptRef(*new EditingStyle(style));
+ }
+
static Ref<EditingStyle> create(CSSPropertyID propertyID, const String& value)
{
return adoptRef(*new EditingStyle(propertyID, value));
EditingStyle();
EditingStyle(Node*, PropertiesToInclude);
EditingStyle(const Position&, PropertiesToInclude);
+ WEBCORE_EXPORT explicit EditingStyle(const CSSStyleDeclaration*);
explicit EditingStyle(const StyleProperties*);
EditingStyle(CSSPropertyID, const String& value);
EditingStyle(CSSPropertyID, CSSValueID);
applyStyle(style, editingAction);
}
-void Editor::applyStyleToSelection(RefPtr<EditingStyle>&& style, EditAction editingAction)
+void Editor::applyStyleToSelection(Ref<EditingStyle>&& style, EditAction editingAction)
{
- if (!style || style->isEmpty() || !canEditRichly())
+ if (style->isEmpty() || !canEditRichly())
return;
// FIXME: This is wrong for text decorations since m_mutableStyle is empty.
void applyStyle(RefPtr<EditingStyle>&&, EditAction);
void applyParagraphStyle(StyleProperties*, EditAction = EditActionUnspecified);
WEBCORE_EXPORT void applyStyleToSelection(StyleProperties*, EditAction);
- void applyStyleToSelection(RefPtr<EditingStyle>&&, EditAction);
+ WEBCORE_EXPORT void applyStyleToSelection(Ref<EditingStyle>&&, EditAction);
void applyParagraphStyleToSelection(StyleProperties*, EditAction);
void appliedEditing(PassRefPtr<CompositeEditCommand>);
return node->document().frame();
}
-static bool applyCommandToFrame(Frame& frame, EditorCommandSource source, EditAction action, RefPtr<EditingStyle>&& style)
+static bool applyCommandToFrame(Frame& frame, EditorCommandSource source, EditAction action, Ref<EditingStyle>&& style)
{
// FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
switch (source) {
static bool executeStrikethrough(Frame& frame, Event*, EditorCommandSource source, const String&)
{
- RefPtr<EditingStyle> style = EditingStyle::create();
+ Ref<EditingStyle> style = EditingStyle::create();
style->setStrikeThroughChange(textDecorationChangeForToggling(frame.editor(), CSSPropertyWebkitTextDecorationsInEffect, "line-through"));
// FIXME: Needs a new EditAction!
return applyCommandToFrame(frame, source, EditActionUnderline, WTF::move(style));
static bool executeUnderline(Frame& frame, Event*, EditorCommandSource source, const String&)
{
- RefPtr<EditingStyle> style = EditingStyle::create();
+ Ref<EditingStyle> style = EditingStyle::create();
TextDecorationChange change = textDecorationChangeForToggling(frame.editor(), CSSPropertyWebkitTextDecorationsInEffect, "underline");
style->setUnderlineChange(change);
return applyCommandToFrame(frame, source, EditActionUnderline, WTF::move(style));
+2015-05-06 Ryosuke Niwa <rniwa@webkit.org>
+
+ Toggling underline on font panel removes strike through
+ https://bugs.webkit.org/show_bug.cgi?id=144670
+ <rdar://problem/3790443>
+
+ Reviewed by Darin Adler.
+
+ Use setStrikeThroughChange and setUnderlineChange added in r183770 to toggle underline and strike through.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _applyEditingStyleToSelection:withUndoAction:]):
+ (-[WebHTMLView _styleForAttributeChange:]):
+ (-[WebHTMLView changeAttributes:]):
+
2015-05-04 Ryosuke Niwa <rniwa@webkit.org>
Toggling underline or strike through affects each other
}
}
+- (void)_applyEditingStyleToSelection:(Ref<EditingStyle>&&)editingStyle withUndoAction:(EditAction)undoAction
+{
+ if (Frame* coreFrame = core([self _frame]))
+ coreFrame->editor().applyStyleToSelection(WTF::move(editingStyle), undoAction);
+}
+
#if !PLATFORM(IOS)
- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
{
[self _applyStyleToSelection:[self _styleFromFontManagerOperation] withUndoAction:EditActionSetFont];
}
-- (DOMCSSStyleDeclaration *)_styleForAttributeChange:(id)sender
+- (Ref<EditingStyle>)_styleForAttributeChange:(id)sender
{
DOMCSSStyleDeclaration *style = [self _emptyStyle];
else if ([b objectForKey:NSShadowAttributeName] == nil)
[style setTextShadow:@"none"];
- int sa = [[a objectForKey:NSStrikethroughStyleAttributeName] intValue];
- int sb = [[b objectForKey:NSStrikethroughStyleAttributeName] intValue];
- if (sa == sb) {
- if (sa == NSUnderlineStyleNone)
- [style setProperty:@"-webkit-text-decorations-in-effect" value:@"none" priority:@""];
- // we really mean "no line-through" rather than "none"
- else
- [style setProperty:@"-webkit-text-decorations-in-effect" value:@"line-through" priority:@""];
- // we really mean "add line-through" rather than "line-through"
- }
-
- sa = [[a objectForKey:NSSuperscriptAttributeName] intValue];
- sb = [[b objectForKey:NSSuperscriptAttributeName] intValue];
+ int sa = [[a objectForKey:NSSuperscriptAttributeName] intValue];
+ int sb = [[b objectForKey:NSSuperscriptAttributeName] intValue];
if (sa == sb) {
if (sa > 0)
[style setVerticalAlign:@"super"];
else
[style setVerticalAlign:@"baseline"];
}
+
+ auto editingStyle = EditingStyle::create(core(style));
+
+ int strikeThroughA = [[a objectForKey:NSStrikethroughStyleAttributeName] intValue];
+ int strikeThroughB = [[b objectForKey:NSStrikethroughStyleAttributeName] intValue];
+ if (strikeThroughA == strikeThroughB) {
+ bool shouldRemoveStrikeThrough = strikeThroughA == NSUnderlineStyleNone;
+ editingStyle->setStrikeThroughChange(shouldRemoveStrikeThrough ? TextDecorationChange::Remove : TextDecorationChange::Add);
+ }
int ua = [[a objectForKey:NSUnderlineStyleAttributeName] intValue];
int ub = [[b objectForKey:NSUnderlineStyleAttributeName] intValue];
if (ua == ub) {
- if (ua == NSUnderlineStyleNone)
- [style setProperty:@"-webkit-text-decorations-in-effect" value:@"none" priority:@""];
- // we really mean "no underline" rather than "none"
- else
- [style setProperty:@"-webkit-text-decorations-in-effect" value:@"underline" priority:@""];
- // we really mean "add underline" rather than "underline"
+ bool shouldRemoveUnderline = ua == NSUnderlineStyleNone;
+ editingStyle->setUnderlineChange(shouldRemoveUnderline ? TextDecorationChange::Remove : TextDecorationChange::Add);
}
- return style;
+ return editingStyle;
}
- (void)changeAttributes:(id)sender
{
COMMAND_PROLOGUE
- [self _applyStyleToSelection:[self _styleForAttributeChange:sender] withUndoAction:EditActionChangeAttributes];
+ [self _applyEditingStyleToSelection:[self _styleForAttributeChange:sender] withUndoAction:EditActionChangeAttributes];
}
- (DOMCSSStyleDeclaration *)_styleFromColorPanelWithSelector:(SEL)selector