mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
09bea9b394
- Bug 1215921 - Range Analysis: Recover observable operands if they are recoverable. r=jandem,sunfish (5d0387ba66)
- Bug 1221923 - Remove pointless "initialized" static in VMFunction::addToFunctions; r=Waldo (fbf61fff54)
- Bug 12228397 - Bail out when dividing large unsigned integer by one. r=sunfish (cbd9d34bcf)
- Bug 1229292 - IonMonkey: MIPS64: Fix skip nops in conditional branches. r=huangwenjun06 (2244600084)
- Bug 1090957 - IonMonkey: MIPS: Implement atomics in MacroAssembler. r=lth (29399e4a33)
- Bug 1229989 - IonMonkey: MIPS: Fix patchCall for mips32. r=luke (1ae6f20686)
- Bug 1213747 - IonMonkey: MIPS: Import MIPS64 support into MoveEmitter-mips-shared. r=nbp f=rankov (16d46fe32e)
- Bug 1233863 - ARM64: Record the correct branch offset. r=sstangl (b2f940056e)
- Bug 1233884 - Remove unused CompactBufferWriters from MozBaseAssembler. r=jolesen (e37860be67)
- Bug 1233863 - ARM64: Avoid BumpSystemStackPointer(). r=sstangl (5c06e601c1)
- Bug 1229802 - Simplify MacroAssemblerARMCompat::decBranchPtr. r=nbp (a908c62e5b)
- bit of Bug 1217515 - Clean up the way touch event support is configured (2cfd0e4c65)
- Bug 1221459 - Remove SelectionStateChangedEvent. r=mtseng, r=smaug (9a827ab9fc)
- Bug 1209479 - Map Android back button to nsIWebNavigation::GoBack() for the current active frame r=fabrice (be41e7b8da)
- Bug 1165841 - Part 1: add window into nsINfcEventListener. r=dimi (475a56ab28)
- Bug 1165841 - Part 2: move window-related code to nsNfc.js. r=dimi (e2a0487b75)
- Bug 1165841 - Part 3: remove _rfState and init from NfcContentHelper. r=dimi (b8be95012d)
- Bug 1165841 - Part 4: using eventListeners. r=dimi (a22ff6d56c)
- Bug 1165841 - Part 5: remove listener when window is destroyed. r=dimi (48716e2ba1)
- Bug 1168292 - Part 1: update SYSTEM_APP_ID. r=dimi (ecdbbefb03)
- Bug 1168292 - Part 2: notify listener with correct tabId. r=dimi (4fb26c705e)
- Bug 1168292 - Part 3: add tabId in notifyUserAccepted. r=dimi (1b36a15b65)
- Bug 1170053 - [Aries] Not able to share a picture using NFC. r=yoshi (0b80df2866)
- Bug 1172159 - [NFC] Introduce getFocusTabId function. r=allstars.chh (b917d0dac7)
- Bug 1168704 - Rename setFocusApp in nslNfcContentHelper. r=yoshi (9918707442)
- more missing of Bug 1209479 (6480ccc315)
- Bug 1166210 - Remove ServicesSetting changes listener in NfcContentHelper. r=yoshi (6e8f388637)
- Bug 1121900 - [flatfish] build break by "error: undefined reference to 'mozilla::dom::MozIsoDepTech::mTechnology'". r=yoshi (b5aaaada08)
- Bug 976457 - B2G NFC: API for supporting NFC_A tags. r=yoshi r=smaug (b908a5d60a)
- Bug 1156208 - this.nfc.getErrorMessage is not a function. r=dimi (42e33fcfc9)
- Bug 1225701 - Add comments in TouchCaret and SelectionCarets for their obsolescence. r=mtseng (ba85234c0e)
- Bug 1210341 - (v3) Reduce accessiblecaret size. r=TYLin Bug 1221459 - Remove TouchCaret and SelectionCarets. r=mtseng, r=roc (ad6282ff96)
- Bug 1216986 - Fix usage of nsIURI.host in password manager and prompt code to support IPv6. r=dolske,liuche,kanru (cec90a6251)
- Bug 962249 part 1 - Add Element.scroll{Top,Left}Min (chrome-only) and convert most of scrollLeftMax uses and part of scrollTopMax uses to combinations with the new properties. r=roc,bz (13ed8ee58f)
- Bug 962249 part 3 - Add Window.scrollMin{X,Y} (chrome-only) and conve… (b9b6e6aa8f)
- Bug 918771 - Part 1: Move Fragment Serialization logic into nsContentUtils::SerializeNodeToMarkup, r=bz (865ea1d334)
- Bug 918771 - Part 2: Send text/html as MIME type for XHR send() of HTML document, r=bz (129b8d4115)
- Bug 918771 - Part 3: Update Web Platform tests to check for correct behavior, r=bz (ed0536f5b8)
- Bug 1085284 - Implement URLSearchParams iterable<>, r=bz (db1edd6d74)
- Bug 1224643. Fix handling of U+0000 in URLSearchParams serialization. r=baku (55856e5353)
- Bug 1224580. Copy of URLSearchParams should not copy its observer pointer. r=baku (1a5d859de5)
- Bug 1153145 - Ensure trusted focus events from web content focus plugins. r=smaug (d79fb35d4b)
- Bug 1183901, properly support WrapperCache on DistributedContentList, r=wchen (f15879c8ca)
- Bug 1188887: P1. Allow seeking when readyState is HAVE_NOTHING. r=jwwang (aa33721a44)
- Bug 1188887: P2. Add mochitest testing new seek behavior. r=jwwang (0520088343)
- Bug 1232223 - Part 6: Remove function prototype for undefined function IsAudioAPIEnabled(). r=jya (5126eb83ed)
- Bug 1232223 - Part 5: Run wave tests unconditionally. r=jya (668e6b9b77)
- Bug 1232223 - Part 1: Remove MOZ_WEBM #ifdefs because WebM is always supported, though not necessarily enabled. r=jya r=glandium (b3ec44f5bc)
- Bug 1232223 - Part 2: Remove MOZ_VPX #ifdefs because VPx is always supported, though not necessarily enabled. r=jya (c8853a16c4)
- Bug 1232223 - Part 3: Remove MOZ_WAVE #ifdefs because Wave is always supported. r=jya (e5c18f912c)
- Bug 1232223 - Part 4: Run webm tests unconditionally. r=jya (a81ab83b00)
- fix (9d9acad7f8)
- bug 1169640 - use nsIPrompt instead of nsIPromptService for insecure form submission r=mrbkap (1091d0d839)
- Bug 1231919 - crash in mozilla::a11y::DocAccessible::ValidateARIAOwned, r=davidb (3466d77e14)
- bug 1172538 - make sure a document has an IPC actor before shutting it down r=davidb, lsocks (823a447f7f)
- Bug 1147646 - Crash in mozilla::a11y::DocAccessible::ProcessContentInserted while stability testing, r=davidb (c9e4e7ef2f)
- Bug 1230118 - added asserts on aOwner and aOwner->Elm() r=surkov (94295ffd61)
- Bug 1213281 - crash in mozilla::a11y::DocAccessible::UpdateTreeOnInsertion, r=davidb (6442f927cd)
- bug 1196460 - add method to get wrapper of proxy for document containing this proxied accessible r=surkov (0cc7ff8758)
- Bug 1222174 - add override declarations in AccessibleWrap.h; r=tbsaunde (a8c1d0d3f3)
- bug 1187055 - check the proxy being destroyed has a wrapper before cleaning it up r=davidb (b73966446c)
- bug 1196460 - remove proxy's ids when they are destroyed r=surkov (3cbc9a8536)
- bug 1196372 - make GetHWNDFor() work with proxied accessibles r=surkov (28a6057913)
- Bug 1196460 - teach GetChildIDFor() to deal with proxied accessibles r=surkov (4746bfa128)
- bug 1199735 - remove event logging from the windows AccessibleWrap::HandleAccEvent r=davidb (869e18d13f)
- bug 1199735 - factor win event dispatch logic into its own function r=davidb (0a9704aa9d)
- bug 1196460 - create different proxy wrappers depending on the type of the proxy r=surkov (cd2d18ebdc)
- bug 1213327 - store interfaces a proxy implements on the Accessible wrapping it (406c9a3715)
- bug 1213606 - work around proxy's that don't have a wrapper for their document r=davidb (252a3ff2e7)
- bug 1192330 - update text change data for proxied text change events r=surkov (4deb371062)
- bug 1199735 - fire windows events on proxies r=davidb (6400387e71)
- bug 1186536 - Bail out of ProxyTextChangeEvent() if the proxy doesn't have a wrapper r=davidb (b40f69c77b)
- bug 1207862 - make WrapperFor() take a const ProxyAccessible * r=davidb (8e79dc6d75)
- bug 1213402 - fixup silly array , on windows r=me landing on a CLOSED TREE (33368af3af)
- bug 606080 - add class to generate unique 32 bit ids r=froydnj (ebf0888dcc)
- Bug 1231148 - Avoid requiring IDL files installed in $DIST/idl to run AccEventGen.py. r=ted (22078343ce)
- Bug 1229838 - rel=apple-touch-icon-precomposed should fire mozbrowsericonchange. r=fabrice (2a3e93da96)
- Bug 1231040 - Check for premulting better. - r=jrmuizel (811609bbb3)
- Bug 1224475 - Start agent after seeking. r=baku (a009b58f2c)
- Bug 1231557 - Use the URL Classifier in Media elements. r=cpearce,r=gcp (9f5503581d)
- bug 1228484 throw instead of capturing a second stream to a different graph r=roc (e762799424)
- Bug 1198435 - MediaElementTableCount now checks that the element is not present for URIs other than the expected one. r=rillian (838b1b886b)
- Bug 1224991 - Log format string mismatch the number of parameters. r=cpearce. (9cd2770bd2)
- Bug 1144409 - Encrypted event should be fired once per initData. r=cpearce (e50b380feb)
- Bug 1213589 part.1 Make ContentEventHandler::GetTextLength() and GetNativeTextLength() called only with a text node r=smaug (10955440a9)
- Bug 1213589 part.2 Clean up GenerateFlatTextContent(), GelerateFlatFontRanges() and GetFlatTextOffsetOfRange() of ContentEventHandler r=smaug (3f6bf987ff)
- Bug 1213589 part.3 ContentEventHandler::GetFlatTextLengthInRange() should handle specially when it's called by nsIMutationObserver::ContentRemoved() r=smaug (ed03499803)
- Bug 1213859 part.4 ContentEventHandler should use NS_NewPreContentIterator rathr than NS_NewContentIterator at converting between DOM tree and flattened text r=smaug (fe6e3b1114)
- Bug 1213589 part.5 Redesign the rules to create range in ContentEventHandler::SetRangeFromFlatTextOffset() r=smaug (edaa7baf87)
- Bug 1213589 part.6 ContentEventHandler should insert line breaks at open tag of elements except non-replaced inline elements r=smaug (c2e9cc11dc)
- Bug 1213589 part.7 Add new testcases to runSetSelectionEventTest() and runQueryTextContentEventTest() for checking the behavior with open tag r=smaug (bcea465e5e)
- Bug 1213589 part.8 When there are no nodes causing text, ContentEventHandler should set start of the editor root to start of the range r=smaug (a6d6b4d8d5)
- Bug 1213589 part.9 ContentEventHandler::ShouldBreakLineBefore() should return false if the content is unknown HTML element r=smaug (960936477f)
- Bug 1214164 - Don't honor all <option> descendants of <select>; r=bz (188bfe2b89)
- Bug 1228876. Correctly ignore nested optgroups even if an optgroup is inserted into another, existing, optgroup. r=mats (f2058c8b68)
- Bug 1193637 - Use IsMap() in HTMLImageElement::PreHandleEvent; r=mrbkap (6f2ef9da61)
- Bug 1160819 - ResponsiveImageSelector - improve some over-aggressive assertions (b5d40119ac)
- Bug 1233259, only in-document images should respond to viewport changes, r=mystor (eb448e258c)
- Bug 773429 - Remove dom.disable_image_src_set. r=khuey (fa06677726)
- Bug 1230110 - HTMLImageElement should call its superclass's DestroyContent(). r=smaug (bac1d12c65)
- Bug 1231245 - Fix logging of Matrix4x4. r=botond (f5c93b67cb)
- Bug 1208661 - Remove some no-longer-used debugging code. r=BenWa (2c86e3efd2)
- Bug 1228602 - Ensure that we pick up the presShell resolution from the layer if there isn't a metrics. r=botond (3c1835a022)
- Annotate FrameMetrics that are created for ScrollInfoLayers. (bug 1192919 part 1, r=kats) (5be0234333)
- Minimize the displayport for frames that must animate synchronously. (bug 1192919 part 2, r=kats) (5abc63e72d)
- Force a paint to be scheduled for scroll info layers. (bug 1192919 part 3, r=kats) (4ed61248c7)
- Bug 1141127 - When inside a slop area around the first touchstart, prevent touchmove events from going to content. r=botond (18fa91d74e)
- Bug 1174532 - Even if the APZC is not pannable, have a small slop area to consume touchmove events. r=botond (ff8e6f46fe)
- Bug 1208636 - Adjust displayport size based on available system memory. r=kats (d1ff9798b2)
- Bug 1232094 - Make some APZ prefs live. r=botond (d45207bc5b)
- Bug 1231168 - Disable memory-based displayport size adjustment by default. r=mchang (c17b445171)
- Turn apz.use_paint_duration off. (bug 1192919 part 4, r=kats) (dc094c9617)
- Bug 1170325 - Undo an unnecessary signature change to AsyncPanZoomAnimation::TakeDeferredTasks(). r=Waldo (62eafb38ef)
- Bug 1216355 - Ensure that if a repaint request is ignored due to a stale generation number the next repaint request doesn't get dropped. r=botond (c070172b48)
- Bug 1228407 - Rearrange some code by extracting a helper function. r=botond (ae53af7449)
- Bug 1228407 - Update existing smooth scroll animations with new destinations when possible, rather than canceling and restarting them. r=kip (c15022d920)
- Dispatch all APZ repaint requests immediately, and rely on content vsync. (bug 1192919 part 5, r=kats) (53ea2674c8)
- Bug 1230552 - Update some out-of-date comments and remove an old #undef. r=kats (16ba5a82e1)
- Bug 1230552 - Introduce a structure to group fling handoff state. r=kats (4f98893742)
- Bug 1230552 - Extend the immediate scroll handoff pref to apply to flings. r=kats (6b3d4fb0e5)
- Bug 1231228 - Correctly check for whether an APZC along the handoff chain is panned into overscroll. r=kats (bbaeb881af)
- Bug 1226920 - For instances of ForEachNode where we want to traverse the entire tree, use an action that returns void. r=botond (e42de54aea)
- Bug 1230552 - Make immediate scroll handoff for panning prefable. r=kats (89ddb8853a)
- Bug 1230552 - Fuzz a floating-point comparison to avoid an intermittent test failure. r=bustage (839bee076d)
- Bug 1231228 - Gtest. r=kats (e141ee97ef)
- Bug 1208973 - Move function bodies into .cpp file, and remove an unused one. r=botond (ef89b08738)
- Bug 1208973 - Refactor and add logging to TaskThrottler. r=botond (0a88091e20)
- Bug 1208973 - Ensure all code in TaskThrottler is threadsafe since it gets called from various threads. r=botond (9735621fd1)
- Bug 1213273 - Use a chromium Task instead of an nsITimer for the timeout in TaskThrottler. r=mstange (6cc9a9369e)
- Bug 1217251 - In TaskThrottler, dispatch the timeout task correctly from the Java UI thread on Android. r=kats (ee64d9458e)
- Bug 1230552 - Const-correctness improvements. r=kats (cc56f3404a)
- Bug 1230552 - Introduce a helper AsyncPanZoomController::CurrentInputBlock(). r=kats (4cef12a744)
- Remove the TaskThrottler. (bug 1192919 part 6, r=kats) (534312c146)
- Bug 1169695 - Advance the stored time when sampling the transform for a future frame. r=botod (3b08c07827)
- Bug 1169695 - Remove as many manual calls to spin the task queue as possible. r=botond (80c390ec7a)
- Bug 1218618 - Assert that the hit-testing tree's root node doesn't have siblings. r=kats (95ec1d07a7)
- Bug 1225178 - Don't start APZ drag if we don't have a displayport to handle it. r=kats (c29d4f962d)
- bit of End APZ wheel transactions when the mouse moves out of frame. (bug 1142866 part 2, r=kats,botond) (5a0c79d052)
- Bug 1226320 - Fix a refactoring in APZCTreeManager that didn't preserve semantics correctly. r=kats (35b92bd4a1)
655 lines
21 KiB
C++
655 lines
21 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
#ifndef mozilla_dom_HTMLSelectElement_h
|
|
#define mozilla_dom_HTMLSelectElement_h
|
|
|
|
#include "mozilla/Attributes.h"
|
|
#include "nsGenericHTMLElement.h"
|
|
#include "nsIDOMHTMLSelectElement.h"
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
|
#include "mozilla/dom/HTMLOptionsCollection.h"
|
|
#include "mozilla/ErrorResult.h"
|
|
#include "nsCheapSets.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsError.h"
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
|
#include "nsContentUtils.h"
|
|
|
|
class nsContentList;
|
|
class nsIDOMHTMLOptionElement;
|
|
class nsIHTMLCollection;
|
|
class nsISelectControlFrame;
|
|
class nsPresState;
|
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPostVisitor;
|
|
class EventChainPreVisitor;
|
|
|
|
namespace dom {
|
|
|
|
class HTMLSelectElement;
|
|
|
|
#define NS_SELECT_STATE_IID \
|
|
{ /* 4db54c7c-d159-455f-9d8e-f60ee466dbf3 */ \
|
|
0x4db54c7c, \
|
|
0xd159, \
|
|
0x455f, \
|
|
{0x9d, 0x8e, 0xf6, 0x0e, 0xe4, 0x66, 0xdb, 0xf3} \
|
|
}
|
|
|
|
/**
|
|
* The restore state used by select
|
|
*/
|
|
class SelectState : public nsISupports
|
|
{
|
|
public:
|
|
SelectState()
|
|
{
|
|
}
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_SELECT_STATE_IID)
|
|
NS_DECL_ISUPPORTS
|
|
|
|
void PutOption(int32_t aIndex, const nsAString& aValue)
|
|
{
|
|
// If the option is empty, store the index. If not, store the value.
|
|
if (aValue.IsEmpty()) {
|
|
mIndices.Put(aIndex);
|
|
} else {
|
|
mValues.Put(aValue);
|
|
}
|
|
}
|
|
|
|
bool ContainsOption(int32_t aIndex, const nsAString& aValue)
|
|
{
|
|
return mValues.Contains(aValue) || mIndices.Contains(aIndex);
|
|
}
|
|
|
|
private:
|
|
virtual ~SelectState()
|
|
{
|
|
}
|
|
|
|
nsCheapSet<nsStringHashKey> mValues;
|
|
nsCheapSet<nsUint32HashKey> mIndices;
|
|
};
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(SelectState, NS_SELECT_STATE_IID)
|
|
|
|
class MOZ_STACK_CLASS SafeOptionListMutation
|
|
{
|
|
public:
|
|
/**
|
|
* @param aSelect The select element which option list is being mutated.
|
|
* Can be null.
|
|
* @param aParent The content object which is being mutated.
|
|
* @param aKid If not null, a new child element is being inserted to
|
|
* aParent. Otherwise a child element will be removed.
|
|
* @param aIndex The index of the content object in the parent.
|
|
*/
|
|
SafeOptionListMutation(nsIContent* aSelect, nsIContent* aParent,
|
|
nsIContent* aKid, uint32_t aIndex, bool aNotify);
|
|
~SafeOptionListMutation();
|
|
void MutationFailed() { mNeedsRebuild = true; }
|
|
private:
|
|
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
|
static void operator delete(void*, size_t) {}
|
|
/** The select element which option list is being mutated. */
|
|
RefPtr<HTMLSelectElement> mSelect;
|
|
/** true if the current mutation is the first one in the stack. */
|
|
bool mTopLevelMutation;
|
|
/** true if it is known that the option list must be recreated. */
|
|
bool mNeedsRebuild;
|
|
/** Option list must be recreated if more than one mutation is detected. */
|
|
nsMutationGuard mGuard;
|
|
};
|
|
|
|
|
|
/**
|
|
* Implementation of <select>
|
|
*/
|
|
class HTMLSelectElement final : public nsGenericHTMLFormElementWithState,
|
|
public nsIDOMHTMLSelectElement,
|
|
public nsIConstraintValidation
|
|
{
|
|
public:
|
|
/**
|
|
* IS_SELECTED whether to set the option(s) to true or false
|
|
*
|
|
* CLEAR_ALL whether to clear all other options (for example, if you
|
|
* are normal-clicking on the current option)
|
|
*
|
|
* SET_DISABLED whether it is permissible to set disabled options
|
|
* (for JavaScript)
|
|
*
|
|
* NOTIFY whether to notify frames and such
|
|
*/
|
|
enum OptionType {
|
|
IS_SELECTED = 1 << 0,
|
|
CLEAR_ALL = 1 << 1,
|
|
SET_DISABLED = 1 << 2,
|
|
NOTIFY = 1 << 3
|
|
};
|
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
|
|
|
explicit HTMLSelectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|
FromParser aFromParser = NOT_FROM_PARSER);
|
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLSelectElement, select)
|
|
|
|
// nsISupports
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
virtual int32_t TabIndexDefault() override;
|
|
|
|
// Element
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// nsIDOMHTMLSelectElement
|
|
NS_DECL_NSIDOMHTMLSELECTELEMENT
|
|
|
|
// WebIdl HTMLSelectElement
|
|
bool Autofocus() const
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::autofocus);
|
|
}
|
|
void SetAutofocus(bool aVal, ErrorResult& aRv)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::autofocus, aVal, aRv);
|
|
}
|
|
void GetAutocomplete(DOMString& aValue);
|
|
void SetAutocomplete(const nsAString& aValue, ErrorResult& aRv)
|
|
{
|
|
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
|
|
}
|
|
bool Disabled() const
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
}
|
|
void SetDisabled(bool aVal, ErrorResult& aRv)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aVal, aRv);
|
|
}
|
|
HTMLFormElement* GetForm() const
|
|
{
|
|
return nsGenericHTMLFormElementWithState::GetForm();
|
|
}
|
|
bool Multiple() const
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::multiple);
|
|
}
|
|
void SetMultiple(bool aVal, ErrorResult& aRv)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::multiple, aVal, aRv);
|
|
}
|
|
// Uses XPCOM GetName.
|
|
void SetName(const nsAString& aName, ErrorResult& aRv)
|
|
{
|
|
SetHTMLAttr(nsGkAtoms::name, aName, aRv);
|
|
}
|
|
bool Required() const
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::required);
|
|
}
|
|
void SetRequired(bool aVal, ErrorResult& aRv)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::required, aVal, aRv);
|
|
}
|
|
uint32_t Size() const
|
|
{
|
|
return GetUnsignedIntAttr(nsGkAtoms::size, 0);
|
|
}
|
|
void SetSize(uint32_t aSize, ErrorResult& aRv)
|
|
{
|
|
SetUnsignedIntAttr(nsGkAtoms::size, aSize, aRv);
|
|
}
|
|
|
|
// Uses XPCOM GetType.
|
|
|
|
HTMLOptionsCollection* Options() const
|
|
{
|
|
return mOptions;
|
|
}
|
|
uint32_t Length() const
|
|
{
|
|
return mOptions->Length();
|
|
}
|
|
void SetLength(uint32_t aLength, ErrorResult& aRv);
|
|
Element* IndexedGetter(uint32_t aIdx, bool& aFound) const
|
|
{
|
|
return mOptions->IndexedGetter(aIdx, aFound);
|
|
}
|
|
HTMLOptionElement* Item(uint32_t aIdx) const
|
|
{
|
|
return mOptions->ItemAsOption(aIdx);
|
|
}
|
|
HTMLOptionElement* NamedItem(const nsAString& aName) const
|
|
{
|
|
return mOptions->GetNamedItem(aName);
|
|
}
|
|
void Add(const HTMLOptionElementOrHTMLOptGroupElement& aElement,
|
|
const Nullable<HTMLElementOrLong>& aBefore,
|
|
ErrorResult& aRv);
|
|
// Uses XPCOM Remove.
|
|
void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption,
|
|
ErrorResult& aRv)
|
|
{
|
|
mOptions->IndexedSetter(aIndex, aOption, aRv);
|
|
}
|
|
|
|
static bool MatchSelectedOptions(nsIContent* aContent, int32_t, nsIAtom*,
|
|
void*);
|
|
|
|
nsIHTMLCollection* SelectedOptions();
|
|
|
|
int32_t SelectedIndex() const
|
|
{
|
|
return mSelectedIndex;
|
|
}
|
|
void SetSelectedIndex(int32_t aIdx, ErrorResult& aRv)
|
|
{
|
|
aRv = SetSelectedIndexInternal(aIdx, true);
|
|
}
|
|
void GetValue(DOMString& aValue);
|
|
// Uses XPCOM SetValue.
|
|
|
|
// nsIConstraintValidation::WillValidate is fine.
|
|
// nsIConstraintValidation::Validity() is fine.
|
|
// nsIConstraintValidation::GetValidationMessage() is fine.
|
|
// nsIConstraintValidation::CheckValidity() is fine.
|
|
using nsIConstraintValidation::CheckValidity;
|
|
// nsIConstraintValidation::SetCustomValidity() is fine.
|
|
|
|
using nsINode::Remove;
|
|
|
|
|
|
// nsINode
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
// nsIContent
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
|
|
virtual nsresult PostHandleEvent(
|
|
EventChainPostVisitor& aVisitor) override;
|
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) override;
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
bool aNotify) override;
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
|
|
|
|
// Overriden nsIFormControl methods
|
|
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_SELECT; }
|
|
NS_IMETHOD Reset() override;
|
|
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
|
|
NS_IMETHOD SaveState() override;
|
|
virtual bool RestoreState(nsPresState* aState) override;
|
|
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
|
|
|
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
|
|
|
EventStates IntrinsicState() const override;
|
|
|
|
/**
|
|
* To be called when stuff is added under a child of the select--but *before*
|
|
* they are actually added.
|
|
*
|
|
* @param aOptions the content that was added (usually just an option, but
|
|
* could be an optgroup node with many child options)
|
|
* @param aParent the parent the options were added to (could be an optgroup)
|
|
* @param aContentIndex the index where the options are being added within the
|
|
* parent (if the parent is an optgroup, the index within the optgroup)
|
|
*/
|
|
NS_IMETHOD WillAddOptions(nsIContent* aOptions,
|
|
nsIContent* aParent,
|
|
int32_t aContentIndex,
|
|
bool aNotify);
|
|
|
|
/**
|
|
* To be called when stuff is removed under a child of the select--but
|
|
* *before* they are actually removed.
|
|
*
|
|
* @param aParent the parent the option(s) are being removed from
|
|
* @param aContentIndex the index of the option(s) within the parent (if the
|
|
* parent is an optgroup, the index within the optgroup)
|
|
*/
|
|
NS_IMETHOD WillRemoveOptions(nsIContent* aParent,
|
|
int32_t aContentIndex,
|
|
bool aNotify);
|
|
|
|
/**
|
|
* Checks whether an option is disabled (even if it's part of an optgroup)
|
|
*
|
|
* @param aIndex the index of the option to check
|
|
* @return whether the option is disabled
|
|
*/
|
|
NS_IMETHOD IsOptionDisabled(int32_t aIndex,
|
|
bool* aIsDisabled);
|
|
bool IsOptionDisabled(HTMLOptionElement* aOption);
|
|
|
|
/**
|
|
* Sets multiple options (or just sets startIndex if select is single)
|
|
* and handles notifications and cleanup and everything under the sun.
|
|
* When this method exits, the select will be in a consistent state. i.e.
|
|
* if you set the last option to false, it will select an option anyway.
|
|
*
|
|
* @param aStartIndex the first index to set
|
|
* @param aEndIndex the last index to set (set same as first index for one
|
|
* option)
|
|
* @param aOptionsMask determines whether to set, clear all or disable
|
|
* options and whether frames are to be notified of such.
|
|
* @return whether any options were actually changed
|
|
*/
|
|
bool SetOptionsSelectedByIndex(int32_t aStartIndex,
|
|
int32_t aEndIndex,
|
|
uint32_t aOptionsMask);
|
|
|
|
/**
|
|
* Finds the index of a given option element
|
|
*
|
|
* @param aOption the option to get the index of
|
|
* @param aStartIndex the index to start looking at
|
|
* @param aForward TRUE to look forward, FALSE to look backward
|
|
* @return the option index
|
|
*/
|
|
NS_IMETHOD GetOptionIndex(nsIDOMHTMLOptionElement* aOption,
|
|
int32_t aStartIndex,
|
|
bool aForward,
|
|
int32_t* aIndex);
|
|
|
|
/**
|
|
* Called when an attribute is about to be changed
|
|
*/
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
nsIContent* aBindingParent,
|
|
bool aCompileEventHandlers) override;
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
|
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
nsAttrValueOrString* aValue,
|
|
bool aNotify) override;
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
const nsAttrValue* aValue, bool aNotify) override;
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
bool aNotify) override;
|
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified) override;
|
|
virtual bool IsDoneAddingChildren() override {
|
|
return mIsDoneAddingChildren;
|
|
}
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
nsIAtom* aAttribute,
|
|
const nsAString& aValue,
|
|
nsAttrValue& aResult) override;
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
int32_t aModType) const override;
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSelectElement,
|
|
nsGenericHTMLFormElementWithState)
|
|
|
|
HTMLOptionsCollection* GetOptions()
|
|
{
|
|
return mOptions;
|
|
}
|
|
|
|
// nsIConstraintValidation
|
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
|
ValidityStateType aType) override;
|
|
|
|
void UpdateValueMissingValidityState();
|
|
/**
|
|
* Insert aElement before the node given by aBefore
|
|
*/
|
|
void Add(nsGenericHTMLElement& aElement, nsGenericHTMLElement* aBefore,
|
|
ErrorResult& aError);
|
|
void Add(nsGenericHTMLElement& aElement, int32_t aIndex, ErrorResult& aError)
|
|
{
|
|
// If item index is out of range, insert to last.
|
|
// (since beforeElement becomes null, it is inserted to last)
|
|
nsIContent* beforeContent = mOptions->GetElementAt(aIndex);
|
|
return Add(aElement, nsGenericHTMLElement::FromContentOrNull(beforeContent),
|
|
aError);
|
|
}
|
|
|
|
/**
|
|
* Is this a combobox?
|
|
*/
|
|
bool IsCombobox() const
|
|
{
|
|
return !Multiple() && Size() <= 1;
|
|
}
|
|
|
|
protected:
|
|
virtual ~HTMLSelectElement();
|
|
|
|
friend class SafeOptionListMutation;
|
|
|
|
// Helper Methods
|
|
/**
|
|
* Check whether the option specified by the index is selected
|
|
* @param aIndex the index
|
|
* @return whether the option at the index is selected
|
|
*/
|
|
bool IsOptionSelectedByIndex(int32_t aIndex);
|
|
/**
|
|
* Starting with (and including) aStartIndex, find the first selected index
|
|
* and set mSelectedIndex to it.
|
|
* @param aStartIndex the index to start with
|
|
*/
|
|
void FindSelectedIndex(int32_t aStartIndex, bool aNotify);
|
|
/**
|
|
* Select some option if possible (generally the first non-disabled option).
|
|
* @return true if something was selected, false otherwise
|
|
*/
|
|
bool SelectSomething(bool aNotify);
|
|
/**
|
|
* Call SelectSomething(), but only if nothing is selected
|
|
* @see SelectSomething()
|
|
* @return true if something was selected, false otherwise
|
|
*/
|
|
bool CheckSelectSomething(bool aNotify);
|
|
/**
|
|
* Called to trigger notifications of frames and fixing selected index
|
|
*
|
|
* @param aSelectFrame the frame for this content (could be null)
|
|
* @param aIndex the index that was selected or deselected
|
|
* @param aSelected whether the index was selected or deselected
|
|
* @param aChangeOptionState if false, don't do anything to the
|
|
* HTMLOptionElement at aIndex. If true, change
|
|
* its selected state to aSelected.
|
|
* @param aNotify whether to notify the style system and such
|
|
*/
|
|
void OnOptionSelected(nsISelectControlFrame* aSelectFrame,
|
|
int32_t aIndex,
|
|
bool aSelected,
|
|
bool aChangeOptionState,
|
|
bool aNotify);
|
|
/**
|
|
* Restore state to a particular state string (representing the options)
|
|
* @param aNewSelected the state string to restore to
|
|
*/
|
|
void RestoreStateTo(SelectState* aNewSelected);
|
|
|
|
// Adding options
|
|
/**
|
|
* Insert option(s) into the options[] array and perform notifications
|
|
* @param aOptions the option or optgroup being added
|
|
* @param aListIndex the index to start adding options into the list at
|
|
* @param aDepth the depth of aOptions (1=direct child of select ...)
|
|
*/
|
|
void InsertOptionsIntoList(nsIContent* aOptions,
|
|
int32_t aListIndex,
|
|
int32_t aDepth,
|
|
bool aNotify);
|
|
/**
|
|
* Remove option(s) from the options[] array
|
|
* @param aOptions the option or optgroup being added
|
|
* @param aListIndex the index to start removing options from the list at
|
|
* @param aDepth the depth of aOptions (1=direct child of select ...)
|
|
*/
|
|
nsresult RemoveOptionsFromList(nsIContent* aOptions,
|
|
int32_t aListIndex,
|
|
int32_t aDepth,
|
|
bool aNotify);
|
|
|
|
// nsIConstraintValidation
|
|
void UpdateBarredFromConstraintValidation();
|
|
bool IsValueMissing();
|
|
|
|
/**
|
|
* Get the index of the first option at, under or following the content in
|
|
* the select, or length of options[] if none are found
|
|
* @param aOptions the content
|
|
* @return the index of the first option
|
|
*/
|
|
int32_t GetOptionIndexAt(nsIContent* aOptions);
|
|
/**
|
|
* Get the next option following the content in question (not at or under)
|
|
* (this could include siblings of the current content or siblings of the
|
|
* parent or children of siblings of the parent).
|
|
* @param aOptions the content
|
|
* @return the index of the next option after the content
|
|
*/
|
|
int32_t GetOptionIndexAfter(nsIContent* aOptions);
|
|
/**
|
|
* Get the first option index at or under the content in question.
|
|
* @param aOptions the content
|
|
* @return the index of the first option at or under the content
|
|
*/
|
|
int32_t GetFirstOptionIndex(nsIContent* aOptions);
|
|
/**
|
|
* Get the first option index under the content in question, within the
|
|
* range specified.
|
|
* @param aOptions the content
|
|
* @param aStartIndex the first child to look at
|
|
* @param aEndIndex the child *after* the last child to look at
|
|
* @return the index of the first option at or under the content
|
|
*/
|
|
int32_t GetFirstChildOptionIndex(nsIContent* aOptions,
|
|
int32_t aStartIndex,
|
|
int32_t aEndIndex);
|
|
|
|
/**
|
|
* Get the frame as an nsISelectControlFrame (MAY RETURN nullptr)
|
|
* @return the select frame, or null
|
|
*/
|
|
nsISelectControlFrame* GetSelectFrame();
|
|
|
|
/**
|
|
* Helper method for dispatching ContentReset notifications to list
|
|
* and combo box frames.
|
|
*/
|
|
void DispatchContentReset();
|
|
|
|
/**
|
|
* Rebuilds the options array from scratch as a fallback in error cases.
|
|
*/
|
|
void RebuildOptionsArray(bool aNotify);
|
|
|
|
#ifdef DEBUG
|
|
void VerifyOptionsArray();
|
|
#endif
|
|
|
|
nsresult SetSelectedIndexInternal(int32_t aIndex, bool aNotify);
|
|
|
|
void SetSelectionChanged(bool aValue, bool aNotify);
|
|
|
|
/**
|
|
* Marks the selectedOptions list as dirty, so that it'll populate itself
|
|
* again.
|
|
*/
|
|
void UpdateSelectedOptions();
|
|
|
|
/**
|
|
* Return whether an element should have a validity UI.
|
|
* (with :-moz-ui-invalid and :-moz-ui-valid pseudo-classes).
|
|
*
|
|
* @return Whether the element should have a validity UI.
|
|
*/
|
|
bool ShouldShowValidityUI() const {
|
|
/**
|
|
* Always show the validity UI if the form has already tried to be submitted
|
|
* but was invalid.
|
|
*
|
|
* Otherwise, show the validity UI if the selection has been changed.
|
|
*/
|
|
if (mForm && mForm->HasEverTriedInvalidSubmit()) {
|
|
return true;
|
|
}
|
|
|
|
return mSelectionHasChanged;
|
|
}
|
|
|
|
/** The options[] array */
|
|
RefPtr<HTMLOptionsCollection> mOptions;
|
|
nsContentUtils::AutocompleteAttrState mAutocompleteAttrState;
|
|
/** false if the parser is in the middle of adding children. */
|
|
bool mIsDoneAddingChildren;
|
|
/** true if our disabled state has changed from the default **/
|
|
bool mDisabledChanged;
|
|
/** true if child nodes are being added or removed.
|
|
* Used by SafeOptionListMutation.
|
|
*/
|
|
bool mMutating;
|
|
/**
|
|
* True if DoneAddingChildren will get called but shouldn't restore state.
|
|
*/
|
|
bool mInhibitStateRestoration;
|
|
/**
|
|
* True if the selection has changed since the element's creation.
|
|
*/
|
|
bool mSelectionHasChanged;
|
|
/**
|
|
* True if the default selected option has been set.
|
|
*/
|
|
bool mDefaultSelectionSet;
|
|
/**
|
|
* True if :-moz-ui-invalid can be shown.
|
|
*/
|
|
bool mCanShowInvalidUI;
|
|
/**
|
|
* True if :-moz-ui-valid can be shown.
|
|
*/
|
|
bool mCanShowValidUI;
|
|
|
|
/** The number of non-options as children of the select */
|
|
uint32_t mNonOptionChildren;
|
|
/** The number of optgroups anywhere under the select */
|
|
uint32_t mOptGroupCount;
|
|
/**
|
|
* The current selected index for selectedIndex (will be the first selected
|
|
* index if multiple are selected)
|
|
*/
|
|
int32_t mSelectedIndex;
|
|
/**
|
|
* The temporary restore state in case we try to restore before parser is
|
|
* done adding options
|
|
*/
|
|
nsCOMPtr<SelectState> mRestoreState;
|
|
|
|
/**
|
|
* The live list of selected options.
|
|
*/
|
|
RefPtr<nsContentList> mSelectedOptions;
|
|
|
|
private:
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
nsRuleData* aData);
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_dom_HTMLSelectElement_h
|