Bug 1511563 - Don't make NAC editable by default. r=masayuki

I think this is a more consistent fix for the issue.

Differential Revision: https://phabricator.services.mozilla.com/D16521
This commit is contained in:
Emilio Cobos Álvarez 2019-01-14 17:03:55 +01:00
parent 54816c1c42
commit 729263c3df
5 changed files with 21 additions and 28 deletions

View file

@ -282,41 +282,20 @@ void Element::UpdateState(bool aNotify) {
} // namespace mozilla
void nsIContent::UpdateEditableState(bool aNotify) {
// Guaranteed to be non-element content
NS_ASSERTION(!IsElement(), "What happened here?");
nsIContent* parent = GetParent();
// Skip over unknown native anonymous content to avoid setting a flag we
// can't clear later
bool isUnknownNativeAnon = false;
if (IsInNativeAnonymousSubtree()) {
isUnknownNativeAnon = true;
nsCOMPtr<nsIContent> root = this;
while (root && !root->IsRootOfNativeAnonymousSubtree()) {
root = root->GetParent();
}
// root should always be true here, but isn't -- bug 999416
if (root) {
nsIFrame* rootFrame = root->GetPrimaryFrame();
if (rootFrame) {
nsContainerFrame* parentFrame = rootFrame->GetParent();
nsITextControlFrame* textCtrl = do_QueryFrame(parentFrame);
isUnknownNativeAnon = !textCtrl;
}
}
}
// Don't implicitly set the flag on the root of a native anonymous subtree.
// This needs to be set explicitly, see for example
// nsTextControlFrame::CreateRootNode().
SetEditableFlag(parent && parent->HasFlag(NODE_IS_EDITABLE) &&
!isUnknownNativeAnon);
!IsRootOfNativeAnonymousSubtree());
}
namespace mozilla {
namespace dom {
void Element::UpdateEditableState(bool aNotify) {
nsIContent* parent = GetParent();
SetEditableFlag(parent && parent->HasFlag(NODE_IS_EDITABLE));
nsIContent::UpdateEditableState(aNotify);
if (aNotify) {
UpdateState(aNotify);
} else {

View file

@ -153,9 +153,14 @@ inline bool nsINode::IsEditable() const {
return true;
}
Document* doc = GetUncomposedDoc();
// All editable anonymous content should be made explicitly editable via the
// NODE_IS_EDITABLE flag.
if (IsInNativeAnonymousSubtree()) {
return false;
}
// Check if the node is in a document and the document is in designMode.
Document* doc = GetUncomposedDoc();
return doc && doc->HasFlag(NODE_IS_EDITABLE);
}

View file

@ -0,0 +1,8 @@
<script>
document.addEventListener("DOMContentLoaded", function(){
document.designMode='on'
window.getSelection().modify('move', 'right', 'line')
})
</script>
<br>
<keygen>

View file

@ -556,3 +556,4 @@ pref(layout.css.column-span.enabled,true) load 1507244.html
load 1510080.html
load 1510485.html
pref(layout.css.column-span.enabled,true) load 1511535.html
load 1511563.html

View file

@ -406,7 +406,7 @@ function runBasicTest(aIsEditable, aInDesignMode, aDescription)
description: "input[type=file]",
focusable: !aInDesignMode,
focusEventNotFired: aIsEditable && !aInDesignMode,
expectedEnabled: kEnabledStateOnNonEditableElement },
expectedEnabled: kEnabledStateOnReadonlyField },
{ id: "button",
description: "input[type=button]",
focusable: !aInDesignMode,