Files
palemoon27/layout/forms/nsFormControlFrame.cpp
T
roytam1 6e5e89ee47 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1161686 - libmar's |SECU_GetModulePassword| can leak allocated string (command line build utility). Free unused return of GetPasswordString. r=bbondy (25107e4c3e)
- Bug 1253775 - Remove libmar and libbz2 Makefile.ins; r=ted (7d693933b8)
- Bug 1186934 - update jemalloc to upstream HEAD; r=glandium (cd4fdf0c93)
- Bug 1254850 - Update jemalloc 4 to version 4.1.0. r=njn (6cc351fb51)
- Bug 1254948 - Remove makefiles used to transition from jemalloc_config.c to jemalloc_config.cpp; r=glandium (c8e0684478)
- Bug 1263735: Update libcubeb to remove wasapi stubbing for enumeration r=kinetik (156c7e4ef8)
- Bug 1264594 - Update libcubeb to revision 727121. r=kinetik (e982bc0eef)
- Bug 1264892: Use system declaration of |__system_property_get| on B2G, r=padenot (b50185e037)
- Bug 1265692 - Update cubeb to 0bc02f9. r=padenot,kinetik (420c905a02)
- Bug 1251502 - Add a duplex AudioUnit implementation. r=kinetik,padenot (a4e00f217a)
- Bug 1266753 - Update cubeb to revision dbdfb to pick up OSX device notification changes. r=padenot (12532f1cf6)
- Bug 1266753 - Fix mac bustage: use the old enum values, on a CLOSED TREE. r=padenot (afe9874670)
- Bug 1251502 - Compile the resampling code in cubeb for OSX and Linux. r=kinetik (6f07d50796)
- Bug 1236937 - Use correct value for Pi in AAFilter.cpp. r=padenot (d54113bf18)
- Bug 1235675 - Add the source directory to the -include directive in media/libsoundtouch/src/moz.build. r=mshal (0d56029898)
- Bug 1135942 - Enable MMX/SSE code unconditionally in libsoundtouch, it does runtime detection anyways. r=padenot (1e1c3c6c84)
- Bug 1264208 - Enable libav assertions. r=jya (a89a7683ac)
- Bug 1134744 - Fix baseline for form controls when line is inverted relative to block dir. r=smontagu (8be618ce3f)
- Bug 1261284: Don't include <button>'s children in overflow areas, if we know we're going to clip them when painting. r=mats (094dd9c33b)
- Bug 1263773 - Mark a bunch of classes in layout as MOZ_RAII. r=dholbert (e28d735a60)
- Bug 1249664 - Save the combobox's dropped-down state across frame reconstruction. r=dbaron (6caf06c91e)
- Bug 1253977 part 1 - Update focus state on combobox frame destruction/construction properly. r=tn (0c1841dc35)
- Bug 1253977 part 2 - Reftests. (985b87a008)
- Bug 1212688 - Drill through any <optgroup> scroll frames to get at its <option> child frames when estimating the list's row size. r=roc (67b9ac481c)
- Bug 1228670 - Null-check GetContentInsertionFrame() before using it. r=bz (bffbf4769c)
- Bug 1208978 - Limit the size of a potentially-scrollable dropdown list to the actual size of its contents, as our estimate based on row count may be too large if the row heights vary. r=roc (b9447f9f1c)
- Bug 1121515 - Error tapping empty listitem in a <select> box, r=roc, wesj (bffe267a89)
- Bug 1194733 - Don't honor DefaultPrevented for mouseup events in list control frames. r=enndeakin@gmail.com (37c43372b6)
- remove JXR support which was partially broken anyway (3440b4e0ef)
- Bug 940103 - Import compare-locales in the tree. r=gps (b8dd4f7e14)
- Bug 1237678 - update compare-locales to version 1.0. r=mathjazz (09dc0e35aa)
- bits of 1225280 (1869476ed8)
- Bug 1239504 - Avoid ASan leak report by holding PseudoStack in ImageBridgeChild. r=sotaro (d9125680ad)
- Bug 1223193: P1. Make ImageBridgeChild::mShuttingDown atomic. r=nical (3a5b496dae)
- Bug 1223193: P2. Cancel ImageBridge proxy functions if shutdown has started. r=nical (a66cd45878)
- Bug 1243466 - Don't crash if DeallocPImageContainerChild is called prematurely. r=sotaro (e8d4776fde)
- Bug 1251808 (Followup) - Mark the new SourceSurfaceImage constructor explicit. r=me (1087add7d0)
- Bug 1260391: Fix |ImageBridgeChild::UseOverlaySource|, r=dvander (e423cc3a27)
- Bug 1255823 - Add a two-step destruction process to PAPZ. r=dvander (3d53adaecc)
- Bug 1261321 - Null-check when the CompositableClient when forcing its destruction at shutdown. r=jnicol (7180c6d737)
- Bug 1259301 - Remove GeckoContentController::RequestFlingSnap(). r=kats (d94da5f624)
- Bug 1264703 - Follow up: don't print unhandled BUILDSTATUS messages when running |./mach configure| r=gps (c3f0b8a9b3)
- Bug 1263506 - Ensure MOZ_GMP_PATH in gtests always has native dir separators. r=glandium (ea91c448ed)
- Bug 1253512 (part 1) - Overhaul DMD's "sampling". r=erahm. (536dcdf84e)
- Bug 1282185 (part 1) - Remove a bogus assertion in DMD. r=erahm. (ec09953fac)
- Bug 1253512 (part 2) - Aggregate live blocks. r=erahm. (57db2ffa75)
- Bug 1254029 - Do not wait in ImageBridgeChild::FlushAllImages() except gonk r=nical (aeac940199)
- Bug 1259174 - Fix absolute paths in TEST_HARNESS_FILES. r=mshal (d97df14fc0)
- Bug 1245701 - Allow absolute paths with wildcards in FINAL_TARGET_FILES; r=glandium (4434843c71)
- Bug 1255450 - [mach] Create setting for defining command aliases, r=gps (3a00add9bb)
- Bug 1262495 - [mach] Allow running root commands that have subcommands on their own, r=gps (4a1d3d4959)
- Bug 1255470 - [mach] don't raise if a subcommand exists and but wasn't found in args, r=gps (654dc84f95)
- Bug 1255450 - [mach] Implement 'wildcard' settings for enabling sections with user-defined options, r=gps (2b1ccdf573)
- Bug 1255450 - [mach] Simplify managing of locale documentation for settings, r=gps (44cfacff8b)
- Bug 1255450 - [mach] Enable runtime configuration files, r=gps (76cc69734c)
- Bug 1255450 - mach settings documentation fix, DONTBUILD, r=me (d3395c787a)
- Bug 991343 - Suppress time output when running inside emacs, r=gps (62193e5661)
- Bug 1255467 - Ability for a mach command to dispatch to another's subcommand, r=gps (adfff83191)
- Bug 1241989 - Speed up install manifests by avoiding path operations. r=gps (9e89d59d52)
- Bug 1249210 - Install files using multiple threads on Windows; r=glandium (003f19169d)
- Bug 1260241 - Pre: Add compress option to Jarrer.add. r=glandium (07e96dafee)
- Bug 1212427 - Reference extra Python paths in Sphinx config; r=mshal (8d2595fd10)
- Bug 1252294 - Add python/futures to sys.path when building Sphinx docs; r=chmanchester (78f2010814)
- Bug 1241398 - Remove the FilePurger class. r=gps (4852afa2db)
- No Bug - Add python/futures to mach search paths to avoid exception when running mach build or mach test. r=gps DONTBUILD (00dbc53adb)
- Bug 1252601 - Handle requests errors gracefully when submitting telemetry data r=gps (aaf93000d3)
- Bug 1250656 - Don't block mach command completion when submitting build telemetry data r=gps (eb0566eff4)
- Bug 1213959 - Set SHELL in Read the Docs environment; r=ted (eb960eb450)
- Bug 1175895 - separate tier start message for mach; r=ted (cd56ddae05)
- Bug 1077670 - Package tests in parallel. r=gps (28b531ba3d)
- Bug 1195870 - Upload android multi apk to Taskcluster; r=jlund (b934b74abb)
- Bug 1149164 - Report stripped size of libxul.so in treeherder builds;# (c987d5b361)
- Bug 1139911 - Set proper buildbot status on make-check errors and test failures, r=chmanchester (31fad0c64c)
- Bug 1217431 - Don't get 'latest' URLs for android updates; r=jlund (0af5cb0aaa)
- Bug 1247375 - Part 1: Add TaskCluster job building Fennec with --disable-compile-environment. r=dustin (2307971041)
- bug 1202811 - Invoke mozharness with python 2.7 from build-linux.sh. r=dustin (0f76400e1a)
- Bug 1231320: pull from secrets API in TaskCluster r=garndt,mshal,pmoore (f48267b79f)
- Bug 1198173 - Intermittent failures trying to clone tooltool. r=dustin (8fbc340092)
- Bug 1220684: use namespaced docker-worker caches; r=garndt (82f8ecf9d4)
- Bug 1226413 - Allow task images to be built upon push r=wcosta (01332cb4ac)
- Bug 1145682 - Remove commit descriptions from decision tasks r=me a=taskcluster-only (50ad583085)
- Bug 1140546 - Add automatic reruns to decision tasks r=me a=taskcluster-only (021cfe8bc2)
- Bug 1143069 - Add symbol to task graph for branch configs r=garndt (1c4d35b939)
- Bug 1169797: send decision tasks to production treeherder, too; r=lightsofapollo, r=ryanvm (89307f0ee6)
- Bug 1245538 - index decision task in taskcluster. r=dustin (264fe43463)
- Bug 1139590 - Do not escape source in decision task r=me a=taskcluster-only (02620c615b)
- Bug 1236655 - Use builder 0.5.11 image for decision tasks r=wcosta (84e0bd217d)
- Bug 1257619 - Add revision and revision_hash information to tasks r=dustin (a68f16782b)
- Bug 1140981 - Remove comment from task name in try decision task r=me a=taskcluster-only (89c4558261)
- Bug 1234076 - upgrade tc-vcs to 2.3.17 r=wcosta (46b7e181d1)
- Bug 1231318: pass MOZ_BUILD_DATE to builds based on pushdate; r=jlund (26b3a32288)
- bug 1238009 - in-tree tasks should link their source to the yml file they were generated from. r=dustin (04d42dfdd2)
- Bug 1264652 - Add scope to extend task graph to the decision task r=dustin (2969af45a7)
- Bug 1237740 - Fix build.sh error message typo. r=wcosta DONTBUILD (7a2c6b52f7)
- Bug 1212877: improve build.sh to run from any directory; r=wcosta DONTBUILD (18edc840df)
- bit of 1226413 (b580943caf)
- Bug 1237681: build desktop-build and desktop-test on demand; r=wcosta (f30d2d0fec)
- Bug 957951 - Use mach to invoke printconfigsetting.py. r=jlund (dfd953692e)
- Bug 1253478 - Use Atomic<uint64_t> in AsyncTransactionTracker r=nical (c1f2cf892f)
- Bug 1150338 - Use the tooltool gcc in automation rather than /tools, r=terrence (15f1fa12bc)
- Bug 1259848 - Various fixes for finding gcc in the correct location for spidermonkey TC builds and hazard shell builds, r=terrence (9963274899)
2024-07-12 10:33:28 +08:00

