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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp

Issue 2209773002: Remove the blocking touch handlers for the input[type=range] and add touch-action instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the touch event handlers to the container in the shadow dom Created 4 years, 4 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/css/resolver/StyleAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
index 90e4221c16c3c86f203ecf958624440bb553e9a0..ef95752a7c715c5351695045cbadd943364452db 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
@@ -29,6 +29,7 @@
#include "core/css/resolver/StyleAdjuster.h"
#include "core/HTMLNames.h"
+#include "core/InputTypeNames.h"
#include "core/SVGNames.h"
#include "core/dom/ContainerNode.h"
#include "core/dom/Document.h"
@@ -41,6 +42,7 @@
#include "core/html/HTMLPlugInElement.h"
#include "core/html/HTMLTableCellElement.h"
#include "core/html/HTMLTextAreaElement.h"
+#include "core/html/shadow/ShadowElementNames.h"
#include "core/layout/LayoutTheme.h"
#include "core/style/ComputedStyle.h"
#include "core/style/ComputedStyleConstants.h"
@@ -336,6 +338,15 @@ static void adjustStyleForDisplay(ComputedStyle& style, const ComputedStyle& par
}
}
+static void adjustSliderStyle(ComputedStyle& style, Element* e, const ComputedStyle& sliderStyle)
+{
+ if (sliderStyle.appearance() == SliderVerticalPart) {
+ style.setTouchAction(TouchActionPanX);
+ } else {
+ style.setTouchAction(TouchActionPanY);
+ }
+}
+
void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyle& parentStyle, Element* element)
{
if (style.display() != NONE) {
@@ -414,6 +425,23 @@ void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl
style.clearMultiCol();
}
adjustStyleForAlignment(style, parentStyle);
+
majidvp 2016/08/12 03:35:43 I think tkent@ suggestion was to move this to Layo
+ // This block is for initialzation stage, when container's layoubtObject() hasn't been initialized.
majidvp 2016/08/12 03:35:43 s/initialzation/initialization/
+ if (element && element->getAttribute("id") == ShadowElementNames::sliderContainer()) {
+ Element* host = element->shadowHost();
+ if (host && isHTMLInputElement(host) && static_cast<HTMLInputElement*>(host)->type() == InputTypeNames::range) {
majidvp 2016/08/12 03:35:43 blink has helper function that should be used inst
+ adjustSliderStyle(style, element, host->layoutObject()->styleRef());
majidvp 2016/08/12 03:35:43 Instead of passing the whole style reference as la
+ }
+ }
+
+ // This block is for later stage when the <input>'s appearance changes but container's adjustComputedStyle wouldn't be called.
+ // Container's layoutObject() has been initialized this time.
majidvp 2016/08/12 03:35:43 I am not an style expert but I think a better appr
tkent 2016/08/12 06:15:18 Yes, adding -webkit-appearance:inherit to ::-webki
sunyunjia 2016/09/20 21:39:07 According to https://bugs.chromium.org/p/chromium/
+ if (element && isHTMLInputElement(element) && static_cast<HTMLInputElement*>(element)->type() == InputTypeNames::range && element->userAgentShadowRoot()) {
+ Element* container = element->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderContainer());
+ if (container && container->layoutObject()) {
+ adjustSliderStyle(container->layoutObject()->mutableStyleRef(), container, style);
+ }
+ }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698