Widget should not depend on AXObjectCache
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Apr 2013 10:07:28 +0000 (10:07 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 21 Apr 2013 10:07:28 +0000 (10:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114514

Reviewed by Chris Fleizach.

Source/WebCore:

Move AXObjectCache usage from platform files to FrameView.

* WebCore.exp.in: Update symbols.
* page/FrameView.cpp:
(WebCore::FrameView::didAddScrollbar): Handle scrollbar updates in
AXObjectCache.
(WebCore::FrameView::willRemoveScrollbar): Handle scrollbar
updates in AXObjectCache and remove the scrollbar from the cache.
* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::setHasHorizontalScrollbar): Use
didAddScrollbar/willRemoveScrollbar
(WebCore::ScrollView::setHasVerticalScrollbar): Ditto.
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::didAddScrollbar): This is the old
didAddVerticalScrollbar and didAddHorizontalScrollbar joined in a
single method that receives a ScrollbarOrientation parameter.
(WebCore::ScrollableArea::willRemoveScrollbar): This is the old
willRemoveVerticalScrollbar and
willRemoveHorizontalScrollbarScrollbar joined in a single method
that receives a ScrollbarOrientation parameter.
* platform/ScrollableArea.h:
(ScrollableArea):
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::~Scrollbar): Remove AXObjectCache usage.
* platform/Scrollbar.h:
* platform/Widget.h:
(Widget): Remove axObjectCache() method.
* platform/mac/ScrollAnimatorMac.h:
(ScrollAnimatorMac):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::createScrollbar): Use didAddScrollbar.
(WebCore::RenderLayer::destroyScrollbar): Use willRemoveScrollbar.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::createScrollbar): Use didAddScrollbar.
(WebCore::RenderListBox::destroyScrollbar): Use willRemoveScrollbar.

Source/WebKit2:

Update to API changes.

* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::createScrollbar):
* WebProcess/Plugins/PDF/SimplePDFPlugin.mm:
(WebKit::SimplePDFPlugin::createScrollbar):
(WebKit::SimplePDFPlugin::destroyScrollbar):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/Scrollbar.cpp
Source/WebCore/platform/Scrollbar.h
Source/WebCore/platform/Widget.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm

index ee03eaf..2944cae 100644 (file)
@@ -1,3 +1,47 @@
+2013-04-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Widget should not depend on AXObjectCache
+        https://bugs.webkit.org/show_bug.cgi?id=114514
+
+        Reviewed by Chris Fleizach.
+
+        Move AXObjectCache usage from platform files to FrameView.
+
+        * WebCore.exp.in: Update symbols.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::didAddScrollbar): Handle scrollbar updates in
+        AXObjectCache.
+        (WebCore::FrameView::willRemoveScrollbar): Handle scrollbar
+        updates in AXObjectCache and remove the scrollbar from the cache.
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setHasHorizontalScrollbar): Use
+        didAddScrollbar/willRemoveScrollbar
+        (WebCore::ScrollView::setHasVerticalScrollbar): Ditto.
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::didAddScrollbar): This is the old
+        didAddVerticalScrollbar and didAddHorizontalScrollbar joined in a
+        single method that receives a ScrollbarOrientation parameter.
+        (WebCore::ScrollableArea::willRemoveScrollbar): This is the old
+        willRemoveVerticalScrollbar and
+        willRemoveHorizontalScrollbarScrollbar joined in a single method
+        that receives a ScrollbarOrientation parameter.
+        * platform/ScrollableArea.h:
+        (ScrollableArea):
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::~Scrollbar): Remove AXObjectCache usage.
+        * platform/Scrollbar.h:
+        * platform/Widget.h:
+        (Widget): Remove axObjectCache() method.
+        * platform/mac/ScrollAnimatorMac.h:
+        (ScrollAnimatorMac):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::createScrollbar): Use didAddScrollbar.
+        (WebCore::RenderLayer::destroyScrollbar): Use willRemoveScrollbar.
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::createScrollbar): Use didAddScrollbar.
+        (WebCore::RenderListBox::destroyScrollbar): Use willRemoveScrollbar.
+
 2013-04-20  Dirk Schulze  <krit@webkit.org>
 
         [Part 5] Parse color value for custom() function parameters
index ce4b8ca..373c630 100644 (file)
@@ -365,19 +365,17 @@ __ZN7WebCore14SchemeRegistry57removeURLSchemeRegisteredAsBypassingContentSecurit
 __ZN7WebCore14SchemeRegistry58registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsingERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry62registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsingERKN3WTF6StringE
 __ZN7WebCore14ScrollableArea15contentsResizedEv
