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 051088eea9a012c4fd362fdc75944d906903af5a..ff8465ea92149be531f4b62e2ac92e9093f2b307 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" |
| @@ -366,6 +368,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. |
|
flackr
2017/06/07 18:21:47
Should we remove the computed touch action then? i
sunxd
2017/06/08 19:08:11
I think in the original code, we continue with tre
flackr
2017/06/08 19:35:21
Sorry, I think there may be a misunderstanding, St
sunxd
2017/06/09 21:00:35
OK, that sounds reasonable to me, done!
|
| + // 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; |
| + } |
| + |
| + // When a gesture is started, the browser intersects the touch-action values |
| + // of the touched element and all its ancestors up to the one that implements |
|
flackr
2017/06/07 18:21:47
Since we won't actually do a walk intersecting the
sunxd
2017/06/08 19:08:12
Done.
|
| + // the gesture. So a scrolling element should cancel all panning-restricted |
| + // touch actions applied by ancestors of the scrolling element. |
| + 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(); |
|
flackr
2017/06/07 18:21:47
This confuses me, why do we need to mask with the
sunxd
2017/06/08 19:08:11
I think we are masking with iframe's touch action
flackr
2017/06/08 19:35:21
Ah I see, so if I understand correctly, we're grab
sunxd
2017/06/12 17:27:04
Yes, now I made iframe updates only trigger the re
|
| + if (frame_style) { |
| + action &= |
| + frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan; |
|
flackr
2017/06/07 18:21:47
Shouldn't we re-enable panning if it was disabled
sunxd
2017/06/08 19:08:11
Oh I think I should write:
action = frame_style->
flackr
2017/06/08 19:35:20
Yes, that makes more sense.
sunxd
2017/06/09 21:00:35
Done.
|
| + } |
| + } |
| + |
| + // Apply the adjusted parent effective touch actions. |
| + style.SetEffectiveTouchAction(style.GetTouchAction() & action); |
| +} |
| + |
| void StyleAdjuster::AdjustComputedStyle( |
| ComputedStyle& style, |
| const ComputedStyle& parent_style, |
| @@ -496,6 +544,7 @@ void StyleAdjuster::AdjustComputedStyle( |
| if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| style.SetJustifyItems(parent_style.JustifyItems()); |
| } |
| -} |
| + AdjustEffectiveTouchAction(style, parent_style, element); |
| +} |
| } // namespace blink |