layout/forms/nsFileControlFrame.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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
michael@0 6 #ifndef nsFileControlFrame_h___
michael@0 7 #define nsFileControlFrame_h___
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "nsBlockFrame.h"
michael@0 11 #include "nsIFormControlFrame.h"
michael@0 12 #include "nsIDOMEventListener.h"
michael@0 13 #include "nsIAnonymousContentCreator.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15
michael@0 16 class nsTextControlFrame;
michael@0 17 class nsIDOMDragEvent;
michael@0 18
michael@0 19 class nsFileControlFrame : public nsBlockFrame,
michael@0 20 public nsIFormControlFrame,
michael@0 21 public nsIAnonymousContentCreator
michael@0 22 {
michael@0 23 public:
michael@0 24 nsFileControlFrame(nsStyleContext* aContext);
michael@0 25
michael@0 26 virtual void Init(nsIContent* aContent,
michael@0 27 nsIFrame* aParent,
michael@0 28 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
michael@0 29
michael@0 30 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 31 const nsRect& aDirtyRect,
michael@0 32 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
michael@0 33
michael@0 34 NS_DECL_QUERYFRAME
michael@0 35 NS_DECL_FRAMEARENA_HELPERS
michael@0 36
michael@0 37 // nsIFormControlFrame
michael@0 38 virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
michael@0 39 virtual void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE;
michael@0 40
michael@0 41 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
michael@0 42
michael@0 43 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
michael@0 44
michael@0 45 #ifdef DEBUG_FRAME_DUMP
michael@0 46 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
michael@0 47 #endif
michael@0 48
michael@0 49 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
michael@0 50 nsIAtom* aAttribute,
michael@0 51 int32_t aModType) MOZ_OVERRIDE;
michael@0 52 virtual void ContentStatesChanged(mozilla::EventStates aStates) MOZ_OVERRIDE;
michael@0 53 virtual bool IsLeaf() const MOZ_OVERRIDE
michael@0 54 {
michael@0 55 return true;
michael@0 56 }
michael@0 57
michael@0 58 // nsIAnonymousContentCreator
michael@0 59 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
michael@0 60 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
michael@0 61 uint32_t aFilter) MOZ_OVERRIDE;
michael@0 62
michael@0 63 #ifdef ACCESSIBILITY
michael@0 64 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
michael@0 65 #endif
michael@0 66
michael@0 67 typedef bool (*AcceptAttrCallback)(const nsAString&, void*);
michael@0 68
michael@0 69 protected:
michael@0 70
michael@0 71 class MouseListener;
michael@0 72 friend class MouseListener;
michael@0 73 class MouseListener : public nsIDOMEventListener {
michael@0 74 public:
michael@0 75 NS_DECL_ISUPPORTS
michael@0 76
michael@0 77 MouseListener(nsFileControlFrame* aFrame)
michael@0 78 : mFrame(aFrame)
michael@0 79 {}
michael@0 80 virtual ~MouseListener() {}
michael@0 81
michael@0 82 void ForgetFrame() {
michael@0 83 mFrame = nullptr;
michael@0 84 }
michael@0 85
michael@0 86 protected:
michael@0 87 nsFileControlFrame* mFrame;
michael@0 88 };
michael@0 89
michael@0 90 class SyncDisabledStateEvent;
michael@0 91 friend class SyncDisabledStateEvent;
michael@0 92 class SyncDisabledStateEvent : public nsRunnable
michael@0 93 {
michael@0 94 public:
michael@0 95 SyncDisabledStateEvent(nsFileControlFrame* aFrame)
michael@0 96 : mFrame(aFrame)
michael@0 97 {}
michael@0 98
michael@0 99 NS_IMETHOD Run() MOZ_OVERRIDE {
michael@0 100 nsFileControlFrame* frame = static_cast<nsFileControlFrame*>(mFrame.GetFrame());
michael@0 101 NS_ENSURE_STATE(frame);
michael@0 102
michael@0 103 frame->SyncDisabledState();
michael@0 104 return NS_OK;
michael@0 105 }
michael@0 106
michael@0 107 private:
michael@0 108 nsWeakFrame mFrame;
michael@0 109 };
michael@0 110
michael@0 111 class DnDListener: public MouseListener {
michael@0 112 public:
michael@0 113 DnDListener(nsFileControlFrame* aFrame)
michael@0 114 : MouseListener(aFrame)
michael@0 115 {}
michael@0 116
michael@0 117 NS_DECL_NSIDOMEVENTLISTENER
michael@0 118
michael@0 119 static bool IsValidDropData(nsIDOMDragEvent* aEvent);
michael@0 120 };
michael@0 121
michael@0 122 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 123 {
michael@0 124 return nsBlockFrame::IsFrameOfType(aFlags &
michael@0 125 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
michael@0 126 }
michael@0 127
michael@0 128 /**
michael@0 129 * The text box input.
michael@0 130 * @see nsFileControlFrame::CreateAnonymousContent
michael@0 131 */
michael@0 132 nsCOMPtr<nsIContent> mTextContent;
michael@0 133 /**
michael@0 134 * The browse button input.
michael@0 135 * @see nsFileControlFrame::CreateAnonymousContent
michael@0 136 */
michael@0 137 nsCOMPtr<nsIContent> mBrowse;
michael@0 138
michael@0 139 /**
michael@0 140 * Drag and drop mouse listener.
michael@0 141 * This makes sure we don't get used after destruction.
michael@0 142 */
michael@0 143 nsRefPtr<DnDListener> mMouseListener;
michael@0 144
michael@0 145 protected:
michael@0 146 /**
michael@0 147 * Sync the disabled state of the content with anonymous children.
michael@0 148 */
michael@0 149 void SyncDisabledState();
michael@0 150
michael@0 151 /**
michael@0 152 * Updates the displayed value by using aValue.
michael@0 153 */
michael@0 154 void UpdateDisplayedValue(const nsAString& aValue, bool aNotify);
michael@0 155 };
michael@0 156
michael@0 157 #endif // nsFileControlFrame_h___

mercurial