Bug 1229237 (part 4) - Make ThemeGeometry::mRect a LayoutDeviceIntRect. r=botond.

This commit is contained in:
Nicholas Nethercote 2015-11-22 20:32:29 -08:00
parent 086ae9a5bb
commit 7bb1055535
7 changed files with 28 additions and 23 deletions

View File

@ -2223,7 +2223,9 @@ RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame);
nsRect borderBox(aFrame->GetOffsetTo(displayRoot), aFrame->GetSize());
aBuilder->RegisterThemeGeometry(aType,
borderBox.ToNearestPixels(aFrame->PresContext()->AppUnitsPerDevPixel()));
LayoutDeviceIntRect::FromUnknownRect(
borderBox.ToNearestPixels(
aFrame->PresContext()->AppUnitsPerDevPixel())));
}
}

View File

@ -601,7 +601,7 @@ public:
* for the themed widget
*/
void RegisterThemeGeometry(uint8_t aWidgetType,
const nsIntRect& aRect) {
const mozilla::LayoutDeviceIntRect& aRect) {
if (mIsPaintingToWindow) {
mThemeGeometries.AppendElement(ThemeGeometry(aWidgetType, aRect));
}

View File

@ -68,7 +68,8 @@ public:
* @param aType The vibrancy type to use in the region.
* @param aRegion The vibrant area, in device pixels.
*/
void UpdateVibrantRegion(VibrancyType aType, const nsIntRegion& aRegion);
void UpdateVibrantRegion(VibrancyType aType,
const LayoutDeviceIntRegion& aRegion);
/**
* Clear the vibrant areas that we know about.
@ -102,7 +103,7 @@ public:
// The following are only public because otherwise ClearVibrantRegionFunc
// can't see them.
struct VibrantRegion {
nsIntRegion region;
LayoutDeviceIntRegion region;
nsTArray<NSView*> effectViews;
};
void ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const;

View File

@ -11,7 +11,8 @@
using namespace mozilla;
void
VibrancyManager::UpdateVibrantRegion(VibrancyType aType, const nsIntRegion& aRegion)
VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
const LayoutDeviceIntRegion& aRegion)
{
auto& vr = *mVibrantRegions.LookupOrAdd(uint32_t(aType));
if (vr.region == aRegion) {
@ -27,12 +28,12 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType, const nsIntRegion& aReg
vr.effectViews.SwapElements(viewsToRecycle);
// vr.effectViews is now empty.
nsIntRegionRectIterator iter(aRegion);
const nsIntRect* iterRect = nullptr;
LayoutDeviceIntRegion::RectIterator iter(aRegion);
const LayoutDeviceIntRect* iterRect = nullptr;
for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) {
if (iterRect) {
NSView* view = nil;
NSRect rect = mCoordinateConverter.UntypedDevPixelsToCocoaPoints(*iterRect);
NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(*iterRect);
if (i < viewsToRecycle.Length()) {
view = viewsToRecycle[i];
[view setFrame:rect];
@ -70,9 +71,9 @@ VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
{
[[NSColor clearColor] set];
nsIntRegionRectIterator iter(aVibrantRegion.region);
while (const nsIntRect* rect = iter.Next()) {
NSRectFill(mCoordinateConverter.UntypedDevPixelsToCocoaPoints(*rect));
LayoutDeviceIntRegion::RectIterator iter(aVibrantRegion.region);
while (const LayoutDeviceIntRect* rect = iter.Next()) {
NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(*rect));
}
}

View File

@ -2405,7 +2405,7 @@ FindFirstRectOfType(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometries,
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
if (g.mType == aThemeGeometryType) {
return LayoutDeviceIntRect::FromUnknownRect(g.mRect);
return g.mRect;
}
}
return LayoutDeviceIntRect();
@ -2446,11 +2446,11 @@ nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometri
[win placeFullScreenButton:[mView convertRect:DevPixelsToCocoaPoints(fullScreenButtonRect) toView:nil]];
}
static nsIntRegion
static LayoutDeviceIntRegion
GatherThemeGeometryRegion(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometries,
nsITheme::ThemeGeometryType aThemeGeometryType)
{
nsIntRegion region;
LayoutDeviceIntRegion region;
for (size_t i = 0; i < aThemeGeometries.Length(); ++i) {
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
if (g.mType == aThemeGeometryType) {
@ -2489,17 +2489,17 @@ nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries)
return;
}
nsIntRegion sheetRegion =
LayoutDeviceIntRegion sheetRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeSheet);
nsIntRegion vibrantLightRegion =
LayoutDeviceIntRegion vibrantLightRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeVibrancyLight);
nsIntRegion vibrantDarkRegion =
LayoutDeviceIntRegion vibrantDarkRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeVibrancyDark);
nsIntRegion menuRegion =
LayoutDeviceIntRegion menuRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeMenu);
nsIntRegion tooltipRegion =
LayoutDeviceIntRegion tooltipRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeTooltip);
nsIntRegion highlightedMenuItemRegion =
LayoutDeviceIntRegion highlightedMenuItemRegion =
GatherThemeGeometryRegion(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeHighlightedMenuItem);
MakeRegionsNonOverlapping(sheetRegion, vibrantLightRegion, vibrantDarkRegion,

View File

@ -344,9 +344,10 @@ class nsIWidget : public nsISupports {
// nsITheme::ThemeGeometryTypeForWidget.
nsITheme::ThemeGeometryType mType;
// The device-pixel rect within the window for the themed widget
nsIntRect mRect;
LayoutDeviceIntRect mRect;
ThemeGeometry(nsITheme::ThemeGeometryType aType, const nsIntRect& aRect)
ThemeGeometry(nsITheme::ThemeGeometryType aType,
const LayoutDeviceIntRect& aRect)
: mType(aType)
, mRect(aRect)
{ }

View File

@ -3757,7 +3757,7 @@ nsWindow::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries)
if (!IsWin10OrLater()) {
for (size_t i = 0; i < aThemeGeometries.Length(); i++) {
if (aThemeGeometries[i].mType == nsNativeThemeWin::eThemeGeometryTypeWindowButtons) {
nsIntRect bounds = aThemeGeometries[i].mRect;
LayoutDeviceIntRect bounds = aThemeGeometries[i].mRect;
clearRegion.Or(clearRegion, nsIntRect(bounds.X(), bounds.Y(), bounds.Width(), bounds.Height() - 2.0));
clearRegion.Or(clearRegion, nsIntRect(bounds.X() + 1.0, bounds.YMost() - 2.0, bounds.Width() - 1.0, 1.0));
clearRegion.Or(clearRegion, nsIntRect(bounds.X() + 2.0, bounds.YMost() - 1.0, bounds.Width() - 3.0, 1.0));