2008-05-05 Steve Falkenburg <sfalken@apple.com>
authorsfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2008 20:51:32 +0000 (20:51 +0000)
committersfalken@apple.com <sfalken@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 May 2008 20:51:32 +0000 (20:51 +0000)
        Add WebPreference for application chrome mode.

        Reviewed by Dave Hyatt.

        * Interfaces/IWebPreferencesPrivate.idl:
        * WebPreferenceKeysPrivate.h:
        * WebPreferences.cpp:
        (WebPreferences::initializeDefaultSettings):
        (WebPreferences::inApplicationChromeMode):
        (WebPreferences::setApplicationChromeMode):
        * WebPreferences.h:
        * WebView.cpp:
        (WebView::notifyPreferencesChanged):

2008-05-05  Steve Falkenburg  <sfalken@apple.com>

        Add support for default button appearance.
        Add WebCore setting for app chrome mode.

        Reviewed by Dave Hyatt.

        * css/CSSPrimitiveValueMappings.h:
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        * css/CSSValueKeywords.in: Added default-button value keyword.
        * page/Settings.cpp:
        (WebCore::Settings::Settings):
        (WebCore::Settings::setApplicationChromeMode):
        * page/Settings.h:
        (WebCore::Settings::inApplicationChromeMode):
        * rendering/RenderButton.cpp:
        (WebCore::RenderButton::RenderButton):
        (WebCore::RenderButton::setStyle):
        (WebCore::RenderButton::timerFired):
        * rendering/RenderButton.h:
        * rendering/RenderStyle.h:
        (WebCore::):
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::adjustStyle):
        (WebCore::RenderTheme::paint):
        (WebCore::RenderTheme::paintBorderOnly):
        (WebCore::RenderTheme::paintDecorations):
        (WebCore::RenderTheme::isControlStyled):
        (WebCore::RenderTheme::isDefault):
        * rendering/RenderTheme.h:
        (WebCore::):
        * rendering/RenderThemeSafari.cpp:
        (WebCore::RenderThemeSafari::determineState):
        (WebCore::RenderThemeSafari::adjustRepaintRect):
        (WebCore::RenderThemeSafari::adjustButtonStyle):
        * rendering/RenderThemeWin.cpp:
        (WebCore::RenderThemeWin::supportsFocus):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32881 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
WebCore/ChangeLog
WebCore/css/CSSPrimitiveValueMappings.h
WebCore/css/CSSValueKeywords.in
WebCore/page/Settings.cpp
WebCore/page/Settings.h
WebCore/rendering/RenderButton.cpp
WebCore/rendering/RenderButton.h
WebCore/rendering/RenderStyle.h
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebCore/rendering/RenderThemeSafari.cpp
WebCore/rendering/RenderThemeWin.cpp
WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebPreferencesPrivate.idl
WebKit/win/WebPreferenceKeysPrivate.h
WebKit/win/WebPreferences.cpp
WebKit/win/WebPreferences.h
WebKit/win/WebView.cpp

index b9e7557..d8c39da 100644 (file)
@@ -1,3 +1,41 @@
+2008-05-05  Steve Falkenburg  <sfalken@apple.com>
+
+        Add support for default button appearance.
+        Add WebCore setting for app chrome mode.
+        
+        Reviewed by Dave Hyatt.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSValueKeywords.in: Added default-button value keyword.
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore::Settings::setApplicationChromeMode):
+        * page/Settings.h:
+        (WebCore::Settings::inApplicationChromeMode):
+        * rendering/RenderButton.cpp:
+        (WebCore::RenderButton::RenderButton):
+        (WebCore::RenderButton::setStyle):
+        (WebCore::RenderButton::timerFired):
+        * rendering/RenderButton.h:
+        * rendering/RenderStyle.h:
+        (WebCore::):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::adjustStyle):
+        (WebCore::RenderTheme::paint):
+        (WebCore::RenderTheme::paintBorderOnly):
+        (WebCore::RenderTheme::paintDecorations):
+        (WebCore::RenderTheme::isControlStyled):
+        (WebCore::RenderTheme::isDefault):
+        * rendering/RenderTheme.h:
+        (WebCore::):
+        * rendering/RenderThemeSafari.cpp:
+        (WebCore::RenderThemeSafari::determineState):
+        (WebCore::RenderThemeSafari::adjustRepaintRect):
+        (WebCore::RenderThemeSafari::adjustButtonStyle):
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::supportsFocus):
+
 2008-05-05  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index bf745d1..1312c2a 100644 (file)
