Files
palemoon27/widget/WidgetUtils.cpp
T
roytam1 b4ae1472a9 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1168005 - NS_QUERY_TEXT_RECT on e10s should set mString. r=masayuki (b31a73fd1)
- Bug 1166436 part.1 Create mozilla::ContentCache and TabParent should store the text to it r=m_kato (d38cd5b53)
- Bug 1166323 - Remove IME sequence number. r=masayuki,nchen (6df799fcd)
- Bug 1166436 part.2 mozilla::ContentCache should store a selection range and TabParent should use it r=m_kato (94bb8cae3)
- Bug 1166436 part.3 mozilla::ContentCache should store active composition information and TabParent should use them r=m_kato (f1d9bd4fd)
- Bug 1166436 part.4 mozilla::ContentCache should store text rects and caret rect and TabParent should use them r=m_kato (da3d2a6a8)
- Bug 1166436 part.5 mContentCache should store writing mode at selection and TabParent should use it r=m_kato (ffb7801a4)
- Bug 1166436 part.6 mContentCache should store editor rect and TabParent should use it r=m_kato (cfbd6a896)
- Bug 1166436 part.7 mozilla::ContentCache should handle WidgetQueryContentEvent r=m_kato (e0b1a5534)
- Bug 1166436 part.8 Make mozilla::ContentCache available in IPC r=m_kato (60b2a7d8f)
- Bug 1166436 part.9 PuppetWidget should have mozilla::ContentCache and send it to TabParent r=m_kato (a0f6d5c61)
- Bug 1165515 - Part 4: Add PR_LOG_INFO. r=froydnj (dc5db5c34)
- Bug 1165515 - Part 6: Add PR_LOG_VERBOSE. r=froydnj (5705657b8)
- Bug 1165515 - Part 13-1: Add log level enum class. r=froydnj (943b666ca)
- Bug 1166436 part.10 Optimize IME notification handling in PuppetWidget r=m_kato (7a29fe4be)
- Bug 1166436 part.11 Remove unnecessary public methods of mozilla::ContentCache r=m_kato (3e78f5e4b)
- Bug 1166436 part.12 Log the behavior of mozilla::ContentCache r=m_kato (8a7dbd2c5)
- Bug 1166436 part.13 mozilla::ContentCache should guess caret offset if the offset is in the range of cached text rects r=m_kato (be496f793)
- Bug 1166436 part.14 Store text rects after focus/anchor of selection r=m_kato (b6ce2e2e0)
- Bug 1166436 part.15 ContentCache::CacheTextRects() should refer TextComposition::LastData() because TextComposition::String() may not be modified yet when it's called r=m_kato (3ab6fd703)
- Bug 1166436 part.16 Make each member of mozilla::ContentCache used by chrome process or content process r=m_kato (35be9f90a)
- Bug 1166436 part.17 ContentCache::HandleQueryContentEvent() should return caret rect if mInput.mLength of NS_QUERY_TEXT_RECT event is 0 r=m_kato (0740f40ad)
- Bug 1166436 part.18 ContentCache should guess caret rect if there is a text rect cache of the previous character r=m_kato (e2a84217f)
- Bug 1166436 part.19 ContentCache::mSelection should have invalid state and it should be checked r=m_kato (39a054b22)
- Bug 972945 - Add autoconf test to enable AltiVec on supported targets only. r=glandium (1e3eb367d)
2021-02-24 07:43:00 +08:00

110 lines
2.9 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/WidgetUtils.h"
#ifdef XP_WIN
#include "WinUtils.h"
#endif
namespace mozilla {
gfx::Matrix
ComputeTransformForRotation(const nsIntRect& aBounds,
ScreenRotation aRotation)
{
gfx::Matrix transform;
static const gfx::Float floatPi = static_cast<gfx::Float>(M_PI);
switch (aRotation) {
case ROTATION_0:
break;
case ROTATION_90:
transform.PreTranslate(aBounds.width, 0);
transform.PreRotate(floatPi / 2);
break;
case ROTATION_180:
transform.PreTranslate(aBounds.width, aBounds.height);
transform.PreRotate(floatPi);
break;
case ROTATION_270:
transform.PreTranslate(0, aBounds.height);
transform.PreRotate(floatPi * 3 / 2);
break;
default:
MOZ_CRASH("Unknown rotation");
}
return transform;
}
gfx::Matrix
ComputeTransformForUnRotation(const nsIntRect& aBounds,
ScreenRotation aRotation)
{
gfx::Matrix transform;
static const gfx::Float floatPi = static_cast<gfx::Float>(M_PI);
switch (aRotation) {
case ROTATION_0:
break;
case ROTATION_90:
transform.PreTranslate(0, aBounds.height);
transform.PreRotate(floatPi * 3 / 2);
break;
case ROTATION_180:
transform.PreTranslate(aBounds.width, aBounds.height);
transform.PreRotate(floatPi);
break;
case ROTATION_270:
transform.PreTranslate(aBounds.width, 0);
transform.PreRotate(floatPi / 2);
break;
default:
MOZ_CRASH("Unknown rotation");
}
return transform;
}
nsIntRect RotateRect(nsIntRect aRect,
const nsIntRect& aBounds,
ScreenRotation aRotation)
{
switch (aRotation) {
case ROTATION_0:
return aRect;
case ROTATION_90:
return nsIntRect(aRect.y,
aBounds.width - aRect.x - aRect.width,
aRect.height, aRect.width);
case ROTATION_180:
return nsIntRect(aBounds.width - aRect.x - aRect.width,
aBounds.height - aRect.y - aRect.height,
aRect.width, aRect.height);
case ROTATION_270:
return nsIntRect(aBounds.height - aRect.y - aRect.height,
aRect.x,
aRect.height, aRect.width);
default:
MOZ_CRASH("Unknown rotation");
return aRect;
}
}
namespace widget {
uint32_t
WidgetUtils::IsTouchDeviceSupportPresent()
{
#ifdef XP_WIN
return WinUtils::IsTouchDeviceSupportPresent();
#else
return 0;
#endif
}
} // namespace widget
} // namespace mozilla