mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
f38f996411
- bug 1249738 - make sWakeLockObservers a function static r=dhylands (a606893142) - bug 1249738 - make sSystemClockChangeObservers a function static r=dhylands (c994867638) - bug 1249738 - make sSystemTimezoneChangeObservers a function static r=dhylands (d053417e69) - Bug 1184285 - Stop warning if RemoveObserver() is called for unregistered observer. r=dhylands (5119547e11) - Bug 1244754 - part 1 - backport zero-length gradient interval fix from Skia upstream. r=jrmuizel (c1ae572de9) - Bug 1229975 - backport fix for Skia's GrConvexPolyEffect. r=mchang (80aba4e282) - Bug 1206961 - Use channel->AsyncOpen2() in image/imgLoader.cpp; removing security checks from the callsite reveals that we have to pass the accurate contentPolicyType to ValidateEntry (r=seth,bz) (0d771560b6) - Bug 1266615 - Fix C4334 in imgFrame.cpp. r=padenot (2d8227a6cc) - Bug 1230907 - mPixelRowSize added to constructor with 0 value. r=seth (5681184935) - Bug 1249550 (part 1) - Flip BMPs with negative height when downscaling. r=tn. (ca5978c766) - Bug 1249550 (part 2) - Add a test. r=tn. (d3c61944de) - Bug 1255675. SurfacePipe handles removing the frame rect, so pass the frame rect directly. (ef71f57a9a) - Bug 1255104 - Use SurfacePipe in nsIconDecoder. r=njn (e10c6c8a29) - Bug 1120141. Don't use surface with alpha for first frames of all pngs. r=edwin (5e5ffc4465) - Bug 1265631 - patch 1 - Add line-break data from Unicode's LineBreak.txt to nsUnicodeProperties for builds without ICU. r=masayuki (9873992421) - Bug 1265631 - patch 2 - Implement GetLineBreakClass() accessor to get Unicode line-break class from ICU or nsUnicodeProperties data. r=masayuki (fe7fcbf270) - Bug 1265631 - Reftests for line-breaking with supplementary-plane characters. r=masayuki (55e1974356) - Bug 1265631 - patch 3 - Add surrogate support to nsJISx4051LineBreaker so that supplementary-plane characters get correct line-breaking behavior. r=masayuki (ef24e8efc5) - Bug 1265631 - followup with adjustments for review comments on patch 3. no_r=me (4fbc8d5a98) - Bug 1128454 - Fix IPDL test (r=jimm) (82cb7e77fa) - Bug 1254373: Make TestDemon build on Windows; r=billm (11eeb63019) - Bug 1227327 - Use regular background image display items for painting button backgrounds. r=mattwoodrow (7a36d30032) - Bug 1255022 - Make the test_transformed_scrolling_repaints* tests mochitest-plain instead of mochitest-chrome. r=mstange (3d150690e7) - Bug 1268195 - When restoring a scroll position outside of incremental load, don't keep trying in a loop - just do it once and stop. r=tnikkel (ab9f4f57ab) - Bug 1265256 - Use the canvas positioning area when computing the background-attachment:fixed rect for canvas frames. r=mstange (3dda1b8beb) - Bug 623432 part 1 - When the target scroll point is at the screen edge and no scrolling occured, then try to scroll 10px in that direction anyway. r=tn (f9952f107d) - Bug 623432 part 2 - Ignore scrollbars while drag-selecting content. r=tn (ca26f1145e) - Bug 623432 part 3 - Check nsFrameSelection::GetDragState() earlier to optimize away some more expensive calls. r=tn (6d540874e2) - Bug 1269539 - Ensure that the scroll position is restored properly on reloading a page which loads incrementally. r=tnikkel (1e018dca29) - Bug 1239808 - Fix mozharness mach command for test_packages.json retrieval. r=jlund (9639ec1459) - Bug 1248097, part 1 - Fix indentation in SpecialPowersObserver.jsm. r=jmaher (75ed8bf7b9) - Bug 1248097, part 2 - If no name is specified for createFiles, use createUnique to create one. r=jmaher (aa9b8b60f7) - Bug 1248097, part 3 - Add file creation support for options. r=jmaher (9086ae5f9c) - Bug 1248097, part 4 - Don't throw away the _createdFiles array every time. r=jmaher (4a7732a4d4) - Bug 1241576 - Convert testing/ to use channel.open2() (r=sicking) (ecadf38f7b) - Bug 1251139 - Support running a function in the parent with loadChromeScript. r=jmaher (50377424bb) - Bug 1153128 - Add sendSyncMessage to SpecialPowers.loadChromeScript. =jmaher (f53c487b0c) - bug 1254091 convert test_mousecapture.xul to mochitest-plain so we can run it in e10s, r=enndeakin (900bce80cf) - Bug 1254091 - part 2: fix focus messaging from SpecialPowers to refer to the right window, r=enndeakin (4ec66a9b8f) - Bug 1258534 - Port test_bug599295.html to mochitest-plain so that it can be turned on in e10s mode; r=mrbkap (2a669777de) - Bug 1260076 - [Mochitest] implement SpecialPowers.loadPrivilegedScript, r=bholley (8e2076f952) - Bug 1252750 - Part 1: Create a helper function on SpecialPowersAPI which creates a nested event queue and spins it for a bit. r=mrbkap (fdefa1a3d6) - Bug 1205358 - Fix up nsUrlClassifierPrefixSet memory reporting. r=gcp. (1c9d78607d) - Bug 1244259 - Limit PrefixSet read and write buffer sizes to file size. r=froydnj (0906574833) - Bug 1247615 - Fix off-by-one error in PrefixSet Delta storage compaction. r=froydnj (b72f052289) - Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in toolkit subdirectory.r=erahm (9d00df5d13) - Bug 1213400 - Fix crash in broken Safe Browsing list updates. r=gcp (a073ec1a8f) - Bug 1160263: Don't allow add-ons to override the periodic XPI signature check. r=rstrong (1ef54384cc) - Bug 1180273 - Adding missing 'this' pointer when forwarding newChannel2 calls (r=gijs,sicking) (b173efdff4) - Bug 1147562 - Update remaining callsites of newChannel before landing the shim in b2g/ (r=sicking) (10ab6df542) - Bug 1194087 - MailtoProtocolHandler, SmsProtocolHandler, and TelProtocolHandler will all fire twice after introduction of newChannel2 r=asuth (ff7cc15c67) - Bug 1204703 - Add AsyncOpen2 to channels in toolkit/ and b2g/ (r=sicking) (8d4b8ad5c6) - Bug 1264383 - makeFilteringListener breaks eventremoval with shims. r=mconley (6a9d6d5079) - Bug 1256468 - sessionHistory shim should QI DocShell to nsIWebNavigation automatically. r=krizsa (9a111454cb) - Bug 1164011 - Test for CPOW shims. r=mconley (bbf7880955) - Bug 1236409 - Remove toolkit impl of XUL prompt for nsICookiePromptService r=margaret (9f620ba65a) - Bug 1236259 - Quote MOZ_APP_ID; r=gps (58b8e287b8) - Bug 1174036 - Handle dynamically-removed textareas gracefully. r=mikedeboer r=ehsan (0797d45e3b) - Bug 1259531 - [e10s] Fix test_bug451286.xul to run in e10s by converting to a mochitest-browser test. r=mikedeboer (00539d564c) - Bug 1237798 - Use correct Components object inside CommonJS. r=Yoric (895beb28e2) - Bug 1188158 - Move nsIPrivateBrowsingTrackingProtectionWhitelist to its own component in toolkit; r=jdm (6c75ab641b) - Bug 1221537 - Provide a flash.bat script for Windows to device image builds (especially aries). r=fabrice (3eb8a25c0a) - Bug 1232285 - The Terminator's notion of ticks is incorrect. r=Yoric (bc2688343c) - Bug 1252382 - Get rid of PR_Sleep in the terminator;r=froydnj (a76de950df) - Bug 1242084 - nsTerminator::UpdateTelemetry() leaks 8 byte nsStringBuffer when app.update.channel gets set to Beta. r=gfritzsche (56902dc11b) - align some tests (e5179f8158) - Bug 1260908 - Allow keyed histograms to accumulate early in startup (r=gfritzsche) (1852efe810) - Bug 1254550 - Make Telemetry configuration consistent across builds. r=gfritzsche (16dcbf9a83)
523 lines
15 KiB
C++
523 lines
15 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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 "nsButtonFrameRenderer.h"
|
|
#include "nsCSSRendering.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsCSSPseudoElements.h"
|
|
#include "nsNameSpaceManager.h"
|
|
#include "mozilla/StyleSetHandle.h"
|
|
#include "mozilla/StyleSetHandleInlines.h"
|
|
#include "nsDisplayList.h"
|
|
#include "nsITheme.h"
|
|
#include "nsFrame.h"
|
|
#include "mozilla/EventStates.h"
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#define ACTIVE "active"
|
|
#define HOVER "hover"
|
|
#define FOCUS "focus"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::image;
|
|
|
|
nsButtonFrameRenderer::nsButtonFrameRenderer()
|
|
{
|
|
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
|
|
}
|
|
|
|
nsButtonFrameRenderer::~nsButtonFrameRenderer()
|
|
{
|
|
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
|
|
|
|
#ifdef DEBUG
|
|
if (mInnerFocusStyle) {
|
|
mInnerFocusStyle->FrameRelease();
|
|
}
|
|
if (mOuterFocusStyle) {
|
|
mOuterFocusStyle->FrameRelease();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void
|
|
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsPresContext* aPresContext)
|
|
{
|
|
mFrame = aFrame;
|
|
ReResolveStyles(aPresContext);
|
|
}
|
|
|
|
nsIFrame*
|
|
nsButtonFrameRenderer::GetFrame()
|
|
{
|
|
return mFrame;
|
|
}
|
|
|
|
void
|
|
nsButtonFrameRenderer::SetDisabled(bool aDisabled, bool notify)
|
|
{
|
|
if (aDisabled)
|
|
mFrame->GetContent()->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
|
notify);
|
|
else
|
|
mFrame->GetContent()->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, notify);
|
|
}
|
|
|
|
bool
|
|
nsButtonFrameRenderer::isDisabled()
|
|
{
|
|
return mFrame->GetContent()->AsElement()->
|
|
State().HasState(NS_EVENT_STATE_DISABLED);
|
|
}
|
|
|
|
class nsDisplayButtonBoxShadowOuter : public nsDisplayItem {
|
|
public:
|
|
nsDisplayButtonBoxShadowOuter(nsDisplayListBuilder* aBuilder,
|
|
nsButtonFrameRenderer* aRenderer)
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBoxShadowOuter);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayButtonBoxShadowOuter() {
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBoxShadowOuter);
|
|
}
|
|
#endif
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
|
bool* aSnap) override;
|
|
NS_DISPLAY_DECL_NAME("ButtonBoxShadowOuter", TYPE_BUTTON_BOX_SHADOW_OUTER)
|
|
private:
|
|
nsButtonFrameRenderer* mBFR;
|
|
};
|
|
|
|
nsRect
|
|
nsDisplayButtonBoxShadowOuter::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
|
|
*aSnap = false;
|
|
return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
|
}
|
|
|
|
void
|
|
nsDisplayButtonBoxShadowOuter::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) {
|
|
nsRect frameRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
nsRect buttonRect;
|
|
mBFR->GetButtonRect(frameRect, buttonRect);
|
|
|
|
nsCSSRendering::PaintBoxShadowOuter(mFrame->PresContext(), *aCtx, mFrame,
|
|
buttonRect, mVisibleRect);
|
|
}
|
|
|
|
class nsDisplayButtonBorder : public nsDisplayItem {
|
|
public:
|
|
nsDisplayButtonBorder(nsDisplayListBuilder* aBuilder,
|
|
nsButtonFrameRenderer* aRenderer)
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBorder);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayButtonBorder() {
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBorder);
|
|
}
|
|
#endif
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
HitTestState* aState,
|
|
nsTArray<nsIFrame*> *aOutFrames) override {
|
|
aOutFrames->AppendElement(mFrame);
|
|
}
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
|
bool* aSnap) override;
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
nsRegion *aInvalidRegion) override;
|
|
NS_DISPLAY_DECL_NAME("ButtonBorderBackground", TYPE_BUTTON_BORDER_BACKGROUND)
|
|
private:
|
|
nsButtonFrameRenderer* mBFR;
|
|
};
|
|
|
|
nsDisplayItemGeometry*
|
|
nsDisplayButtonBorder::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
{
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
|
}
|
|
|
|
void
|
|
nsDisplayButtonBorder::ComputeInvalidationRegion(
|
|
nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
nsRegion *aInvalidRegion)
|
|
{
|
|
auto geometry =
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
bool snap;
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
}
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
}
|
|
|
|
void nsDisplayButtonBorder::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
NS_ASSERTION(mFrame, "No frame?");
|
|
nsPresContext* pc = mFrame->PresContext();
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
// draw the border and background inside the focus and outline borders
|
|
DrawResult result =
|
|
mBFR->PaintBorder(aBuilder, pc, *aCtx, mVisibleRect, r);
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
|
}
|
|
|
|
nsRect
|
|
nsDisplayButtonBorder::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
|
|
*aSnap = false;
|
|
return aBuilder->IsForEventDelivery() ? nsRect(ToReferenceFrame(), mFrame->GetSize())
|
|
: mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
|
}
|
|
|
|
class nsDisplayButtonForeground : public nsDisplayItem {
|
|
public:
|
|
nsDisplayButtonForeground(nsDisplayListBuilder* aBuilder,
|
|
nsButtonFrameRenderer* aRenderer)
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
|
MOZ_COUNT_CTOR(nsDisplayButtonForeground);
|
|
}
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
virtual ~nsDisplayButtonForeground() {
|
|
MOZ_COUNT_DTOR(nsDisplayButtonForeground);
|
|
}
|
|
#endif
|
|
|
|
nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
|
|
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
nsRegion *aInvalidRegion) override;
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx) override;
|
|
NS_DISPLAY_DECL_NAME("ButtonForeground", TYPE_BUTTON_FOREGROUND)
|
|
private:
|
|
nsButtonFrameRenderer* mBFR;
|
|
};
|
|
|
|
nsDisplayItemGeometry*
|
|
nsDisplayButtonForeground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
{
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
|
}
|
|
|
|
void
|
|
nsDisplayButtonForeground::ComputeInvalidationRegion(
|
|
nsDisplayListBuilder* aBuilder,
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
nsRegion* aInvalidRegion)
|
|
{
|
|
auto geometry =
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
bool snap;
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
}
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
}
|
|
|
|
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
|
|
nsRenderingContext* aCtx)
|
|
{
|
|
nsPresContext *presContext = mFrame->PresContext();
|
|
const nsStyleDisplay *disp = mFrame->StyleDisplay();
|
|
if (!mFrame->IsThemed(disp) ||
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) {
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
|
|
|
// Draw the focus and outline borders.
|
|
DrawResult result =
|
|
mBFR->PaintOutlineAndFocusBorders(aBuilder, presContext, *aCtx,
|
|
mVisibleRect, r);
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
|
}
|
|
}
|
|
|
|
nsresult
|
|
nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
|
nsDisplayList* aBackground,
|
|
nsDisplayList* aForeground)
|
|
{
|
|
if (mFrame->StyleEffects()->mBoxShadow) {
|
|
aBackground->AppendNewToTop(new (aBuilder)
|
|
nsDisplayButtonBoxShadowOuter(aBuilder, this));
|
|
}
|
|
|
|
nsRect buttonRect;
|
|
GetButtonRect(mFrame->GetRectRelativeToSelf(), buttonRect);
|
|
|
|
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
|
aBuilder, mFrame, buttonRect, aBackground);
|
|
|
|
aBackground->AppendNewToTop(new (aBuilder)
|
|
nsDisplayButtonBorder(aBuilder, this));
|
|
|
|
// Only display focus rings if we actually have them. Since at most one
|
|
// button would normally display a focus ring, most buttons won't have them.
|
|
if ((mOuterFocusStyle && mOuterFocusStyle->StyleBorder()->HasBorder()) ||
|
|
(mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder())) {
|
|
aForeground->AppendNewToTop(new (aBuilder)
|
|
nsDisplayButtonForeground(aBuilder, this));
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
DrawResult
|
|
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(
|
|
nsDisplayListBuilder* aBuilder,
|
|
nsPresContext* aPresContext,
|
|
nsRenderingContext& aRenderingContext,
|
|
const nsRect& aDirtyRect,
|
|
const nsRect& aRect)
|
|
{
|
|
// once we have all that we'll draw the focus if we have it. We will
|
|
// need to draw 2 focuses, the inner and the outer. This is so we
|
|
// can do any kind of look and feel. Some buttons have focus on the
|
|
// outside like mac and motif. While others like windows have it
|
|
// inside (dotted line). Usually only one will be specifed. But I
|
|
// guess you could have both if you wanted to.
|
|
|
|
nsRect rect;
|
|
|
|
PaintBorderFlags flags = aBuilder->ShouldSyncDecodeImages()
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
: PaintBorderFlags();
|
|
|
|
DrawResult result = DrawResult::SUCCESS;
|
|
|
|
if (mOuterFocusStyle) {
|
|
// ---------- paint the outer focus border -------------
|
|
|
|
GetButtonOuterFocusRect(aRect, rect);
|
|
|
|
result &=
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
aDirtyRect, rect, mOuterFocusStyle, flags);
|
|
}
|
|
|
|
if (mInnerFocusStyle) {
|
|
// ---------- paint the inner focus border -------------
|
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
|
|
|
result &=
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
aDirtyRect, rect, mInnerFocusStyle, flags);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
DrawResult
|
|
nsButtonFrameRenderer::PaintBorder(
|
|
nsDisplayListBuilder* aBuilder,
|
|
nsPresContext* aPresContext,
|
|
nsRenderingContext& aRenderingContext,
|
|
const nsRect& aDirtyRect,
|
|
const nsRect& aRect)
|
|
{
|
|
// get the button rect this is inside the focus and outline rects
|
|
nsRect buttonRect;
|
|
GetButtonRect(aRect, buttonRect);
|
|
|
|
nsStyleContext* context = mFrame->StyleContext();
|
|
|
|
PaintBorderFlags borderFlags = aBuilder->ShouldSyncDecodeImages()
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
: PaintBorderFlags();
|
|
|
|
nsCSSRendering::PaintBoxShadowInner(aPresContext, aRenderingContext,
|
|
mFrame, buttonRect);
|
|
|
|
DrawResult result =
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
aDirtyRect, buttonRect, context, borderFlags);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
void
|
|
nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
{
|
|
focusRect = aRect;
|
|
}
|
|
|
|
void
|
|
nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
|
|
{
|
|
r = aRect;
|
|
r.Deflate(GetButtonOuterFocusBorderAndPadding());
|
|
}
|
|
|
|
|
|
void
|
|
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
{
|
|
GetButtonRect(aRect, focusRect);
|
|
focusRect.Deflate(GetButtonBorderAndPadding());
|
|
focusRect.Deflate(GetButtonInnerFocusMargin());
|
|
}
|
|
|
|
|
|
nsMargin
|
|
nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
|
|
{
|
|
nsMargin result(0,0,0,0);
|
|
|
|
if (mOuterFocusStyle) {
|
|
if (!mOuterFocusStyle->StylePadding()->GetPadding(result)) {
|
|
NS_NOTYETIMPLEMENTED("percentage padding");
|
|
}
|
|
result += mOuterFocusStyle->StyleBorder()->GetComputedBorder();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
nsMargin
|
|
nsButtonFrameRenderer::GetButtonBorderAndPadding()
|
|
{
|
|
return mFrame->GetUsedBorderAndPadding();
|
|
}
|
|
|
|
/**
|
|
* Gets the size of the buttons border this is the union of the normal and disabled borders.
|
|
*/
|
|
nsMargin
|
|
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
|
|
{
|
|
nsMargin innerFocusMargin(0,0,0,0);
|
|
|
|
if (mInnerFocusStyle) {
|
|
const nsStyleMargin* margin = mInnerFocusStyle->StyleMargin();
|
|
if (!margin->GetMargin(innerFocusMargin)) {
|
|
NS_NOTYETIMPLEMENTED("percentage margin");
|
|
}
|
|
}
|
|
|
|
return innerFocusMargin;
|
|
}
|
|
|
|
nsMargin
|
|
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
|
|
{
|
|
nsMargin result(0,0,0,0);
|
|
|
|
if (mInnerFocusStyle) {
|
|
if (!mInnerFocusStyle->StylePadding()->GetPadding(result)) {
|
|
NS_NOTYETIMPLEMENTED("percentage padding");
|
|
}
|
|
result += mInnerFocusStyle->StyleBorder()->GetComputedBorder();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// gets all the focus borders and padding that will be added to the regular border
|
|
nsMargin
|
|
nsButtonFrameRenderer::GetAddedButtonBorderAndPadding()
|
|
{
|
|
return GetButtonOuterFocusBorderAndPadding() + GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
|
|
}
|
|
|
|
/**
|
|
* Call this when styles change
|
|
*/
|
|
void
|
|
nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
|
|
{
|
|
// get all the styles
|
|
nsStyleContext* context = mFrame->StyleContext();
|
|
StyleSetHandle styleSet = aPresContext->StyleSet();
|
|
|
|
#ifdef DEBUG
|
|
if (mInnerFocusStyle) {
|
|
mInnerFocusStyle->FrameRelease();
|
|
}
|
|
if (mOuterFocusStyle) {
|
|
mOuterFocusStyle->FrameRelease();
|
|
}
|
|
#endif
|
|
|
|
// style for the inner such as a dotted line (Windows)
|
|
mInnerFocusStyle =
|
|
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
|
CSSPseudoElementType::mozFocusInner,
|
|
context);
|
|
|
|
// style for outer focus like a ridged border (MAC).
|
|
mOuterFocusStyle =
|
|
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
|
CSSPseudoElementType::mozFocusOuter,
|
|
context);
|
|
|
|
#ifdef DEBUG
|
|
if (mInnerFocusStyle) {
|
|
mInnerFocusStyle->FrameAddRef();
|
|
}
|
|
if (mOuterFocusStyle) {
|
|
mOuterFocusStyle->FrameAddRef();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
nsStyleContext*
|
|
nsButtonFrameRenderer::GetStyleContext(int32_t aIndex) const
|
|
{
|
|
switch (aIndex) {
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
return mInnerFocusStyle;
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
return mOuterFocusStyle;
|
|
default:
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
void
|
|
nsButtonFrameRenderer::SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext)
|
|
{
|
|
switch (aIndex) {
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
#ifdef DEBUG
|
|
if (mInnerFocusStyle) {
|
|
mInnerFocusStyle->FrameRelease();
|
|
}
|
|
#endif
|
|
mInnerFocusStyle = aStyleContext;
|
|
break;
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
#ifdef DEBUG
|
|
if (mOuterFocusStyle) {
|
|
mOuterFocusStyle->FrameRelease();
|
|
}
|
|
#endif
|
|
mOuterFocusStyle = aStyleContext;
|
|
break;
|
|
}
|
|
#ifdef DEBUG
|
|
aStyleContext->FrameAddRef();
|
|
#endif
|
|
}
|