226 lines
6.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 "nsFormControlFrame.h"
#include "nsGkAtoms.h"
#include "nsLayoutUtils.h"
#include "nsIDOMHTMLInputElement.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/LookAndFeel.h"
#include "nsDeviceContext.h"
#include "nsIContent.h"
using namespace mozilla;
//#define FCF_NOISY
nsFormControlFrame::nsFormControlFrame(nsStyleContext* aContext)
: nsAtomicContainerFrame(aContext)
{
}
nsFormControlFrame::~nsFormControlFrame()
{
}
nsIAtom*
nsFormControlFrame::GetType() const
{
return nsGkAtoms::formControlFrame;
}
void
nsFormControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
// Unregister the access key registered in reflow
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
nsAtomicContainerFrame::DestroyFrom(aDestructRoot);
}
NS_QUERYFRAME_HEAD(nsFormControlFrame)
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsAtomicContainerFrame)
/* virtual */ nscoord
nsFormControlFrame::GetMinISize(nsRenderingContext *aRenderingContext)
{
nscoord result;
DISPLAY_MIN_WIDTH(this, result);
result = GetIntrinsicISize();
return result;
}
/* virtual */ nscoord
nsFormControlFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
{
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
result = GetIntrinsicISize();
return result;
}
/* virtual */
LogicalSize
nsFormControlFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
WritingMode aWM,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
const LogicalSize& aMargin,
const LogicalSize& aBorder,
const LogicalSize& aPadding,
bool aShrinkWrap)
{
const WritingMode wm = GetWritingMode();
LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
return result.ConvertTo(aWM, wm);
}
nscoord
nsFormControlFrame::GetIntrinsicISize()
{
// Provide a reasonable default for sites that use an "auto" height.
// Note that if you change this, you should change the values in forms.css
// as well. This is the 13px default width minus the 2px default border.
return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2);
}
nscoord
nsFormControlFrame::GetIntrinsicBSize()
{
// Provide a reasonable default for sites that use an "auto" height.
// Note that if you change this, you should change the values in forms.css
// as well. This is the 13px default width minus the 2px default border.
return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2);
}
nscoord
nsFormControlFrame::GetLogicalBaseline(WritingMode aWritingMode) const
{
NS_ASSERTION(!NS_SUBTREE_DIRTY(this),
"frame must not be dirty");
// Treat radio buttons and checkboxes as having an intrinsic baseline
// at the block-end of the control (use the block-end content edge rather
// than the margin edge).
// For "inverted" lines (typically in writing-mode:vertical-lr), use the
// block-start end instead.
return aWritingMode.IsLineInverted()
? GetLogicalUsedBorderAndPadding(aWritingMode).BStart(aWritingMode)
: BSize(aWritingMode) -
GetLogicalUsedBorderAndPadding(aWritingMode).BEnd(aWritingMode);
}
void
nsFormControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFormControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsFormControlFrame::Reflow: aMaxSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
if (mState & NS_FRAME_FIRST_REFLOW) {
RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
}
aStatus = NS_FRAME_COMPLETE;
aDesiredSize.SetSize(aReflowState.GetWritingMode(),
aReflowState.ComputedSizeWithBorderPadding());
if (nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
aDesiredSize.Width() *= inflation;
aDesiredSize.Height() *= inflation;
}
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("exit nsFormControlFrame::Reflow: size=%d,%d",
aDesiredSize.Width(), aDesiredSize.Height()));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
aDesiredSize.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aDesiredSize);
}
nsresult
nsFormControlFrame::RegUnRegAccessKey(nsIFrame * aFrame, bool aDoReg)
{
NS_ENSURE_ARG_POINTER(aFrame);
nsPresContext* presContext = aFrame->PresContext();
NS_ASSERTION(presContext, "aPresContext is NULL in RegUnRegAccessKey!");
nsAutoString accessKey;
nsIContent* content = aFrame->GetContent();
content->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
if (!accessKey.IsEmpty()) {
EventStateManager* stateManager = presContext->EventStateManager();
if (aDoReg) {
stateManager->RegisterAccessKey(content, (uint32_t)accessKey.First());
} else {
stateManager->UnregisterAccessKey(content, (uint32_t)accessKey.First());
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
void
nsFormControlFrame::SetFocus(bool aOn, bool aRepaint)
{
}
nsresult
nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
// Check for user-input:none style
const nsStyleUserInterface* uiStyle = StyleUserInterface();
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
return NS_OK;
}
void
nsFormControlFrame::GetCurrentCheckState(bool *aState)
{
nsCOMPtr<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(mContent);
if (inputElement) {
inputElement->GetChecked(aState);
}
}
nsresult
nsFormControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
{
return NS_OK;
}
// static
nsRect
nsFormControlFrame::GetUsableScreenRect(nsPresContext* aPresContext)
{
nsRect screen;
nsDeviceContext *context = aPresContext->DeviceContext();
int32_t dropdownCanOverlapOSBar =
LookAndFeel::GetInt(LookAndFeel::eIntID_MenusCanOverlapOSBar, 0);
if ( dropdownCanOverlapOSBar )
context->GetRect(screen);
else
context->GetClientRect(screen);
return screen;
}