@@ -186,6 +186,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EAppearance e)
         case ButtonBevelAppearance:
             m_value.ident = CSSValueButtonBevel;
             break;
+        case DefaultButtonAppearance:
+            m_value.ident = CSSValueDefaultButton;
+            break;
         case ListboxAppearance:
             m_value.ident = CSSValueListbox;
             break;
index 0722479..2c86510 100644 (file)
@@ -492,6 +492,7 @@ push-button
 square-button
 button
 button-bevel
+default-button
 listbox
 listitem
 media-fullscreen-button
index b88ccd7..583f881 100644 (file)
@@ -74,6 +74,7 @@ Settings::Settings(Page* page)
     , m_needsSiteSpecificQuirks(false)
     , m_fontRenderingMode(0)
     , m_webArchiveDebugModeEnabled(false)
+    , m_inApplicationChromeMode(false)
     , m_offlineWebApplicationCacheEnabled(false)
 {
     // A Frame may not have been created yet, so we initialize the AtomicString 
@@ -339,6 +340,11 @@ void Settings::setLocalStorageDatabasePath(const String& path)
     m_localStorageDatabasePath = path;
 }
 
+void Settings::setApplicationChromeMode(bool mode)
+{
+    m_inApplicationChromeMode = mode;
+}
+
 void Settings::setOfflineWebApplicationCacheEnabled(bool enabled)
 {
     m_offlineWebApplicationCacheEnabled = enabled;
index 259353f..09903a3 100644 (file)
@@ -157,6 +157,9 @@ namespace WebCore {
         void setLocalStorageDatabasePath(const String&);
         const String& localStorageDatabasePath() const { return m_localStorageDatabasePath; }
 
+        void setApplicationChromeMode(bool);
+        bool inApplicationChromeMode() const { return m_inApplicationChromeMode; }
+
         void setOfflineWebApplicationCacheEnabled(bool);
         bool offlineWebApplicationCacheEnabled() const { return m_offlineWebApplicationCacheEnabled; }
     private:
@@ -200,6 +203,7 @@ namespace WebCore {
         bool m_needsSiteSpecificQuirks : 1;
         unsigned m_fontRenderingMode : 1;
         bool m_webArchiveDebugModeEnabled : 1;
+        bool m_inApplicationChromeMode : 1;
         bool m_offlineWebApplicationCacheEnabled : 1;
     };
 
index 6a15fdb..c40537d 100644 (file)
@@ -28,6 +28,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "RenderTextFragment.h"
+#include "RenderTheme.h"
 
 namespace WebCore {
 
@@ -37,6 +38,9 @@ RenderButton::RenderButton(Node* node)
     : RenderFlexibleBox(node)
     , m_buttonText(0)
     , m_inner(0)
+#if PLATFORM(WIN)
+    , m_default(false)
+#endif
 {
 }
 
@@ -70,6 +74,18 @@ void RenderButton::setStyle(RenderStyle* style)
     if (m_inner) // RenderBlock handled updating the anonymous block's style.
         m_inner->style()->setBoxFlex(1.0f);
     setReplaced(isInline());
+
+#if PLATFORM(WIN)
+    if (!m_default && theme()->isDefault(this)) {
+        if (!m_timer)
+            m_timer.set(new Timer<RenderButton>(this, &RenderButton::timerFired));
+        m_timer->startRepeating(0.01);
+        m_default = true;
+    } else if (m_default && !theme()->isDefault(this)) {
+        m_default = false;
+        m_timer.clear();
+    }
+#endif
 }
 
 void RenderButton::updateFromElement()
@@ -122,5 +138,13 @@ IntRect RenderButton::controlClipRect(int tx, int ty) const
     return IntRect(tx + borderLeft(), ty + borderTop(), m_width - borderLeft() - borderRight(), m_height - borderTop() - borderBottom());
 }
 
+#if PLATFORM(WIN)
+
+void RenderButton::timerFired(Timer<RenderButton>*)
+{
+    repaint();
+}
+
+#endif
 
 } // namespace WebCore
index 04bee3f..4f87704 100644 (file)
@@ -24,6 +24,8 @@
 #define RenderButton_h
 
 #include "RenderFlexibleBox.h"
+#include "Timer.h"
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
@@ -58,8 +60,17 @@ public:
 protected:
     virtual bool hasLineIfEmpty() const { return true; }
 
+#if PLATFORM(WIN)
+    void timerFired(Timer<RenderButton>*);
+#endif
+
     RenderTextFragment* m_buttonText;
     RenderBlock* m_inner;
+
+#if PLATFORM(WIN)
+    OwnPtr<Timer<RenderButton> > m_timer;
+    bool m_default;
+#endif
 };
 
 } // namespace WebCore
index 19e1a93..782c079 100644 (file)
@@ -1118,7 +1118,7 @@ enum EResize {
 
 enum EAppearance {
     NoAppearance, CheckboxAppearance, RadioAppearance, PushButtonAppearance, SquareButtonAppearance, ButtonAppearance,
-    ButtonBevelAppearance, ListboxAppearance, ListItemAppearance, 
+    ButtonBevelAppearance, DefaultButtonAppearance, ListboxAppearance, ListItemAppearance, 
     MediaFullscreenButtonAppearance, MediaMuteButtonAppearance, MediaPlayButtonAppearance,
     MediaSeekBackButtonAppearance, MediaSeekForwardButtonAppearance, MediaSliderAppearance, MediaSliderThumbAppearance,
     MenulistAppearance, MenulistButtonAppearance, MenulistTextAppearance, MenulistTextFieldAppearance,
index 536a0c1..1479d51 100644 (file)
@@ -32,6 +32,7 @@
 #include "Page.h"
 #include "RenderStyle.h"
 #include "SelectionController.h"
+#include "Settings.h"
 
 // The methods in this file are shared by all themes on every platform.
 
@@ -66,6 +67,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El
             return adjustRadioStyle(selector, style, e);
         case PushButtonAppearance:
         case SquareButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
             return adjustButtonStyle(selector, style, e);
         case TextFieldAppearance:
@@ -119,6 +121,7 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf
             return paintRadio(o, paintInfo, r);
         case PushButtonAppearance:
         case SquareButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
             return paintButton(o, paintInfo, r);
         case MenulistAppearance:
@@ -188,6 +191,7 @@ bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo
         case RadioAppearance:
         case PushButtonAppearance:
         case SquareButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
         case MenulistAppearance:
         case SliderHorizontalAppearance:
@@ -222,6 +226,7 @@ bool RenderTheme::paintDecorations(RenderObject* o, const RenderObject::PaintInf
         case RadioAppearance:
         case PushButtonAppearance:
         case SquareButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
         case MenulistAppearance:
         case SliderHorizontalAppearance:
@@ -316,6 +321,7 @@ bool RenderTheme::isControlStyled(const RenderStyle* style, const BorderData& bo
     switch (style->appearance()) {
         case PushButtonAppearance:
         case SquareButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
         case ListboxAppearance:
         case MenulistAppearance:
@@ -423,6 +429,21 @@ bool RenderTheme::isHovered(const RenderObject* o) const
     return o->element()->hovered();
 }
 
+bool RenderTheme::isDefault(const RenderObject* o) const
+{
+    if (!o->document())
+        return false;
+
+    Settings* settings = o->document()->settings();
+    if (!settings || !settings->inApplicationChromeMode())
+        return false;
+    
+    if (!o->style())
+        return false;
+    
+    return o->style()->appearance() == DefaultButtonAppearance;
+}
+
 void RenderTheme::adjustCheckboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
 {
     // A summary of the rules for checkbox designed to match WinIE:
index 5ae04b0..c7328ff 100644 (file)
@@ -37,7 +37,8 @@ enum ControlState {
     FocusState,
     EnabledState,
     CheckedState,
-    ReadOnlyState
+    ReadOnlyState,
+    DefaultState
 };
 
 class RenderTheme {
@@ -138,7 +139,8 @@ public:
     bool isPressed(const RenderObject*) const;
     bool isHovered(const RenderObject*) const;
     bool isReadOnlyControl(const RenderObject*) const;
-    
+    bool isDefault(const RenderObject*) const;
+
     virtual int popupInternalPaddingLeft(RenderStyle*) const { return 0; }
     virtual int popupInternalPaddingRight(RenderStyle*) const { return 0; }
     virtual int popupInternalPaddingTop(RenderStyle*) const { return 0; }
index 37a6e3a..178e049 100644 (file)
@@ -94,6 +94,8 @@ ThemeControlState RenderThemeSafari::determineState(RenderObject* o) const
         result |= SafariTheme::IndeterminateCheckedState;
     if (isFocused(o))
         result |= SafariTheme::FocusedState;
+    if (isDefault(o))
+        result |= SafariTheme::DefaultState;
     return result;
 }
 
@@ -228,6 +230,7 @@ void RenderThemeSafari::adjustRepaintRect(const RenderObject* o, IntRect& r)
             break;
         }
         case PushButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance: {
             // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
             // shadow" and the check.  We don't consider this part of the bounds of the control in WebKit.
index 97d11f3..ab45343 100644 (file)
@@ -130,6 +130,7 @@ bool RenderThemeWin::supportsFocus(EAppearance appearance)
 {
     switch (appearance) {
         case PushButtonAppearance:
+        case DefaultButtonAppearance:
         case ButtonAppearance:
         case TextFieldAppearance:
         case TextAreaAppearance:
index ac1eb38..7cf09f4 100644 (file)
@@ -1,3 +1,19 @@
+2008-05-05  Steve Falkenburg  <sfalken@apple.com>
+
+        Add WebPreference for application chrome mode.
+        
+        Reviewed by Dave Hyatt.
+
+        * Interfaces/IWebPreferencesPrivate.idl:
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        (WebPreferences::inApplicationChromeMode):
+        (WebPreferences::setApplicationChromeMode):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged):
+
 2008-05-02  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Geoffrey Garen.
index 70defb2..7cc4c85 100644 (file)
@@ -48,4 +48,7 @@ interface IWebPreferencesPrivate : IUnknown
 
     HRESULT setAuthorAndUserStylesEnabled([in] BOOL enabled);
     HRESULT authorAndUserStylesEnabled([out, retval] BOOL* enabled);
+
+    HRESULT inApplicationChromeMode([out, retval] BOOL *allowed);
+    HRESULT setApplicationChromeMode([in] BOOL allowed);
 }
index 12a3b74..1b0c485 100644 (file)
@@ -97,6 +97,8 @@
 
 #define WebKitDOMPasteAllowedPreferenceKey "WebKitDOMPasteAllowedPreferenceKey" // default: false
 
+#define WebKitApplicationChromeModePreferenceKey "WebKitApplicationChromeMode" // default: false
+
 // If this key is present and has a value of true, we have already removed the default values from the user's preferences <rdar://problem/5214504>
 #define WebKitDidMigrateDefaultSettingsFromSafari3BetaPreferenceKey "WebKitDidMigrateDefaultSettingsFromSafari3BetaPreferenceKey"
 
index 689efc0..be923c6 100644 (file)
@@ -229,6 +229,7 @@ void WebPreferences::initializeDefaultSettings()
     CFDictionaryAddValue(defaults, CFSTR(WebKitCacheModelPreferenceKey), cacheModelRef.get());
 
     CFDictionaryAddValue(defaults, CFSTR(WebKitAuthorAndUserStylesEnabledPreferenceKey), kCFBooleanTrue);
+    CFDictionaryAddValue(defaults, CFSTR(WebKitApplicationChromeModePreferenceKey), kCFBooleanFalse);
 
     defaultSettings = defaults;
 }
@@ -1117,6 +1118,18 @@ HRESULT STDMETHODCALLTYPE WebPreferences::authorAndUserStylesEnabled(BOOL* enabl
     return S_OK;
 }
 
+HRESULT WebPreferences::inApplicationChromeMode(BOOL* enabled)
+{
+    *enabled = boolValueForKey(CFSTR(WebKitApplicationChromeModePreferenceKey));
+    return S_OK;
+}
+    
+HRESULT WebPreferences::setApplicationChromeMode(BOOL enabled)
+{
+    setBoolValue(CFSTR(WebKitApplicationChromeModePreferenceKey), enabled);
+    return S_OK;
+}
+
 void WebPreferences::willAddToWebView()
 {
     ++m_numWebViews;
index 91bc558..314c1dc 100644 (file)
@@ -290,6 +290,12 @@ public:
     virtual HRESULT STDMETHODCALLTYPE setAuthorAndUserStylesEnabled(BOOL);
     virtual HRESULT STDMETHODCALLTYPE authorAndUserStylesEnabled(BOOL*);
 
+    virtual HRESULT STDMETHODCALLTYPE inApplicationChromeMode( 
+        /* [retval][out] */ BOOL *enabled);
+    
+    virtual HRESULT STDMETHODCALLTYPE setApplicationChromeMode( 
+        /* [in] */ BOOL enabled);
+
     // WebPreferences
 
     // This method accesses a different preference key than developerExtrasEnabled.
index c254d4e..cbeddc6 100644 (file)
@@ -4045,6 +4045,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         settings->setAuthorAndUserStylesEnabled(enabled);
     }
 
+    hr = prefsPrivate->inApplicationChromeMode(&enabled);
+    if (FAILED(hr))
+        return hr;
+    settings->setApplicationChromeMode(enabled);
+
     m_mainFrame->invalidate(); // FIXME
 
     hr = updateSharedSettingsFromPreferencesIfNeeded(preferences.get());