1/* 2 * Copyright (C) 2014 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 VisibleContentRectUpdateInfo_h 27#define VisibleContentRectUpdateInfo_h 28 29#include <WebCore/FloatRect.h> 30 31namespace IPC { 32class ArgumentDecoder; 33class ArgumentEncoder; 34} 35 36namespace WebKit { 37 38class VisibleContentRectUpdateInfo { 39public: 40 VisibleContentRectUpdateInfo() 41 : m_scale(-1) 42 , m_inStableState(false) 43 , m_isChangingObscuredInsetsInteractively(false) 44 , m_lastLayerTreeTransactionID(0) 45 { 46 } 47 48 VisibleContentRectUpdateInfo(const WebCore::FloatRect& exposedRect, const WebCore::FloatRect& unobscuredRect, const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates, const WebCore::FloatRect& customFixedPositionRect, double scale, bool inStableState, bool isChangingObscuredInsetsInteractively, double timestamp, double horizontalVelocity, double verticalVelocity, double scaleChangeRate, uint64_t lastLayerTreeTranscationId) 49 : m_exposedRect(exposedRect) 50 , m_unobscuredRect(unobscuredRect) 51 , m_unobscuredRectInScrollViewCoordinates(unobscuredRectInScrollViewCoordinates) 52 , m_customFixedPositionRect(customFixedPositionRect) 53 , m_scale(scale) 54 , m_inStableState(inStableState) 55 , m_isChangingObscuredInsetsInteractively(isChangingObscuredInsetsInteractively) 56 , m_timestamp(timestamp) 57 , m_horizontalVelocity(horizontalVelocity) 58 , m_verticalVelocity(verticalVelocity) 59 , m_scaleChangeRate(scaleChangeRate) 60 , m_lastLayerTreeTransactionID(lastLayerTreeTranscationId) 61 { 62 } 63 64 const WebCore::FloatRect& exposedRect() const { return m_exposedRect; } 65 const WebCore::FloatRect& unobscuredRect() const { return m_unobscuredRect; } 66 const WebCore::FloatRect& unobscuredRectInScrollViewCoordinates() const { return m_unobscuredRectInScrollViewCoordinates; } 67 const WebCore::FloatRect& customFixedPositionRect() const { return m_customFixedPositionRect; } 68 double scale() const { return m_scale; } 69 bool inStableState() const { return m_inStableState; } 70 bool isChangingObscuredInsetsInteractively() const { return m_isChangingObscuredInsetsInteractively; } 71 72 double timestamp() const { return m_timestamp; } 73 double horizontalVelocity() const { return m_horizontalVelocity; } 74 double verticalVelocity() const { return m_verticalVelocity; } 75 double scaleChangeRate() const { return m_scaleChangeRate; } 76 77 uint64_t lastLayerTreeTransactionID() const { return m_lastLayerTreeTransactionID; } 78 79 void encode(IPC::ArgumentEncoder&) const; 80 static bool decode(IPC::ArgumentDecoder&, VisibleContentRectUpdateInfo&); 81 82private: 83 WebCore::FloatRect m_exposedRect; 84 WebCore::FloatRect m_unobscuredRect; 85 WebCore::FloatRect m_unobscuredRectInScrollViewCoordinates; 86 WebCore::FloatRect m_customFixedPositionRect; 87 double m_scale; 88 bool m_inStableState; 89 bool m_isChangingObscuredInsetsInteractively; 90 double m_timestamp; 91 double m_horizontalVelocity; 92 double m_verticalVelocity; 93 double m_scaleChangeRate; 94 uint64_t m_lastLayerTreeTransactionID; 95}; 96 97inline bool operator==(const VisibleContentRectUpdateInfo& a, const VisibleContentRectUpdateInfo& b) 98{ 99 // Note: the comparison doesn't include timestamp and velocity since we care about equality based on the other data. 100 return a.scale() == b.scale() 101 && a.exposedRect() == b.exposedRect() 102 && a.unobscuredRect() == b.unobscuredRect() 103 && a.customFixedPositionRect() == b.customFixedPositionRect() 104 && a.inStableState() == b.inStableState(); 105} 106 107} // namespace WebKit 108 109#endif // VisibleContentRectUpdateInfo_h 110