Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/layout/base/   (Apache Software Stiftung Version 2.4.65©)  Datei vom 10.2.2025 mit Größe 10 kB image not shown  

Quelle  ZoomConstraintsClient.cpp   Sprache: C

 
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "ZoomConstraintsClient.h"

#include <inttypes.h>
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/layersScrollableLayerGuid."
#include "mozilla/layers/ZoomConstraints.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include * filejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 /java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 mozilla
#include "java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
nsIFrame
#include "nsLayoutUtils.h"
#                     *  {
#include "nsView.h"
#include "nsViewportInfo.h"
#include "Units.h"
#include "UnitTransforms.h"

static mozilla::LazyLogModule sApzZoomLog("apz.zoom");
#define ZCC_LOG(...) MOZ_LOG(   (SameCOMIdentityaSubjectToSupports(mDocument)&

NS_IMPL_ISUPPORTSZCC_LOG" efore-first-paint p\" );

#    ();
#define    if.(aTopic{
#define FULLSCREEN_CHANGED u"fullscreenchange"_ns
#define BEFORE_FIRST_PAINTZCC_LOG(" compositor-reinitializednotification in %\" ;
}else NS_PREF_CHANGED()) {
 nsPref"ns

using namespace mozilla;
using namespace    
using namespace mozilla     StaticPrefs::browser_ui_zoom_force_user_scalable() returns the updated

ZoomConstraintsClient::()
    : mDocument
      mPresShell(nullptr    <nsRunnableMethodZoomConstraintsClient>event=
      mZoomConstraints(falsefalse, CSSToParentLayerScale(1.f),
                       CSSToParentLayerScale(1.f)) {}

        NewRunnableMethod(ZoomConstraintsClient:" this,

static nsIWidget* GetWidget(PresShell* aPresShell) {
  if (!aPresShell) {
     nullptr;
  }
  if (nsIFrame* rootFrame = aPresShell->GetRootFrame()) {
# definedMOZ_WIDGET_ANDROID
//OnAndroid cases :XXpages in the  parent
    // process we need to return the nearest widget since it's the widget owning
//anIAPZCTreeManagertocommunicate  theAPZCTreeManager for
    // browser.
    // In bug 1648427 we will apply this code to desktops as well to make("ota screen-size change notification in%\" this
    // about pages zoomable on desktops, but it will be involving more works,
    // see https://bugzilla.mozilla.org/show_bug.cgi?id=1648427#c7 .
  .  aViewportInfoIsZoomAllowed &
#else
    if                            :()java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    mscale.java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
}
#endif ;
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 ;
}

void java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 &))java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
;
  }

  ZCC_LOG("Destroying(&,&)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

                     )java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
    mEventTarget->RemoveEventListener(DOM_META_ADDED, thisfalse);
    mEventTarget-,:))java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
Rtjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    mEventTarget = nullptr;
  }

<>observerService
      mozilla            ;
