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

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

Issue 2916563003: Compute effective touch action in StyleAdjuster. (Closed)
Patch Set: fix layout test failures Created 3 years, 7 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 051088eea9a012c4fd362fdc75944d906903af5a..02c27fe5f1d4f89cd375e0039b7b39e870102b87 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"
@@ -451,6 +453,7 @@ void StyleAdjuster::AdjustComputedStyle(
AdjustStyleForEditing(style);
bool is_svg_element = element && element->IsSVGElement();
+ bool is_svg_root = false;
wkorman 2017/06/02 03:07:05 Please add unit tests for this new logic. I haven'
flackr 2017/06/05 18:43:10 nit: Calculate this here, i.e. bool is_svg_root =
sunxd 2017/06/05 20:12:04 Done % StyleAdjusterTest.
sunxd 2017/06/05 20:12:04 Sure I'll look into this.
sunxd 2017/06/05 20:12:04 Acknowledged.
if (is_svg_element) {
// display: contents computes to inline for replaced elements and form
// controls, and isn't specified for other kinds of SVG content[1], so let's
@@ -467,8 +470,11 @@ void StyleAdjuster::AdjustComputedStyle(
// Only the root <svg> element in an SVG document fragment tree honors css
// position.
if (!(isSVGSVGElement(*element) && element->parentNode() &&
- !element->parentNode()->IsSVGElement()))
+ !element->parentNode()->IsSVGElement())) {
style.SetPosition(ComputedStyle::InitialPosition());
+ } else {
+ is_svg_root = true;
+ }
// SVG text layout code expects us to be a block-level style element.
if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) &&
@@ -496,6 +502,43 @@ void StyleAdjuster::AdjustComputedStyle(
if (parent_style.JustifyItemsPositionType() == kLegacyPosition)
style.SetJustifyItems(parent_style.JustifyItems());
}
+
+ TouchAction action = parent_style.GetEffectiveTouchAction();
+ bool is_non_replaced_inline_elements =
+ style.IsDisplayInlineType() &&
+ !(style.IsDisplayReplacedType() || is_svg_root ||
+ isHTMLImageElement(element));
+ bool is_table_row_or_column = style.Display() == EDisplay::kTableRow ||
wkorman 2017/06/02 03:07:05 Can we use IsDisplayTableType() or is that too bro
sunxd 2017/06/05 20:12:03 Yes that function is too broad. I think table capt
sunxd 2017/06/06 15:24:59 Done.
+ style.Display() == EDisplay::kTableRowGroup ||
+ style.Display() == EDisplay::kTableColumn ||
+ style.Display() == EDisplay::kTableColumnGroup;
+ if (is_non_replaced_inline_elements || is_table_row_or_column) {
wkorman 2017/06/02 03:07:05 What made us choose this filtering criteria? If th
sunxd 2017/06/05 20:12:03 Sure I'll add one here. According to spec, the tou
sunxd 2017/06/05 20:12:04 Acknowledged.
sunxd 2017/06/06 15:24:58 Done.
+ style.SetEffectiveTouchAction(action);
+ return;
flackr 2017/06/05 18:43:10 Seems to me early returns are dangerous in a long
sunxd 2017/06/05 20:12:04 Acknowledged.
sunxd 2017/06/06 15:24:58 Done.
+ }
+
+ bool overflow_x = style.OverflowX() == EOverflow::kScroll ||
+ style.OverflowX() == EOverflow::kAuto ||
+ style.OverflowX() == EOverflow::kOverlay;
flackr 2017/06/05 18:43:10 Seems like this could use a helper function on Com
sunxd 2017/06/05 20:12:03 Acknowledged.
sunxd 2017/06/06 15:24:59 Done.
+ bool overflow_y = style.OverflowY() == EOverflow::kScroll ||
+ style.OverflowY() == EOverflow::kAuto ||
+ style.OverflowY() == EOverflow::kWebkitPagedY ||
flackr 2017/06/05 18:43:10 Why only kWebkitPagedY? Should overflow_x also che
sunxd 2017/06/05 20:12:03 I adopted the logic from here: https://cs.chromium
sunxd 2017/06/12 17:27:04 Done.
+ style.OverflowY() == EOverflow::kOverlay;
+ if (overflow_x || overflow_y)
+ action |= TouchAction::kTouchActionPan;
wkorman 2017/06/02 03:07:05 Add a comment re: why we or-in kTouchActionPan her
sunxd 2017/06/05 20:12:04 Acknowledged.
sunxd 2017/06/06 15:24:58 Done.
+
+ if (element && element == element->GetDocument().documentElement() &&
wkorman 2017/06/02 03:07:05 Add a brief comment re: what we are doing at a hig
sunxd 2017/06/05 20:12:03 Acknowledged.
sunxd 2017/06/06 15:24:59 Done.
+ element->GetDocument().LocalOwner()) {
+ const ComputedStyle* frame_style =
+ element->GetDocument().LocalOwner()->GetComputedStyle();
+ if (frame_style) {
+ action &=
+ frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan;
flackr 2017/06/05 18:43:10 This won't re-enable panning since it is strictly
sunxd 2017/06/05 20:12:04 Yes. Scrollers / frames only mask its ancestors pa
+ }
+ }
+
+ // Apply TouchAction bits from its parent style
wkorman 2017/06/02 03:07:05 Clarify comment to note that we've incorporated ot
sunxd 2017/06/05 20:12:04 Acknowledged.
sunxd 2017/06/12 17:27:04 Done.
+ style.SetEffectiveTouchAction(style.GetTouchAction() & action);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698