Files
palemoon27/layout/forms/nsGfxRadioControlFrame.cpp
roytam1 7c9b1cc625 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1230034 part 1 - Remove NS_PROPERTY_DESCRIPTOR_CONST macro. r=dbaron (7251a79067)
- Bug 1230034 part 2 - Constify aFrame parameters of frame property functions. r=dbaron (da8f373594)
- Bug 1230034 part 3 - Move some frame property declaration around. r=dbaron (d081d6b103)
- Bug 1235467. If the root reference frame is transformed don't use an ancestor of the root reference frame as the local reference frame. r=mattwoodrow (05fd8ae29c)
- Bug 1163583 - Crashtest. (cc20379288)
- Bug 1235489 - Remove assertion which is breakable when reflow is interrupted. r=jfkthame (f6a4001b55)
- Bug 1224669 - Reftest with extreme negative letter-spacing affecting intrinsic width. r=dholbert (b7dc81eb9a)
- Bug 1224669 - Clamp width to be non-negative during intrinsic width calculation. r=dholbert (9fa8d6cab7)
- Bug 1239251 - Initialize mCommonAncestorWithLastFrame with nullptr in constructor BuildTextRunsScanner. r=roc (2178f72ee3)
- Bug 1231175 - Reftest for failure to recognize mixed directionality in RTL para beginning with number within embed/isolate controls. r=smontagu (f3b0755b4c)
- Bug 1231175 - Missed change from Unicode 6.3 bidi algorithm update (ported from ICU's ubidi): include new ENL and ENR bidi pseudo-types in MASK_LTR. r=smontagu (f9c2cb657c)
- Bug 1233135 - Do not touch display value of anonymous box for ruby. r=dbaron (efe08e7e4a)
- Bug 1228716 - Give different frame keys for nsDisplayBlendContainer. r=roc (d7dfe4af0f)
- Bug 1235696. The animated geometry root of a transfromed and sticky pos frame should be the frame itself. r=mattwoodrow (d94a1284c5)
- Bug 1240073 - Use the transformed frame as the AGR for active transform so that FrameLayerBuilder knows that they can move independently. r=tnikkel (67b1ea8173)
- Bug 1237982 - Force perspective layers to always be active. r=thinker (591f169a91)
- Bug 1230774 - Use correct Z order to sort perspective items. r=roc (1be759c298)
- Bug 1230693 - Rebase transforms to the origin for callers than don't want them offset. r=mstange (cabb21c6e7)
- Bug 1230780 - Propagate preserve-3d handling through nsDisplayPerspective. r=thinker (8f82183587)
- Bug 1237457 - Partially Moz2Dify nsDisplayGeneric. r=roc. (e2221425d5)
- Bug 1226796 - Remove redundant preprocessor flags in nsContainerFrame.cpp. r=jfkthame (1853453cd4)
- Bug 1211635 - Popups should be treated as top-level windows, allowing XUL alerts translucency. r=MattN r=roc (07bd00b85a)
2023-08-22 11:29:06 +08:00

94 lines
2.9 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 "nsGfxRadioControlFrame.h"
#include "gfx2DGlue.h"
#include "gfxUtils.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/PathHelpers.h"
#include "nsLayoutUtils.h"
#include "nsRenderingContext.h"
#include "nsDisplayList.h"
using namespace mozilla;
using namespace mozilla::gfx;
nsIFrame*
NS_NewGfxRadioControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsGfxRadioControlFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame)
nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext* aContext):
nsFormControlFrame(aContext)
{
}
nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
{
}
#ifdef ACCESSIBILITY
a11y::AccType
nsGfxRadioControlFrame::AccessibleType()
{
return a11y::eHTMLRadioButtonType;
}
#endif
//--------------------------------------------------------------
// Draw the dot for a non-native radio button in the checked state.
static void
PaintCheckedRadioButton(nsIFrame* aFrame,
DrawTarget* aDrawTarget,
const nsRect& aDirtyRect,
nsPoint aPt)
{
// The dot is an ellipse 2px on all sides smaller than the content-box,
// drawn in the foreground color.
nsRect rect(aPt, aFrame->GetSize());
rect.Deflate(aFrame->GetUsedBorderAndPadding());
rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
nsPresContext::CSSPixelsToAppUnits(2));
Rect devPxRect =
ToRect(nsLayoutUtils::RectToGfxRect(rect,
aFrame->PresContext()->AppUnitsPerDevPixel()));
ColorPattern color(ToDeviceColor(aFrame->StyleColor()->mColor));
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
RefPtr<Path> ellipse = builder->Finish();
aDrawTarget->Fill(ellipse, color);
}
void
nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
if (!IsVisibleForPainting(aBuilder))
return;
if (IsThemed())
return; // The theme will paint the check, if any.
bool checked = true;
GetCurrentCheckState(&checked); // Get check state from the content model
if (!checked)
return;
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
"CheckedRadioButton",
nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
}