Commit afd38807 authored by Tima Vaisburd's avatar Tima Vaisburd Committed by Commit Bot

[Smart Text] Disable surrounding text for input elements.

This CL effectively reverts
https://codereview.chromium.org/2907963002, which appears to
causing problems, including leaking of input fields to
Google servers.

Disabling until a better fix is found.

BUG=751408, 753579, 721840

Change-Id: Iecddba6ebed8faf3c266daa232613c57fa5a7464
Reviewed-on: https://chromium-review.googlesource.com/622747Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Tima Vaisburd <timav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495985}
parent 8a7267ff
...@@ -64,14 +64,11 @@ void SurroundingText::Initialize(const Position& start_position, ...@@ -64,14 +64,11 @@ void SurroundingText::Initialize(const Position& start_position,
return; return;
DCHECK(!document->NeedsLayoutTreeUpdate()); DCHECK(!document->NeedsLayoutTreeUpdate());
// The forward range starts at the selection end and ends at the document's // Do not create surrounding text for input elements.
// or the input element's end. It will then be updated to only contain the
// text in the right range around the selection.
DCHECK_EQ(RootEditableElementOf(start_position), DCHECK_EQ(RootEditableElementOf(start_position),
RootEditableElementOf(end_position)); RootEditableElementOf(end_position));
Element* const root_editable = RootEditableElementOf(start_position); if (RootEditableElementOf(start_position))
Element* const root_element = return;
root_editable ? root_editable : document->documentElement();
// Do not create surrounding text if start or end position is within a // Do not create surrounding text if start or end position is within a
// control. // control.
...@@ -81,9 +78,13 @@ void SurroundingText::Initialize(const Position& start_position, ...@@ -81,9 +78,13 @@ void SurroundingText::Initialize(const Position& start_position,
end_position.ComputeContainerNode())) end_position.ComputeContainerNode()))
return; return;
// The forward range starts at the selection end and ends at the document's
// end. It will then be updated to only contain the text in the right range
// around the selection.
CharacterIterator forward_iterator( CharacterIterator forward_iterator(
end_position, end_position,
Position::LastPositionInNode(*root_element).ParentAnchoredEquivalent(), Position::LastPositionInNode(*document->documentElement())
.ParentAnchoredEquivalent(),
TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build()); TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build());
if (!forward_iterator.AtEnd()) if (!forward_iterator.AtEnd())
forward_iterator.Advance(max_length - half_max_length); forward_iterator.Advance(max_length - half_max_length);
...@@ -92,7 +93,8 @@ void SurroundingText::Initialize(const Position& start_position, ...@@ -92,7 +93,8 @@ void SurroundingText::Initialize(const Position& start_position,
// starts at the document's or input element's start and ends at the selection // starts at the document's or input element's start and ends at the selection
// start and will be updated. // start and will be updated.
BackwardsCharacterIterator backwards_iterator( BackwardsCharacterIterator backwards_iterator(
Position::FirstPositionInNode(*root_element).ParentAnchoredEquivalent(), Position::FirstPositionInNode(*document->documentElement())
.ParentAnchoredEquivalent(),
start_position, start_position,
TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build()); TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build());
if (!backwards_iterator.AtEnd()) if (!backwards_iterator.AtEnd())
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "core/editing/Position.h" #include "core/editing/Position.h"
#include "core/editing/VisibleSelection.h" #include "core/editing/VisibleSelection.h"
#include "core/html/HTMLElement.h" #include "core/html/HTMLElement.h"
#include "core/html/TextControlElement.h"
#include "core/testing/DummyPageHolder.h" #include "core/testing/DummyPageHolder.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -286,24 +285,4 @@ TEST_F(SurroundingTextTest, TreeRangeSelection) { ...@@ -286,24 +285,4 @@ TEST_F(SurroundingTextTest, TreeRangeSelection) {
} }
} }
TEST_F(SurroundingTextTest, TextAreaSelection) {
SetHTML(
String("<p>First paragraph</p>"
"<textarea id='selection'>abc def ghi</textarea>"
"<p>Second paragraph</p>"));
TextControlElement* text_ctrl =
(TextControlElement*)GetDocument().getElementById("selection");
text_ctrl->SetSelectionRange(4, 7);
VisibleSelection selection = CreateVisibleSelection(text_ctrl->Selection());
SurroundingText surrounding_text(
*CreateRange(FirstEphemeralRangeOf(selection)), 20);
EXPECT_EQ("abc def ghi", surrounding_text.Content().SimplifyWhiteSpace());
EXPECT_EQ(4u, surrounding_text.StartOffsetInContent());
EXPECT_EQ(7u, surrounding_text.EndOffsetInContent());
}
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment