| Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| index 60ef9c2598a6be301ff403ab218034e448a039c1..ffb9380785b26be5170b7f14c8c2b01e7c0cd5d7 100644
|
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| @@ -79,8 +79,14 @@ std::ostream& operator<<(std::ostream& os, PositionMoveType type) {
|
| return os << *it;
|
| }
|
|
|
| +bool isCheckingEditableStyleFromAX = false;
|
| +
|
| } // namespace
|
|
|
| +bool* checkingEditableStyleFromAXIndicator() {
|
| + return &isCheckingEditableStyleFromAX;
|
| +}
|
| +
|
| bool needsLayoutTreeUpdate(const Node& node) {
|
| const Document& document = node.document();
|
| if (document.needsLayoutTreeUpdate())
|
| @@ -271,18 +277,14 @@ int comparePositions(const VisiblePosition& a, const VisiblePosition& b) {
|
| }
|
|
|
| enum EditableLevel { Editable, RichlyEditable };
|
| -static bool hasEditableLevel(const Node& node, EditableLevel editableLevel) {
|
| - DCHECK(node.document().isActive());
|
| - // TODO(editing-dev): We should have this check:
|
| - // DCHECK_GE(node.document().lifecycle().state(),
|
| - // DocumentLifecycle::StyleClean);
|
| +
|
| +// TODO(editing-dev): Eliminate the code paths entering this function with dirty
|
| +// style, and replace it with hasEditableLevel. See crbug.com/667575
|
| +static bool hasEditableLevelDeprecated(const Node& node,
|
| + EditableLevel editableLevel) {
|
| if (node.isPseudoElement())
|
| return false;
|
|
|
| - // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but
|
| - // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
|
| - // would fire in the middle of Document::setFocusedNode().
|
| -
|
| for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(node)) {
|
| if ((ancestor.isHTMLElement() || ancestor.isDocumentNode()) &&
|
| ancestor.layoutObject()) {
|
| @@ -302,6 +304,43 @@ static bool hasEditableLevel(const Node& node, EditableLevel editableLevel) {
|
| return false;
|
| }
|
|
|
| +static bool hasEditableLevel(const Node& node, EditableLevel editableLevel) {
|
| + DCHECK(node.document().isActive());
|
| + DCHECK_GE(node.document().lifecycle().state(), DocumentLifecycle::StyleClean);
|
| + return hasEditableLevelDeprecated(node, editableLevel);
|
| +}
|
| +
|
| +bool canCheckEditableStyleCorrectly(const Node& node) {
|
| + Document& document = node.document();
|
| + if (document.lifecycle().state() >= DocumentLifecycle::StyleClean)
|
| + return true;
|
| + if (isCheckingEditableStyleFromAX) {
|
| + // See crbug.com/668590 for details.
|
| + // Reached by:
|
| + // fast/events/onchange-text-form-field.html
|
| + // fast/dom/search-shadow-host-crash.html
|
| + // editing/pasteboard/style-from-rules.html
|
| + // editing/style/inline-style-extend-run.html
|
| + // editing/undo/remove-css-property-and-remove-style.html
|
| + // editing/selection/first-letter-selection-crash.html
|
| + // editing/selection/extend-by-word-002.html
|
| + // fast/dynamic/checkbox-selection-crash.html
|
| + return false;
|
| + }
|
| + if (document.lifecycle().inDetach()) {
|
| + // fast/text/custom-font-data-crash2.html reaches here.
|
| + // See crbug.com/668586 for details.
|
| + return false;
|
| + }
|
| + if (document.nthIndexCache()) {
|
| + // imported/wpt/html/semantics/selectors/pseudo-classes/
|
| + // readwrite-readonly.html reaches here.
|
| + // See crbug.com/668592 for details.
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| bool hasEditableStyle(const Node& node) {
|
| // TODO(editing-dev): We shouldn't check editable style in inactive documents.
|
| // We should hoist this check in the call stack, replace it by a DCHECK of
|
| @@ -310,6 +349,11 @@ bool hasEditableStyle(const Node& node) {
|
| if (!node.document().isActive())
|
| return false;
|
|
|
| + if (!canCheckEditableStyleCorrectly(node))
|
| + return hasEditableLevelDeprecated(node, Editable);
|
| +
|
| + if (node.document().lifecycle().state() < DocumentLifecycle::StyleClean)
|
| + node.document().updateStyleAndLayoutTree();
|
| return hasEditableLevel(node, Editable);
|
| }
|
|
|
| @@ -321,6 +365,9 @@ bool hasRichlyEditableStyle(const Node& node) {
|
| if (!node.document().isActive())
|
| return false;
|
|
|
| + if (node.document().lifecycle().state() < DocumentLifecycle::StyleClean)
|
| + node.document().updateStyleAndLayoutTree();
|
| +
|
| return hasEditableLevel(node, RichlyEditable);
|
| }
|
|
|
|
|