+__ZN7WebCore14ScrollableArea15didAddScrollbarEPNS_9ScrollbarENS_20ScrollbarOrientationE
 __ZN7WebCore14ScrollableArea16handleWheelEventERKNS_18PlatformWheelEventE
 __ZN7WebCore14ScrollableArea17willEndLiveResizeEv
+__ZN7WebCore14ScrollableArea19willRemoveScrollbarEPNS_9ScrollbarENS_20ScrollbarOrientationE
 __ZN7WebCore14ScrollableArea19willStartLiveResizeEv
 __ZN7WebCore14ScrollableArea19invalidateScrollbarEPNS_9ScrollbarERKNS_7IntRectE
 __ZNK7WebCore14ScrollableArea21mouseEnteredScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea22invalidateScrollCornerERKNS_7IntRectE
-__ZN7WebCore14ScrollableArea23didAddVerticalScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea24setScrollbarOverlayStyleENS_21ScrollbarOverlayStyleE
-__ZN7WebCore14ScrollableArea25didAddHorizontalScrollbarEPNS_9ScrollbarE
-__ZN7WebCore14ScrollableArea27willRemoveVerticalScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea27notifyScrollPositionChangedERKNS_8IntPointE
 __ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE
-__ZN7WebCore14ScrollableArea29willRemoveHorizontalScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea30scrollToOffsetWithoutAnimationERKNS_10FloatPointE
 __ZN7WebCore14ScrollableArea6scrollENS_15ScrollDirectionENS_17ScrollGranularityEf
 __ZN7WebCore14ScrollableAreaC2Ev
index 727c906..0f87335 100644 (file)
@@ -4129,4 +4129,20 @@ void FrameView::setScrollingPerformanceLoggingEnabled(bool flag)
 #endif
 }
 
+void FrameView::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
+{
+    ScrollableArea::didAddScrollbar(scrollbar, orientation);
+    if (AXObjectCache* cache = axObjectCache())
+        cache->handleScrollbarUpdate(this);
+}
+
+void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
+{
+    ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
+    if (AXObjectCache* cache = axObjectCache()) {
+        cache->remove(scrollbar);
+        cache->handleScrollbarUpdate(this);
+    }
+}
+
 } // namespace WebCore
index 30730a8..1fc9c5d 100644 (file)
@@ -38,6 +38,7 @@
 
 namespace WebCore {
 
+class AXObjectCache;
 class Element;
 class Event;
 class FloatSize;
@@ -485,6 +486,10 @@ private:
 #endif
 #endif
 
+    // Override scrollbar notifications to update the AXObject cache.
+    virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
+    virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) OVERRIDE;
+
     void scheduleResizeEvent();
     void sendResizeEvent();
     void delayedResizeEventTimerFired(Timer<FrameView>*);
index dbc3ce9..a9bf745 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "ScrollView.h"
 
-#include "AXObjectCache.h"
 #include "GraphicsContext.h"
 #include "GraphicsLayer.h"
 #include "HostWindow.h"
@@ -91,16 +90,13 @@ void ScrollView::setHasHorizontalScrollbar(bool hasBar)
     if (hasBar && !m_horizontalScrollbar) {
         m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
         addChild(m_horizontalScrollbar.get());
-        didAddHorizontalScrollbar(m_horizontalScrollbar.get());
+        didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
         m_horizontalScrollbar->styleChanged();
     } else if (!hasBar && m_horizontalScrollbar) {
-        willRemoveHorizontalScrollbar(m_horizontalScrollbar.get());
+        willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
         removeChild(m_horizontalScrollbar.get());
         m_horizontalScrollbar = 0;
     }
-    
-    if (AXObjectCache* cache = axObjectCache())
-        cache->handleScrollbarUpdate(this);
 }
 
 void ScrollView::setHasVerticalScrollbar(bool hasBar)
@@ -109,16 +105,13 @@ void ScrollView::setHasVerticalScrollbar(bool hasBar)
     if (hasBar && !m_verticalScrollbar) {
         m_verticalScrollbar = createScrollbar(VerticalScrollbar);
         addChild(m_verticalScrollbar.get());
-        didAddVerticalScrollbar(m_verticalScrollbar.get());
+        didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
         m_verticalScrollbar->styleChanged();
     } else if (!hasBar && m_verticalScrollbar) {
-        willRemoveVerticalScrollbar(m_verticalScrollbar.get());
+        willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
         removeChild(m_verticalScrollbar.get());
         m_verticalScrollbar = 0;
     }
-    
-    if (AXObjectCache* cache = axObjectCache())
-        cache->handleScrollbarUpdate(this);
 }
 
 #if !PLATFORM(GTK)
