mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-05 23:07:31 +09:00
Issue #2721 - Create special case exception for <A>.Click() outside of DOM
This removes the requirement for there to be a non-null PresShell to dispatch `Click()` events on `<A>` elements (only), since the exception to the rule has propagated to the spec. With these changes it should now be possible do create an anchor and `Click()` on it from JS without actually first attaching it to the DOM of the presented document, as abused by scripted downloads in pages (instead of using the A attribute to custom-name downloads).
This commit is contained in:
parent
72a17a5284
commit
37de431ac0
15 changed files with 79 additions and 94 deletions
|
|
@ -165,11 +165,10 @@ HTMLEditor::~HTMLEditor()
|
|||
// free any default style propItems
|
||||
RemoveAllDefaultProperties();
|
||||
|
||||
if (mLinkHandler && IsInitialized()) {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
|
||||
if (ps && ps->GetPresContext()) {
|
||||
ps->GetPresContext()->SetLinkHandler(mLinkHandler);
|
||||
if (mDisabledLinkHandling) {
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (doc) {
|
||||
doc->SetLinkHandlingEnabled(mOldLinkHandlingEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,13 +289,14 @@ HTMLEditor::Init(nsIDOMDocument* aDoc,
|
|||
mCSSEditUtils = MakeUnique<CSSEditUtils>(this);
|
||||
|
||||
// disable links
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
nsPresContext *context = presShell->GetPresContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!IsPlaintextEditor() && !IsInteractionAllowed()) {
|
||||
mLinkHandler = context->GetLinkHandler();
|
||||
context->SetLinkHandler(nullptr);
|
||||
mDisabledLinkHandling = true;
|
||||
mOldLinkHandlingEnabled = doc->LinkHandlingEnabled();
|
||||
doc->SetLinkHandlingEnabled(false);
|
||||
}
|
||||
|
||||
// init the type-in state
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class nsDocumentFragment;
|
|||
class nsIDOMKeyEvent;
|
||||
class nsITransferable;
|
||||
class nsIClipboard;
|
||||
class nsILinkHandler;
|
||||
class nsTableWrapperFrame;
|
||||
class nsIDOMRange;
|
||||
class nsRange;
|
||||
|
|
@ -1079,7 +1078,8 @@ protected:
|
|||
void AddMouseClickListener(nsIDOMElement* aElement);
|
||||
void RemoveMouseClickListener(nsIDOMElement* aElement);
|
||||
|
||||
nsCOMPtr<nsILinkHandler> mLinkHandler;
|
||||
bool mDisabledLinkHandling = false;
|
||||
bool mOldLinkHandlingEnabled = false;
|
||||
|
||||
public:
|
||||
friend class HTMLEditorEventListener;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue