Chromium Code Reviews| 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 d561f3f6cb0dcfc2b8bc7f28686600aa54c3415c..4a995a3aef75e94cee445867174411d969eb5ada 100644 |
| --- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp |
| +++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp |
| @@ -35,6 +35,7 @@ |
| #include "core/dom/ContainerNode.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/Element.h" |
| +#include "core/dom/NodeComputedStyle.h" |
| #include "core/frame/LocalFrameView.h" |
| #include "core/frame/Settings.h" |
| #include "core/frame/UseCounter.h" |
| @@ -44,6 +45,7 @@ |
| #include "core/html/HTMLPlugInElement.h" |
| #include "core/html/HTMLTableCellElement.h" |
| #include "core/html/HTMLTextAreaElement.h" |
| +#include "core/layout/LayoutObject.h" |
| #include "core/layout/LayoutTheme.h" |
| #include "core/style/ComputedStyle.h" |
| #include "core/style/ComputedStyleConstants.h" |
| @@ -368,6 +370,52 @@ static void AdjustStyleForDisplay(ComputedStyle& style, |
| } |
| } |
| +static void AdjustEffectiveTouchAction(ComputedStyle& style, |
| + const ComputedStyle& parent_style, |
| + Element* element) { |
| + TouchAction action = parent_style.GetEffectiveTouchAction(); |
| + |
| + bool is_svg_root = element && element->IsSVGElement() && |
| + isSVGSVGElement(*element) && element->parentNode() && |
| + !element->parentNode()->IsSVGElement(); |
| + bool is_non_replaced_inline_elements = |
| + style.IsDisplayInlineType() && |
| + !(style.IsDisplayReplacedType() || is_svg_root || |
| + isHTMLImageElement(element)); |
| + bool is_table_row_or_column = style.IsDisplayTableRowOrColumnType(); |
| + |
| + // According to W3C specs, touch actions are only supported by elements that |
| + // support both the CSS width and height properties. |
| + // See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property. |
| + if (is_non_replaced_inline_elements || is_table_row_or_column) { |
| + style.SetEffectiveTouchAction(action); |
| + return; |
| + } |
| + |
| + // The effective touch action is the intersection of the touch-action values |
| + // of the current element and all of its ancestors up to the one that |
| + // implements the gesture. Since panning is implemented by the scroller it is |
| + // re-enabled for scrolling elements. |
| + if (style.ScrollsOverflow()) |
| + action |= TouchAction::kTouchActionPan; |
| + |
| + // The panning-restricted cancellation should also apply to iframes, so we |
| + // allow (panning & local touch action) on the first descendant element of a |
|
flackr
2017/06/08 19:35:21
local touch action? Is this the owning frame node'
sunxd
2017/06/09 21:00:35
Yeah that's a good point, I have verified that a c
|
| + // iframe element. |
| + if (element && element == element->GetDocument().documentElement() && |
| + element->GetDocument().LocalOwner()) { |
| + const ComputedStyle* frame_style = |
| + element->GetDocument().LocalOwner()->GetComputedStyle(); |
| + if (frame_style) { |
| + action = |
| + frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan; |
| + } |
| + } |
| + |
| + // Apply the adjusted parent effective touch actions. |
| + style.SetEffectiveTouchAction(style.GetTouchAction() & action); |
| +} |
| + |
| void StyleAdjuster::AdjustComputedStyle( |
| ComputedStyle& style, |
| const ComputedStyle& parent_style, |
| @@ -498,6 +546,7 @@ void StyleAdjuster::AdjustComputedStyle( |
| if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| style.SetJustifyItems(parent_style.JustifyItems()); |
| } |
| -} |
| + AdjustEffectiveTouchAction(style, parent_style, element); |
| +} |
| } // namespace blink |