index 08a626b..06e3968 100644 (file)
@@ -261,30 +261,23 @@ void ScrollableArea::finishCurrentScrollAnimations() const
         scrollAnimator->finishCurrentScrollAnimations();
 }
 
-void ScrollableArea::didAddVerticalScrollbar(Scrollbar* scrollbar)
+void ScrollableArea::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
 {
-    scrollAnimator()->didAddVerticalScrollbar(scrollbar);
-
-    // <rdar://problem/9797253> AppKit resets the scrollbar's style when you attach a scrollbar
-    setScrollbarOverlayStyle(scrollbarOverlayStyle());
-}
-
-void ScrollableArea::willRemoveVerticalScrollbar(Scrollbar* scrollbar)
-{
-    scrollAnimator()->willRemoveVerticalScrollbar(scrollbar);
-}
-
-void ScrollableArea::didAddHorizontalScrollbar(Scrollbar* scrollbar)
-{
-    scrollAnimator()->didAddHorizontalScrollbar(scrollbar);
+    if (orientation == VerticalScrollbar)
+        scrollAnimator()->didAddVerticalScrollbar(scrollbar);
+    else
+        scrollAnimator()->didAddHorizontalScrollbar(scrollbar);
 
     // <rdar://problem/9797253> AppKit resets the scrollbar's style when you attach a scrollbar
     setScrollbarOverlayStyle(scrollbarOverlayStyle());
 }
 
-void ScrollableArea::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)
+void ScrollableArea::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
 {
-    scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar);
+    if (orientation == VerticalScrollbar)
+        scrollAnimator()->willRemoveVerticalScrollbar(scrollbar);
+    else
+        scrollAnimator()->willRemoveHorizontalScrollbar(scrollbar);
 }
 
 void ScrollableArea::contentsResized()
index 4334fce..c7ca8c9 100644 (file)
@@ -83,10 +83,8 @@ public:
 
     void finishCurrentScrollAnimations() const;
 
-    void didAddVerticalScrollbar(Scrollbar*);
-    void willRemoveVerticalScrollbar(Scrollbar*);
-    virtual void didAddHorizontalScrollbar(Scrollbar*);
-    virtual void willRemoveHorizontalScrollbar(Scrollbar*);
+    virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation);
+    virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation);
 
     virtual void contentsResized();
 
index db92552..0e1b2fb 100644 (file)
@@ -38,9 +38,6 @@
 #endif
 
 // FIXME: The following #includes are a layering violation and should be removed.
-#include "AXObjectCache.h"
-#include "AccessibilityScrollbar.h"
-#include "Document.h"
 #include "EventHandler.h"
 #include "Frame.h"
 #include "FrameView.h"
@@ -110,9 +107,6 @@ Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient
 
 Scrollbar::~Scrollbar()
 {
-    if (AXObjectCache* cache = existingAXObjectCache())
-        cache->remove(this);
-    
     stopTimerIfNeeded();
     
     m_theme->unregisterScrollbar(this);
@@ -567,14 +561,6 @@ bool Scrollbar::isWindowActive() const
     return m_scrollableArea && m_scrollableArea->isActive();
 }
 
-AXObjectCache* Scrollbar::existingAXObjectCache() const
-{
-    if (!parent())
-        return 0;
-    
-    return parent()->axObjectCache();
-}
-
 void Scrollbar::invalidateRect(const IntRect& rect)
 {
     if (suppressInvalidation())
index d574cc6..00c7618 100644 (file)
@@ -206,7 +206,6 @@ protected:
 
 private:
     virtual bool isScrollbar() const { return true; }
-    virtual AXObjectCache* existingAXObjectCache() const;
 };
 
 } // namespace WebCore
