109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)/*
209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *
409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * modification, are permitted provided that the following conditions
609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * are met:
709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
1009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
1109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
1209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) *
1309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
1409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
1709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
2109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) */
2509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
2609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "config.h"
2709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/frame/Settings.h"
2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
295d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "platform/RuntimeEnabledFeatures.h"
3009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "platform/scroll/ScrollbarTheme.h"
3109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
3309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
3409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// NOTEs
3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)//  1) EditingMacBehavior comprises builds on Mac;
3609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)//  2) EditingWindowsBehavior comprises builds on Windows;
3709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)//  3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS/Android (and then abusing the terminology);
3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)//  4) EditingAndroidBehavior comprises Android builds.
3909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// 99) MacEditingBehavior is used a fallback.
4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static EditingBehaviorType editingBehaviorTypeForPlatform()
4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    return
4309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if OS(MACOSX)
4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    EditingMacBehavior
4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#elif OS(WIN)
4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    EditingWindowsBehavior
4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#elif OS(ANDROID)
4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    EditingAndroidBehavior
4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#else // Rest of the UNIX-like systems
5009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    EditingUnixBehavior
5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif
5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    ;
5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
5409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static const bool defaultUnifiedTextCheckerEnabled = false;
5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if OS(MACOSX)
5709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static const bool defaultSmartInsertDeleteEnabled = true;
5809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#else
5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static const bool defaultSmartInsertDeleteEnabled = false;
6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif
6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if OS(WIN)
6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static const bool defaultSelectTrailingWhitespaceEnabled = true;
6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#else
6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)static const bool defaultSelectTrailingWhitespaceEnabled = false;
6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif
6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)Settings::Settings()
6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    : m_openGLMultisamplingEnabled(false)
6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
7009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    , m_textAutosizingWindowSizeOverride(320, 480)
7109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    , m_textAutosizingEnabled(true)
7209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#else
7309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    , m_textAutosizingEnabled(false)
7409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif
7509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    SETTINGS_INITIALIZER_LIST
7609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
7709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
7809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
7909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)PassOwnPtr<Settings> Settings::create()
8009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
8109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    return adoptPtr(new Settings);
8209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
8309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
8409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)SETTINGS_SETTER_BODIES
8509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
8609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::setDelegate(SettingsDelegate* delegate)
8709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
8809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    m_delegate = delegate;
8909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
9009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
9109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::invalidate(SettingsDelegate::ChangeType changeType)
9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    if (m_delegate)
9409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        m_delegate->settingsChanged(changeType);
9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
9609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
9709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::setTextAutosizingEnabled(bool textAutosizingEnabled)
9809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
9909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    if (m_textAutosizingEnabled == textAutosizingEnabled)
10009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        return;
10109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
10209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    m_textAutosizingEnabled = textAutosizingEnabled;
10309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    invalidate(SettingsDelegate::TextAutosizingChange);
10409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
10509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
10609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// FIXME: Move to Settings.in once make_settings can understand IntSize.
10709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::setTextAutosizingWindowSizeOverride(const IntSize& textAutosizingWindowSizeOverride)
10809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
10909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    if (m_textAutosizingWindowSizeOverride == textAutosizingWindowSizeOverride)
11009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        return;
11109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
11209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    m_textAutosizingWindowSizeOverride = textAutosizingWindowSizeOverride;
11309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    invalidate(SettingsDelegate::TextAutosizingChange);
11409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
11509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
11609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::setMockScrollbarsEnabled(bool flag)
11709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
11809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    ScrollbarTheme::setMockScrollbarsEnabled(flag);
11909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
12009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
12109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)bool Settings::mockScrollbarsEnabled()
12209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
12309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    return ScrollbarTheme::mockScrollbarsEnabled();
12409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
12509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
12609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)void Settings::setOpenGLMultisamplingEnabled(bool flag)
12709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
12809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    if (m_openGLMultisamplingEnabled == flag)
12909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        return;
13009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
13109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    m_openGLMultisamplingEnabled = flag;
13209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    invalidate(SettingsDelegate::MultisamplingChange);
13309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
13409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
135c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
136