| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "PlatformLocale.h" | 63 #include "PlatformLocale.h" |
| 64 #include "PlatformMouseEvent.h" | 64 #include "PlatformMouseEvent.h" |
| 65 #include "RenderTextControlSingleLine.h" | 65 #include "RenderTextControlSingleLine.h" |
| 66 #include "RenderTheme.h" | 66 #include "RenderTheme.h" |
| 67 #include "RuntimeEnabledFeatures.h" | 67 #include "RuntimeEnabledFeatures.h" |
| 68 #include "ScopedEventQueue.h" | 68 #include "ScopedEventQueue.h" |
| 69 #include "SearchInputType.h" | 69 #include "SearchInputType.h" |
| 70 #include "ShadowRoot.h" | 70 #include "ShadowRoot.h" |
| 71 #include "ScriptEventListener.h" | 71 #include "ScriptEventListener.h" |
| 72 #include "StyleResolver.h" | 72 #include "StyleResolver.h" |
| 73 #include "TouchEvent.h" | |
| 74 #include <wtf/MathExtras.h> | 73 #include <wtf/MathExtras.h> |
| 75 #include <wtf/StdLibExtras.h> | 74 #include <wtf/StdLibExtras.h> |
| 76 | 75 |
| 77 #if ENABLE(INPUT_TYPE_COLOR) | 76 #if ENABLE(INPUT_TYPE_COLOR) |
| 78 #include "ColorInputType.h" | 77 #include "ColorInputType.h" |
| 79 #endif | 78 #endif |
| 80 | 79 |
| 81 #if ENABLE(INPUT_SPEECH) | 80 #if ENABLE(INPUT_SPEECH) |
| 82 #include "RuntimeEnabledFeatures.h" | 81 #include "RuntimeEnabledFeatures.h" |
| 83 #endif | 82 #endif |
| 84 | 83 |
| 84 #if ENABLE(TOUCH_EVENTS) |
| 85 #include "TouchEvent.h" |
| 86 #endif |
| 87 |
| 85 using namespace std; | 88 using namespace std; |
| 86 | 89 |
| 87 namespace WebCore { | 90 namespace WebCore { |
| 88 | 91 |
| 89 using namespace HTMLNames; | 92 using namespace HTMLNames; |
| 90 | 93 |
| 91 #if ENABLE(DATALIST_ELEMENT) | 94 #if ENABLE(DATALIST_ELEMENT) |
| 92 class ListAttributeTargetObserver : IdTargetObserver { | 95 class ListAttributeTargetObserver : IdTargetObserver { |
| 93 WTF_MAKE_FAST_ALLOCATED; | 96 WTF_MAKE_FAST_ALLOCATED; |
| 94 public: | 97 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 123 , m_autocomplete(Uninitialized) | 126 , m_autocomplete(Uninitialized) |
| 124 , m_isAutofilled(false) | 127 , m_isAutofilled(false) |
| 125 #if ENABLE(DATALIST_ELEMENT) | 128 #if ENABLE(DATALIST_ELEMENT) |
| 126 , m_hasNonEmptyList(false) | 129 , m_hasNonEmptyList(false) |
| 127 #endif | 130 #endif |
| 128 , m_stateRestored(false) | 131 , m_stateRestored(false) |
| 129 , m_parsingInProgress(createdByParser) | 132 , m_parsingInProgress(createdByParser) |
| 130 , m_valueAttributeWasUpdatedAfterParsing(false) | 133 , m_valueAttributeWasUpdatedAfterParsing(false) |
| 131 , m_wasModifiedByUser(false) | 134 , m_wasModifiedByUser(false) |
| 132 , m_canReceiveDroppedFiles(false) | 135 , m_canReceiveDroppedFiles(false) |
| 136 #if ENABLE(TOUCH_EVENTS) |
| 133 , m_hasTouchEventHandler(false) | 137 , m_hasTouchEventHandler(false) |
| 138 #endif |
| 134 , m_inputType(InputType::createText(this)) | 139 , m_inputType(InputType::createText(this)) |
| 135 { | 140 { |
| 136 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag)); | 141 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag)); |
| 137 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 142 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 138 setHasCustomStyleCallbacks(); | 143 setHasCustomStyleCallbacks(); |
| 139 #endif | 144 #endif |
| 140 ScriptWrappable::init(this); | 145 ScriptWrappable::init(this); |
| 141 } | 146 } |
| 142 | 147 |
| 143 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagNa
me, Document* document, HTMLFormElement* form, bool createdByParser) | 148 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagNa
me, Document* document, HTMLFormElement* form, bool createdByParser) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 164 if (needsSuspensionCallback()) | 169 if (needsSuspensionCallback()) |
| 165 document()->unregisterForPageCacheSuspensionCallbacks(this); | 170 document()->unregisterForPageCacheSuspensionCallbacks(this); |
| 166 | 171 |
| 167 // Need to remove form association while this is still an HTMLInputElement | 172 // Need to remove form association while this is still an HTMLInputElement |
| 168 // so that virtual functions are called correctly. | 173 // so that virtual functions are called correctly. |
| 169 setForm(0); | 174 setForm(0); |
| 170 // setForm(0) may register this to a document-level radio button group. | 175 // setForm(0) may register this to a document-level radio button group. |
| 171 // We should unregister it to avoid accessing a deleted object. | 176 // We should unregister it to avoid accessing a deleted object. |
| 172 if (isRadioButton()) | 177 if (isRadioButton()) |
| 173 document()->formController()->checkedRadioButtons().removeButton(this); | 178 document()->formController()->checkedRadioButtons().removeButton(this); |
| 179 #if ENABLE(TOUCH_EVENTS) |
| 174 if (m_hasTouchEventHandler) | 180 if (m_hasTouchEventHandler) |
| 175 document()->didRemoveEventTargetNode(this); | 181 document()->didRemoveEventTargetNode(this); |
| 182 #endif |
| 176 } | 183 } |
| 177 | 184 |
| 178 const AtomicString& HTMLInputElement::name() const | 185 const AtomicString& HTMLInputElement::name() const |
| 179 { | 186 { |
| 180 return m_name.isNull() ? emptyAtom : m_name; | 187 return m_name.isNull() ? emptyAtom : m_name; |
| 181 } | 188 } |
| 182 | 189 |
| 183 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState
(const FormControlState& state) | 190 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState
(const FormControlState& state) |
| 184 { | 191 { |
| 185 return FileInputType::filesFromFormControlState(state); | 192 return FileInputType::filesFromFormControlState(state); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 479 |
| 473 m_inputType->destroyShadowSubtree(); | 480 m_inputType->destroyShadowSubtree(); |
| 474 | 481 |
| 475 bool wasAttached = attached(); | 482 bool wasAttached = attached(); |
| 476 if (wasAttached) | 483 if (wasAttached) |
| 477 detach(); | 484 detach(); |
| 478 | 485 |
| 479 m_inputType = newType.release(); | 486 m_inputType = newType.release(); |
| 480 m_inputType->createShadowSubtree(); | 487 m_inputType->createShadowSubtree(); |
| 481 | 488 |
| 489 #if ENABLE(TOUCH_EVENTS) |
| 482 bool hasTouchEventHandler = m_inputType->hasTouchEventHandler(); | 490 bool hasTouchEventHandler = m_inputType->hasTouchEventHandler(); |
| 483 if (hasTouchEventHandler != m_hasTouchEventHandler) { | 491 if (hasTouchEventHandler != m_hasTouchEventHandler) { |
| 484 if (hasTouchEventHandler) | 492 if (hasTouchEventHandler) |
| 485 document()->didAddTouchEventHandler(this); | 493 document()->didAddTouchEventHandler(this); |
| 486 else | 494 else |
| 487 document()->didRemoveTouchEventHandler(this); | 495 document()->didRemoveTouchEventHandler(this); |
| 488 m_hasTouchEventHandler = hasTouchEventHandler; | 496 m_hasTouchEventHandler = hasTouchEventHandler; |
| 489 } | 497 } |
| 498 #endif |
| 490 | 499 |
| 491 setNeedsWillValidateCheck(); | 500 setNeedsWillValidateCheck(); |
| 492 | 501 |
| 493 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); | 502 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); |
| 494 | 503 |
| 495 if (didStoreValue && !willStoreValue && hasDirtyValue()) { | 504 if (didStoreValue && !willStoreValue && hasDirtyValue()) { |
| 496 setAttribute(valueAttr, m_valueIfDirty); | 505 setAttribute(valueAttr, m_valueIfDirty); |
| 497 m_valueIfDirty = String(); | 506 m_valueIfDirty = String(); |
| 498 } | 507 } |
| 499 if (!didStoreValue && willStoreValue) { | 508 if (!didStoreValue && willStoreValue) { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 } | 1128 } |
| 1120 | 1129 |
| 1121 void HTMLInputElement::defaultEventHandler(Event* evt) | 1130 void HTMLInputElement::defaultEventHandler(Event* evt) |
| 1122 { | 1131 { |
| 1123 if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && static_
cast<MouseEvent*>(evt)->button() == LeftButton) { | 1132 if (evt->isMouseEvent() && evt->type() == eventNames().clickEvent && static_
cast<MouseEvent*>(evt)->button() == LeftButton) { |
| 1124 m_inputType->handleClickEvent(static_cast<MouseEvent*>(evt)); | 1133 m_inputType->handleClickEvent(static_cast<MouseEvent*>(evt)); |
| 1125 if (evt->defaultHandled()) | 1134 if (evt->defaultHandled()) |
| 1126 return; | 1135 return; |
| 1127 } | 1136 } |
| 1128 | 1137 |
| 1138 #if ENABLE(TOUCH_EVENTS) |
| 1129 if (evt->isTouchEvent()) { | 1139 if (evt->isTouchEvent()) { |
| 1130 m_inputType->handleTouchEvent(static_cast<TouchEvent*>(evt)); | 1140 m_inputType->handleTouchEvent(static_cast<TouchEvent*>(evt)); |
| 1131 if (evt->defaultHandled()) | 1141 if (evt->defaultHandled()) |
| 1132 return; | 1142 return; |
| 1133 } | 1143 } |
| 1144 #endif |
| 1134 | 1145 |
| 1135 if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) { | 1146 if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) { |
| 1136 m_inputType->handleKeydownEvent(static_cast<KeyboardEvent*>(evt)); | 1147 m_inputType->handleKeydownEvent(static_cast<KeyboardEvent*>(evt)); |
| 1137 if (evt->defaultHandled()) | 1148 if (evt->defaultHandled()) |
| 1138 return; | 1149 return; |
| 1139 } | 1150 } |
| 1140 | 1151 |
| 1141 // Call the base event handler before any of our own event handling for almo
st all events in text fields. | 1152 // Call the base event handler before any of our own event handling for almo
st all events in text fields. |
| 1142 // Makes editing keyboard handling take precedence over the keydown and keyp
ress handling in this function. | 1153 // Makes editing keyboard handling take precedence over the keydown and keyp
ress handling in this function. |
| 1143 bool callBaseClassEarly = isTextField() && (evt->type() == eventNames().keyd
ownEvent || evt->type() == eventNames().keypressEvent); | 1154 bool callBaseClassEarly = isTextField() && (evt->type() == eventNames().keyd
ownEvent || evt->type() == eventNames().keypressEvent); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 if (hasImageLoader()) | 1522 if (hasImageLoader()) |
| 1512 imageLoader()->elementDidMoveToNewDocument(); | 1523 imageLoader()->elementDidMoveToNewDocument(); |
| 1513 | 1524 |
| 1514 bool needsSuspensionCallback = this->needsSuspensionCallback(); | 1525 bool needsSuspensionCallback = this->needsSuspensionCallback(); |
| 1515 if (oldDocument) { | 1526 if (oldDocument) { |
| 1516 // Always unregister for cache callbacks when leaving a document, even i
f we would otherwise like to be registered | 1527 // Always unregister for cache callbacks when leaving a document, even i
f we would otherwise like to be registered |
| 1517 if (needsSuspensionCallback) | 1528 if (needsSuspensionCallback) |
| 1518 oldDocument->unregisterForPageCacheSuspensionCallbacks(this); | 1529 oldDocument->unregisterForPageCacheSuspensionCallbacks(this); |
| 1519 if (isRadioButton()) | 1530 if (isRadioButton()) |
| 1520 oldDocument->formController()->checkedRadioButtons().removeButton(th
is); | 1531 oldDocument->formController()->checkedRadioButtons().removeButton(th
is); |
| 1532 #if ENABLE(TOUCH_EVENTS) |
| 1521 if (m_hasTouchEventHandler) | 1533 if (m_hasTouchEventHandler) |
| 1522 oldDocument->didRemoveEventTargetNode(this); | 1534 oldDocument->didRemoveEventTargetNode(this); |
| 1535 #endif |
| 1523 } | 1536 } |
| 1524 | 1537 |
| 1525 if (needsSuspensionCallback) | 1538 if (needsSuspensionCallback) |
| 1526 document()->registerForPageCacheSuspensionCallbacks(this); | 1539 document()->registerForPageCacheSuspensionCallbacks(this); |
| 1527 | 1540 |
| 1541 #if ENABLE(TOUCH_EVENTS) |
| 1528 if (m_hasTouchEventHandler) | 1542 if (m_hasTouchEventHandler) |
| 1529 document()->didAddTouchEventHandler(this); | 1543 document()->didAddTouchEventHandler(this); |
| 1544 #endif |
| 1530 | 1545 |
| 1531 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); | 1546 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); |
| 1532 } | 1547 } |
| 1533 | 1548 |
| 1534 void HTMLInputElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t | 1549 void HTMLInputElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
t |
| 1535 { | 1550 { |
| 1536 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); | 1551 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); |
| 1537 | 1552 |
| 1538 addSubresourceURL(urls, src()); | 1553 addSubresourceURL(urls, src()); |
| 1539 } | 1554 } |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 } | 1973 } |
| 1959 | 1974 |
| 1960 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 1975 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 1961 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() | 1976 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() |
| 1962 { | 1977 { |
| 1963 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl
eForElement(this)); | 1978 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl
eForElement(this)); |
| 1964 } | 1979 } |
| 1965 #endif | 1980 #endif |
| 1966 | 1981 |
| 1967 } // namespace | 1982 } // namespace |
| OLD | NEW |