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..77c9018c0cfc6f8f78e8d85f57822850ffea6e1f 100644 |
| --- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp |
| +++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp |
| @@ -35,6 +35,8 @@ |
| #include "core/dom/ContainerNode.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/Element.h" |
| +#include "core/dom/NodeComputedStyle.h" |
| +#include "core/dom/StyleChangeReason.h" |
| #include "core/frame/LocalFrameView.h" |
| #include "core/frame/Settings.h" |
| #include "core/frame/UseCounter.h" |
| @@ -44,6 +46,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 +371,63 @@ 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 |
| + // 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; |
|
flackr
2017/06/19 15:45:42
I still think it'd be cleaner to re-enable kTouchA
sunxd
2017/06/21 15:13:03
Done.
|
| + } |
| + } |
| + |
| + // Apply the adjusted parent effective touch actions. |
| + style.SetEffectiveTouchAction(style.GetTouchAction() & action); |
| + |
| + if (element && element->IsFrameOwnerElement() && |
| + ToHTMLFrameOwnerElement(element)->contentDocument()) { |
| + Element* content_document_element = |
| + ToHTMLFrameOwnerElement(element)->contentDocument()->documentElement(); |
| + if (content_document_element) { |
| + content_document_element->SetNeedsStyleRecalc( |
| + kSubtreeStyleChange, StyleChangeReasonForTracing::Create( |
| + StyleChangeReason::kStyleSheetChange)); |
|
flackr
2017/06/19 15:45:42
kStyleSheetChange is not the correct reason to set
sunxd
2017/06/21 15:13:03
Done.
|
| + } |
| + } |
| +} |
| + |
| void StyleAdjuster::AdjustComputedStyle( |
| ComputedStyle& style, |
| const ComputedStyle& parent_style, |
| @@ -498,6 +558,7 @@ void StyleAdjuster::AdjustComputedStyle( |
| if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| style.SetJustifyItems(parent_style.JustifyItems()); |
| } |
| -} |
| + AdjustEffectiveTouchAction(style, parent_style, element); |
| +} |
| } // namespace blink |