Skip to content

Commit

Permalink
Backed out 5 changesets (bug 1092888) because something in the push m…
Browse files Browse the repository at this point in the history
…ade Gij(2) permafail.

Backed out changeset 0ad25135a27f (bug 1092888)
Backed out changeset 7cd8260bfc16 (bug 1092888)
Backed out changeset 86385291d8c8 (bug 1092888)
Backed out changeset be16d194d5df (bug 1092888)
Backed out changeset daee46827258 (bug 1092888)
  • Loading branch information
rvandermeulen committed Dec 9, 2014
1 parent b2a40f8 commit 9dc33ba
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 50 deletions.
8 changes: 4 additions & 4 deletions editor/reftests/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ skip-if(Android||B2G) needs-focus == 462758-grabbers-resizers.html 462758-grabbe
== 388980-1.html 388980-1-ref.html
needs-focus == spellcheck-superscript-1.html spellcheck-superscript-1-ref.html
skip-if(B2G) fails-if(Android) needs-focus != spellcheck-superscript-2.html spellcheck-superscript-2-ref.html # bug 783658
needs-focus pref(selectioncaret.enabled,false) == 824080-1.html 824080-1-ref.html
needs-focus == 824080-1.html 824080-1-ref.html
needs-focus == 824080-2.html 824080-2-ref.html
needs-focus pref(selectioncaret.enabled,false) == 824080-3.html 824080-3-ref.html
needs-focus test-pref(selectioncaret.enabled,false) == 824080-3.html 824080-3-ref.html
needs-focus != 824080-2.html 824080-3.html
needs-focus pref(selectioncaret.enabled,false) == 824080-4.html 824080-4-ref.html
needs-focus pref(selectioncaret.enabled,false) == 824080-5.html 824080-5-ref.html
needs-focus == 824080-4.html 824080-4-ref.html
needs-focus test-pref(selectioncaret.enabled,false) == 824080-5.html 824080-5-ref.html
needs-focus != 824080-4.html 824080-5.html
needs-focus == 824080-6.html 824080-6-ref.html
needs-focus pref(selectioncaret.enabled,false) == 824080-7.html 824080-7-ref.html
Expand Down
54 changes: 26 additions & 28 deletions layout/base/SelectionCarets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ static const char* kSelectionCaretsLogModuleName = "SelectionCarets";
static const int32_t kMoveStartTolerancePx = 5;
// Time for trigger scroll end event, in miliseconds.
static const int32_t kScrollEndTimerDelay = 300;
// Read from preference "selectioncaret.noneditable". Indicate whether support
// non-editable fields selection or not. We have stable state for editable
// fields selection now. And we don't want to break this stable state when
// enabling non-editable support. So I add a pref to control to support or
// not. Once non-editable fields support is stable. We should remove this
// pref.
static bool kSupportNonEditableFields = false;

NS_IMPL_ISUPPORTS(SelectionCarets,
nsIReflowObserver,
Expand Down Expand Up @@ -97,6 +104,8 @@ SelectionCarets::SelectionCarets(nsIPresShell* aPresShell)
if (!addedPref) {
Preferences::AddIntVarCache(&sSelectionCaretsInflateSize,
"selectioncaret.inflatesize.threshold");
Preferences::AddBoolVarCache(&kSupportNonEditableFields,
"selectioncaret.noneditable");
addedPref = true;
}
}
Expand Down Expand Up @@ -451,11 +460,6 @@ SelectionCarets::UpdateSelectionCarets()

// Check start and end frame is rtl or ltr text
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
if (!fs) {
SetVisibility(false);
return;
}

int32_t startOffset;
nsIFrame* startFrame = FindFirstNodeWithFrame(mPresShell->GetDocument(),
firstRange, fs, false, startOffset);
Expand All @@ -469,6 +473,14 @@ SelectionCarets::UpdateSelectionCarets()
return;
}

// If frame isn't editable and we don't support non-editable fields, bail
// out.
if (!kSupportNonEditableFields &&
(!startFrame->GetContent()->IsEditable() ||
!endFrame->GetContent()->IsEditable())) {
return;
}

// Check if startFrame is after endFrame.
if (nsLayoutUtils::CompareTreePosition(startFrame, endFrame) > 0) {
SetVisibility(false);
Expand Down Expand Up @@ -547,6 +559,12 @@ SelectionCarets::SelectWord()
return NS_OK;
}

// If frame isn't editable and we don't support non-editable fields, bail
// out.
if (!kSupportNonEditableFields && !ptFrame->GetContent()->IsEditable()) {
return NS_OK;
}

bool selectable;
ptFrame->IsSelectable(&selectable, nullptr);
if (!selectable) {
Expand Down Expand Up @@ -592,9 +610,7 @@ SelectionCarets::SelectWord()

// Clear maintain selection otherwise we cannot select less than a word
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
if (fs) {
fs->MaintainSelection();
}
fs->MaintainSelection();
return rs;
}

Expand Down Expand Up @@ -684,9 +700,6 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
}

nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
if (!fs) {
return nsEventStatus_eConsumeNoDefault;
}

nsresult result;
nsIFrame *newFrame = nullptr;
Expand All @@ -711,10 +724,6 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
}

