Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 bool is_document_element = | |
| 379 element && element == element->GetDocument().documentElement(); | |
| 380 bool is_frame_owner_element = element && element->IsFrameOwnerElement(); | |
| 381 | |
| 382 if (!style.ScrollsOverflow() && | |
| 383 style.GetTouchAction() == TouchAction::kTouchActionAuto && | |
| 384 !is_document_element && !is_frame_owner_element) { | |
| 385 style.SetEffectiveTouchAction(action); | |
| 386 return; | |
| 387 } | |
| 388 | |
| 389 bool is_svg_root = element && element->IsSVGElement() && | |
| 390 isSVGSVGElement(*element) && element->parentNode() && | |
| 391 !element->parentNode()->IsSVGElement(); | |
| 392 bool is_non_replaced_inline_elements = | |
| 393 style.IsDisplayInlineType() && | |
| 394 !(style.IsDisplayReplacedType() || is_svg_root || | |
| 395 isHTMLImageElement(element)); | |
| 396 bool is_table_row_or_column = style.IsDisplayTableRowOrColumnType(); | |
| 397 | |
| 398 // According to W3C specs, touch actions are only supported by elements that | |
| 399 // support both the CSS width and height properties. | |
| 400 // See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property. | |
| 401 if (is_non_replaced_inline_elements || is_table_row_or_column) { | |
| 402 style.SetEffectiveTouchAction(action); | |
| 403 style.SetTouchAction(TouchAction::kTouchActionAuto); | |
| 404 return; | |
| 405 } | |
| 406 | |
| 407 // The effective touch action is the intersection of the touch-action values | |
| 408 // of the current element and all of its ancestors up to the one that | |
| 409 // implements the gesture. Since panning is implemented by the scroller it is | |
| 410 // re-enabled for scrolling elements. | |
| 411 if (style.ScrollsOverflow()) | |
| 412 action |= TouchAction::kTouchActionPan; | |
| 413 | |
| 414 // The panning-restricted cancellation should also apply to iframes, so we | |
| 415 // allow (panning & local touch action) on the first descendant element of a | |
| 416 // iframe element. | |
| 417 if (is_document_element && element->GetDocument().LocalOwner()) { | |
| 418 const ComputedStyle* frame_style = | |
| 419 element->GetDocument().LocalOwner()->GetComputedStyle(); | |
| 420 if (frame_style) { | |
| 421 action = | |
| 422 frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan; | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 // Apply the adjusted parent effective touch actions. | |
| 427 style.SetEffectiveTouchAction(style.GetTouchAction() & action); | |
| 428 | |
| 429 if (is_frame_owner_element && | |
| 430 ToHTMLFrameOwnerElement(element)->contentDocument()) { | |
| 431 Element* content_document_element = | |
| 432 ToHTMLFrameOwnerElement(element)->contentDocument()->documentElement(); | |
| 433 if (content_document_element) { | |
| 434 content_document_element->SetNeedsStyleRecalc( | |
|
flackr
2017/06/15 00:32:42
Maybe SetEffectiveTouchAction on the content docum
sunxd
2017/06/15 16:10:27
So "mysteriously" setting the effective touch acti
| |
| 435 kSubtreeStyleChange, StyleChangeReasonForTracing::Create( | |
| 436 StyleChangeReason::kStyleSheetChange)); | |
| 437 } | |
| 438 } | |
| 439 } | |
| 440 | |
| 371 void StyleAdjuster::AdjustComputedStyle( | 441 void StyleAdjuster::AdjustComputedStyle( |
| 372 ComputedStyle& style, | 442 ComputedStyle& style, |
| 373 const ComputedStyle& parent_style, | 443 const ComputedStyle& parent_style, |
| 374 const ComputedStyle& layout_parent_style, | 444 const ComputedStyle& layout_parent_style, |
| 375 Element* element) { | 445 Element* element) { |
| 376 if (style.Display() != EDisplay::kNone) { | 446 if (style.Display() != EDisplay::kNone) { |
| 377 if (element && element->IsHTMLElement()) | 447 if (element && element->IsHTMLElement()) |
| 378 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); | 448 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); |
| 379 | 449 |
| 380 // Per the spec, position 'static' and 'relative' in the top layer compute | 450 // Per the spec, position 'static' and 'relative' in the top layer compute |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 if (style.GetPosition() == EPosition::kSticky) | 561 if (style.GetPosition() == EPosition::kSticky) |
| 492 style.SetSubtreeIsSticky(true); | 562 style.SetSubtreeIsSticky(true); |
| 493 | 563 |
| 494 // If the inherited value of justify-items includes the 'legacy' keyword, | 564 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 495 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 565 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| 496 // 'normal'. | 566 // 'normal'. |
| 497 if (style.JustifyItemsPosition() == kItemPositionAuto) { | 567 if (style.JustifyItemsPosition() == kItemPositionAuto) { |
| 498 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) | 568 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| 499 style.SetJustifyItems(parent_style.JustifyItems()); | 569 style.SetJustifyItems(parent_style.JustifyItems()); |
| 500 } | 570 } |
| 571 | |
| 572 AdjustEffectiveTouchAction(style, parent_style, element); | |
| 501 } | 573 } |
| 502 | |
| 503 } // namespace blink | 574 } // namespace blink |
| OLD | NEW |