Esempio n. 1
0
void TextFieldInputType::forwardEvent(Event* event) {
  if (SpinButtonElement* spinButton = spinButtonElement()) {
    spinButton->forwardEvent(event);
    if (event->defaultHandled())
      return;
  }

  if (element().layoutObject() &&
      (event->isMouseEvent() || event->isDragEvent() ||
       event->hasInterface(EventNames::WheelEvent) ||
       event->type() == EventTypeNames::blur ||
       event->type() == EventTypeNames::focus)) {
    LayoutTextControlSingleLine* layoutTextControl =
        toLayoutTextControlSingleLine(element().layoutObject());
    if (event->type() == EventTypeNames::blur) {
      if (LayoutBox* innerEditorLayoutObject =
              element().innerEditorElement()->layoutBox()) {
        // FIXME: This class has no need to know about PaintLayer!
        if (PaintLayer* innerLayer = innerEditorLayoutObject->layer()) {
          if (PaintLayerScrollableArea* innerScrollableArea =
                  innerLayer->getScrollableArea()) {
            innerScrollableArea->setScrollOffset(ScrollOffset(0, 0),
                                                 ProgrammaticScroll);
          }
        }
      }

      layoutTextControl->capsLockStateMayHaveChanged();
    } else if (event->type() == EventTypeNames::focus) {
      layoutTextControl->capsLockStateMayHaveChanged();
    }

    element().forwardEvent(event);
  }
}
void TextFieldInputType::forwardEvent(Event* event)
{
    if (SpinButtonElement* spinButton = spinButtonElement()) {
        spinButton->forwardEvent(event);
        if (event->defaultHandled())
            return;
    }

    if (element().layoutObject() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(EventNames::WheelEvent) || event->type() == EventTypeNames::blur || event->type() == EventTypeNames::focus)) {
        LayoutTextControlSingleLine* layoutTextControl = toLayoutTextControlSingleLine(element().layoutObject());
        if (event->type() == EventTypeNames::blur) {
            if (LayoutBox* innerEditorLayoutObject = element().innerEditorElement()->layoutBox()) {
                // FIXME: This class has no need to know about DeprecatedPaintLayer!
                if (DeprecatedPaintLayer* innerLayer = innerEditorLayoutObject->layer()) {
                    if (DeprecatedPaintLayerScrollableArea* innerScrollableArea = innerLayer->scrollableArea()) {
                        IntSize scrollOffset(!layoutTextControl->style()->isLeftToRightDirection() ? innerScrollableArea->scrollWidth().toInt() : 0, 0);
                        innerScrollableArea->scrollToOffset(scrollOffset, ScrollOffsetClamped);
                    }
                }
            }

            layoutTextControl->capsLockStateMayHaveChanged();
        } else if (event->type() == EventTypeNames::focus) {
            layoutTextControl->capsLockStateMayHaveChanged();
        }

        element().forwardEvent(event);
    }
}