Ejemplo n.º 1
0
TEST(MediaQueryEvaluatorTest, Cached) {
  MediaValuesCached::MediaValuesCachedData data;
  data.viewportWidth = 500;
  data.viewportHeight = 500;
  data.deviceWidth = 500;
  data.deviceHeight = 500;
  data.devicePixelRatio = 2.0;
  data.colorBitsPerComponent = 24;
  data.monochromeBitsPerComponent = 0;
  data.primaryPointerType = PointerTypeFine;
  data.primaryHoverType = HoverTypeHover;
  data.defaultFontSize = 16;
  data.threeDEnabled = true;
  data.mediaType = MediaTypeNames::screen;
  data.strictMode = true;
  data.displayMode = WebDisplayModeBrowser;
  MediaValues* mediaValues = MediaValuesCached::create(data);

  MediaQueryEvaluator mediaQueryEvaluator(*mediaValues);
  testMQEvaluator(screenTestCases, mediaQueryEvaluator);
  testMQEvaluator(viewportTestCases, mediaQueryEvaluator);

  data.mediaType = MediaTypeNames::print;
  mediaValues = MediaValuesCached::create(data);
  MediaQueryEvaluator printMediaQueryEvaluator(*mediaValues);
  testMQEvaluator(printTestCases, printMediaQueryEvaluator);
}
Ejemplo n.º 2
0
TEST(MediaQueryEvaluatorTest, CachedFloatViewportNonFloatFriendly) {
  MediaValuesCached::MediaValuesCachedData data;
  data.viewportWidth = 821;
  data.viewportHeight = 821;
  MediaValues* mediaValues = MediaValuesCached::create(data);

  MediaQueryEvaluator mediaQueryEvaluator(*mediaValues);
  testMQEvaluator(floatNonFriendlyViewportTestCases, mediaQueryEvaluator);
}
Ejemplo n.º 3
0
TEST(MediaQueryEvaluatorTest, CachedFloatViewport) {
  MediaValuesCached::MediaValuesCachedData data;
  data.viewportWidth = 600.5;
  data.viewportHeight = 700.125;
  MediaValues* mediaValues = MediaValuesCached::create(data);

  MediaQueryEvaluator mediaQueryEvaluator(*mediaValues);
  testMQEvaluator(floatViewportTestCases, mediaQueryEvaluator);
}
TEST(MediaQueryEvaluatorTest, DynamicNoView)
{
    OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 500));
    pageHolder->frame().setView(nullptr);
    MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
    RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar");
    bool output = false;
    ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get()));
}
Ejemplo n.º 5
0
TEST(MediaQueryEvaluatorTest, DynamicNoView) {
  std::unique_ptr<DummyPageHolder> pageHolder =
      DummyPageHolder::create(IntSize(500, 500));
  LocalFrame* frame = &pageHolder->frame();
  pageHolder.reset();
  ASSERT_EQ(nullptr, frame->view());
  MediaQueryEvaluator mediaQueryEvaluator(frame);
  MediaQuerySet* querySet = MediaQuerySet::create("foobar");
  EXPECT_FALSE(mediaQueryEvaluator.eval(querySet));
}
Ejemplo n.º 6
0
TEST(MediaQueryEvaluatorTest, Dynamic) {
  std::unique_ptr<DummyPageHolder> pageHolder =
      DummyPageHolder::create(IntSize(500, 500));
  pageHolder->frameView().setMediaType(MediaTypeNames::screen);

  MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
  testMQEvaluator(viewportTestCases, mediaQueryEvaluator);
  pageHolder->frameView().setMediaType(MediaTypeNames::print);
  testMQEvaluator(printTestCases, mediaQueryEvaluator);
}
Ejemplo n.º 7
0
TEST(MediaQueryEvaluatorTest, DynamicNoView)
{
    OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 500));
    RefPtrWillBeRawPtr<LocalFrame> frame = &pageHolder->frame();
    pageHolder.clear();
    ASSERT_EQ(nullptr, frame->view());
    MediaQueryEvaluator mediaQueryEvaluator(frame.get());
    RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar");
    EXPECT_FALSE(mediaQueryEvaluator.eval(querySet.get()));
}
Ejemplo n.º 8
0
TEST(MediaQueryEvaluatorTest, InitialViewport) {
  std::unique_ptr<DummyPageHolder> pageHolder =
      DummyPageHolder::create(IntSize(500, 500));
  pageHolder->frameView().setMediaType(MediaTypeNames::screen);
  pageHolder->frameView().setLayoutSizeFixedToFrameSize(false);
  pageHolder->frameView().setInitialViewportSize(IntSize(500, 500));
  pageHolder->frameView().setLayoutSize(IntSize(800, 800));
  pageHolder->frameView().setFrameRect(IntRect(0, 0, 800, 800));

  MediaQueryEvaluator mediaQueryEvaluator(
      MediaValuesInitialViewport::create(pageHolder->frame()));
  testMQEvaluator(viewportTestCases, mediaQueryEvaluator);
}
Ejemplo n.º 9
0
static bool match(std::unique_ptr<MediaQueryExp>&& expression, RenderStyle& style, Frame* frame)
{
    if (expression->mediaFeature().isEmpty())
        return true;

    auto expList = std::make_unique<Vector<std::unique_ptr<MediaQueryExp>>>();
    expList->append(WTFMove(expression));

    RefPtr<MediaQuerySet> mediaQuerySet = MediaQuerySet::create();
    mediaQuerySet->addMediaQuery(std::make_unique<MediaQuery>(MediaQuery::None, "all", WTFMove(expList)));

    MediaQueryEvaluator mediaQueryEvaluator("screen", frame, &style);
    return mediaQueryEvaluator.eval(mediaQuerySet.get());
}
static bool mediaAttributeMatches(Frame* frame, RenderStyle* renderStyle, const String& attributeValue)
{
    RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::createAllowingDescriptionSyntax(attributeValue);
    MediaQueryEvaluator mediaQueryEvaluator("screen", frame, renderStyle);
    return mediaQueryEvaluator.eval(mediaQueries.get());
}
Ejemplo n.º 11
0
bool SizesAttributeParser::mediaConditionMatches(PassRefPtrWillBeRawPtr<MediaQuerySet> mediaCondition)
{
    // A Media Condition cannot have a media type other then screen.
    MediaQueryEvaluator mediaQueryEvaluator(*m_mediaValues);
    return mediaQueryEvaluator.eval(mediaCondition.get());
}
Ejemplo n.º 12
0
bool SizesAttributeParser::mediaConditionMatches(PassRefPtrWillBeRawPtr<MediaQuerySet> mediaCondition)
{
    // FIXME: How do I handle non-screen media types here?
    MediaQueryEvaluator mediaQueryEvaluator(MediaTypeNames::screen, *m_mediaValues);
    return mediaQueryEvaluator.eval(mediaCondition.get());
}