Changeset 30005 in webkit


Ignore:
Timestamp:
Feb 5, 2008 9:31:30 AM (16 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Darin Adler.

  • WebCore part of <rdar://problem/5724303> Should implement writing direction shortcuts
  • WebCore.base.exp: Added Editor::setBaseWritingDirection() and Frame::baseWritingDirectionForSelectionStart().
  • page/mac/WebCoreFrameBridge.h: Removed -baseWritingDirectionForSelectionStart.
  • page/mac/WebCoreFrameBridge.mm: Ditto.

WebKit/mac:

Reviewed by Darin Adler.

  • WebKit part of <rdar://problem/5724303> Should implement writing direction shortcuts

The key bindings are Command-Control-left arrow and
Command-Control-right arrow. To match AppKit, the bindings are enabled
only when certain user defaults are set.

  • WebView/WebHTMLView.mm: (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]): (-[WebHTMLView toggleBaseWritingDirection:]): Changed to call Frame::baseWritingDirectionForSelectionStart() and Editor::setBaseWritingDirection() directly. (-[WebHTMLView changeBaseWritingDirection:]): Ditto. (writingDirectionKeyBindingsEnabled): Added. (-[WebHTMLView _changeBaseWritingDirectionTo:]): Added this helper method. (-[WebHTMLView changeBaseWritingDirectionToLTR:]): Added. (-[WebHTMLView changeBaseWritingDirectionToRTL:]): Added.
  • WebView/WebView.mm:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30003 r30005  
     12008-02-05  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - WebCore part of <rdar://problem/5724303> Should implement writing direction shortcuts
     6
     7        * WebCore.base.exp: Added Editor::setBaseWritingDirection() and
     8        Frame::baseWritingDirectionForSelectionStart().
     9        * page/mac/WebCoreFrameBridge.h: Removed
     10        -baseWritingDirectionForSelectionStart.
     11        * page/mac/WebCoreFrameBridge.mm: Ditto.
     12
    1132008-02-05  Mark Rowe  <mrowe@apple.com>
    214
  • trunk/WebCore/WebCore.base.exp

    r29905 r30005  
    426426__ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
    427427__ZN7WebCore6Editor21isSelectionMisspelledEv
     428__ZN7WebCore6Editor23setBaseWritingDirectionERKNS_6StringE
    428429__ZN7WebCore6Editor24advanceToNextMisspellingEb
    429430__ZN7WebCore6Editor24isSelectionUngrammaticalEv
     
    539540__ZN7WebCoreeqERKNS_19ResourceRequestBaseES2_
    540541__ZN7WebCoreeqERKNS_4KURLES2_
     542__ZNK7WebCore5Frame37baseWritingDirectionForSelectionStartEv
    541543__ZNK7WebCore11CachedImage5imageEv
    542544__ZNK7WebCore11ContextMenu19platformDescriptionEv
  • trunk/WebCore/page/mac/WebCoreFrameBridge.h

    r29889 r30005  
    162162
    163163- (NSFont *)fontForSelection:(BOOL *)hasMultipleFonts;
    164 - (NSWritingDirection)baseWritingDirectionForSelectionStart;
    165164
    166165- (NSString *)stringWithData:(NSData *)data; // using the encoding of the frame's main resource
  • trunk/WebCore/page/mac/WebCoreFrameBridge.mm

    r29581 r30005  
    11311131}
    11321132
    1133 - (NSWritingDirection)baseWritingDirectionForSelectionStart
    1134 {
    1135     return m_frame ? m_frame->baseWritingDirectionForSelectionStart() : (NSWritingDirection)NSWritingDirectionLeftToRight;
    1136 }
    1137 
    11381133- (void)dragSourceMovedTo:(NSPoint)windowLoc
    11391134{
  • trunk/WebKit/mac/ChangeLog

    r30003 r30005  
     12008-02-05  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - WebKit part of <rdar://problem/5724303> Should implement writing direction shortcuts
     6
     7        The key bindings are Command-Control-left arrow and
     8        Command-Control-right arrow. To match AppKit, the bindings are enabled
     9        only when certain user defaults are set.
     10
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]):
     13        (-[WebHTMLView toggleBaseWritingDirection:]): Changed to call
     14        Frame::baseWritingDirectionForSelectionStart() and
     15        Editor::setBaseWritingDirection() directly.
     16        (-[WebHTMLView changeBaseWritingDirection:]): Ditto.
     17        (writingDirectionKeyBindingsEnabled): Added.
     18        (-[WebHTMLView _changeBaseWritingDirectionTo:]): Added this helper
     19        method.
     20        (-[WebHTMLView changeBaseWritingDirectionToLTR:]): Added.
     21        (-[WebHTMLView changeBaseWritingDirectionToRTL:]): Added.
     22        * WebView/WebView.mm:
     23
    1242008-02-05  Mark Rowe  <mrowe@apple.com>
    225
  • trunk/WebKit/mac/WebView/WebHTMLView.mm

    r29889 r30005  
    22662266            || action == @selector(pasteFont:))
    22672267        return [self _canEdit];
    2268    
     2268
    22692269    if (action == @selector(showGuessPanel:)) {
    22702270#ifndef BUILDING_ON_TIGER
     
    42184218        return;
    42194219   
    4220     NSString *direction = @"RTL";
    4221     switch ([[self _bridge] baseWritingDirectionForSelectionStart]) {
     4220    Frame* coreFrame = core([self _frame]);
     4221    if (!coreFrame)
     4222        return;
     4223
     4224    const char* direction = "rtl";
     4225    switch (coreFrame->baseWritingDirectionForSelectionStart()) {
    42224226        case NSWritingDirectionLeftToRight:
    42234227            break;
    42244228        case NSWritingDirectionRightToLeft:
    4225             direction = @"LTR";
     4229            direction = "ltr";
    42264230            break;
    42274231        // The writingDirectionForSelectionStart method will never return "natural". It
     
    42324236    }
    42334237
    4234     DOMCSSStyleDeclaration *style = [self _emptyStyle];
    4235     [style setDirection:direction];
    4236     [self _applyParagraphStyleToSelection:style withUndoAction:EditActionSetWritingDirection];
     4238    if (Frame* coreFrame = core([self _frame]))
     4239        coreFrame->editor()->setBaseWritingDirection(direction);
    42374240}
    42384241
     
    42504253    ASSERT(writingDirection != NSWritingDirectionNatural);
    42514254
    4252     DOMCSSStyleDeclaration *style = [self _emptyStyle];
    4253     [style setDirection:writingDirection == NSWritingDirectionLeftToRight ? @"LTR" : @"RTL"];
    4254     [self _applyParagraphStyleToSelection:style withUndoAction:EditActionSetWritingDirection];
     4255    if (Frame* coreFrame = core([self _frame]))
     4256        coreFrame->editor()->setBaseWritingDirection(writingDirection == NSWritingDirectionLeftToRight ? "ltr" : "rtl");
     4257}
     4258
     4259static BOOL writingDirectionKeyBindingsEnabled()
     4260{
     4261    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     4262    return [defaults boolForKey:@"NSAllowsBaseWritingDirectionKeyBindings"] || [defaults boolForKey:@"AppleTextDirection"];
     4263}
     4264
     4265- (void)_changeBaseWritingDirectionTo:(NSWritingDirection)direction
     4266{
     4267    if (![self _canEdit])
     4268        return;
     4269
     4270    static BOOL bindingsEnabled = writingDirectionKeyBindingsEnabled();
     4271
     4272    if (!bindingsEnabled) {
     4273        NSBeep();
     4274        return;
     4275    }
     4276
     4277    if (Frame* coreFrame = core([self _frame]))
     4278        coreFrame->editor()->setBaseWritingDirection(direction == NSWritingDirectionLeftToRight ? "ltr" : "rtl");
     4279}
     4280
     4281- (void)changeBaseWritingDirectionToLTR:(id)sender
     4282{
     4283    COMMAND_PROLOGUE
     4284
     4285    [self _changeBaseWritingDirectionTo:NSWritingDirectionLeftToRight];
     4286}
     4287
     4288- (void)changeBaseWritingDirectionToRTL:(id)sender
     4289{
     4290    COMMAND_PROLOGUE
     4291
     4292    [self _changeBaseWritingDirectionTo:NSWritingDirectionRightToLeft];
    42554293}
    42564294
  • trunk/WebKit/mac/WebView/WebView.mm

    r29811 r30005  
    150150macro(changeAttributes) \
    151151macro(changeBaseWritingDirection) \
     152macro(changeBaseWritingDirectionToLTR) \
     153macro(changeBaseWritingDirectionToRTL) \
    152154macro(changeColor) \
    153155macro(changeDocumentBackgroundColor) \
Note: See TracChangeset for help on using the changeset viewer.