Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show a scrolling indicator light when compositing borders are turned on
https://bugs.webkit.org/show_bug.cgi?id=82758
<rdar://problem/11143892>

Reviewed by Andreas Kling.

Source/WebCore:

With this change, turning on compositing borders also turn on a tiny indicator in the top left corner.
This indicator uses color coding to show where wheel events are handled and where the scroll layer position is updated:

  - Green means that both wheel events and scroll layer position updates are handled on the scrolling thread.
  - Yellow means that wheel events need to be dispatched to the main thread (due to wheel event handlers), but that scroll layer position
    updates still happen on the scrolling thread.
  - Red means that scroll layer position updates happen on the main thread (due to background-attachment: fixed or fixed position objects).

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::commitNewTreeState):
Call updateDebugRootLayer().

* page/scrolling/ScrollingTreeNode.h:
(WebCore::ScrollingTreeNode::shouldUpdateScrollLayerPositionOnMainThread):
Make this public.

(ScrollingTreeNode):
* page/scrolling/mac/ScrollingTreeMac.mm: Added.
(WebCore::ScrollingTree::setDebugRootLayer):
Set up a new debug info sublayer.

(WebCore::ScrollingTree::updateDebugRootLayer):
Update the debug root layer background color based on the scrolling tree state.

Source/WebKit2:

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::updatePreferences):
Add a hook for letting drawing area subclasses know when preferences change.

* WebProcess/WebPage/WebPage.cpp:
Call DrawingArea::updatePreferences.

