| Index: third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| index 4636b51ca279bced01f675cfab460ba2ab0074da..60324823b6e325a7f9c141e23f439f8ce9b9b3e1 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
|
| @@ -4,7 +4,7 @@
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions
|
| * are met:
|
| - * 1. Redistributions of source code must retain the above copyright
|
| + * 1. Redistributions of source code must retainsssshowTree the above copyright
|
| * notice, this list of conditions and the following disclaimer.
|
| * 2. Redistributions in binary form must reproduce the above copyright
|
| * notice, this list of conditions and the following disclaimer in the
|
| @@ -38,6 +38,7 @@
|
| #include "wtf/text/CString.h"
|
| #include "wtf/text/CharacterNames.h"
|
| #include "wtf/text/StringBuilder.h"
|
| +#include <ostream> // NOLINT
|
|
|
| namespace blink {
|
|
|
| @@ -854,8 +855,13 @@ void VisibleSelectionTemplate<Strategy>::updateIfNeeded()
|
| template <typename Strategy>
|
| void VisibleSelectionTemplate<Strategy>::validatePositionsIfNeeded()
|
| {
|
| - if (!isValidPosition(m_base) || !isValidPosition(m_extent) || !isValidPosition(m_start) || !isValidPosition(m_end))
|
| - validate();
|
| + if (!m_base.inShadowIncludingDocument() || !m_extent.inShadowIncludingDocument()) {
|
| + *this = VisibleSelectionTemplate();
|
| + return;
|
| + }
|
| + if (isValidPosition(m_base) && isValidPosition(m_extent) && isValidPosition(m_start) && isValidPosition(m_end))
|
| + return;
|
| + validate();
|
| }
|
|
|
| template <typename Strategy>
|
| @@ -892,28 +898,6 @@ bool VisibleSelectionTemplate<Strategy>::operator==(const VisibleSelectionTempla
|
| #ifndef NDEBUG
|
|
|
| template <typename Strategy>
|
| -void VisibleSelectionTemplate<Strategy>::debugPosition(const char* message) const
|
| -{
|
| - fprintf(stderr, "VisibleSelection (%s) ===============\n", message);
|
| -
|
| - if (m_baseIsFirst) {
|
| - m_start.debugPosition("start: ");
|
| - m_base.debugPosition("base: ");
|
| - m_end.debugPosition("end: ");
|
| - m_extent.debugPosition("extent: ");
|
| - } else {
|
| - m_start.debugPosition("start: ");
|
| - m_extent.debugPosition("extent: ");
|
| - m_end.debugPosition("end: ");
|
| - m_base.debugPosition("base: ");
|
| - }
|
| -
|
| - fprintf(stderr, "isDirectional=%s\n", isDirectional() ? "true" : "false");
|
| - fprintf(stderr, "affinity=%s\n", affinity() == TextAffinity::Downstream ? "DOWNSTREaM" : affinity() == TextAffinity::Upstream ? "UPSTREAM" : "UNKNOWN");
|
| - fprintf(stderr, "================================\n");
|
| -}
|
| -
|
| -template <typename Strategy>
|
| void VisibleSelectionTemplate<Strategy>::formatForDebugger(char* buffer, unsigned length) const
|
| {
|
| StringBuilder result;
|
| @@ -936,15 +920,18 @@ void VisibleSelectionTemplate<Strategy>::formatForDebugger(char* buffer, unsigne
|
| }
|
|
|
| template <typename Strategy>
|
| +void VisibleSelectionTemplate<Strategy>::debugPosition(const char* message) const
|
| +{
|
| + VLOG(0) << message << ' ' << *this;
|
| +}
|
| +
|
| +template <typename Strategy>
|
| void VisibleSelectionTemplate<Strategy>::showTreeForThis() const
|
| {
|
| - if (start().anchorNode()) {
|
| - start().anchorNode()->showTreeAndMark(start().anchorNode(), "S", end().anchorNode(), "E");
|
| - fputs("start: ", stderr);
|
| - start().showAnchorTypeAndOffset();
|
| - fputs("end: ", stderr);
|
| - end().showAnchorTypeAndOffset();
|
| - }
|
| + if (!start().anchorNode())
|
| + return;
|
| + start().anchorNode()->showTreeAndMark(start().anchorNode(), "S", end().anchorNode(), "E");
|
| + VLOG(0) << *this;
|
| }
|
|
|
| #endif
|
| @@ -952,6 +939,26 @@ void VisibleSelectionTemplate<Strategy>::showTreeForThis() const
|
| template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingStrategy>;
|
| template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingInFlatTreeStrategy>;
|
|
|
| +std::ostream& operator<<(std::ostream& ostream, const VisibleSelection& selection)
|
| +{
|
| + return ostream << "VisibleSelection(base=" << selection.base()
|
| + << " extent=" << selection.extent()
|
| + << " start=" << selection.start()
|
| + << " end=" << selection.end()
|
| + << selection.affinity()
|
| + << (selection.isDirectional() ? "Directional" : "NotDirectional") << ')';
|
| +}
|
| +
|
| +std::ostream& operator<<(std::ostream& ostream, const VisibleSelectionInFlatTree& selection)
|
| +{
|
| + return ostream << "VisibleSelection(base=" << selection.base()
|
| + << " extent=" << selection.extent()
|
| + << " start=" << selection.start()
|
| + << " end=" << selection.end()
|
| + << selection.affinity()
|
| + << (selection.isDirectional() ? "Directional" : "NotDirectional") << ')';
|
| +}
|
| +
|
| } // namespace blink
|
|
|
| #ifndef NDEBUG
|
|
|