draw image selection using thebes in cairo builds instead of tiling an image. bug 328390. r=vlad sr=roc

This commit is contained in:
pavlov%pavlov.net 2006-03-16 21:42:50 +00:00
Родитель 6847bfbfe0
Коммит 5f68395a20
4 изменённых файлов: 58 добавлений и 4 удалений

Просмотреть файл

@ -82,10 +82,15 @@ endif
XPIDLSRCS = \
nsIChromeEventHandler.idl \
nsISelectionImageService.idl \
nsIStyleSheetService.idl \
$(NULL)
ifndef MOZ_ENABLE_CAIRO_GFX
XPIDLSRCS += \
nsISelectionImageService.idl \
$(NULL)
endif
EXPORTS = \
nsBidi.h \
nsBidiPresUtils.h \

Просмотреть файл

@ -83,8 +83,9 @@
//needed for resetting of image service color
#include "nsLayoutCID.h"
#ifndef MOZ_CAIRO_GFX
#include "nsISelectionImageService.h"
#endif
static nscolor
MakeColorPref(const char *colstr)
{
@ -1234,6 +1235,7 @@ nsPresContext::SysColorChanged()
// they may be using system colors
GetDocumentColorPreferences();
#ifndef MOZ_CAIRO_GFX
// Clear out all of the style data since it may contain RGB values
// which originated from system colors.
nsCOMPtr<nsISelectionImageService> imageService;
@ -1243,6 +1245,7 @@ nsPresContext::SysColorChanged()
{
imageService->Reset();
}
#endif
// We need to do a full reflow (and view update) here. Clearing the style
// data without reflowing/updating views will lead to incorrect change hints

Просмотреть файл

@ -118,7 +118,9 @@
#include "nsSpaceManager.h"
#include "nsTextTransformer.h"
#include "nsIFrameTraversal.h"
#ifndef MOZ_CAIRO_GFX
#include "nsISelectionImageService.h"
#endif
#include "nsCSSLoader.h"
#include "nsXULAtoms.h"
#include "nsLayoutCID.h"
@ -480,7 +482,10 @@ nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult
#endif
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
#ifndef MOZ_CAIRO_GFX
nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult);
#endif
nsresult NS_NewSelection(nsIFrameSelection** aResult);
nsresult NS_NewDomSelection(nsISelection** aResult);
@ -548,7 +553,9 @@ MAKE_CTOR(CreateNewIFrameBoxObject, nsIBoxObject, NS_NewIFrameBoxO
MAKE_CTOR(CreateNewScrollBoxObject, nsIBoxObject, NS_NewScrollBoxObject)
MAKE_CTOR(CreateNewTreeBoxObject, nsIBoxObject, NS_NewTreeBoxObject)
#endif
#ifndef MOZ_CAIRO_GFX
MAKE_CTOR(CreateSelectionImageService, nsISelectionImageService,NS_NewSelectionImageService)
#endif
#ifdef MOZ_SVG
#ifdef MOZ_SVG_RENDERER_GDIPLUS
MAKE_CTOR(CreateNewSVGRendererGDIPlus, nsISVGRenderer, NS_NewSVGRendererGDIPlus)
@ -885,10 +892,12 @@ static const nsModuleComponentInfo gComponents[] = {
nsnull,
CreateNewFrameTraversal },
#ifndef MOZ_CAIRO_GFX
{ "selection image storage",
NS_SELECTIONIMAGESERVICE_CID,
nsnull,
CreateSelectionImageService },
#endif
{ "caret",
NS_CARET_CID,

Просмотреть файл

@ -100,7 +100,9 @@
// For triple-click pref
#include "nsIServiceManager.h"
#ifndef MOZ_CAIRO_GFX
#include "nsISelectionImageService.h"
#endif
#include "imgIContainer.h"
#include "imgIRequest.h"
#include "gfxIImageFrame.h"
@ -114,6 +116,10 @@
#include "nsBlockFrame.h"
#include "nsDisplayList.h"
#ifdef MOZ_CAIRO_GFX
#include "gfxContext.h"
#endif
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
@ -273,7 +279,7 @@ nsIFrameDebug::RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aIn
#endif
// end nsIFrameDebug
#ifndef MOZ_CAIRO_GFX
// frame image selection drawing service implementation
class SelectionImageService : public nsISelectionImageService
{
@ -430,7 +436,7 @@ nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult)
NS_ADDREF(*aResult);
return NS_OK;
}
#endif /* MOZ_CAIRO_GFX */
//end selection service
@ -785,11 +791,13 @@ private:
void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
nsIRenderingContext* aCtx, const nsRect& aDirtyRect)
{
#ifndef MOZ_CAIRO_GFX
nsCOMPtr<nsISelectionImageService> imageService
= do_GetService(kSelectionImageService);
if (!imageService)
return;
nsCOMPtr<imgIContainer> container;
imageService->GetImage(mSelectionValue, getter_AddRefs(container));
if (!container)
@ -798,6 +806,35 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
rect.IntersectRect(rect, aDirtyRect);
aCtx->DrawTile(container, 0, 0, &rect);
#else
nscolor color = NS_RGB(255, 255, 255);
nsILookAndFeel::nsColorID lookandFeel;
nsresult result;
if (mSelectionValue != nsISelectionController::SELECTION_ON)
lookandFeel = nsILookAndFeel::eColor_TextSelectBackgroundDisabled;
else
lookandFeel = nsILookAndFeel::eColor_TextSelectBackground;
nsCOMPtr<nsILookAndFeel> look;
look = do_GetService(kLookAndFeelCID,&result);
if (NS_SUCCEEDED(result) && look)
look->GetColor(lookandFeel, color);
gfxRGBA c(color);
c.a = .5;
nsRefPtr<gfxContext> ctx = (gfxContext*)aCtx->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
ctx->Save();
ctx->SetColor(c);
nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
rect.IntersectRect(rect, aDirtyRect);
rect.ScaleRoundOut(mFrame->GetPresContext()->TwipsToPixels());
ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height), PR_TRUE);
ctx->Fill();
ctx->Restore();
#endif
}
/********************************************************