mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 589857 - Remove the nsFileControlFrame::mTextFrame member in favor of just retrieving it from the text input content when needed. r=bzbarsky
This commit is contained in:
parent
bea48586cb
commit
4c6039468a
@ -90,6 +90,7 @@
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "nsTextControlFrame.h"
|
||||
|
||||
#include "nsIDOMDOMStringList.h"
|
||||
#include "nsIDOMDragEvent.h"
|
||||
@ -108,8 +109,7 @@ NS_NewFileControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
NS_IMPL_FRAMEARENA_HELPERS(nsFileControlFrame)
|
||||
|
||||
nsFileControlFrame::nsFileControlFrame(nsStyleContext* aContext):
|
||||
nsBlockFrame(aContext),
|
||||
mTextFrame(nsnull)
|
||||
nsBlockFrame(aContext)
|
||||
{
|
||||
AddStateBits(NS_BLOCK_FLOAT_MGR);
|
||||
}
|
||||
@ -134,7 +134,6 @@ nsFileControlFrame::Init(nsIContent* aContent,
|
||||
void
|
||||
nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
||||
{
|
||||
mTextFrame = nsnull;
|
||||
ENSURE_TRUE(mContent);
|
||||
|
||||
// Remove the drag events
|
||||
@ -453,8 +452,9 @@ nsFileControlFrame::CaptureMouseListener::HandleEvent(nsIDOMEvent* aMouseEvent)
|
||||
rv = capturePicker->Init(win, title, mMode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Tell our textframe to remember the currently focused value
|
||||
mFrame->mTextFrame->InitFocusedValue();
|
||||
// Tell our text control frame to remember the currently focused value.
|
||||
nsTextControlFrame* textControlFrame = mFrame->GetTextControlFrame();
|
||||
textControlFrame->InitFocusedValue();
|
||||
|
||||
// Show dialog
|
||||
PRUint32 result;
|
||||
@ -486,16 +486,16 @@ nsFileControlFrame::CaptureMouseListener::HandleEvent(nsIDOMEvent* aMouseEvent)
|
||||
// uneditable text box with the file name inside.
|
||||
// Set new selected files
|
||||
if (newFiles.Count()) {
|
||||
// Tell mTextFrame that this update of the value is a user initiated
|
||||
// change. Otherwise it'll think that the value is being set by a script
|
||||
// and not fire onchange when it should.
|
||||
bool oldState = mFrame->mTextFrame->GetFireChangeEventState();
|
||||
mFrame->mTextFrame->SetFireChangeEventState(true);
|
||||
// Tell our text control frame that this update of the value is a user
|
||||
// initiated change. Otherwise it'll think that the value is being set by
|
||||
// a script and not fire onchange when it should.
|
||||
bool oldState = textControlFrame->GetFireChangeEventState();
|
||||
textControlFrame->SetFireChangeEventState(true);
|
||||
inputElement->SetFiles(newFiles, true);
|
||||
textControlFrame->SetFireChangeEventState(oldState);
|
||||
|
||||
mFrame->mTextFrame->SetFireChangeEventState(oldState);
|
||||
// May need to fire an onchange here
|
||||
mFrame->mTextFrame->CheckFireOnChange();
|
||||
textControlFrame->CheckFireOnChange();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -556,11 +556,12 @@ nsFileControlFrame::BrowseMouseListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
nsCOMPtr<nsIDOMFileList> fileList;
|
||||
dataTransfer->GetFiles(getter_AddRefs(fileList));
|
||||
|
||||
bool oldState = mFrame->mTextFrame->GetFireChangeEventState();
|
||||
mFrame->mTextFrame->SetFireChangeEventState(true);
|
||||
nsTextControlFrame* textControlFrame = mFrame->GetTextControlFrame();
|
||||
bool oldState = textControlFrame->GetFireChangeEventState();
|
||||
textControlFrame->SetFireChangeEventState(true);
|
||||
inputElement->SetFiles(fileList, true);
|
||||
mFrame->mTextFrame->SetFireChangeEventState(oldState);
|
||||
mFrame->mTextFrame->CheckFireOnChange();
|
||||
textControlFrame->SetFireChangeEventState(oldState);
|
||||
textControlFrame->CheckFireOnChange();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -594,55 +595,11 @@ nsFileControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFileControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
nsTextControlFrame*
|
||||
nsFileControlFrame::GetTextControlFrame()
|
||||
{
|
||||
DO_GLOBAL_REFLOW_COUNT("nsFileControlFrame");
|
||||
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
|
||||
if (mState & NS_FRAME_FIRST_REFLOW) {
|
||||
mTextFrame = GetTextControlFrame(aPresContext, this);
|
||||
NS_ENSURE_TRUE(mTextFrame, NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
// nsBlockFrame takes care of all our reflow
|
||||
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
|
||||
aStatus);
|
||||
}
|
||||
|
||||
nsNewFrame*
|
||||
nsFileControlFrame::GetTextControlFrame(nsPresContext* aPresContext, nsIFrame* aStart)
|
||||
{
|
||||
nsNewFrame* result = nsnull;
|
||||
#ifndef DEBUG_NEWFRAME
|
||||
// find the text control frame.
|
||||
nsIFrame* childFrame = aStart->GetFirstPrincipalChild();
|
||||
|
||||
while (childFrame) {
|
||||
// see if the child is a text control
|
||||
nsCOMPtr<nsIFormControl> formCtrl =
|
||||
do_QueryInterface(childFrame->GetContent());
|
||||
|
||||
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_TEXT) {
|
||||
result = (nsNewFrame*)childFrame;
|
||||
}
|
||||
|
||||
// if not continue looking
|
||||
nsNewFrame* frame = GetTextControlFrame(aPresContext, childFrame);
|
||||
if (frame)
|
||||
result = frame;
|
||||
|
||||
childFrame = childFrame->GetNextSibling();
|
||||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
return nsnull;
|
||||
#endif
|
||||
nsITextControlFrame* tc = do_QueryFrame(mTextContent->GetPrimaryFrame());
|
||||
return static_cast<nsTextControlFrame*>(tc);
|
||||
}
|
||||
|
||||
PRIntn
|
||||
|
@ -45,9 +45,7 @@
|
||||
#include "nsICapturePicker.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsTextControlFrame.h"
|
||||
typedef nsTextControlFrame nsNewFrame;
|
||||
|
||||
class nsTextControlFrame;
|
||||
class nsIDOMDragEvent;
|
||||
|
||||
class nsFileControlFrame : public nsBlockFrame,
|
||||
@ -75,11 +73,6 @@ public:
|
||||
|
||||
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
|
||||
|
||||
NS_IMETHOD Reflow(nsPresContext* aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
@ -106,8 +99,6 @@ public:
|
||||
typedef bool (*AcceptAttrCallback)(const nsAString&, void*);
|
||||
void ParseAcceptAttribute(AcceptAttrCallback aCallback, void* aClosure) const;
|
||||
|
||||
nsIFrame* GetTextFrame() { return mTextFrame; }
|
||||
|
||||
protected:
|
||||
|
||||
class MouseListener;
|
||||
@ -173,11 +164,6 @@ protected:
|
||||
|
||||
virtual PRIntn GetSkipSides() const;
|
||||
|
||||
/**
|
||||
* The text frame (populated on initial reflow).
|
||||
* @see nsFileControlFrame::Reflow
|
||||
*/
|
||||
nsNewFrame* mTextFrame;
|
||||
/**
|
||||
* The text box input.
|
||||
* @see nsFileControlFrame::CreateAnonymousContent
|
||||
@ -201,19 +187,11 @@ protected:
|
||||
nsRefPtr<BrowseMouseListener> mMouseListener;
|
||||
nsRefPtr<CaptureMouseListener> mCaptureMouseListener;
|
||||
|
||||
private:
|
||||
protected:
|
||||
/**
|
||||
* Find the first text frame child (first frame child whose content has input
|
||||
* type=text) of a frame.
|
||||
* XXX this is an awfully complicated implementation of something we could
|
||||
* likely do by just doing GetPrimaryFrame on mTextContent
|
||||
*
|
||||
* @param aPresContext the current pres context
|
||||
* @param aStart the parent frame to search children of
|
||||
* @return the text control frame, or null if not found
|
||||
*/
|
||||
nsNewFrame* GetTextControlFrame(nsPresContext* aPresContext,
|
||||
nsIFrame* aStart);
|
||||
nsTextControlFrame* GetTextControlFrame();
|
||||
|
||||
/**
|
||||
* Copy an attribute from file content to text and button content.
|
||||
|
Loading…
Reference in New Issue
Block a user