зеркало из https://github.com/mozilla/gecko-dev.git
Fix for 129893, cocoa changes to gfx/layout/view, r=pink, sr=ben
This commit is contained in:
Родитель
fba198f16c
Коммит
e0734fa45e
|
@ -411,6 +411,17 @@ public:
|
|||
*/
|
||||
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* For platforms (e.g., Cocoa) that implicitly double buffer, this call can be used
|
||||
* to force a buffer flush following the painting of a rectangle. This
|
||||
* call needs to be used any time drawing of rects is being done "on the fly",
|
||||
* outside of the normal painting process.
|
||||
* Examples include the blinking caret and tabbing through subimages in an
|
||||
* image map.
|
||||
*/
|
||||
NS_IMETHOD FlushRect(const nsRect& aRect) = 0;
|
||||
NS_IMETHOD FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Draw a poly in the current foreground color
|
||||
* @param aPoints points to use for the drawing, last must equal first
|
||||
|
|
|
@ -70,6 +70,10 @@ public:
|
|||
|
||||
// CLASS METHODS
|
||||
|
||||
// See the description in nsIRenderingContext.h
|
||||
NS_IMETHOD FlushRect(const nsRect& aRect);
|
||||
NS_IMETHOD FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
||||
|
||||
/**
|
||||
* Gets the Pen Mode for the RenderingContext
|
||||
* @param aPenMode The Pen Mode to be retrieved
|
||||
|
|
|
@ -155,9 +155,19 @@ public:
|
|||
//------------------------------------------------------------------------
|
||||
static void SetPortToKnownGoodPort()
|
||||
{
|
||||
#ifndef MOZ_WIDGET_COCOA
|
||||
WindowPtr firstWindow = GetTheWindowList();
|
||||
if (firstWindow)
|
||||
::SetGWorld(::GetWindowPort(firstWindow), ::GetMainDevice());
|
||||
#else
|
||||
static GrafPtr gGoodPort = nsnull;
|
||||
if (!gGoodPort) {
|
||||
Rect macRect;
|
||||
::SetRect(&macRect, 0, 0, 2, 2);
|
||||
::NewGWorld(&gGoodPort, 16, &macRect, nsnull, nsnull, 0);
|
||||
}
|
||||
::SetGWorld(gGoodPort, nsnull);
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -360,6 +360,10 @@ NS_IMETHODIMP nsImageMac :: DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt3
|
|||
if (!mImageBitsHandle)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
nsGraphicsUtils::SetPortToKnownGoodPort();
|
||||
#endif
|
||||
|
||||
// lock and set up bits handles
|
||||
LockImagePixels(PR_FALSE);
|
||||
LockImagePixels(PR_TRUE);
|
||||
|
@ -380,7 +384,7 @@ NS_IMETHODIMP nsImageMac :: DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt3
|
|||
PixMap* destPixels;
|
||||
dstMacImage->GetPixMap(&destPixels);
|
||||
NS_ASSERTION(destPixels, "No dest pixels!");
|
||||
|
||||
|
||||
CopyBitsWithMask((BitMap*)(&mImagePixmap),
|
||||
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
|
||||
(BitMap*)(destPixels), srcRect, maskRect, dstRect);
|
||||
|
|
|
@ -216,7 +216,12 @@ void nsRenderingContextMac::SelectDrawingSurface(nsDrawingSurfaceMac* aSurface,
|
|||
|
||||
nsGraphicsUtils::SafeSetPort(mPort);
|
||||
|
||||
#ifndef MOZ_WIDGET_COCOA
|
||||
// Cocoa widgets automatically set the correct origin, and
|
||||
// it can differ from this value (because of an oddity where
|
||||
// the widget shrinks when its partially offscreen).
|
||||
::SetOrigin(-mGS->mOffx, -mGS->mOffy); // line order...
|
||||
#endif
|
||||
|
||||
if (aChanges & kClippingChanged)
|
||||
::SetClip(mGS->mClipRegion); // ...does matter
|
||||
|
@ -282,7 +287,9 @@ nsresult nsRenderingContextMac::SetPortTextState()
|
|||
void nsRenderingContextMac::SetupPortState()
|
||||
{
|
||||
nsGraphicsUtils::SafeSetPort(mPort);
|
||||
#ifndef MOZ_WIDGET_COCOA
|
||||
::SetOrigin(-mGS->mOffx, -mGS->mOffy);
|
||||
#endif
|
||||
::SetClip(mGS->mClipRegion);
|
||||
}
|
||||
|
||||
|
@ -1482,6 +1489,37 @@ NS_IMETHODIMP nsRenderingContextMac::InvertRect(nscoord aX, nscoord aY, nscoord
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextMac::FlushRect(const nsRect& aRect)
|
||||
{
|
||||
return FlushRect(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextMac::FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
if (mPort) {
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
|
||||
mGS->mTMatrix.TransformCoord(&x, &y, &w, &h);
|
||||
RgnHandle rgn = ::NewRgn();
|
||||
::SetRectRgn(rgn, pinToShort(x), pinToShort(y), pinToShort(x + w), pinToShort(y + h));
|
||||
::QDFlushPortBuffer(mPort, rgn);
|
||||
::DisposeRgn(rgn);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::GetGraphics(nsIGraphics* *aGraphics)
|
||||
{
|
||||
NS_ASSERTION((aGraphics != nsnull), "aGraphics is NULL");
|
||||
|
|
|
@ -113,6 +113,8 @@ public:
|
|||
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD InvertRect(const nsRect& aRect);
|
||||
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD FlushRect(const nsRect& aRect);
|
||||
NS_IMETHOD FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD DrawEllipse(const nsRect& aRect);
|
||||
|
|
|
@ -977,3 +977,15 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledTile(imgIContainer *aImage, nsco
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::FlushRect(const nsRect& aRect)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -977,3 +977,15 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledTile(imgIContainer *aImage, nsco
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::FlushRect(const nsRect& aRect)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -918,7 +918,7 @@ void nsCaret::DrawCaret()
|
|||
nsRect clipRect;
|
||||
nsIView *drawingView;
|
||||
GetViewForRendering(mLastCaretFrame, eRenderingViewCoordinates, viewOffset, clipRect, drawingView);
|
||||
|
||||
|
||||
if (drawingView == nsnull)
|
||||
return;
|
||||
|
||||
|
@ -1067,6 +1067,11 @@ void nsCaret::DrawCaret()
|
|||
else
|
||||
mRendContext->SetColor(NS_RGB(255,255,255));
|
||||
mRendContext->InvertRect(mCaretRect);
|
||||
|
||||
// Ensure the buffer is flushed (Cocoa needs this), since we're drawing
|
||||
// outside the normal painting process.
|
||||
mRendContext->FlushRect(mCaretRect);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
if (!mHookRect.IsEmpty()) // if Bidi support is disabled, the rectangle remains empty and won't be drawn
|
||||
mRendContext->InvertRect(mHookRect);
|
||||
|
@ -1074,7 +1079,7 @@ void nsCaret::DrawCaret()
|
|||
|
||||
PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?"
|
||||
mRendContext->PopState(emptyClip);
|
||||
|
||||
|
||||
ToggleDrawnStatus();
|
||||
|
||||
#ifdef DONT_REUSE_RENDERING_CONTEXT
|
||||
|
|
|
@ -3134,7 +3134,14 @@ PresShell::ScrollLine(PRBool aForward)
|
|||
result = viewManager->GetRootScrollableView(&scrollView);
|
||||
if (NS_SUCCEEDED(result) && scrollView)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
// Emulate the Mac IE behavior of scrolling a minimum of 2 lines
|
||||
// rather than 1. This vastly improves scrolling speed.
|
||||
scrollView->ScrollByLines(0, aForward ? 2 : -2);
|
||||
#else
|
||||
scrollView->ScrollByLines(0, aForward ? 1 : -1);
|
||||
#endif
|
||||
|
||||
//NEW FOR LINES
|
||||
// force the update to happen now, otherwise multiple scrolls can
|
||||
// occur before the update is processed. (bug #7354)
|
||||
|
|
|
@ -918,7 +918,7 @@ void nsCaret::DrawCaret()
|
|||
nsRect clipRect;
|
||||
nsIView *drawingView;
|
||||
GetViewForRendering(mLastCaretFrame, eRenderingViewCoordinates, viewOffset, clipRect, drawingView);
|
||||
|
||||
|
||||
if (drawingView == nsnull)
|
||||
return;
|
||||
|
||||
|
@ -1067,6 +1067,11 @@ void nsCaret::DrawCaret()
|
|||
else
|
||||
mRendContext->SetColor(NS_RGB(255,255,255));
|
||||
mRendContext->InvertRect(mCaretRect);
|
||||
|
||||
// Ensure the buffer is flushed (Cocoa needs this), since we're drawing
|
||||
// outside the normal painting process.
|
||||
mRendContext->FlushRect(mCaretRect);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
if (!mHookRect.IsEmpty()) // if Bidi support is disabled, the rectangle remains empty and won't be drawn
|
||||
mRendContext->InvertRect(mHookRect);
|
||||
|
@ -1074,7 +1079,7 @@ void nsCaret::DrawCaret()
|
|||
|
||||
PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?"
|
||||
mRendContext->PopState(emptyClip);
|
||||
|
||||
|
||||
ToggleDrawnStatus();
|
||||
|
||||
#ifdef DONT_REUSE_RENDERING_CONTEXT
|
||||
|
|
|
@ -3134,7 +3134,14 @@ PresShell::ScrollLine(PRBool aForward)
|
|||
result = viewManager->GetRootScrollableView(&scrollView);
|
||||
if (NS_SUCCEEDED(result) && scrollView)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
// Emulate the Mac IE behavior of scrolling a minimum of 2 lines
|
||||
// rather than 1. This vastly improves scrolling speed.
|
||||
scrollView->ScrollByLines(0, aForward ? 2 : -2);
|
||||
#else
|
||||
scrollView->ScrollByLines(0, aForward ? 1 : -1);
|
||||
#endif
|
||||
|
||||
//NEW FOR LINES
|
||||
// force the update to happen now, otherwise multiple scrolls can
|
||||
// occur before the update is processed. (bug #7354)
|
||||
|
|
|
@ -169,6 +169,12 @@ nsScrollbarButtonFrame::MouseClicked()
|
|||
|
||||
// get the increment amount
|
||||
PRInt32 increment = nsSliderFrame::GetIncrement(content);
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
// Emulate the Mac IE behavior of scrolling 2 lines instead of 1
|
||||
// on a button press. This makes scrolling appear smoother and
|
||||
// keeps us competitive with IE.
|
||||
increment *= 2;
|
||||
#endif
|
||||
|
||||
nsString value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value))
|
||||
|
|
|
@ -212,7 +212,6 @@ NS_IMETHODIMP nsScrollPortView::GetScrollPreference(nsScrollPreference &aScrollP
|
|||
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
|
||||
{
|
||||
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
|
|
@ -803,13 +803,13 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
|
|||
}
|
||||
|
||||
//make sure visibility state is accurate
|
||||
|
||||
|
||||
if (aResetVisibility) {
|
||||
nsViewVisibility vis;
|
||||
|
||||
GetVisibility(vis);
|
||||
SetVisibility(vis);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
|
||||
|
|
|
@ -79,7 +79,12 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|||
we ask for a specific z-order, we don't assume that widget z-ordering actually works.
|
||||
*/
|
||||
|
||||
//#define NO_DOUBLE_BUFFER
|
||||
// #define NO_DOUBLE_BUFFER
|
||||
|
||||
// Cocoa never double buffers
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
#define NO_DOUBLE_BUFFER
|
||||
#endif
|
||||
|
||||
// if defined widget changes like moves and resizes are defered until and done
|
||||
// all in one pass.
|
||||
|
@ -1412,7 +1417,7 @@ NS_IMETHODIMP nsViewManager::Composite()
|
|||
{
|
||||
if (nsnull != mRootWindow)
|
||||
mRootWindow->Update();
|
||||
|
||||
|
||||
mUpdateCnt = 0;
|
||||
}
|
||||
|
||||
|
@ -3107,9 +3112,8 @@ NS_IMETHODIMP nsViewManager::GetWidget(nsIWidget **aWidget)
|
|||
|
||||
NS_IMETHODIMP nsViewManager::ForceUpdate()
|
||||
{
|
||||
if (mRootWindow) {
|
||||
if (mRootWindow)
|
||||
mRootWindow->Update();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче