Bug 1181130 - Part 3: Keep track of editable descendants per node and prevent NS_STYLE_USER_SELECT_ALL selection for nodes with editable descendants. r=bz

This commit is contained in:
William Chen
2015-08-14 10:52:38 -07:00
parent d56752bb50
commit fe0c135b44
9 changed files with 250 additions and 2 deletions

View File

@@ -525,6 +525,14 @@ nsGenericHTMLElement::IntrinsicState() const
return state;
}
uint32_t
nsGenericHTMLElement::EditableInclusiveDescendantCount()
{
bool isEditable = IsInUncomposedDoc() && HasFlag(NODE_IS_EDITABLE) &&
GetContentEditableValue() == eTrue;
return EditableDescendantCount() + isEditable;
}
nsresult
nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
@@ -548,6 +556,7 @@ nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
aDocument->
AddToNameTable(this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
}
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue) {
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(aDocument);
if (htmlDocument) {
@@ -2917,6 +2926,12 @@ nsGenericHTMLElement::ChangeEditableState(int32_t aChange)
if (htmlDocument) {
htmlDocument->ChangeContentEditableCount(this, aChange);
}
nsIContent* parent = GetParent();
while (parent) {
parent->ChangeEditableDescendantCount(aChange);
parent = parent->GetParent();
}
}
if (document->HasFlag(NODE_IS_EDITABLE)) {