Convert the caps lock indicator to be implemented using the shadow DOM
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 23:33:21 +0000 (23:33 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 23:33:21 +0000 (23:33 +0000)
commit9a0477112ff44b808c56c451a2ffefb37a5294d3
tree64d18d1eebd28c735d68bac5ab8fe6d1af28f1fc
parent0901bfba32831e46d34dd3c89ae6590987c4ca70
Convert the caps lock indicator to be implemented using the shadow DOM
https://bugs.webkit.org/show_bug.cgi?id=141868

Reviewed by Dan Bernstein.

Source/WebCore:

- Re-adds 'caps-lock-indicator' as a valid -webkit-appearance value. It was removed
  in r74099 to work around a site bug, that should not be a problem anymore.
- Converts the caps lock indicator to be implemented as part of the shadow DOM rather
  than a paint time effect. This gives the proper overflow behavior (it now clips) and
  behaves correctly in RTL.

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
Make 'caps-lock-indicator' a valid -webkit-appearance value.

* css/CSSValueKeywords.in:
Remove comment that indicated that caps-lock-indicator was not a valid
-webkit-appearance value.

* css/html.css:
(input::-webkit-caps-lock-indicator):
Add new default style for the new -webkit-caps-lock-indicator pseudo-element. The
trick employed here is to use a content: image to both implement the painting of
the caps lock indicator, and to get the sizing right (shrink-to-fit, height: 100%).

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::capsLockIndicatorElement):
(WebCore::HTMLInputElement::capsLockStateMayHaveChanged):
* html/HTMLInputElement.h:
* html/InputType.cpp:
(WebCore::InputType::capsLockStateMayHaveChanged):
* html/InputType.h:
(WebCore::InputType::capsLockIndicatorElement):
Pipe notification of changes in the caps locks state to the <input> element
rather than the RenderTextControlSingleLine. Also add an accessor for the caps
lock indicator element in the shadow DOM.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent):
(WebCore::TextFieldInputType::shouldHaveCapsLockIndicator):
(WebCore::TextFieldInputType::createShadowSubtree):
(WebCore::TextFieldInputType::capsLockIndicatorElement):
(WebCore::TextFieldInputType::destroyShadowSubtree):
(WebCore::TextFieldInputType::shouldDrawCapsLockIndicator):
(WebCore::TextFieldInputType::capsLockStateMayHaveChanged):
* html/TextFieldInputType.h:
Add a new element to the text field shadow DOM to act as the caps lock indicator.
Give it a pseudo-element ID of -webkit-caps-lock-indicator so it can be referenced
from CSS. The element is always in the DOM for a password field. It toggles between
display: none and display: block depending on the state of the caps lock key.

* page/EventHandler.cpp:
(WebCore::EventHandler::capsLockStateMayHaveChanged):
Pipe notification of changes in the caps locks state to the <input> element
rather than the RenderTextControlSingleLine.

* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::paint): Deleted.
(WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged): Deleted.
* rendering/RenderTextControlSingleLine.h:
Remove logic for drawing the caps lock indicator.

* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::paintMeter):
(WebCore::RenderTheme::adjustCapsLockIndicatorStyle):
(WebCore::RenderTheme::paintCapsLockIndicator):
(WebCore::RenderTheme::shouldHaveCapsLockIndicator):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::paintCapsLockIndicator): Deleted.
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::shouldHaveCapsLockIndicator):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::shouldHaveCapsLockIndicator):
(WebCore::RenderThemeMac::paintCapsLockIndicator): Deleted.
Now that the caps lock indicator is implemented like other aspects of form controls,
the theme code can be converted to be similar as well.

LayoutTests:

* fast/css/appearance-caps-lock-indicator-expected.txt:
* fast/css/appearance-caps-lock-indicator.html:
* platform/mac/fast/css/text-overflow-input-expected.txt:
* platform/mac/fast/forms/basic-inputs-expected.txt:
* platform/mac/fast/forms/input-appearance-height-expected.txt:
* platform/mac/fast/forms/input-value-expected.txt:
* platform/mac/fast/forms/placeholder-pseudo-style-expected.txt:
* platform/mac/fast/forms/validation-message-appearance-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/appearance-caps-lock-indicator-expected.txt
LayoutTests/fast/css/appearance-caps-lock-indicator.html
LayoutTests/platform/mac-mavericks/fast/css/text-overflow-input-expected.txt
LayoutTests/platform/mac-mavericks/fast/forms/basic-inputs-expected.txt
LayoutTests/platform/mac-mavericks/fast/forms/input-appearance-height-expected.txt
LayoutTests/platform/mac-mavericks/fast/forms/input-value-expected.txt
LayoutTests/platform/mac-mavericks/fast/forms/placeholder-pseudo-style-expected.txt
LayoutTests/platform/mac-mavericks/fast/forms/validation-message-appearance-expected.txt
LayoutTests/platform/mac-mavericks/tables/mozilla_expected_failures/bugs/bug92647-1-expected.txt
LayoutTests/platform/mac/fast/css/text-overflow-input-expected.txt
LayoutTests/platform/mac/fast/forms/basic-inputs-expected.txt
LayoutTests/platform/mac/fast/forms/input-appearance-height-expected.txt
LayoutTests/platform/mac/fast/forms/input-value-expected.txt
LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt
LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/html.css
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TextFieldInputType.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm