Diff
Modified: trunk/Source/WebCore/ChangeLog (183870 => 183871)
--- trunk/Source/WebCore/ChangeLog 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/ChangeLog 2015-05-06 16:42:33 UTC (rev 183871)
@@ -1,3 +1,23 @@
+2015-05-06 Ryosuke Niwa <rn...@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 <jber...@webkit.org>
More build fixing.
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (183870 => 183871)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2015-05-06 16:42:33 UTC (rev 183871)
@@ -348,6 +348,14 @@
init(position.deprecatedNode(), propertiesToInclude);
}
+EditingStyle::EditingStyle(const CSSStyleDeclaration* style)
+ : EditingStyle()
+{
+ if (style)
+ m_mutableStyle = style->copyProperties();
+ extractFontSizeDelta();
+}
+
EditingStyle::EditingStyle(const StyleProperties* style)
: EditingStyle()
{
Modified: trunk/Source/WebCore/editing/EditingStyle.h (183870 => 183871)
--- trunk/Source/WebCore/editing/EditingStyle.h 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/editing/EditingStyle.h 2015-05-06 16:42:33 UTC (rev 183871)
@@ -94,6 +94,11 @@
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));
@@ -167,6 +172,7 @@
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);
Modified: trunk/Source/WebCore/editing/Editor.cpp (183870 => 183871)
--- trunk/Source/WebCore/editing/Editor.cpp 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/editing/Editor.cpp 2015-05-06 16:42:33 UTC (rev 183871)
@@ -941,9 +941,9 @@
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.
Modified: trunk/Source/WebCore/editing/Editor.h (183870 => 183871)
--- trunk/Source/WebCore/editing/Editor.h 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/editing/Editor.h 2015-05-06 16:42:33 UTC (rev 183871)
@@ -186,7 +186,7 @@
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>);
Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (183870 => 183871)
--- trunk/Source/WebCore/editing/EditorCommand.cpp 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp 2015-05-06 16:42:33 UTC (rev 183871)
@@ -98,7 +98,7 @@
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) {
@@ -1034,7 +1034,7 @@
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));
@@ -1101,7 +1101,7 @@
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));
Modified: trunk/Source/WebKit/mac/ChangeLog (183870 => 183871)
--- trunk/Source/WebKit/mac/ChangeLog 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebKit/mac/ChangeLog 2015-05-06 16:42:33 UTC (rev 183871)
@@ -1,3 +1,18 @@
+2015-05-06 Ryosuke Niwa <rn...@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 <rn...@webkit.org>
Toggling underline or strike through affects each other
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (183870 => 183871)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2015-05-06 16:36:25 UTC (rev 183870)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2015-05-06 16:42:33 UTC (rev 183871)
@@ -4795,6 +4795,12 @@
}
}
+- (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
{
@@ -4985,7 +4991,7 @@
[self _applyStyleToSelection:[self _styleFromFontManagerOperation] withUndoAction:EditActionSetFont];
}
-- (DOMCSSStyleDeclaration *)_styleForAttributeChange:(id)sender
+- (Ref<EditingStyle>)_styleForAttributeChange:(id)sender
{
DOMCSSStyleDeclaration *style = [self _emptyStyle];
@@ -5032,20 +5038,9 @@
else if ([b objectForKey:NSShadowAttributeName] == nil)
[style setTextShadow:@"none"];
- int sa = [[a objectForKey:NSStrikethroughStyleAttributeName] intValue];
- int sb = [[b objectForKey:NSStrikethroughStyleAttributeName] intValue];
+ int sa = [[a objectForKey:NSSuperscriptAttributeName] intValue];
+ int sb = [[b objectForKey:NSSuperscriptAttributeName] 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];
- if (sa == sb) {
if (sa > 0)
[style setVerticalAlign:@"super"];
else if (sa < 0)
@@ -5053,26 +5048,31 @@
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