Commit d0124a2b authored by vollick's avatar vollick Committed by Commit bot

Avoid element id collisions with the visual viewport

The frame scroll layer and the inner viewport layer had previously been
given the same element id.

BUG=658252

Review-Url: https://chromiumcodereview.appspot.com/2443633002
Cr-Commit-Position: refs/heads/master@{#426928}
parent d0803376
......@@ -391,9 +391,10 @@ void VisualViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot) {
m_innerViewportContainerLayer->platformLayer());
m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, true);
if (mainFrame()) {
if (Document* document = mainFrame()->document())
if (Document* document = mainFrame()->document()) {
m_innerViewportScrollLayer->setElementId(createCompositorElementId(
DOMNodeIds::idForNode(document), CompositorSubElementId::Scroll));
DOMNodeIds::idForNode(document), CompositorSubElementId::Viewport));
}
}
m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
......
......@@ -10,7 +10,7 @@
namespace blink {
enum class CompositorSubElementId { Primary, Scroll, LinkHighlight };
enum class CompositorSubElementId { Primary, Scroll, Viewport, LinkHighlight };
using CompositorElementId = cc::ElementId;
......
......@@ -1175,6 +1175,12 @@ void GraphicsLayer::setElementId(const CompositorElementId& id) {
layer->setElementId(id);
}
CompositorElementId GraphicsLayer::elementId() const {
if (WebLayer* layer = platformLayer())
return layer->elementId();
return CompositorElementId();
}
void GraphicsLayer::setCompositorMutableProperties(uint32_t properties) {
if (WebLayer* layer = platformLayer())
layer->setCompositorMutableProperties(properties);
......
......@@ -268,6 +268,8 @@ class PLATFORM_EXPORT GraphicsLayer : public WebLayerScrollClient,
WebLayer* contentsLayer() const { return m_contentsLayer; }
void setElementId(const CompositorElementId&);
CompositorElementId elementId() const;
void setCompositorMutableProperties(uint32_t);
ContentLayerDelegate* contentLayerDelegateForTesting() const {
......
......@@ -19,6 +19,7 @@
#include "platform/PlatformGestureEvent.h"
#include "platform/geometry/DoublePoint.h"
#include "platform/geometry/DoubleRect.h"
#include "platform/graphics/CompositorElementId.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/URLTestHelpers.h"
#include "public/platform/Platform.h"
......@@ -783,6 +784,9 @@ TEST_P(ParameterizedVisualViewportTest,
// Ensure the scroll layer matches the frame view's size.
EXPECT_SIZE_EQ(FloatSize(320, 240), visualViewport.scrollLayer()->size());
EXPECT_EQ(static_cast<int>(CompositorSubElementId::Viewport),
visualViewport.scrollLayer()->elementId().secondaryId);
// Ensure the location and scale were reset.
EXPECT_SIZE_EQ(FloatSize(), visualViewport.scrollOffset());
EXPECT_EQ(1, visualViewport.scale());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment