DrawingAreaImpl.h revision ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb
1/* 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef DrawingAreaImpl_h 27#define DrawingAreaImpl_h 28 29#include "DrawingArea.h" 30#include "Region.h" 31#include "RunLoop.h" 32 33namespace WebKit { 34 35struct UpdateInfo; 36 37class DrawingAreaImpl : public DrawingArea { 38public: 39 static PassRefPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&); 40 virtual ~DrawingAreaImpl(); 41 42private: 43 DrawingAreaImpl(WebPage*, const WebPageCreationParameters&); 44 45 // DrawingArea 46 virtual void setNeedsDisplay(const WebCore::IntRect&); 47 virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); 48 virtual void attachCompositingContext(); 49 virtual void detachCompositingContext(); 50 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); 51 virtual void scheduleCompositingLayerSync(); 52 virtual void syncCompositingLayers(); 53 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 54 55 // CoreIPC message handlers. 56 virtual void setSize(const WebCore::IntSize&); 57 virtual void didUpdate(); 58 virtual void suspendPainting(); 59 virtual void resumePainting(); 60 61 void scheduleDisplay(); 62 void display(); 63 void display(UpdateInfo&); 64 65 Region m_dirtyRegion; 66 WebCore::IntRect m_scrollRect; 67 WebCore::IntSize m_scrollOffset; 68 69 // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the 70 // web process won't paint more frequent than the UI process can handle. 71 bool m_isWaitingForDidUpdate; 72 73 // Whether painting is suspended. We'll still keep track of the dirty region but we 74 // won't paint until painting has resumed again. 75 bool m_isPaintingSuspended; 76 77 RunLoop::Timer<DrawingAreaImpl> m_displayTimer; 78}; 79 80} // namespace WebKit 81 82#endif // DrawingAreaImpl_h 83