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

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

Issue 2916563003: Compute effective touch action in StyleAdjuster. (Closed)
Patch Set: Add rendering test that tests iframe style change 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 // The panning-restricted cancellation should also apply to iframes, so we
401 // allow (panning & local touch action) on the first descendant element of a
402 // iframe element.
403 bool is_child_document =
404 element && element == element->GetDocument().documentElement() &&
405 element->GetDocument().LocalOwner();
406
407 if (is_child_document) {
408 const ComputedStyle* frame_style =
409 element->GetDocument().LocalOwner()->GetComputedStyle();
410 if (frame_style)
flackr 2017/06/21 15:24:34 Is it possible for frame_style to be null? This is
sunxd 2017/06/22 17:22:55 In many webkit_unit_tests, e.g. PrintContextFrameT
411 action = frame_style->GetEffectiveTouchAction();
412 }
413
414 if (style.ScrollsOverflow() || is_child_document)
415 action |= TouchAction::kTouchActionPan;
416
417 // Apply the adjusted parent effective touch actions.
418 style.SetEffectiveTouchAction(style.GetTouchAction() & action);
419
420 if (element && element->IsFrameOwnerElement() &&
421 ToHTMLFrameOwnerElement(element)->contentDocument()) {
422 Element* content_document_element =
423 ToHTMLFrameOwnerElement(element)->contentDocument()->documentElement();
424 if (content_document_element) {
425 content_document_element->SetNeedsStyleRecalc(
426 kSubtreeStyleChange,
427 StyleChangeReasonForTracing::Create(
428 StyleChangeReason::kInheritedStyleChangeFromParentFrame));
429 }
430 }
431 }
432
371 void StyleAdjuster::AdjustComputedStyle( 433 void StyleAdjuster::AdjustComputedStyle(
372 ComputedStyle& style, 434 ComputedStyle& style,
373 const ComputedStyle& parent_style, 435 const ComputedStyle& parent_style,
374 const ComputedStyle& layout_parent_style, 436 const ComputedStyle& layout_parent_style,
375 Element* element) { 437 Element* element) {
376 if (style.Display() != EDisplay::kNone) { 438 if (style.Display() != EDisplay::kNone) {
377 if (element && element->IsHTMLElement()) 439 if (element && element->IsHTMLElement())
378 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); 440 AdjustStyleForHTMLElement(style, ToHTMLElement(*element));
379 441
380 // Per the spec, position 'static' and 'relative' in the top layer compute 442 // 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) 553 if (style.GetPosition() == EPosition::kSticky)
492 style.SetSubtreeIsSticky(true); 554 style.SetSubtreeIsSticky(true);
493 555
494 // If the inherited value of justify-items includes the 'legacy' keyword, 556 // If the inherited value of justify-items includes the 'legacy' keyword,
495 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to 557 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to
496 // 'normal'. 558 // 'normal'.
497 if (style.JustifyItemsPosition() == kItemPositionAuto) { 559 if (style.JustifyItemsPosition() == kItemPositionAuto) {
498 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) 560 if (parent_style.JustifyItemsPositionType() == kLegacyPosition)
499 style.SetJustifyItems(parent_style.JustifyItems()); 561 style.SetJustifyItems(parent_style.JustifyItems());
500 } 562 }
563
564 AdjustEffectiveTouchAction(style, parent_style, element);
501 } 565 }
502
503 } // namespace blink 566 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698