index e7f1e59..1adff85 100644 (file)
@@ -97,7 +97,6 @@ typedef PlatformWidget PlatformPageClient;
 
 namespace WebCore {
 
-class AXObjectCache;
 class Cursor;
 class Event;
 class Font;
@@ -231,9 +230,6 @@ public:
     virtual IntPoint convertToContainingView(const IntPoint&) const;
     virtual IntPoint convertFromContainingView(const IntPoint&) const;
 
-    // A means to access the AX cache when this object can get a pointer to it.
-    virtual AXObjectCache* axObjectCache() const { return 0; }
-    
 private:
     void init(PlatformWidget); // Must be called by all Widget constructors to initialize cross-platform data.
 
index 0ad65bf..c3b0634 100644 (file)
@@ -2876,10 +2876,7 @@ PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientat
         widget = RenderScrollbar::createCustomScrollbar(this, orientation, actualRenderer->node());
     else {
         widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
-        if (orientation == HorizontalScrollbar)
-            didAddHorizontalScrollbar(widget.get());
-        else 
-            didAddVerticalScrollbar(widget.get());
+        didAddScrollbar(widget.get(), orientation);
     }
     renderer()->document()->view()->addChild(widget.get());        
     return widget.release();
@@ -2891,12 +2888,8 @@ void RenderLayer::destroyScrollbar(ScrollbarOrientation orientation)
     if (!scrollbar)
         return;
 
-    if (!scrollbar->isCustomScrollbar()) {
-        if (orientation == HorizontalScrollbar)
-            willRemoveHorizontalScrollbar(scrollbar.get());
-        else
-            willRemoveVerticalScrollbar(scrollbar.get());
-    }
+    if (!scrollbar->isCustomScrollbar())
+        willRemoveScrollbar(scrollbar.get(), orientation);
 
     scrollbar->removeFromParent();
     scrollbar->disconnectFromScrollableArea();
index 721d7f4..4214f67 100644 (file)
@@ -850,7 +850,7 @@ PassRefPtr<Scrollbar> RenderListBox::createScrollbar()
         widget = RenderScrollbar::createCustomScrollbar(this, VerticalScrollbar, this->node());
     else {
         widget = Scrollbar::createNativeScrollbar(this, VerticalScrollbar, theme()->scrollbarControlSizeForPart(ListboxPart));
-        didAddVerticalScrollbar(widget.get());
+        didAddScrollbar(widget.get(), VerticalScrollbar);
     }
     document()->view()->addChild(widget.get());        
     return widget.release();
@@ -862,7 +862,7 @@ void RenderListBox::destroyScrollbar()
         return;
 
     if (!m_vBar->isCustomScrollbar())
-        ScrollableArea::willRemoveVerticalScrollbar(m_vBar.get());
+        ScrollableArea::willRemoveScrollbar(m_vBar.get(), VerticalScrollbar);
     m_vBar->removeFromParent();
     m_vBar->disconnectFromScrollableArea();
     m_vBar = 0;
index 529aa39..ffe66b6 100644 (file)
@@ -1,3 +1,18 @@
+2013-04-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Widget should not depend on AXObjectCache
+        https://bugs.webkit.org/show_bug.cgi?id=114514
+
+        Reviewed by Chris Fleizach.
+
+        Update to API changes.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::createScrollbar):
+        * WebProcess/Plugins/PDF/SimplePDFPlugin.mm:
+        (WebKit::SimplePDFPlugin::createScrollbar):
+        (WebKit::SimplePDFPlugin::destroyScrollbar):
+
 2013-04-20  Manuel Rego Casasnovas  <rego@igalia.com>
 
         [GTK] Fix unit test webkit2/WebKitFindController/hide
index ccc4cd1..9fe4b01 100644 (file)
@@ -275,14 +275,11 @@ PassRefPtr<Scrollbar> PDFPlugin::createScrollbar(ScrollbarOrientation orientatio
     if (orientation == HorizontalScrollbar) {
         m_horizontalScrollbarLayer.adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
         [m_containerLayer.get() addSublayer:m_horizontalScrollbarLayer.get()];
-        
-        didAddHorizontalScrollbar(widget.get());
     } else {
         m_verticalScrollbarLayer.adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
         [m_containerLayer.get() addSublayer:m_verticalScrollbarLayer.get()];
-        
-        didAddVerticalScrollbar(widget.get());
     }
+    didAddScrollbar(widget.get(), orientation);
     pluginView()->frame()->view()->addChild(widget.get());
     return widget.release();
 }
index 2bd2e8b..901c406 100644 (file)
@@ -260,10 +260,7 @@ void SimplePDFPlugin::updateScrollbars()
 PassRefPtr<Scrollbar> SimplePDFPlugin::createScrollbar(ScrollbarOrientation orientation)
 {
     RefPtr<Scrollbar> widget = Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
-    if (orientation == HorizontalScrollbar)
-        didAddHorizontalScrollbar(widget.get());
-    else 
-        didAddVerticalScrollbar(widget.get());
+    didAddScrollbar(widget.get(), orientation);
     pluginView()->frame()->view()->addChild(widget.get());
     return widget.release();
 }
@@ -274,11 +271,7 @@ void SimplePDFPlugin::destroyScrollbar(ScrollbarOrientation orientation)
     if (!scrollbar)
         return;
 
-    if (orientation == HorizontalScrollbar)
-        willRemoveHorizontalScrollbar(scrollbar.get());
-    else
-        willRemoveVerticalScrollbar(scrollbar.get());
-
+    willRemoveScrollbar(scrollbar.get(), orientation);
     scrollbar->removeFromParent();
     scrollbar->disconnectFromScrollableArea();
     scrollbar = 0;