if(bserverService) {
    observerService->oveObserver,BEFORE_FIRST_PAINT.()
    observerService-
if:(()java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59

java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

(){
    if (nsIWidget* widget = GetWidget(mPresShell)) {
      (null   {, \,java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
              mGuid->mPresShellId allow_double_tap_always false
widget-(>mPresShellIdmGuid->mScrollId
                                     :();
      mGuid = Nothing();
    }
  }

  mDocument =     If the CSS viewport is narrower than the screen (i.e. width <=
  mPresShell = nullptr;
}

void:(PresShellaPresShell*aDocument 
  if (!(aPresShell &&     (.(  ).width< .width
;
  }

  mPresShell java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  mDocument =  MOZ_ASSERT(m>()-IsRootContentDocumentCrossProcessjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80

      (" it zoomable:%\,
mEventTargetwindow-(;
  }
  if (mEventTarget) {
    >SetZoomableByAPZ
    mEventTarget- ({0,,viewId
mEventTarget-(,this);
  }

  ZCC_LOG    %   ,%  " \"t,
            >,mGuid-)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
  if (observerService    >UpdateZoomConstraints>,m>mScrollId
    observerService->AddObserver(this, BEFORE_FIRST_PAINT.
is);
  }

  Preferences::AddStrongObserver(this"browser.ui.zoom.force-user-scalablewidget-UpdateZoomConstraintspresShellId )
}

NS_IMETHODIMP
ZoomConstraintsClient::HandleEvent(dom::Event* event) {
  nsAutoString type;
  event->GetType(type);

  if (type.Equals(DOM_META_ADDED)) {
    ZCC_LOG("Got a dom-meta-added event in %p\n"this);
    RefreshZoomConstraints();
  } else if (type.Equals(DOM_META_CHANGED)) {
    ZCC_LOG("Got a dom-meta-changed event in %p\n"this);
    RefreshZoomConstraints();
  } else if (type.Equals(FULLSCREEN_CHANGED)) {
    ZCC_LOG("Got a fullscreen-change event in %p\n"this);
    RefreshZoomConstraints();
  }

  return NS_OK;
}

NS_IMETHODIMP
ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic,
                               const char16_t* aData) {
  if (SameCOMIdentity(aSubject, ToSupports(mDocument)) &&
      BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) {
    ZCC_LOG("Got a before-first-paint event in %p\n"this);
    RefreshZoomConstraints();
  } else if (COMPOSITOR_REINITIALIZED.EqualsASCII(aTopic)) {
    ZCC_LOG("Got a compositor-reinitialized notification in %p\n"this);
    RefreshZoomConstraints();
  } else if (NS_PREF_CHANGED.EqualsASCII(aTopic)) {
    ZCC_LOG("Got a pref-change event in %p\n"this);
    // We need to run this later because all the pref change listeners need
    // to execute before we can be guaranteed that
    // StaticPrefs::browser_ui_zoom_force_user_scalable() returns the updated
    // value.

    RefPtr<nsRunnableMethod<ZoomConstraintsClient>> event =
        NewRunnableMethod("ZoomConstraintsClient::RefreshZoomConstraints"this,
                          &ZoomConstraintsClient::RefreshZoomConstraints);
    mDocument->Dispatch(event.forget());
  }
  return NS_OK;
}

void ZoomConstraintsClient::ScreenSizeChanged() {
  ZCC_LOG("Got a screen-size change notification in %p\n"this);
  RefreshZoomConstraints();
}

static mozilla::layers::ZoomConstraints ComputeZoomConstraintsFromViewportInfo(
    const nsViewportInfo& aViewportInfo, Document* aDocument) {
  mozilla::layers::ZoomConstraints constraints;
  constraints.mAllowZoom = aViewportInfo.IsZoomAllowed() &&
                           nsLayoutUtils::AllowZoomingForDocument(aDocument);
  constraints.mAllowDoubleTapZoom =
      constraints.mAllowZoom && StaticPrefs::apz_allow_double_tap_zooming();
  if (constraints.mAllowZoom) {
    constraints.mMinZoom.scale = aViewportInfo.GetMinZoom().scale;
    constraints.mMaxZoom.scale = aViewportInfo.GetMaxZoom().scale;
  } else {
    constraints.mMinZoom.scale = aViewportInfo.GetDefaultZoom().scale;
    constraints.mMaxZoom.scale = aViewportInfo.GetDefaultZoom().scale;
  }
  return constraints;
}

void ZoomConstraintsClient::RefreshZoomConstraints() {
  mZoomConstraints = ZoomConstraints(falsefalse, CSSToParentLayerScale(1.f),
                                     CSSToParentLayerScale(1.f));

  nsIWidget* widget = GetWidget(mPresShell);
  if (!widget) {
    return;
  }

  // Ignore documents which has been removed from the doc shell.
  if (!mDocument->IsActive()) {
    return;
  }

  uint32_t presShellId = 0;
  ScrollableLayerGuid::ViewID viewId = ScrollableLayerGuid::NULL_SCROLL_ID;
  bool scrollIdentifiersValid =
      APZCCallbackHelper::GetOrCreateScrollIdentifiers(
          mDocument->GetDocumentElement(), &presShellId, &viewId);
  if (!scrollIdentifiersValid) {
    return;
  }

  LayoutDeviceIntSize screenSize;
  if (!nsLayoutUtils::GetDocumentViewerSize(mPresShell->GetPresContext(),
                                            screenSize)) {
    return;
  }

  nsViewportInfo viewportInfo = mDocument->GetViewportInfo(ViewAs<ScreenPixel>(
      screenSize, PixelCastJustification::LayoutDeviceIsScreenForBounds));

  mZoomConstraints =
      ComputeZoomConstraintsFromViewportInfo(viewportInfo, mDocument);

  if (mDocument->Fullscreen()) {
    ZCC_LOG("%p is in fullscreen, disallowing zooming\n"this);
    mZoomConstraints.mAllowZoom = false;
    mZoomConstraints.mAllowDoubleTapZoom = false;
  }

  if (mDocument->IsStaticDocument()) {
    ZCC_LOG("%p is in print or print preview, disallowing double tap zooming\n",
            this);
    mZoomConstraints.mAllowDoubleTapZoom = false;
  }

  if (nsContentUtils::IsPDFJS(mDocument->GetPrincipal())) {
    ZCC_LOG("%p is pdf.js viewer, disallowing double tap zooming\n"this);
    mZoomConstraints.mAllowDoubleTapZoom = false;
  }

  // On macOS the OS can send us a double tap zoom event from the touchpad and
  // there are no touch screen macOS devices so we never wait to see if a second
  // tap is coming so we can always allow double tap zooming on mac. We need
  // this because otherwise the width check usually disables it.
  bool allow_double_tap_always = false;
#ifdef XP_MACOSX
  allow_double_tap_always =
      StaticPrefs::apz_mac_enable_double_tap_zoom_touchpad_gesture();
#endif
  if (!allow_double_tap_always && mZoomConstraints.mAllowDoubleTapZoom) {
    // If the CSS viewport is narrower than the screen (i.e. width <=
    // device-width) then we disable double-tap-to-zoom behaviour.
    CSSToLayoutDeviceScale scale =
        mPresShell->GetPresContext()->CSSToDevPixelScale();
    if ((viewportInfo.GetSize() * scale).width <= screenSize.width) {
      mZoomConstraints.mAllowDoubleTapZoom = false;
    }
  }

  // We only ever create a ZoomConstraintsClient for an RCD, so the RSF of
  // the presShell must be the RCD-RSF (if it exists).
  MOZ_ASSERT(mPresShell->GetPresContext()->IsRootContentDocumentCrossProcess());
  if (ScrollContainerFrame* rcdrsf =
          mPresShell->GetRootScrollContainerFrame()) {
    ZCC_LOG("Notifying RCD-RSF that it is zoomable: %d\n",
            mZoomConstraints.mAllowZoom);
    rcdrsf->SetZoomableByAPZ(mZoomConstraints.mAllowZoom);
  }

  ScrollableLayerGuid newGuid(LayersId{0}, presShellId, viewId);
  if (mGuid && mGuid.value() != newGuid) {
    ZCC_LOG("Clearing old constraints in %p for { %u, %" PRIu64 " }\n"this,
            mGuid->mPresShellId, mGuid->mScrollId);
    // If the guid changes, send a message to clear the old one
    widget->UpdateZoomConstraints(mGuid->mPresShellId, mGuid->mScrollId,
                                  Nothing());
  }
  mGuid = Some(newGuid);
  ZCC_LOG("Sending constraints %s in %p for { %u, %" PRIu64 " }\n",
          ToString(mZoomConstraints).c_str(), this, presShellId, viewId);
  widget->UpdateZoomConstraints(presShellId, viewId, Some(mZoomConstraints));
}

Messung V0.5
C=91 H=97 G=93

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.