Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef nsListControlFrame_h___ |
michael@0 | 6 | #define nsListControlFrame_h___ |
michael@0 | 7 | |
michael@0 | 8 | #ifdef DEBUG_evaughan |
michael@0 | 9 | //#define DEBUG_rods |
michael@0 | 10 | #endif |
michael@0 | 11 | |
michael@0 | 12 | #ifdef DEBUG_rods |
michael@0 | 13 | //#define DO_REFLOW_DEBUG |
michael@0 | 14 | //#define DO_REFLOW_COUNTER |
michael@0 | 15 | //#define DO_UNCONSTRAINED_CHECK |
michael@0 | 16 | //#define DO_PIXELS |
michael@0 | 17 | #endif |
michael@0 | 18 | |
michael@0 | 19 | #include "mozilla/Attributes.h" |
michael@0 | 20 | #include "nsGfxScrollFrame.h" |
michael@0 | 21 | #include "nsIFormControlFrame.h" |
michael@0 | 22 | #include "nsIListControlFrame.h" |
michael@0 | 23 | #include "nsISelectControlFrame.h" |
michael@0 | 24 | #include "nsAutoPtr.h" |
michael@0 | 25 | #include "nsSelectsAreaFrame.h" |
michael@0 | 26 | |
michael@0 | 27 | // X.h defines KeyPress |
michael@0 | 28 | #ifdef KeyPress |
michael@0 | 29 | #undef KeyPress |
michael@0 | 30 | #endif |
michael@0 | 31 | |
michael@0 | 32 | class nsIDOMHTMLSelectElement; |
michael@0 | 33 | class nsIDOMHTMLOptionsCollection; |
michael@0 | 34 | class nsIComboboxControlFrame; |
michael@0 | 35 | class nsPresContext; |
michael@0 | 36 | class nsListEventListener; |
michael@0 | 37 | |
michael@0 | 38 | namespace mozilla { |
michael@0 | 39 | namespace dom { |
michael@0 | 40 | class HTMLOptionElement; |
michael@0 | 41 | class HTMLOptionsCollection; |
michael@0 | 42 | } // namespace dom |
michael@0 | 43 | } // namespace mozilla |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * Frame-based listbox. |
michael@0 | 47 | */ |
michael@0 | 48 | |
michael@0 | 49 | class nsListControlFrame : public nsHTMLScrollFrame, |
michael@0 | 50 | public nsIFormControlFrame, |
michael@0 | 51 | public nsIListControlFrame, |
michael@0 | 52 | public nsISelectControlFrame |
michael@0 | 53 | { |
michael@0 | 54 | public: |
michael@0 | 55 | friend nsIFrame* NS_NewListControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 56 | |
michael@0 | 57 | NS_DECL_QUERYFRAME |
michael@0 | 58 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 59 | |
michael@0 | 60 | // nsIFrame |
michael@0 | 61 | virtual nsresult HandleEvent(nsPresContext* aPresContext, |
michael@0 | 62 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 63 | nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
michael@0 | 64 | |
michael@0 | 65 | virtual nsresult SetInitialChildList(ChildListID aListID, |
michael@0 | 66 | nsFrameList& aChildList) MOZ_OVERRIDE; |
michael@0 | 67 | |
michael@0 | 68 | virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 69 | virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 70 | |
michael@0 | 71 | virtual nsresult Reflow(nsPresContext* aCX, |
michael@0 | 72 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 73 | const nsHTMLReflowState& aReflowState, |
michael@0 | 74 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | virtual void Init(nsIContent* aContent, |
michael@0 | 77 | nsIFrame* aParent, |
michael@0 | 78 | nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
michael@0 | 79 | |
michael@0 | 80 | virtual nsresult DidReflow(nsPresContext* aPresContext, |
michael@0 | 81 | const nsHTMLReflowState* aReflowState, |
michael@0 | 82 | nsDidReflowStatus aStatus) MOZ_OVERRIDE; |
michael@0 | 83 | virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
michael@0 | 84 | |
michael@0 | 85 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 86 | const nsRect& aDirtyRect, |
michael@0 | 87 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 88 | |
michael@0 | 89 | virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE; |
michael@0 | 90 | |
michael@0 | 91 | /** |
michael@0 | 92 | * Get the "type" of the frame |
michael@0 | 93 | * |
michael@0 | 94 | * @see nsGkAtoms::scrollFrame |
michael@0 | 95 | */ |
michael@0 | 96 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 97 | |
michael@0 | 98 | virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
michael@0 | 99 | { |
michael@0 | 100 | return nsHTMLScrollFrame::IsFrameOfType(aFlags & |
michael@0 | 101 | ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 105 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 106 | #endif |
michael@0 | 107 | |
michael@0 | 108 | // nsIFormControlFrame |
michael@0 | 109 | virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; |
michael@0 | 110 | virtual void SetFocus(bool aOn = true, bool aRepaint = false) MOZ_OVERRIDE; |
michael@0 | 111 | |
michael@0 | 112 | virtual mozilla::ScrollbarStyles GetScrollbarStyles() const MOZ_OVERRIDE; |
michael@0 | 113 | virtual bool ShouldPropagateComputedHeightToScrolledContent() const MOZ_OVERRIDE; |
michael@0 | 114 | |
michael@0 | 115 | // for accessibility purposes |
michael@0 | 116 | #ifdef ACCESSIBILITY |
michael@0 | 117 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 118 | #endif |
michael@0 | 119 | |
michael@0 | 120 | // nsIListControlFrame |
michael@0 | 121 | virtual void SetComboboxFrame(nsIFrame* aComboboxFrame) MOZ_OVERRIDE; |
michael@0 | 122 | virtual int32_t GetSelectedIndex() MOZ_OVERRIDE; |
michael@0 | 123 | virtual mozilla::dom::HTMLOptionElement* GetCurrentOption() MOZ_OVERRIDE; |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Gets the text of the currently selected item. |
michael@0 | 127 | * If the there are zero items then an empty string is returned |
michael@0 | 128 | * If there is nothing selected, then the 0th item's text is returned. |
michael@0 | 129 | */ |
michael@0 | 130 | virtual void GetOptionText(uint32_t aIndex, nsAString& aStr) MOZ_OVERRIDE; |
michael@0 | 131 | |
michael@0 | 132 | virtual void CaptureMouseEvents(bool aGrabMouseEvents) MOZ_OVERRIDE; |
michael@0 | 133 | virtual nscoord GetHeightOfARow() MOZ_OVERRIDE; |
michael@0 | 134 | virtual uint32_t GetNumberOfOptions() MOZ_OVERRIDE; |
michael@0 | 135 | virtual void AboutToDropDown() MOZ_OVERRIDE; |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 139 | */ |
michael@0 | 140 | virtual void AboutToRollup() MOZ_OVERRIDE; |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * Dispatch a DOM onchange event synchroniously. |
michael@0 | 144 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 145 | */ |
michael@0 | 146 | virtual void FireOnChange() MOZ_OVERRIDE; |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Makes aIndex the selected option of a combobox list. |
michael@0 | 150 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 151 | */ |
michael@0 | 152 | virtual void ComboboxFinish(int32_t aIndex) MOZ_OVERRIDE; |
michael@0 | 153 | virtual void OnContentReset() MOZ_OVERRIDE; |
michael@0 | 154 | |
michael@0 | 155 | // nsISelectControlFrame |
michael@0 | 156 | NS_IMETHOD AddOption(int32_t index) MOZ_OVERRIDE; |
michael@0 | 157 | NS_IMETHOD RemoveOption(int32_t index) MOZ_OVERRIDE; |
michael@0 | 158 | NS_IMETHOD DoneAddingChildren(bool aIsDone) MOZ_OVERRIDE; |
michael@0 | 159 | |
michael@0 | 160 | /** |
michael@0 | 161 | * Gets the content (an option) by index and then set it as |
michael@0 | 162 | * being selected or not selected. |
michael@0 | 163 | */ |
michael@0 | 164 | NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) MOZ_OVERRIDE; |
michael@0 | 165 | NS_IMETHOD OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) MOZ_OVERRIDE; |
michael@0 | 166 | |
michael@0 | 167 | /** |
michael@0 | 168 | * Mouse event listeners. |
michael@0 | 169 | * @note These methods might destroy the frame, pres shell and other objects. |
michael@0 | 170 | */ |
michael@0 | 171 | nsresult MouseDown(nsIDOMEvent* aMouseEvent); |
michael@0 | 172 | nsresult MouseUp(nsIDOMEvent* aMouseEvent); |
michael@0 | 173 | nsresult MouseMove(nsIDOMEvent* aMouseEvent); |
michael@0 | 174 | nsresult DragMove(nsIDOMEvent* aMouseEvent); |
michael@0 | 175 | nsresult KeyDown(nsIDOMEvent* aKeyEvent); |
michael@0 | 176 | nsresult KeyPress(nsIDOMEvent* aKeyEvent); |
michael@0 | 177 | |
michael@0 | 178 | /** |
michael@0 | 179 | * Returns the options collection for mContent, if any. |
michael@0 | 180 | */ |
michael@0 | 181 | mozilla::dom::HTMLOptionsCollection* GetOptions() const; |
michael@0 | 182 | /** |
michael@0 | 183 | * Returns the HTMLOptionElement for a given index in mContent's collection. |
michael@0 | 184 | */ |
michael@0 | 185 | mozilla::dom::HTMLOptionElement* GetOption(uint32_t aIndex) const; |
michael@0 | 186 | |
michael@0 | 187 | static void ComboboxFocusSet(); |
michael@0 | 188 | |
michael@0 | 189 | // Helper |
michael@0 | 190 | bool IsFocused() { return this == mFocused; } |
michael@0 | 191 | |
michael@0 | 192 | /** |
michael@0 | 193 | * Function to paint the focus rect when our nsSelectsAreaFrame is painting. |
michael@0 | 194 | * @param aPt the offset of this frame, relative to the rendering reference |
michael@0 | 195 | * frame |
michael@0 | 196 | */ |
michael@0 | 197 | void PaintFocus(nsRenderingContext& aRC, nsPoint aPt); |
michael@0 | 198 | /** |
michael@0 | 199 | * If this frame IsFocused(), invalidates an area that includes anything |
michael@0 | 200 | * that PaintFocus will or could have painted --- basically the whole |
michael@0 | 201 | * GetOptionsContainer, plus some extra stuff if there are no options. This |
michael@0 | 202 | * must be called every time mEndSelectionIndex changes. |
michael@0 | 203 | */ |
michael@0 | 204 | void InvalidateFocus(); |
michael@0 | 205 | |
michael@0 | 206 | /** |
michael@0 | 207 | * Function to calculate the height a row, for use with the "size" attribute. |
michael@0 | 208 | * Can't be const because GetNumberOfOptions() isn't const. |
michael@0 | 209 | */ |
michael@0 | 210 | nscoord CalcHeightOfARow(); |
michael@0 | 211 | |
michael@0 | 212 | /** |
michael@0 | 213 | * Function to ask whether we're currently in what might be the |
michael@0 | 214 | * first pass of a two-pass reflow. |
michael@0 | 215 | */ |
michael@0 | 216 | bool MightNeedSecondPass() const { |
michael@0 | 217 | return mMightNeedSecondPass; |
michael@0 | 218 | } |
michael@0 | 219 | |
michael@0 | 220 | void SetSuppressScrollbarUpdate(bool aSuppress) { |
michael@0 | 221 | nsHTMLScrollFrame::SetSuppressScrollbarUpdate(aSuppress); |
michael@0 | 222 | } |
michael@0 | 223 | |
michael@0 | 224 | /** |
michael@0 | 225 | * Return whether the list is in dropdown mode. |
michael@0 | 226 | */ |
michael@0 | 227 | bool IsInDropDownMode() const; |
michael@0 | 228 | |
michael@0 | 229 | /** |
michael@0 | 230 | * Return the number of displayed rows in the list. |
michael@0 | 231 | */ |
michael@0 | 232 | uint32_t GetNumDisplayRows() const { return mNumDisplayRows; } |
michael@0 | 233 | |
michael@0 | 234 | /** |
michael@0 | 235 | * Return true if the drop-down list can display more rows. |
michael@0 | 236 | * (always false if not in drop-down mode) |
michael@0 | 237 | */ |
michael@0 | 238 | bool GetDropdownCanGrow() const { return mDropdownCanGrow; } |
michael@0 | 239 | |
michael@0 | 240 | /** |
michael@0 | 241 | * Dropdowns need views |
michael@0 | 242 | */ |
michael@0 | 243 | virtual bool NeedsView() MOZ_OVERRIDE { return IsInDropDownMode(); } |
michael@0 | 244 | |
michael@0 | 245 | /** |
michael@0 | 246 | * Frees statics owned by this class. |
michael@0 | 247 | */ |
michael@0 | 248 | static void Shutdown(); |
michael@0 | 249 | |
michael@0 | 250 | #ifdef ACCESSIBILITY |
michael@0 | 251 | /** |
michael@0 | 252 | * Post a custom DOM event for the change, so that accessibility can |
michael@0 | 253 | * fire a native focus event for accessibility |
michael@0 | 254 | * (Some 3rd party products need to track our focus) |
michael@0 | 255 | */ |
michael@0 | 256 | void FireMenuItemActiveEvent(); // Inform assistive tech what got focused |
michael@0 | 257 | #endif |
michael@0 | 258 | |
michael@0 | 259 | protected: |
michael@0 | 260 | /** |
michael@0 | 261 | * Updates the selected text in a combobox and then calls FireOnChange(). |
michael@0 | 262 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 263 | * Returns false if calling it destroyed |this|. |
michael@0 | 264 | */ |
michael@0 | 265 | bool UpdateSelection(); |
michael@0 | 266 | |
michael@0 | 267 | /** |
michael@0 | 268 | * Returns whether mContent supports multiple selection. |
michael@0 | 269 | */ |
michael@0 | 270 | bool GetMultiple() const { |
michael@0 | 271 | return mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::multiple); |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | |
michael@0 | 275 | /** |
michael@0 | 276 | * Toggles (show/hide) the combobox dropdown menu. |
michael@0 | 277 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 278 | */ |
michael@0 | 279 | void DropDownToggleKey(nsIDOMEvent* aKeyEvent); |
michael@0 | 280 | |
michael@0 | 281 | nsresult IsOptionDisabled(int32_t anIndex, bool &aIsDisabled); |
michael@0 | 282 | /** |
michael@0 | 283 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 284 | */ |
michael@0 | 285 | void ScrollToFrame(mozilla::dom::HTMLOptionElement& aOptElement); |
michael@0 | 286 | /** |
michael@0 | 287 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 288 | */ |
michael@0 | 289 | void ScrollToIndex(int32_t anIndex); |
michael@0 | 290 | |
michael@0 | 291 | /** |
michael@0 | 292 | * When the user clicks on the comboboxframe to show the dropdown |
michael@0 | 293 | * listbox, they then have to move the mouse into the list. We don't |
michael@0 | 294 | * want to process those mouse events as selection events (i.e., to |
michael@0 | 295 | * scroll list items into view). So we ignore the events until |
michael@0 | 296 | * the mouse moves below our border-inner-edge, when |
michael@0 | 297 | * mItemSelectionStarted is set. |
michael@0 | 298 | * |
michael@0 | 299 | * @param aPoint relative to this frame |
michael@0 | 300 | */ |
michael@0 | 301 | bool IgnoreMouseEventForSelection(nsIDOMEvent* aEvent); |
michael@0 | 302 | |
michael@0 | 303 | /** |
michael@0 | 304 | * If the dropdown is showing and the mouse has moved below our |
michael@0 | 305 | * border-inner-edge, then set mItemSelectionStarted. |
michael@0 | 306 | */ |
michael@0 | 307 | void UpdateInListState(nsIDOMEvent* aEvent); |
michael@0 | 308 | void AdjustIndexForDisabledOpt(int32_t aStartIndex, int32_t &anNewIndex, |
michael@0 | 309 | int32_t aNumOptions, int32_t aDoAdjustInc, int32_t aDoAdjustIncNext); |
michael@0 | 310 | |
michael@0 | 311 | /** |
michael@0 | 312 | * Resets the select back to it's original default values; |
michael@0 | 313 | * those values as determined by the original HTML |
michael@0 | 314 | */ |
michael@0 | 315 | virtual void ResetList(bool aAllowScrolling); |
michael@0 | 316 | |
michael@0 | 317 | nsListControlFrame(nsIPresShell* aShell, nsIDocument* aDocument, nsStyleContext* aContext); |
michael@0 | 318 | virtual ~nsListControlFrame(); |
michael@0 | 319 | |
michael@0 | 320 | /** |
michael@0 | 321 | * Sets the mSelectedIndex and mOldSelectedIndex from figuring out what |
michael@0 | 322 | * item was selected using content |
michael@0 | 323 | * @param aPoint the event point, in listcontrolframe coordinates |
michael@0 | 324 | * @return NS_OK if it successfully found the selection |
michael@0 | 325 | */ |
michael@0 | 326 | nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, int32_t& aCurIndex); |
michael@0 | 327 | |
michael@0 | 328 | bool CheckIfAllFramesHere(); |
michael@0 | 329 | bool IsLeftButton(nsIDOMEvent* aMouseEvent); |
michael@0 | 330 | |
michael@0 | 331 | // guess at a row height based on our own style. |
michael@0 | 332 | nscoord CalcFallbackRowHeight(float aFontSizeInflation); |
michael@0 | 333 | |
michael@0 | 334 | // CalcIntrinsicHeight computes our intrinsic height (taking the "size" |
michael@0 | 335 | // attribute into account). This should only be called in non-dropdown mode. |
michael@0 | 336 | nscoord CalcIntrinsicHeight(nscoord aHeightOfARow, int32_t aNumberOfOptions); |
michael@0 | 337 | |
michael@0 | 338 | // Dropped down stuff |
michael@0 | 339 | void SetComboboxItem(int32_t aIndex); |
michael@0 | 340 | |
michael@0 | 341 | /** |
michael@0 | 342 | * Method to reflow ourselves as a dropdown list. This differs from |
michael@0 | 343 | * reflow as a listbox because the criteria for needing a second |
michael@0 | 344 | * pass are different. This will be called from Reflow() as needed. |
michael@0 | 345 | */ |
michael@0 | 346 | nsresult ReflowAsDropdown(nsPresContext* aPresContext, |
michael@0 | 347 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 348 | const nsHTMLReflowState& aReflowState, |
michael@0 | 349 | nsReflowStatus& aStatus); |
michael@0 | 350 | |
michael@0 | 351 | // Selection |
michael@0 | 352 | bool SetOptionsSelectedFromFrame(int32_t aStartIndex, |
michael@0 | 353 | int32_t aEndIndex, |
michael@0 | 354 | bool aValue, |
michael@0 | 355 | bool aClearAll); |
michael@0 | 356 | bool ToggleOptionSelectedFromFrame(int32_t aIndex); |
michael@0 | 357 | /** |
michael@0 | 358 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 359 | */ |
michael@0 | 360 | bool SingleSelection(int32_t aClickedIndex, bool aDoToggle); |
michael@0 | 361 | bool ExtendedSelection(int32_t aStartIndex, int32_t aEndIndex, |
michael@0 | 362 | bool aClearAll); |
michael@0 | 363 | /** |
michael@0 | 364 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 365 | */ |
michael@0 | 366 | bool PerformSelection(int32_t aClickedIndex, bool aIsShift, |
michael@0 | 367 | bool aIsControl); |
michael@0 | 368 | /** |
michael@0 | 369 | * @note This method might destroy the frame, pres shell and other objects. |
michael@0 | 370 | */ |
michael@0 | 371 | bool HandleListSelection(nsIDOMEvent * aDOMEvent, int32_t selectedIndex); |
michael@0 | 372 | void InitSelectionRange(int32_t aClickedIndex); |
michael@0 | 373 | void PostHandleKeyEvent(int32_t aNewIndex, uint32_t aCharCode, |
michael@0 | 374 | bool aIsShift, bool aIsControlOrMeta); |
michael@0 | 375 | |
michael@0 | 376 | public: |
michael@0 | 377 | nsSelectsAreaFrame* GetOptionsContainer() const { |
michael@0 | 378 | return static_cast<nsSelectsAreaFrame*>(GetScrolledFrame()); |
michael@0 | 379 | } |
michael@0 | 380 | |
michael@0 | 381 | protected: |
michael@0 | 382 | nscoord HeightOfARow() { |
michael@0 | 383 | return GetOptionsContainer()->HeightOfARow(); |
michael@0 | 384 | } |
michael@0 | 385 | |
michael@0 | 386 | /** |
michael@0 | 387 | * @return how many displayable options/optgroups this frame has. |
michael@0 | 388 | */ |
michael@0 | 389 | uint32_t GetNumberOfRows(); |
michael@0 | 390 | |
michael@0 | 391 | // Data Members |
michael@0 | 392 | int32_t mStartSelectionIndex; |
michael@0 | 393 | int32_t mEndSelectionIndex; |
michael@0 | 394 | |
michael@0 | 395 | nsIComboboxControlFrame *mComboboxFrame; |
michael@0 | 396 | uint32_t mNumDisplayRows; |
michael@0 | 397 | bool mChangesSinceDragStart:1; |
michael@0 | 398 | bool mButtonDown:1; |
michael@0 | 399 | // Has the user selected a visible item since we showed the |
michael@0 | 400 | // dropdown? |
michael@0 | 401 | bool mItemSelectionStarted:1; |
michael@0 | 402 | |
michael@0 | 403 | bool mIsAllContentHere:1; |
michael@0 | 404 | bool mIsAllFramesHere:1; |
michael@0 | 405 | bool mHasBeenInitialized:1; |
michael@0 | 406 | bool mNeedToReset:1; |
michael@0 | 407 | bool mPostChildrenLoadedReset:1; |
michael@0 | 408 | |
michael@0 | 409 | //bool value for multiple discontiguous selection |
michael@0 | 410 | bool mControlSelectMode:1; |
michael@0 | 411 | |
michael@0 | 412 | // True if we're in the middle of a reflow and might need a second |
michael@0 | 413 | // pass. This only happens for auto heights. |
michael@0 | 414 | bool mMightNeedSecondPass:1; |
michael@0 | 415 | |
michael@0 | 416 | /** |
michael@0 | 417 | * Set to aPresContext->HasPendingInterrupt() at the start of Reflow. |
michael@0 | 418 | * Set to false at the end of DidReflow. |
michael@0 | 419 | */ |
michael@0 | 420 | bool mHasPendingInterruptAtStartOfReflow:1; |
michael@0 | 421 | |
michael@0 | 422 | // True if the drop-down can show more rows. Always false if this list |
michael@0 | 423 | // is not in drop-down mode. |
michael@0 | 424 | bool mDropdownCanGrow:1; |
michael@0 | 425 | |
michael@0 | 426 | // The last computed height we reflowed at if we're a combobox dropdown. |
michael@0 | 427 | // XXXbz should we be using a subclass here? Or just not worry |
michael@0 | 428 | // about the extra member on listboxes? |
michael@0 | 429 | nscoord mLastDropdownComputedHeight; |
michael@0 | 430 | |
michael@0 | 431 | // At the time of our last dropdown, the backstop color to draw in case we |
michael@0 | 432 | // are translucent. |
michael@0 | 433 | nscolor mLastDropdownBackstopColor; |
michael@0 | 434 | |
michael@0 | 435 | nsRefPtr<nsListEventListener> mEventListener; |
michael@0 | 436 | |
michael@0 | 437 | static nsListControlFrame * mFocused; |
michael@0 | 438 | static nsString * sIncrementalString; |
michael@0 | 439 | |
michael@0 | 440 | #ifdef DO_REFLOW_COUNTER |
michael@0 | 441 | int32_t mReflowId; |
michael@0 | 442 | #endif |
michael@0 | 443 | |
michael@0 | 444 | private: |
michael@0 | 445 | // for incremental typing navigation |
michael@0 | 446 | static nsAString& GetIncrementalString (); |
michael@0 | 447 | static DOMTimeStamp gLastKeyTime; |
michael@0 | 448 | |
michael@0 | 449 | class MOZ_STACK_CLASS AutoIncrementalSearchResetter |
michael@0 | 450 | { |
michael@0 | 451 | public: |
michael@0 | 452 | AutoIncrementalSearchResetter() : |
michael@0 | 453 | mCancelled(false) |
michael@0 | 454 | { |
michael@0 | 455 | } |
michael@0 | 456 | ~AutoIncrementalSearchResetter() |
michael@0 | 457 | { |
michael@0 | 458 | if (!mCancelled) { |
michael@0 | 459 | nsListControlFrame::GetIncrementalString().Truncate(); |
michael@0 | 460 | } |
michael@0 | 461 | } |
michael@0 | 462 | void Cancel() |
michael@0 | 463 | { |
michael@0 | 464 | mCancelled = true; |
michael@0 | 465 | } |
michael@0 | 466 | private: |
michael@0 | 467 | bool mCancelled; |
michael@0 | 468 | }; |
michael@0 | 469 | }; |
michael@0 | 470 | |
michael@0 | 471 | #endif /* nsListControlFrame_h___ */ |
michael@0 | 472 |