Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp

Issue 2815263002: Move form-related files in core/html/shadow to core/html/forms. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp b/third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp
deleted file mode 100644
index 31ad1faf55ee0b26d85d2cdef9dbb2e19e848c06..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/core/html/shadow/DateTimeFieldElement.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "core/html/shadow/DateTimeFieldElement.h"
-
-#include "core/HTMLNames.h"
-#include "core/dom/Document.h"
-#include "core/dom/StyleChangeReason.h"
-#include "core/dom/Text.h"
-#include "core/events/KeyboardEvent.h"
-#include "core/layout/TextRunConstructor.h"
-#include "core/style/ComputedStyle.h"
-#include "platform/text/PlatformLocale.h"
-#include "platform/wtf/text/WTFString.h"
-
-namespace blink {
-
-using namespace HTMLNames;
-
-DateTimeFieldElement::FieldOwner::~FieldOwner() {}
-
-DateTimeFieldElement::DateTimeFieldElement(Document& document,
- FieldOwner& field_owner)
- : HTMLSpanElement(document), field_owner_(&field_owner) {}
-
-DEFINE_TRACE(DateTimeFieldElement) {
- visitor->Trace(field_owner_);
- HTMLSpanElement::Trace(visitor);
-}
-
-float DateTimeFieldElement::ComputeTextWidth(const ComputedStyle& style,
- const String& text) {
- return style.GetFont().Width(ConstructTextRun(style.GetFont(), text, style));
-}
-
-void DateTimeFieldElement::DefaultEventHandler(Event* event) {
- if (event->IsKeyboardEvent()) {
- KeyboardEvent* keyboard_event = ToKeyboardEvent(event);
- if (!IsDisabled() && !IsFieldOwnerDisabled() && !IsFieldOwnerReadOnly()) {
- HandleKeyboardEvent(keyboard_event);
- if (keyboard_event->DefaultHandled()) {
- if (field_owner_)
- field_owner_->FieldDidChangeValueByKeyboard();
- return;
- }
- }
- DefaultKeyboardEventHandler(keyboard_event);
- if (field_owner_)
- field_owner_->FieldDidChangeValueByKeyboard();
- if (keyboard_event->DefaultHandled())
- return;
- }
-
- HTMLElement::DefaultEventHandler(event);
-}
-
-void DateTimeFieldElement::DefaultKeyboardEventHandler(
- KeyboardEvent* keyboard_event) {
- if (keyboard_event->type() != EventTypeNames::keydown)
- return;
-
- if (IsDisabled() || IsFieldOwnerDisabled())
- return;
-
- const String& key = keyboard_event->key();
-
- if (key == "ArrowLeft") {
- if (!field_owner_)
- return;
- // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionLeft,
- // ...) but it doesn't work for shadow nodes. webkit.org/b/104650
- if (!LocaleForOwner().IsRTL() && field_owner_->FocusOnPreviousField(*this))
- keyboard_event->SetDefaultHandled();
- return;
- }
-
- if (key == "ArrowRight") {
- if (!field_owner_)
- return;
- // FIXME: We'd like to use
- // FocusController::advanceFocus(FocusDirectionRight, ...)
- // but it doesn't work for shadow nodes. webkit.org/b/104650
- if (!LocaleForOwner().IsRTL() && field_owner_->FocusOnNextField(*this))
- keyboard_event->SetDefaultHandled();
- return;
- }
-
- if (IsFieldOwnerReadOnly())
- return;
-
- if (key == "ArrowDown") {
- if (keyboard_event->getModifierState("Alt"))
- return;
- keyboard_event->SetDefaultHandled();
- StepDown();
- return;
- }
-
- if (key == "ArrowUp") {
- keyboard_event->SetDefaultHandled();
- StepUp();
- return;
- }
-
- if (key == "Backspace" || key == "Delete") {
- keyboard_event->SetDefaultHandled();
- SetEmptyValue(kDispatchEvent);
- return;
- }
-}
-
-void DateTimeFieldElement::SetFocused(bool value, WebFocusType focus_type) {
- if (field_owner_) {
- if (value) {
- field_owner_->DidFocusOnField(focus_type);
- } else {
- field_owner_->DidBlurFromField(focus_type);
- }
- }
-
- ContainerNode::SetFocused(value, focus_type);
-}
-
-void DateTimeFieldElement::FocusOnNextField() {
- if (!field_owner_)
- return;
- field_owner_->FocusOnNextField(*this);
-}
-
-void DateTimeFieldElement::Initialize(const AtomicString& pseudo,
- const String& ax_help_text,
- int ax_minimum,
- int ax_maximum) {
- // On accessibility, DateTimeFieldElement acts like spin button.
- setAttribute(roleAttr, AtomicString("spinbutton"));
- setAttribute(aria_valuetextAttr, AtomicString(VisibleValue()));
- setAttribute(aria_valueminAttr, AtomicString::Number(ax_minimum));
- setAttribute(aria_valuemaxAttr, AtomicString::Number(ax_maximum));
-
- setAttribute(aria_helpAttr, AtomicString(ax_help_text));
- SetShadowPseudoId(pseudo);
- AppendChild(Text::Create(GetDocument(), VisibleValue()));
-}
-
-bool DateTimeFieldElement::IsDateTimeFieldElement() const {
- return true;
-}
-
-bool DateTimeFieldElement::IsFieldOwnerDisabled() const {
- return field_owner_ && field_owner_->IsFieldOwnerDisabled();
-}
-
-bool DateTimeFieldElement::IsFieldOwnerReadOnly() const {
- return field_owner_ && field_owner_->IsFieldOwnerReadOnly();
-}
-
-bool DateTimeFieldElement::IsDisabled() const {
- return FastHasAttribute(disabledAttr);
-}
-
-Locale& DateTimeFieldElement::LocaleForOwner() const {
- return GetDocument().GetCachedLocale(LocaleIdentifier());
-}
-
-AtomicString DateTimeFieldElement::LocaleIdentifier() const {
- return field_owner_ ? field_owner_->LocaleIdentifier() : g_null_atom;
-}
-
-float DateTimeFieldElement::MaximumWidth(const ComputedStyle&) {
- const float kPaddingLeftAndRight = 2; // This should match to html.css.
- return kPaddingLeftAndRight;
-}
-
-void DateTimeFieldElement::SetDisabled() {
- // Set HTML attribute disabled to change apperance.
- SetBooleanAttribute(disabledAttr, true);
- SetNeedsStyleRecalc(
- kSubtreeStyleChange,
- StyleChangeReasonForTracing::CreateWithExtraData(
- StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_disabled));
-}
-
-bool DateTimeFieldElement::SupportsFocus() const {
- return !IsDisabled() && !IsFieldOwnerDisabled();
-}
-
-void DateTimeFieldElement::UpdateVisibleValue(EventBehavior event_behavior) {
- Text* const text_node = ToText(FirstChild());
- const String new_visible_value = VisibleValue();
- DCHECK_GT(new_visible_value.length(), 0u);
-
- if (text_node->wholeText() == new_visible_value)
- return;
-
- text_node->ReplaceWholeText(new_visible_value);
- if (HasValue()) {
- setAttribute(aria_valuenowAttr,
- AtomicString::Number(ValueForARIAValueNow()));
- } else {
- removeAttribute(aria_valuenowAttr);
- }
- setAttribute(aria_valuetextAttr, AtomicString(new_visible_value));
-
- if (event_behavior == kDispatchEvent && field_owner_)
- field_owner_->FieldValueChanged();
-}
-
-int DateTimeFieldElement::ValueForARIAValueNow() const {
- return ValueAsInteger();
-}
-
-} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698