(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
Call updatePreferences.

(WebKit::TiledCoreAnimationDrawingArea::updatePreferences):
If compositing borders are enabled, create a debug root layer and tell the scrolling tree about it.

(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
If we have a debug root layer, make sure it's in front.

Canonical link: https://commits.webkit.org/100087@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Mar 30, 2012
1 parent fac78d5 commit 44558a3
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 2 deletions.
34 changes: 34 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,37 @@
2012-03-30 Anders Carlsson <andersca@apple.com>

Show a scrolling indicator light when compositing borders are turned on
https://bugs.webkit.org/show_bug.cgi?id=82758
<rdar://problem/11143892>

Reviewed by Andreas Kling.

With this change, turning on compositing borders also turn on a tiny indicator in the top left corner.
This indicator uses color coding to show where wheel events are handled and where the scroll layer position is updated:

- Green means that both wheel events and scroll layer position updates are handled on the scrolling thread.
- Yellow means that wheel events need to be dispatched to the main thread (due to wheel event handlers), but that scroll layer position
updates still happen on the scrolling thread.
- Red means that scroll layer position updates happen on the main thread (due to background-attachment: fixed or fixed position objects).

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::commitNewTreeState):
Call updateDebugRootLayer().

* page/scrolling/ScrollingTreeNode.h:
(WebCore::ScrollingTreeNode::shouldUpdateScrollLayerPositionOnMainThread):
Make this public.

(ScrollingTreeNode):
* page/scrolling/mac/ScrollingTreeMac.mm: Added.
(WebCore::ScrollingTree::setDebugRootLayer):
Set up a new debug info sublayer.

(WebCore::ScrollingTree::updateDebugRootLayer):
Update the debug root layer background color based on the scrolling tree state.

2012-03-30 Peter Rybin <peter.rybin@gmail.com>

Web Inspector: CodeGeneratorInspector.py: add missing runtime assert method for InspectorObject
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/WebCore.exp.in
Expand Up @@ -2147,6 +2147,7 @@ __ZN7WebCore19provideNotificationEPNS_4PageEPNS_18NotificationClientE
#endif

#if ENABLE(THREADED_SCROLLING)
__ZN7WebCore13ScrollingTree17setDebugRootLayerEP7CALayer
__ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
__ZN7WebCore13ScrollingTree22updateBackForwardStateEbb
__ZN7WebCore13ScrollingTreeD1Ev
Expand Down
7 changes: 7 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -387,6 +387,7 @@
1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */; };
1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */; };
1A35862C152522540022A659 /* ScrollingTreeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A35862A152522540022A659 /* ScrollingTreeMac.mm */; };
1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */; };
Expand Down Expand Up @@ -7214,6 +7215,7 @@
1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteAuthorizer.cpp; path = sql/SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomVoidCallback.h; sourceTree = "<group>"; };
1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomVoidCallback.cpp; sourceTree = "<group>"; };
1A35862A152522540022A659 /* ScrollingTreeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeMac.mm; sourceTree = "<group>"; };
1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElement.cpp; sourceTree = "<group>"; };
1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElement.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -14112,6 +14114,7 @@
1AF62F2314DAFE910041556C /* ScrollingThreadMac.mm */,
1AAADDE714DC8DF800AF64B3 /* ScrollingTreeNodeMac.h */,
1AAADDE614DC8DF800AF64B3 /* ScrollingTreeNodeMac.mm */,
1A35862A152522540022A659 /* ScrollingTreeMac.mm */,
1AAADDD814DC74EC00AF64B3 /* ScrollingTreeStateMac.mm */,
);
path = mac;
Expand Down Expand Up @@ -27647,6 +27650,10 @@
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
BCE93F531517E0B0008CCF74 /* RenderMultiColumnFlowThread.cpp in Sources */,
BC85F23F1519187300BC17BE /* RenderNamedFlowThread.cpp in Sources */,
71E623D0151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp in Sources */,
1A35862C152522540022A659 /* ScrollingTreeMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/page/scrolling/ScrollingTree.cpp
Expand Up @@ -138,6 +138,8 @@ void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingTreeState> scrollingT
}

m_rootNode->update(scrollingTreeState.get());

updateDebugRootLayer();
}

void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight)
Expand Down
15 changes: 15 additions & 0 deletions Source/WebCore/page/scrolling/ScrollingTree.h
Expand Up @@ -37,6 +37,11 @@
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>

#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
#endif

namespace WebCore {

class IntPoint;
Expand Down Expand Up @@ -90,9 +95,15 @@ class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {

bool willWheelEventStartSwipeGesture(const PlatformWheelEvent&);

#if PLATFORM(MAC)
void setDebugRootLayer(CALayer *);
#endif

private:
explicit ScrollingTree(ScrollingCoordinator*);

void updateDebugRootLayer();

RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
OwnPtr<ScrollingTreeNode> m_rootNode;

Expand All @@ -106,6 +117,10 @@ class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
bool m_canGoForward;
bool m_mainFramePinnedToTheLeft;
bool m_mainFramePinnedToTheRight;

#if PLATFORM(MAC)
RetainPtr<CALayer> m_debugInfoLayer;
#endif
};

} // namespace WebCore
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/scrolling/ScrollingTreeNode.h
Expand Up @@ -47,6 +47,8 @@ class ScrollingTreeNode {
virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
virtual void setScrollPosition(const IntPoint&) = 0;

bool shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }

protected:
explicit ScrollingTreeNode(ScrollingTree*);

Expand All @@ -55,8 +57,6 @@ class ScrollingTreeNode {
const IntRect& viewportRect() const { return m_viewportRect; }
const IntSize& contentsSize() const { return m_contentsSize; }

bool shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }

ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
ScrollElasticity verticalScrollElasticity() const { return m_verticalScrollElasticity; }

Expand Down
80 changes: 80 additions & 0 deletions Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "ScrollingTree.h"

#import "AutodrainedPool.h"
#import "ScrollingTreeNodeMac.h"
#import <QuartzCore/CATextLayer.h>

namespace WebCore {

void ScrollingTree::setDebugRootLayer(CALayer *rootLayer)
{
AutodrainedPool pool;

[m_debugInfoLayer.get() removeFromSuperlayer];

if (!rootLayer)
return;

m_debugInfoLayer = [CALayer layer];
[rootLayer addSublayer:m_debugInfoLayer.get()];

[m_debugInfoLayer.get() setBorderWidth:1];
[m_debugInfoLayer.get() setBorderColor:CGColorGetConstantColor(kCGColorBlack)];

[m_debugInfoLayer.get() setFrame:CGRectMake(0, 0, 25, 25)];
updateDebugRootLayer();
}

void ScrollingTree::updateDebugRootLayer()
{
if (!m_debugInfoLayer)
return;

AutodrainedPool pool;

RetainPtr<CGColorRef> backgroundColor;

if (m_rootNode->shouldUpdateScrollLayerPositionOnMainThread())
backgroundColor = adoptCF(CGColorCreateGenericRGB(1, 0, 0, .7));

{
MutexLocker lock(m_mutex);
if (m_hasWheelEventHandlers) {
if (!backgroundColor)
backgroundColor = adoptCF(CGColorCreateGenericRGB(1, 1, 0, .7));
}
}

if (!backgroundColor)
backgroundColor = adoptCF(CGColorCreateGenericRGB(0, 1, 0, .7));

[m_debugInfoLayer.get() setBackgroundColor:backgroundColor.get()];
}

} // namespace WebCore
26 changes: 26 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,29 @@
2012-03-30 Anders Carlsson <andersca@apple.com>

Show a scrolling indicator light when compositing borders are turned on
https://bugs.webkit.org/show_bug.cgi?id=82758
<rdar://problem/11143892>

Reviewed by Andreas Kling.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::updatePreferences):
Add a hook for letting drawing area subclasses know when preferences change.

* WebProcess/WebPage/WebPage.cpp:
Call DrawingArea::updatePreferences.

(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
Call updatePreferences.

(WebKit::TiledCoreAnimationDrawingArea::updatePreferences):
If compositing borders are enabled, create a debug root layer and tell the scrolling tree about it.

(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
If we have a debug root layer, make sure it's in front.

2012-03-30 Allan Sandfeld Jensen <allan.jensen@nokia.com>

[Qt] Find zoomable area using area-based hit-testing
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Expand Up @@ -78,6 +78,7 @@ class DrawingArea {
virtual void pageCustomRepresentationChanged() { }

virtual void setPaintingEnabled(bool) { }
virtual void updatePreferences() { }

#if USE(ACCELERATED_COMPOSITING)
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -1971,6 +1971,9 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
#endif

platformPreferencesDidChange(store);

if (m_drawingArea)
m_drawingArea->updatePreferences();
}

#if ENABLE(INSPECTOR)
Expand Down
Expand Up @@ -62,6 +62,7 @@ class TiledCoreAnimationDrawingArea : public DrawingArea, WebCore::GraphicsLayer
virtual void didInstallPageOverlay() OVERRIDE;
virtual void didUninstallPageOverlay() OVERRIDE;
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) OVERRIDE;
virtual void updatePreferences() OVERRIDE;

// WebCore::GraphicsLayerClient
virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE;
Expand Down Expand Up @@ -93,6 +94,8 @@ class TiledCoreAnimationDrawingArea : public DrawingArea, WebCore::GraphicsLayer
RetainPtr<CALayer> m_rootLayer;
RetainPtr<CALayer> m_pendingRootCompositingLayer;

RetainPtr<CALayer> m_debugInfoLayer;

OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
WebCore::FloatPoint m_mainFrameScrollLayerPosition;
};
Expand Down
Expand Up @@ -42,6 +42,7 @@
#import <WebCore/RenderView.h>
#import <WebCore/ScrollingCoordinator.h>
#import <WebCore/ScrollingThread.h>
#import <WebCore/ScrollingTree.h>
#import <WebCore/Settings.h>
#import <wtf/MainThread.h>

Expand Down Expand Up @@ -87,6 +88,8 @@ + (void)synchronize;
LayerTreeContext layerTreeContext;
layerTreeContext.contextID = m_layerHostingContext->contextID();
m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext));

updatePreferences();
}

TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
Expand Down Expand Up @@ -215,6 +218,24 @@ static void dispatchBackToMainThread(uint64_t webPageID, uint64_t callbackID)
scheduleCompositingLayerSync();
}

void TiledCoreAnimationDrawingArea::updatePreferences()
{
bool showDebugBorders = m_webPage->corePage()->settings()->showDebugBorders();

if (showDebugBorders == !!m_debugInfoLayer)
return;

if (showDebugBorders) {
m_debugInfoLayer = [CALayer layer];
[m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
} else {
[m_debugInfoLayer.get() removeFromSuperlayer];
m_debugInfoLayer = nullptr;
}

ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
}

void TiledCoreAnimationDrawingArea::notifyAnimationStarted(const GraphicsLayer*, double)
{
}
Expand Down Expand Up @@ -345,6 +366,9 @@ static void dispatchBackToMainThread(uint64_t webPageID, uint64_t callbackID)
if (m_pageOverlayLayer)
[m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];

if (m_debugInfoLayer)
[m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];

[CATransaction commit];
}

Expand Down

0 comments on commit 44558a3

Please sign in to comment.