[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tkent at chromium.org tkent at chromium.org
Wed Dec 22 11:15:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 46d9f57393083d4c2b74f1f93aaa3fb2b4906515
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 16 04:55:03 2010 +0000

    2010-07-15  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Eric Seidel.
    
            [Chromium] Update ThemeChromiumMac.mm for the recent changes of ThemeMac.mm
            https://bugs.webkit.org/show_bug.cgi?id=41932
    
            Sync with ThemeMac.mm r61760.
            This change doesn't contain r54299, r57603, r57734, r57741, and
            r58533 because they conflict with Chromium change for
            FlippedView().
    
            * platform/chromium/ThemeChromiumMac.mm:
            (WebCore::sizeFromNSControlSize):
            (WebCore::sizeFromFont):
            (WebCore::controlSizeFromPixelSize):
            (WebCore::setControlSize):
            (WebCore::convertControlStatesToThemeDrawState):
            (WebCore::stepperSizes):
            (WebCore::stepperControlSizeForFont):
            (WebCore::paintStepper):
            (WebCore::ThemeChromiumMac::controlSize):
            (WebCore::ThemeChromiumMac::minimumControlSize):
            (WebCore::ThemeChromiumMac::inflateControlPaintRect):
            (WebCore::ThemeChromiumMac::paint):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63514 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2016774..73ee1fd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-07-15  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        [Chromium] Update ThemeChromiumMac.mm for the recent changes of ThemeMac.mm
+        https://bugs.webkit.org/show_bug.cgi?id=41932
+
+        Sync with ThemeMac.mm r61760.
+        This change doesn't contain r54299, r57603, r57734, r57741, and
+        r58533 because they conflict with Chromium change for
+        FlippedView().
+
+        * platform/chromium/ThemeChromiumMac.mm:
+        (WebCore::sizeFromNSControlSize):
+        (WebCore::sizeFromFont):
+        (WebCore::controlSizeFromPixelSize):
+        (WebCore::setControlSize):
+        (WebCore::convertControlStatesToThemeDrawState):
+        (WebCore::stepperSizes):
+        (WebCore::stepperControlSizeForFont):
+        (WebCore::paintStepper):
+        (WebCore::ThemeChromiumMac::controlSize):
+        (WebCore::ThemeChromiumMac::minimumControlSize):
+        (WebCore::ThemeChromiumMac::inflateControlPaintRect):
+        (WebCore::ThemeChromiumMac::paint):
+
 2010-07-15  MORITA Hajime  <morrita at google.com>
 
         Reviewed by David Levin.
diff --git a/WebCore/platform/chromium/ThemeChromiumMac.mm b/WebCore/platform/chromium/ThemeChromiumMac.mm
index 5769e38..7d06ec0 100644
--- a/WebCore/platform/chromium/ThemeChromiumMac.mm
+++ b/WebCore/platform/chromium/ThemeChromiumMac.mm
@@ -32,6 +32,7 @@
 #import "LocalCurrentGraphicsContext.h"
 #import "ScrollView.h"
 #import "WebCoreSystemInterface.h"
+#import <Carbon/Carbon.h>
 #include <wtf/StdLibExtras.h>
 #import <objc/runtime.h>
 
@@ -210,9 +211,9 @@ static NSControlSize controlSizeForFont(const Font& font)
     return NSMiniControlSize;
 }
 
-static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes)
+static LengthSize sizeFromNSControlSize(NSControlSize nsControlSize, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes)
 {
-    IntSize controlSize = sizes[controlSizeForFont(font)];
+    IntSize controlSize = sizes[nsControlSize];
     if (zoomFactor != 1.0f)
         controlSize = IntSize(controlSize.width() * zoomFactor, controlSize.height() * zoomFactor);
     LengthSize result = zoomedSize;
@@ -223,19 +224,27 @@ static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, f
     return result;
 }
 
-static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
+static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes)
+{
+    return sizeFromNSControlSize(controlSizeForFont(font), zoomedSize, zoomFactor, sizes);
+}
+
+static ControlSize controlSizeFromPixelSize(const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
 {
-    NSControlSize size;
     if (minZoomedSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomFactor) &&
         minZoomedSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomFactor))
-        size = NSRegularControlSize;
-    else if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) &&
-             minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor))
-        size = NSSmallControlSize;
-    else
-        size = NSMiniControlSize;
+        return NSRegularControlSize;
+    if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) &&
+        minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor))
+        return NSSmallControlSize;
+    return NSMiniControlSize;
+}
+
+static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
+{
+    ControlSize size = controlSizeFromPixelSize(sizes, minZoomedSize, zoomFactor);
     if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same.
-        [cell setControlSize:size];
+        [cell setControlSize:(NSControlSize)size];
 }
 
 static void updateStates(NSCell* cell, ControlStates states)
@@ -277,6 +286,22 @@ static void updateStates(NSCell* cell, ControlStates states)
         [cell setControlTint:tint];
 }
 
