Don't crash if SafariTheme can't be loaded
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2007 07:20:24 +0000 (07:20 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2007 07:20:24 +0000 (07:20 +0000)
         PlatformScrollBarSafari and RenderThemeSafari were not checking
         whether SafariTheme was successfully loaded. All other uses of
         SafariTheme already check this.

         Reviewed by Steve.

         * platform/win/PlatformScrollBarSafari.cpp:
         (WebCore::PlatformScrollbar::paintButton):
         (WebCore::PlatformScrollbar::paintTrack):
         (WebCore::PlatformScrollbar::paintThumb):
         * rendering/RenderThemeSafari.cpp:
         (WebCore::RenderThemeSafari::isControlStyled):
         (WebCore::RenderThemeSafari::paintCheckbox):
         (WebCore::RenderThemeSafari::paintRadio):
         (WebCore::RenderThemeSafari::paintButton):
         (WebCore::RenderThemeSafari::paintTextField):
         (WebCore::RenderThemeSafari::paintCapsLockIndicator):
         (WebCore::RenderThemeSafari::paintTextArea):
         (WebCore::RenderThemeSafari::paintMenuList):
         (WebCore::RenderThemeSafari::paintSliderThumb):
         (WebCore::RenderThemeSafari::paintSearchField):
         (WebCore::RenderThemeSafari::paintSearchFieldCancelButton):
         (WebCore::RenderThemeSafari::paintSearchFieldResultsDecoration):
         (WebCore::RenderThemeSafari::paintSearchFieldResultsButton):

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

WebCore/ChangeLog
WebCore/platform/win/PlatformScrollBarSafari.cpp
WebCore/rendering/RenderThemeSafari.cpp

index 9693bde66cd2e59b6ca6b6599fff171b223a5e63..19400e8e7d49c8e2e2ed8960e9ec6f6ac33b58b9 100644 (file)
@@ -1,3 +1,35 @@
+2007-11-05  Adam Roben  <aroben@apple.com>
+
+        Don't crash if SafariTheme can't be loaded
+
+        PlatformScrollBarSafari and RenderThemeSafari were not checking
+        whether SafariTheme was successfully loaded. All other uses of
+        SafariTheme already check this.
+
+        Reviewed by Steve.
+
+        * platform/win/PlatformScrollBarSafari.cpp: Don't paint if SafariTheme
+        couldn't be loaded.
+        (WebCore::PlatformScrollbar::paintButton):
+        (WebCore::PlatformScrollbar::paintTrack):
+        (WebCore::PlatformScrollbar::paintThumb):
+        * rendering/RenderThemeSafari.cpp:
+        (WebCore::RenderThemeSafari::isControlStyled): Always return true if
+        we couldn't load SafariTheme. This way we should never try to paint
+        themed controls (and we assert as such in the paint functions).
+        (WebCore::RenderThemeSafari::paintCheckbox):
+        (WebCore::RenderThemeSafari::paintRadio):
+        (WebCore::RenderThemeSafari::paintButton):
+        (WebCore::RenderThemeSafari::paintTextField):
+        (WebCore::RenderThemeSafari::paintCapsLockIndicator):
+        (WebCore::RenderThemeSafari::paintTextArea):
+        (WebCore::RenderThemeSafari::paintMenuList):
+        (WebCore::RenderThemeSafari::paintSliderThumb):
+        (WebCore::RenderThemeSafari::paintSearchField):
+        (WebCore::RenderThemeSafari::paintSearchFieldCancelButton):
+        (WebCore::RenderThemeSafari::paintSearchFieldResultsDecoration):
+        (WebCore::RenderThemeSafari::paintSearchFieldResultsButton):
+
 2007-11-05  Kevin Ollivier  <kevino@theolliviers.com>
 
         Adding the rest of wx port's graphics impl. 
index 276a6622e5370517a5217189dbf6d69ef88600c5..c39a7d8bd34e0c42e9f4e5cea3b22272fd585196 100644 (file)
@@ -341,6 +341,9 @@ int PlatformScrollbar::trackLength() const
 
 void PlatformScrollbar::paintButton(GraphicsContext* context, const IntRect& rect, bool start, const IntRect& damageRect) const
 {
+    if (!paintThemePart)
+        return;
+
     IntRect paintRect = buttonRepaintRect(rect, m_orientation, controlSize(), start);
     
     if (!damageRect.intersects(paintRect))
@@ -364,6 +367,9 @@ void PlatformScrollbar::paintButton(GraphicsContext* context, const IntRect& rec
 
 void PlatformScrollbar::paintTrack(GraphicsContext* context, const IntRect& rect, bool start, const IntRect& damageRect) const
 {
+    if (!paintThemePart)
+        return;
+
     IntRect paintRect = trackRepaintRect(rect, m_orientation, controlSize());
     
     if (!damageRect.intersects(paintRect))
@@ -379,6 +385,9 @@ void PlatformScrollbar::paintTrack(GraphicsContext* context, const IntRect& rect
 
 void PlatformScrollbar::paintThumb(GraphicsContext* context, const IntRect& rect, const IntRect& damageRect) const
 {
+    if (!paintThemePart)
+        return;
+
     if (!damageRect.intersects(rect))
         return;
 
index 99500de3b7e59c48c5316f340016596de35a540f..2da842bc3f22dbf80c64848551090efea676d02e 100644 (file)
@@ -197,6 +197,10 @@ void RenderThemeSafari::systemFont(int propId, FontDescription& fontDescription)
 bool RenderThemeSafari::isControlStyled(const RenderStyle* style, const BorderData& border,
                                      const BackgroundLayer& background, const Color& backgroundColor) const
 {
+    // If we didn't find SafariTheme.dll we won't be able to paint any themed controls.
+    if (!paintThemePart)
+        return true;
+
     if (style->appearance() == TextFieldAppearance || style->appearance() == TextAreaAppearance || style->appearance() == ListboxAppearance)
         return style->border() != border;
     return RenderTheme::isControlStyled(style, border, background, backgroundColor);
@@ -349,6 +353,8 @@ NSControlSize RenderThemeSafari::controlSizeForSystemFont(RenderStyle* style) co
 
 bool RenderThemeSafari::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     NSControlSize controlSize = controlSizeForFont(o->style());
 
     IntRect inflatedRect = inflateRect(r, checkboxSizes()[controlSize], checkboxMargins(controlSize));  
@@ -386,6 +392,8 @@ void RenderThemeSafari::setCheckboxSize(RenderStyle* style) const
 
 bool RenderThemeSafari::paintRadio(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     NSControlSize controlSize = controlSizeForFont(o->style());
  
     IntRect inflatedRect = inflateRect(r, radioSizes()[controlSize], radioMargins(controlSize));    
@@ -508,6 +516,8 @@ void RenderThemeSafari::setButtonSize(RenderStyle* style) const
 
 bool RenderThemeSafari::paintButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     // We inflate the rect as needed to account for padding included in the cell to accommodate the button
     // shadow.  We don't consider this part of the bounds of the control in WebKit.
 
@@ -539,6 +549,8 @@ bool RenderThemeSafari::paintButton(RenderObject* o, const RenderObject::PaintIn
 
 bool RenderThemeSafari::paintTextField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     paintThemePart(TextFieldPart, paintInfo.context->platformContext(), r, (NSControlSize)0, determineState(o) & ~FocusedState);
     return false;
 }
@@ -550,6 +562,8 @@ void RenderThemeSafari::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, El
 bool RenderThemeSafari::paintCapsLockIndicator(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {    
 #if defined(SAFARI_THEME_VERSION) && SAFARI_THEME_VERSION >= 1
+    ASSERT(paintThemePart);
+
     if (paintInfo.context->paintingDisabled())
         return true;
 
@@ -563,6 +577,8 @@ bool RenderThemeSafari::paintCapsLockIndicator(RenderObject* o, const RenderObje
 
 bool RenderThemeSafari::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     paintThemePart(TextAreaPart, paintInfo.context->platformContext(), r, (NSControlSize)0, determineState(o) & ~FocusedState);
     return false;
 }
@@ -601,6 +617,8 @@ const int* RenderThemeSafari::popupButtonPadding(NSControlSize size) const
 
 bool RenderThemeSafari::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& info, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     NSControlSize controlSize = controlSizeFromRect(r, popupButtonSizes());
     IntRect inflatedRect = r;
     IntSize size = popupButtonSizes()[controlSize];
@@ -920,6 +938,8 @@ const float verticalSliderHeightPadding = 0.1f;
 
 bool RenderThemeSafari::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     ASSERT(o->parent()->isSlider());
 
     bool pressed = static_cast<RenderSlider*>(o->parent())->inDragMode();
@@ -945,6 +965,8 @@ void RenderThemeSafari::adjustSliderThumbSize(RenderObject* o) const
 
 bool RenderThemeSafari::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
 {
+    ASSERT(paintThemePart);
+
     paintThemePart(SearchFieldPart, paintInfo.context->platformContext(), r, controlSizeFromRect(r, searchFieldSizes()), determineState(o));
     return false;
 }
@@ -996,6 +1018,8 @@ void RenderThemeSafari::adjustSearchFieldStyle(CSSStyleSelector* selector, Rende
 
 bool RenderThemeSafari::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
 {
+    ASSERT(paintThemePart);
+
     Node* input = o->node()->shadowAncestorNode();
     ASSERT(input);
     RenderObject* renderer = input->renderer();
@@ -1048,6 +1072,8 @@ void RenderThemeSafari::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector
 
 bool RenderThemeSafari::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
 {
+    ASSERT(paintThemePart);
+
     Node* input = o->node()->shadowAncestorNode();
     ASSERT(input);
     RenderObject* renderer = input->renderer();
@@ -1069,6 +1095,8 @@ void RenderThemeSafari::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* se
 
 bool RenderThemeSafari::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect&)
 {
+    ASSERT(paintThemePart);
+
     Node* input = o->node()->shadowAncestorNode();
     ASSERT(input);
     RenderObject* renderer = input->renderer();