Skip to content
  • tonikitoo@webkit.org's avatar
    Refactor platform dependent editing behavior code out of Settings · 3ba5cd53
    tonikitoo@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=39854
    
    [ Re-landing of r60816 with the m_editor initialized before m_selectionController in Frame constructor. ]
    
    Reviewed by Ojan Vafai and Darin Adler.
    Patch by Antonio Gomes <tonikitoo@webkit.org>
    
    WebCore:
    
    As per discussion in bug 36627, the following was suggested by Darin Adler: "before the addition of any
    new EditingBehavior, I think we need to add functions to translate the overall behavior policy into specific
    behaviors rather than directly saying 'behavior == Mac' or 'behavior == Windows'. Helper functions that
    expression the different rules in plain language.".
    
    Patch is a first step of an incremental approach to address this request. It does not yet replace all
    direct use of Editing{Mac,Windows}Behaviors, but adds infra for that and replaces some of them.
    
    No behavior change, so no new tests.
    
    * GNUmakefile.am:
    * WebCore.pro:
    * WebCore/WebCore.gypi
    * WebCore/WebCore.vcproj/WebCore.vcproj
    * WebCore/WebCore.xcodeproj/project.pbxproj
    * page/Settings.cpp:
    (WebCore::Settings::Settings):
    * page/Settings.h: Moved out EditingBehavior enum to WebCore/editing/EditingBehaviorTypes.h,
    and renamed to EditingBehaviorTypes.
    (WebCore::Settings::setEditingBehaviorType): Renamed from setEditingBehavior.
    (WebCore::Settings::editingBehaviorType): Renamed from editingBehavior.
    * editing/EditingBehavior.h: Added.
    (WebCore::EditingBehavior::EditingBehavior): Class to work as a central point for
    editing behavior that might have to be handled differently in the different platforms/ports.
    Class should be not used or instantiated directly, but rather implicitly constructed
    through the Editor class.
    (WebCore::EditingBehavior::shouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom):
    (WebCore::EditingBehavior::shouldConsiderSelectionAsDirectional):
    (WebCore::EditingBehavior::shouldCenterAlignWhenSelectionIsRevealed):
    * editing/EditingBehaviorTypes.h: Added.
    (WebCore::):
    * editing/Editor.cpp:
    (WebCore::Editor::behavior): Getter for EditingBehavior class.
    * editing/Editor.h:
    * editing/EditorCommand.cpp:
    (WebCore::executeToggleStyle):
    (WebCore::SelectionController::setIsDirectional):
    (WebCore::SelectionController::positionForPlatform):
    (WebCore::SelectionController::modify):
    * page/EventHandler.cpp:
    (WebCore::EventHandler::handleMousePressEventSingleClick):
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::positionForPointWithInlineChildren):
    
    - Call sites will look like:
    if (frame->editor()->behavior().shouldThisIfThat()))
       // do something
    
    WebKit:
    
    EditingBehavior enum was renamed to EditingBehaviorTypes and moved out from Settings.h to
    EditingBehaviorTypes.h . Call sites in WebKit/ adjusted accordingly.
    
    WebKit/chromium:
    * src/WebSettingsImpl.cpp:
    (WebKit::WebSettingsImpl::setEditingBehavior):
    
    WebKit/gtk:
    * webkit/webkitprivate.cpp:
    (WebKit::core):
    * webkit/webkitprivate.h:
    * webkit/webkitwebview.cpp:
    (webkit_web_view_update_settings):
    (webkit_web_view_settings_notify):
    
    WebKit/mac:
    * WebView/WebFrame.mm:
    (core):
    * WebView/WebFrameInternal.h:
    * WebView/WebView.mm:
    (-[WebView _preferencesChangedNotification:]):
    
    WebKit/qt:
    * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
    (DumpRenderTreeSupportQt::setEditingBehavior):
    
    WebKit/win:
    * WebView.cpp:
    (WebView::notifyPreferencesChanged):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60841 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    3ba5cd53