Commit 6764bd68 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Prune CreateVisiblePositionDeprecated from Editor::firstRectForRange

This patch also removes the Editor::firstRectForRange(const Range*)
overload because it has no call site.

BUG=647219

Review-Url: https://codereview.chromium.org/2352763004
Cr-Commit-Position: refs/heads/master@{#420602}
parent 489abbd8
...@@ -1163,14 +1163,17 @@ void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, ...@@ -1163,14 +1163,17 @@ void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection,
IntRect Editor::firstRectForRange(const EphemeralRange& range) const IntRect Editor::firstRectForRange(const EphemeralRange& range) const
{ {
DCHECK(!frame().document()->needsLayoutTreeUpdate());
DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
LayoutUnit extraWidthToEndOfLine; LayoutUnit extraWidthToEndOfLine;
DCHECK(range.isNotNull()); DCHECK(range.isNotNull());
IntRect startCaretRect = RenderedPosition(createVisiblePositionDeprecated(range.startPosition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthToEndOfLine); IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startPosition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthToEndOfLine);
if (startCaretRect.isEmpty()) if (startCaretRect.isEmpty())
return IntRect(); return IntRect();
IntRect endCaretRect = RenderedPosition(createVisiblePositionDeprecated(range.endPosition()).deepEquivalent(), TextAffinity::Upstream).absoluteRect(); IntRect endCaretRect = RenderedPosition(createVisiblePosition(range.endPosition()).deepEquivalent(), TextAffinity::Upstream).absoluteRect();
if (endCaretRect.isEmpty()) if (endCaretRect.isEmpty())
return IntRect(); return IntRect();
...@@ -1189,12 +1192,6 @@ IntRect Editor::firstRectForRange(const EphemeralRange& range) const ...@@ -1189,12 +1192,6 @@ IntRect Editor::firstRectForRange(const EphemeralRange& range) const
startCaretRect.height()); startCaretRect.height());
} }
IntRect Editor::firstRectForRange(const Range* range) const
{
DCHECK(range);
return firstRectForRange(EphemeralRange(range));
}
void Editor::computeAndSetTypingStyle(StylePropertySet* style, InputEvent::InputType inputType) void Editor::computeAndSetTypingStyle(StylePropertySet* style, InputEvent::InputType inputType)
{ {
if (!style || style->isEmpty()) { if (!style || style->isEmpty()) {
......
...@@ -217,8 +217,8 @@ public: ...@@ -217,8 +217,8 @@ public:
void computeAndSetTypingStyle(StylePropertySet*, InputEvent::InputType); void computeAndSetTypingStyle(StylePropertySet*, InputEvent::InputType);
// |firstRectForRange| requires up-to-date layout.
IntRect firstRectForRange(const EphemeralRange&) const; IntRect firstRectForRange(const EphemeralRange&) const;
IntRect firstRectForRange(const Range*) const;
void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions); void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
......
...@@ -2046,6 +2046,10 @@ WebInputEventResult EventHandler::sendContextMenuEventForKey(Element* overrideTa ...@@ -2046,6 +2046,10 @@ WebInputEventResult EventHandler::sendContextMenuEventForKey(Element* overrideTa
VisualViewport& visualViewport = frameHost()->visualViewport(); VisualViewport& visualViewport = frameHost()->visualViewport();
if (!overrideTargetElement && start.anchorNode() && (selection.rootEditableElement() || selection.isRange())) { if (!overrideTargetElement && start.anchorNode() && (selection.rootEditableElement() || selection.isRange())) {
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
doc->updateStyleAndLayoutIgnorePendingStylesheets();
IntRect firstRect = m_frame->editor().firstRectForRange(selection.selection().toNormalizedEphemeralRange()); IntRect firstRect = m_frame->editor().firstRectForRange(selection.selection().toNormalizedEphemeralRange());
int x = rightAligned ? firstRect.maxX() : firstRect.x(); int x = rightAligned ? firstRect.maxX() : firstRect.x();
......
...@@ -751,12 +751,16 @@ bool WebFrameWidgetImpl::selectionBounds(WebRect& anchor, WebRect& focus) const ...@@ -751,12 +751,16 @@ bool WebFrameWidgetImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
return false; return false;
FrameSelection& selection = localFrame->selection(); FrameSelection& selection = localFrame->selection();
if (selection.isNone())
return false;
if (selection.isCaret()) { // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets // needs to be audited. See http://crbug.com/590369 for more details.
// needs to be audited. See http://crbug.com/590369 for more details. localFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
localFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
DocumentLifecycle::DisallowTransitionScope disallowTransition(localFrame->document()->lifecycle());
if (selection.isCaret()) {
anchor = focus = selection.absoluteCaretBounds(); anchor = focus = selection.absoluteCaretBounds();
} else { } else {
const EphemeralRange selectedRange = selection.selection().toNormalizedEphemeralRange(); const EphemeralRange selectedRange = selection.selection().toNormalizedEphemeralRange();
......
...@@ -2642,16 +2642,18 @@ bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const ...@@ -2642,16 +2642,18 @@ bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
if (!localFrame) if (!localFrame)
return false; return false;
FrameSelection& selection = localFrame->selection(); FrameSelection& selection = localFrame->selection();
if (!selection.isAvailable()) { if (!selection.isAvailable() || selection.isNone()) {
// plugins/mouse-capture-inside-shadow.html reaches here. // plugins/mouse-capture-inside-shadow.html reaches here.
return false; return false;
} }
if (selection.isCaret()) { // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets // needs to be audited. See http://crbug.com/590369 for more details.
// needs to be audited. See http://crbug.com/590369 for more details. localFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
localFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
DocumentLifecycle::DisallowTransitionScope disallowTransition(localFrame->document()->lifecycle());
if (selection.isCaret()) {
anchor = focus = selection.absoluteCaretBounds(); anchor = focus = selection.absoluteCaretBounds();
} else { } else {
const EphemeralRange selectedRange = selection.selection().toNormalizedEphemeralRange(); const EphemeralRange selectedRange = selection.selection().toNormalizedEphemeralRange();
......
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