Open Bug 483733 Opened 16 years ago Updated 4 years ago

Caret is invisible at far left position in RTL text input boxes

Categories

(Core :: DOM: Editor, defect, P5)

x86
Windows Vista
defect

Tracking

()

People

(Reporter: cpearce, Unassigned)

References

()

Details

This bug was discovered in bug 483564. In the testcase (see URL) on Windows, when you select the RTL div and move the caret (with arrow keys or home key) to the far left, the caret disappears. This regressed between 2006-11-01-04 and 2006-11-02-04.
nsCaret::UpdateCaretRects clamps the rect to the scroll frame and then adjusts the rect based on the clamping.  The adjustment should probably happen before clamping, but the clamping is only at the right hand end anyway.

  // Clamp our position to be within our scroll frame. If we don't, then it
  // clips us, and we don't appear at all. See bug 335560.
  nsIFrame *scrollFrame =
    nsLayoutUtils::GetClosestFrameOfType(aFrame, nsGkAtoms::scrollFrame);
  if (scrollFrame)
  {
    // First, use the scrollFrame to get at the scrollable view that we're in.
    nsIScrollableFrame *scrollable = do_QueryFrame(scrollFrame);
    nsIScrollableView *scrollView = scrollable->GetScrollableView();
    nsIView *view;
    scrollView->GetScrolledView(view);

    // Compute the caret's coordinates in the enclosing view's coordinate
    // space. To do so, we need to correct for both the original frame's
    // offset from the scrollframe, and the scrollable view's offset from the
    // scrolled frame's view.
    nsPoint toScroll = aFrame->GetOffsetTo(scrollFrame) -
      view->GetOffsetTo(scrollFrame->GetView());
    nsRect caretInScroll = mCaretRect + toScroll;

    // Now see if thet caret extends beyond the view's bounds. If it does,
    // then snap it back, put it as close to the edge as it can.
    nscoord overflow = caretInScroll.XMost() - view->GetBounds().width;
    if (overflow > 0)
      mCaretRect.x -= overflow;
  }

  // on RTL frames the right edge of mCaretRect must be equal to framePos
  const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
  if (NS_STYLE_DIRECTION_RTL == vis->mDirection)
    mCaretRect.x -= mCaretRect.width;

Bulk-downgrade of unassigned, untouched DOM/Storage bug's priority.

If you have reason to believe, this is wrong, please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.