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

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

Issue 2916563003: Compute effective touch action in StyleAdjuster. (Closed)
Patch Set: resolve comments Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 17 matching lines...) Expand all
28 * Boston, MA 02110-1301, USA. 28 * Boston, MA 02110-1301, USA.
29 */ 29 */
30 30
31 #include "core/css/resolver/StyleAdjuster.h" 31 #include "core/css/resolver/StyleAdjuster.h"
32 32
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/SVGNames.h" 34 #include "core/SVGNames.h"
35 #include "core/dom/ContainerNode.h" 35 #include "core/dom/ContainerNode.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/Element.h" 37 #include "core/dom/Element.h"
38 #include "core/dom/NodeComputedStyle.h"
39 #include "core/dom/StyleChangeReason.h"
38 #include "core/frame/LocalFrameView.h" 40 #include "core/frame/LocalFrameView.h"
39 #include "core/frame/Settings.h" 41 #include "core/frame/Settings.h"
40 #include "core/frame/UseCounter.h" 42 #include "core/frame/UseCounter.h"
41 #include "core/html/HTMLIFrameElement.h" 43 #include "core/html/HTMLIFrameElement.h"
42 #include "core/html/HTMLImageElement.h" 44 #include "core/html/HTMLImageElement.h"
43 #include "core/html/HTMLInputElement.h" 45 #include "core/html/HTMLInputElement.h"
44 #include "core/html/HTMLPlugInElement.h" 46 #include "core/html/HTMLPlugInElement.h"
45 #include "core/html/HTMLTableCellElement.h" 47 #include "core/html/HTMLTableCellElement.h"
46 #include "core/html/HTMLTextAreaElement.h" 48 #include "core/html/HTMLTextAreaElement.h"
49 #include "core/layout/LayoutObject.h"
47 #include "core/layout/LayoutTheme.h" 50 #include "core/layout/LayoutTheme.h"
48 #include "core/style/ComputedStyle.h" 51 #include "core/style/ComputedStyle.h"
49 #include "core/style/ComputedStyleConstants.h" 52 #include "core/style/ComputedStyleConstants.h"
50 #include "core/svg/SVGSVGElement.h" 53 #include "core/svg/SVGSVGElement.h"
51 #include "platform/Length.h" 54 #include "platform/Length.h"
52 #include "platform/transforms/TransformOperations.h" 55 #include "platform/transforms/TransformOperations.h"
53 #include "platform/wtf/Assertions.h" 56 #include "platform/wtf/Assertions.h"
54 57
55 namespace blink { 58 namespace blink {
56 59
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 UseCounter::Count(document, 364 UseCounter::Count(document,
362 WebFeature::kFlexboxPercentagePaddingVertical); 365 WebFeature::kFlexboxPercentagePaddingVertical);
363 } 366 }
364 if (style.MarginBefore().IsPercentOrCalc() || 367 if (style.MarginBefore().IsPercentOrCalc() ||
365 style.MarginAfter().IsPercentOrCalc()) { 368 style.MarginAfter().IsPercentOrCalc()) {
366 UseCounter::Count(document, WebFeature::kFlexboxPercentageMarginVertical); 369 UseCounter::Count(document, WebFeature::kFlexboxPercentageMarginVertical);
367 } 370 }
368 } 371 }
369 } 372 }
370 373
374 static void AdjustEffectiveTouchAction(ComputedStyle& style,
375 const ComputedStyle& parent_style,
376 Element* element) {
377 TouchAction action = parent_style.GetEffectiveTouchAction();
378
379 bool is_svg_root = element && element->IsSVGElement() &&
380 isSVGSVGElement(*element) && element->parentNode() &&
381 !element->parentNode()->IsSVGElement();
382 bool is_non_replaced_inline_elements =
383 style.IsDisplayInlineType() &&
384 !(style.IsDisplayReplacedType() || is_svg_root ||
385 isHTMLImageElement(element));
386 bool is_table_row_or_column = style.IsDisplayTableRowOrColumnType();
387
388 // According to W3C specs, touch actions are only supported by elements that
389 // support both the CSS width and height properties.
390 // See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property.
391 if (is_non_replaced_inline_elements || is_table_row_or_column) {
392 style.SetEffectiveTouchAction(action);
393 return;
394 }
395
396 // The effective touch action is the intersection of the touch-action values
397 // of the current element and all of its ancestors up to the one that
398 // implements the gesture. Since panning is implemented by the scroller it is
399 // re-enabled for scrolling elements.
400 if (style.ScrollsOverflow())
401 action |= TouchAction::kTouchActionPan;
402
403 // The panning-restricted cancellation should also apply to iframes, so we
404 // allow (panning & local touch action) on the first descendant element of a
405 // iframe element.
406 if (element && element == element->GetDocument().documentElement() &&
407 element->GetDocument().LocalOwner()) {
408 const ComputedStyle* frame_style =
409 element->GetDocument().LocalOwner()->GetComputedStyle();
410 if (frame_style) {
411 action =
412 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.
413 }
414 }
415
416 // Apply the adjusted parent effective touch actions.
417 style.SetEffectiveTouchAction(style.GetTouchAction() & action);
418
419 if (element && element->IsFrameOwnerElement() &&
420 ToHTMLFrameOwnerElement(element)->contentDocument()) {
421 Element* content_document_element =
422 ToHTMLFrameOwnerElement(element)->contentDocument()->documentElement();
423 if (content_document_element) {
424 content_document_element->SetNeedsStyleRecalc(
425 kSubtreeStyleChange, StyleChangeReasonForTracing::Create(
426 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.
427 }
428 }
429 }
430
371 void StyleAdjuster::AdjustComputedStyle( 431 void StyleAdjuster::AdjustComputedStyle(
372 ComputedStyle& style, 432 ComputedStyle& style,
373 const ComputedStyle& parent_style, 433 const ComputedStyle& parent_style,
374 const ComputedStyle& layout_parent_style, 434 const ComputedStyle& layout_parent_style,
375 Element* element) { 435 Element* element) {
376 if (style.Display() != EDisplay::kNone) { 436 if (style.Display() != EDisplay::kNone) {
377 if (element && element->IsHTMLElement()) 437 if (element && element->IsHTMLElement())
378 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); 438 AdjustStyleForHTMLElement(style, ToHTMLElement(*element));
379 439
380 // Per the spec, position 'static' and 'relative' in the top layer compute 440 // Per the spec, position 'static' and 'relative' in the top layer compute
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (style.GetPosition() == EPosition::kSticky) 551 if (style.GetPosition() == EPosition::kSticky)
492 style.SetSubtreeIsSticky(true); 552 style.SetSubtreeIsSticky(true);
493 553
494 // If the inherited value of justify-items includes the 'legacy' keyword, 554 // If the inherited value of justify-items includes the 'legacy' keyword,
495 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to 555 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to
496 // 'normal'. 556 // 'normal'.
497 if (style.JustifyItemsPosition() == kItemPositionAuto) { 557 if (style.JustifyItemsPosition() == kItemPositionAuto) {
498 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) 558 if (parent_style.JustifyItemsPositionType() == kLegacyPosition)
499 style.SetJustifyItems(parent_style.JustifyItems()); 559 style.SetJustifyItems(parent_style.JustifyItems());
500 } 560 }
561
562 AdjustEffectiveTouchAction(style, parent_style, element);
501 } 563 }
502
503 } // namespace blink 564 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698