nsRefPtr<dom::Selection> selection = GetSelection();
if (!selection) {
return nsEventStatus_eConsumeNoDefault;
}

int32_t rangeCount = selection->GetRangeCount();
if (rangeCount <= 0) {
return nsEventStatus_eConsumeNoDefault;
Expand Down Expand Up @@ -765,19 +774,12 @@ SelectionCarets::GetCaretYCenterPosition()
}

nsRefPtr<dom::Selection> selection = GetSelection();
if (!selection) {
return 0;
}

int32_t rangeCount = selection->GetRangeCount();
if (rangeCount <= 0) {
return 0;
}

nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
if (!fs) {
return 0;
}

MOZ_ASSERT(mDragMode != NONE);
nsCOMPtr<nsIContent> node;
Expand Down Expand Up @@ -810,18 +812,14 @@ void
SelectionCarets::SetSelectionDragState(bool aState)
{
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
if (fs) {
fs->SetDragState(aState);
}
fs->SetDragState(aState);
}

void
SelectionCarets::SetSelectionDirection(bool aForward)
{
nsRefPtr<dom::Selection> selection = GetSelection();
if (selection) {
selection->SetDirection(aForward ? eDirNext : eDirPrevious);
}
selection->SetDirection(aForward ? eDirNext : eDirPrevious);
}

static void
Expand Down
6 changes: 3 additions & 3 deletions layout/base/tests/marionette/test_selectioncarets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from marionette import Actions
from marionette_test import MarionetteTestCase
from selection import SelectionManager
from gestures import long_press_without_contextmenu


class SelectionCaretsTest(MarionetteTestCase):
Expand Down Expand Up @@ -49,7 +48,7 @@ def _long_press_to_select_first_word(self, el, sel):
# Long press the caret position. Selection carets should appear, and the
# first word will be selected. On Windows, those spaces after the word
# will also be selected.
long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
self.actions.long_press(el, self._long_press_time, x, y).perform()

def _test_long_press_to_select_a_word(self, el, assertFunc):
sel = SelectionManager(el)
Expand Down Expand Up @@ -217,4 +216,5 @@ def test_contenteditable_move_selection_carets_disabled(self):
########################################################################
def test_content_non_editable_minimum_select_one_character_by_selection(self):
self.openTestHtml(enabled=True)
self._test_minimum_select_one_character(self._content, self.assertEqual)
# Currently, selection carets do not show on non-editable elements.
self._test_minimum_select_one_character(self._content, self.assertNotEqual)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from marionette import Actions
from marionette_test import MarionetteTestCase
from selection import SelectionManager
from gestures import long_press_without_contextmenu


class SelectionCaretsMultipleRangeTest(MarionetteTestCase):
Expand Down Expand Up @@ -37,6 +36,10 @@ def openTestHtml(self, enabled=True):
self._sel6 = self.marionette.find_element(By.ID, 'sel6')
self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')

def _long_press_without_contextmenu(self, el, x, y):
return self.actions.press(el, x, y).move_by_offset(0, 0).\
wait(self._long_press_time).release()

def _long_press_to_select_word(self, el, wordOrdinal):
sel = SelectionManager(el)
original_content = sel.content
Expand All @@ -58,7 +61,7 @@ def _long_press_to_select_word(self, el, wordOrdinal):
# Long press the caret position. Selection carets should appear, and the
# word will be selected. On Windows, those spaces after the word
# will also be selected.
long_press_without_contextmenu(self.marionette, el, self._long_press_time, x, y)
self._long_press_without_contextmenu(el, x, y).perform()

def _to_unix_line_ending(self, s):
"""Changes all Windows/Mac line endings in s to UNIX line endings."""
Expand All @@ -71,7 +74,7 @@ def test_long_press_to_select_non_selectable_word(self):

self.openTestHtml(enabled=True)
halfY = self._nonsel1.size['height'] / 2
long_press_without_contextmenu(self.marionette, self._nonsel1, self._long_press_time, 0, halfY)
self._long_press_without_contextmenu(self._nonsel1, 0, halfY).perform()
sel = SelectionManager(self._nonsel1)
range_count = sel.range_count()
self.assertEqual(range_count, 0)
Expand Down
1 change: 1 addition & 0 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4370,6 +4370,7 @@ pref("touchcaret.expiration.time", 3000);

// Turn off selection caret by default
pref("selectioncaret.enabled", false);
pref("selectioncaret.noneditable", false);

// This will inflate size of selection caret frame when we checking if
// user click on selection caret or not. In app units.
Expand Down
12 changes: 0 additions & 12 deletions testing/marionette/client/marionette/gestures.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,3 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration=
action1.release()
action2.release()
multiAction.add(action1).add(action2).perform()

#element: The element to press.
#time_in_seconds: Time in seconds to wait before releasing the press.
#x: Optional, x-coordinate to tap, relative to the top-left corner of the element.
#y: Optional, y-coordinate to tap, relative to the top-leftcorner of the element.
def long_press_without_contextmenu(marionette_session, element, time_in_seconds, x=None, y=None):
action = Actions(marionette_session)
action.press(element, x, y)
action.move_by_offset(0, 0)
action.wait(time_in_seconds)
action.release()
action.perform()

0 comments on commit 9dc33ba

Please sign in to comment.