+static ThemeDrawState convertControlStatesToThemeDrawState(ThemeButtonKind kind, ControlStates states)
+{
+    if (states & ReadOnlyState)
+        return kThemeStateUnavailableInactive;
+    if (!(states & EnabledState))
+        return kThemeStateUnavailableInactive;
+
+    // Do not process PressedState if !EnabledState or ReadOnlyState.
+    if (states & PressedState) {
+        if (kind == kThemeIncDecButton || kind == kThemeIncDecButtonSmall || kind == kThemeIncDecButtonMini)
+            return states & SpinUpState ? kThemeStatePressedUp : kThemeStatePressedDown;
+        return kThemeStatePressed;
+    }
+    return kThemeStateActive;
+}
+
 static IntRect inflateRect(const IntRect& zoomedRect, const IntSize& zoomedSize, const int* margins, float zoomFactor)
 {
     // Only do the inflation if the available width/height are too small.  Otherwise try to
@@ -571,6 +596,64 @@ static void paintButton(ControlPart part, ControlStates states, GraphicsContext*
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
+// Stepper
+
+static const IntSize* stepperSizes()
+{
+    static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize(13, 15) };
+    return sizes;
+}
+
+// We don't use controlSizeForFont() for steppers because the stepper height
+// should be equal to or less than the corresponding text field height,
+static NSControlSize stepperControlSizeForFont(const Font& font)
+{
+    int fontSize = font.pixelSize();
+    if (fontSize >= 18)
+        return NSRegularControlSize;
+    if (fontSize >= 13)
+        return NSSmallControlSize;
+    return NSMiniControlSize;
+}
+
+static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView*)
+{
+    // We don't use NSStepperCell because there are no ways to draw an
+    // NSStepperCell with the up button highlighted.
+
+    HIThemeButtonDrawInfo drawInfo;
+    drawInfo.version = 0;
+    drawInfo.state = convertControlStatesToThemeDrawState(kThemeIncDecButton, states);
+    drawInfo.adornment = kThemeAdornmentDefault;
+    ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor);
+    if (controlSize == NSSmallControlSize)
+        drawInfo.kind = kThemeIncDecButtonSmall;
+    else if (controlSize == NSMiniControlSize)
+        drawInfo.kind = kThemeIncDecButtonMini;
+    else
+        drawInfo.kind = kThemeIncDecButton;
+
+    IntRect rect(zoomedRect);
+    context->save();
+    if (zoomFactor != 1.0f) {
+        rect.setWidth(rect.width() / zoomFactor);
+        rect.setHeight(rect.height() / zoomFactor);
+        context->translate(rect.x(), rect.y());
+        context->scale(FloatSize(zoomFactor, zoomFactor));
+        context->translate(-rect.x(), -rect.y());
+    }
+    CGRect bounds(rect);
+    // Adjust 'bounds' so that HIThemeDrawButton(bounds,...) draws exactly on 'rect'.
+    CGRect backgroundBounds;
+    HIThemeGetButtonBackgroundBounds(&bounds, &drawInfo, &backgroundBounds);
+    if (bounds.origin.x != backgroundBounds.origin.x)
+        bounds.origin.x += bounds.origin.x - backgroundBounds.origin.x;
+    if (bounds.origin.y != backgroundBounds.origin.y)
+        bounds.origin.y += bounds.origin.y - backgroundBounds.origin.y;
+    HIThemeDrawButton(&bounds, &drawInfo, context->platformContext(), kHIThemeOrientationNormal, 0);
+    context->restore();
+}
+
 // Theme overrides
 
 int ThemeChromiumMac::baselinePositionAdjustment(ControlPart part) const
@@ -613,6 +696,13 @@ LengthSize ThemeChromiumMac::controlSize(ControlPart part, const Font& font, con
         case ListButtonPart:
             return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, listButtonSizes());
 #endif
+        case InnerSpinButtonPart:
+            // We don't use inner spin buttons on Mac.
+            return LengthSize(Length(Fixed), Length(Fixed));
+        case OuterSpinButtonPart:
+            if (!zoomedSize.width().isIntrinsicOrAuto() && !zoomedSize.height().isIntrinsicOrAuto())
+                return zoomedSize;
+            return sizeFromNSControlSize(stepperControlSizeForFont(font), zoomedSize, zoomFactor, stepperSizes());
         default:
             return zoomedSize;
     }
@@ -626,6 +716,14 @@ LengthSize ThemeChromiumMac::minimumControlSize(ControlPart part, const Font& fo
         case ButtonPart:
         case ListButtonPart:
             return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed));
+        case InnerSpinButtonPart:
+            // We don't use inner spin buttons on Mac.
+            return LengthSize(Length(Fixed), Length(Fixed));
+        case OuterSpinButtonPart: {
+            IntSize base = stepperSizes()[NSMiniControlSize];
+            return LengthSize(Length(static_cast<int>(base.width() * zoomFactor), Fixed),
+                              Length(static_cast<int>(base.height() * zoomFactor), Fixed));
+        }
         default:
             return Theme::minimumControlSize(part, font, zoomFactor);
     }
@@ -702,6 +800,15 @@ void ThemeChromiumMac::inflateControlPaintRect(ControlPart part, ControlStates s
             }
             break;
         }
+        case OuterSpinButtonPart: {
+            static const int stepperMargin[4] = { 0, 0, 0, 0};
+            ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor);
+            IntSize zoomedSize = stepperSizes()[controlSize];
+            zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
+            zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
+            zoomedRect = inflateRect(zoomedRect, zoomedSize, stepperMargin, zoomFactor);
+            break;
+        }
         default:
             break;
     }
@@ -724,6 +831,9 @@ void ThemeChromiumMac::paint(ControlPart part, ControlStates states, GraphicsCon
         case ListButtonPart:
             paintButton(part, states, context, zoomedRect, zoomFactor, scrollView);
             break;
+        case OuterSpinButtonPart:
+            paintStepper(states, context, zoomedRect, zoomFactor, scrollView);
+            break;
         default:
             break;
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list