PassRefPtr<RenderStyle> BaseMultipleFieldsDateAndTimeInputType::customStyleForRenderer(PassRefPtr<RenderStyle> originalStyle) { EDisplay originalDisplay = originalStyle->display(); EDisplay newDisplay = originalDisplay; if (originalDisplay == INLINE || originalDisplay == INLINE_BLOCK) newDisplay = INLINE_FLEX; else if (originalDisplay == BLOCK) newDisplay = FLEX; TextDirection contentDirection = computedTextDirection(); if (originalStyle->direction() == contentDirection && originalDisplay == newDisplay) return originalStyle; RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get()); style->setDirection(contentDirection); style->setDisplay(newDisplay); style->setUnique(); return style.release(); }
PassRefPtr<ComputedStyle> MultipleFieldsTemporalInputTypeView::customStyleForLayoutObject( PassRefPtr<ComputedStyle> originalStyle) { EDisplay originalDisplay = originalStyle->display(); EDisplay newDisplay = originalDisplay; if (originalDisplay == EDisplay::Inline || originalDisplay == EDisplay::InlineBlock) newDisplay = EDisplay::InlineFlex; else if (originalDisplay == EDisplay::Block) newDisplay = EDisplay::Flex; TextDirection contentDirection = computedTextDirection(); if (originalStyle->direction() == contentDirection && originalDisplay == newDisplay) return originalStyle; RefPtr<ComputedStyle> style = ComputedStyle::clone(*originalStyle); style->setDirection(contentDirection); style->setDisplay(newDisplay); style->setUnique(); return style.release(); }
void RangeInputType::handleKeydownEvent(KeyboardEvent* event) { if (element().isDisabledOrReadOnly()) return; const String& key = event->key(); const Decimal current = parseToNumberOrNaN(element().value()); DCHECK(current.isFinite()); StepRange stepRange(createStepRange(RejectAny)); // FIXME: We can't use stepUp() for the step value "any". So, we increase // or decrease the value by 1/100 of the value range. Is it reasonable? const Decimal step = equalIgnoringCase(element().fastGetAttribute(stepAttr), "any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step(); const Decimal bigStep = std::max((stepRange.maximum() - stepRange.minimum()) / 10, step); TextDirection dir = LTR; bool isVertical = false; if (element().layoutObject()) { dir = computedTextDirection(); ControlPart part = element().layoutObject()->style()->appearance(); isVertical = part == SliderVerticalPart; } Decimal newValue; if (key == "ArrowUp") newValue = current + step; else if (key == "ArrowDown") newValue = current - step; else if (key == "ArrowLeft") newValue = (isVertical || dir == RTL) ? current + step : current - step; else if (key == "ArrowRight") newValue = (isVertical || dir == RTL) ? current - step : current + step; else if (key == "PageUp") newValue = current + bigStep; else if (key == "PageDown") newValue = current - bigStep; else if (key == "Home") newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); else if (key == "End") newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); else return; // Did not match any key binding. newValue = stepRange.clampValue(newValue); if (newValue != current) { EventQueueScope scope; TextFieldEventBehavior eventBehavior = DispatchInputAndChangeEvent; setValueAsDecimal(newValue, eventBehavior, IGNORE_EXCEPTION); if (AXObjectCache* cache = element().document().existingAXObjectCache()) cache->handleValueChanged(&element()); } event->setDefaultHandled(); }