Program: 23197
Project: 23197
Buggy source:
private void setupViewport(boolean updateRestoreState){
  setViewportSettingsFromNative();
  float adjust=1.0f;
  if (mViewportDensityDpi == -1) {
    if (WebView.DEFAULT_SCALE_PERCENT != 100) {
      adjust=WebView.DEFAULT_SCALE_PERCENT / 100.0f;
    }
  }
 else   if (mViewportDensityDpi > 0) {
    adjust=(float)mContext.getResources().getDisplayMetrics().densityDpi / mViewportDensityDpi;
  }
  int defaultScale=(int)(adjust * 100);
  if (mViewportInitialScale > 0) {
    mViewportInitialScale*=adjust;
  }
  if (mViewportMinimumScale > 0) {
    mViewportMinimumScale*=adjust;
  }
  if (mViewportMaximumScale > 0) {
    mViewportMaximumScale*=adjust;
  }
  if (mViewportWidth == 0) {
    if (mViewportInitialScale == 0) {
      mViewportInitialScale=defaultScale;
    }
  }
  if (mViewportUserScalable == false) {
    mViewportInitialScale=defaultScale;
    mViewportMinimumScale=defaultScale;
    mViewportMaximumScale=defaultScale;
  }
  if (mViewportMinimumScale > mViewportInitialScale && mViewportInitialScale != 0) {
    mViewportMinimumScale=mViewportInitialScale;
  }
  if (mViewportMaximumScale > 0 && mViewportMaximumScale < mViewportInitialScale) {
    mViewportMaximumScale=mViewportInitialScale;
  }
  if (mViewportWidth < 0 && mViewportInitialScale == defaultScale) {
    mViewportWidth=0;
  }
  if (mViewportWidth != 0 && !updateRestoreState)   return;
  int webViewWidth;
  int viewportWidth=mCurrentViewWidth;
  if (viewportWidth == 0) {
    webViewWidth=mWebView.getViewWidth();
    viewportWidth=(int)(webViewWidth / adjust);
    if (viewportWidth == 0) {
      Log.w(LOGTAG,"String_Node_Str");
    }
  }
 else {
    webViewWidth=Math.round(viewportWidth * mCurrentViewScale);
  }
  mRestoreState=new RestoreState();
  mRestoreState.mMinScale=mViewportMinimumScale / 100.0f;
  mRestoreState.mMaxScale=mViewportMaximumScale / 100.0f;
  mRestoreState.mDefaultScale=adjust;
  mRestoreState.mScrollX=mRestoredX;
  mRestoreState.mScrollY=mRestoredY;
  mRestoreState.mMobileSite=(0 == mViewportWidth);
  if (mRestoredScale > 0) {
    mRestoreState.mViewScale=mRestoredScale / 100.0f;
    if (mRestoredScreenWidthScale > 0) {
      mRestoreState.mTextWrapScale=mRestoredScreenWidthScale / 100.0f;
    }
 else {
      mRestoreState.mTextWrapScale=mRestoreState.mViewScale;
    }
  }
 else {
    if (mViewportInitialScale > 0) {
      mRestoreState.mViewScale=mRestoreState.mTextWrapScale=mViewportInitialScale / 100.0f;
    }
 else     if (mViewportWidth > 0 && mViewportWidth < webViewWidth) {
      mRestoreState.mViewScale=mRestoreState.mTextWrapScale=(float)webViewWidth / mViewportWidth;
    }
 else {
      mRestoreState.mTextWrapScale=adjust;
      mRestoreState.mViewScale=0;
    }
  }
  if (mWebView.mHeightCanMeasure) {
    mWebView.mLastHeightSent=0;
    WebView.ViewSizeData data=new WebView.ViewSizeData();
    data.mWidth=mWebView.mLastWidthSent;
    data.mHeight=0;
    data.mTextWrapWidth=data.mWidth;
    data.mScale=-1.0f;
    data.mIgnoreHeight=false;
    data.mAnchorX=data.mAnchorY=0;
    mEventHub.removeMessages(EventHub.VIEW_SIZE_CHANGED);
    mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,EventHub.VIEW_SIZE_CHANGED,data));
  }
 else   if (mSettings.getUseWideViewPort()) {
    if (viewportWidth == 0) {
      mWebView.mLastWidthSent=0;
    }
 else {
      WebView.ViewSizeData data=new WebView.ViewSizeData();
      data.mScale=mRestoreState.mViewScale == 0 ? (mRestoredScale > 0 ? mRestoredScale : mRestoreState.mTextWrapScale) : mRestoreState.mViewScale;
      data.mWidth=Math.round(webViewWidth / data.mScale);
      data.mHeight=mCurrentViewHeight * data.mWidth / viewportWidth;
      data.mTextWrapWidth=Math.round(webViewWidth / mRestoreState.mTextWrapScale);
      data.mIgnoreHeight=false;
      data.mAnchorX=data.mAnchorY=0;
      mEventHub.removeMessages(EventHub.VIEW_SIZE_CHANGED);
      mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,EventHub.VIEW_SIZE_CHANGED,data));
    }
  }
}

Fixed version (ground truth):
private void setupViewport(boolean updateRestoreState){
  setViewportSettingsFromNative();
  float adjust=1.0f;
  if (mViewportDensityDpi == -1) {
    if (WebView.DEFAULT_SCALE_PERCENT != 100) {
      adjust=WebView.DEFAULT_SCALE_PERCENT / 100.0f;
    }
  }
 else   if (mViewportDensityDpi > 0) {
    adjust=(float)mContext.getResources().getDisplayMetrics().densityDpi / mViewportDensityDpi;
  }
  int defaultScale=(int)(adjust * 100);
  if (mViewportInitialScale > 0) {
    mViewportInitialScale*=adjust;
  }
  if (mViewportMinimumScale > 0) {
    mViewportMinimumScale*=adjust;
  }
  if (mViewportMaximumScale > 0) {
    mViewportMaximumScale*=adjust;
  }
  if (mViewportWidth == 0) {
    if (mViewportInitialScale == 0) {
      mViewportInitialScale=defaultScale;
    }
  }
  if (mViewportUserScalable == false) {
    mViewportInitialScale=defaultScale;
    mViewportMinimumScale=defaultScale;
    mViewportMaximumScale=defaultScale;
  }
  if (mViewportMinimumScale > mViewportInitialScale && mViewportInitialScale != 0) {
    mViewportMinimumScale=mViewportInitialScale;
  }
  if (mViewportMaximumScale > 0 && mViewportMaximumScale < mViewportInitialScale) {
    mViewportMaximumScale=mViewportInitialScale;
  }
  if (mViewportWidth < 0 && mViewportInitialScale == defaultScale) {
    mViewportWidth=0;
  }
  if (mViewportWidth != 0 && !updateRestoreState) {
    RestoreState restoreState=new RestoreState();
    restoreState.mMinScale=mViewportMinimumScale / 100.0f;
    restoreState.mMaxScale=mViewportMaximumScale / 100.0f;
    restoreState.mDefaultScale=adjust;
    restoreState.mMobileSite=false;
    restoreState.mScrollX=0;
    Message.obtain(mWebView.mPrivateHandler,WebView.UPDATE_ZOOM_RANGE,restoreState).sendToTarget();
    return;
  }
  int webViewWidth;
  int viewportWidth=mCurrentViewWidth;
  if (viewportWidth == 0) {
    webViewWidth=mWebView.getViewWidth();
    viewportWidth=(int)(webViewWidth / adjust);
    if (viewportWidth == 0) {
      Log.w(LOGTAG,"String_Node_Str");
    }
  }
 else {
    webViewWidth=Math.round(viewportWidth * mCurrentViewScale);
  }
  mRestoreState=new RestoreState();
  mRestoreState.mMinScale=mViewportMinimumScale / 100.0f;
  mRestoreState.mMaxScale=mViewportMaximumScale / 100.0f;
  mRestoreState.mDefaultScale=adjust;
  mRestoreState.mScrollX=mRestoredX;
  mRestoreState.mScrollY=mRestoredY;
  mRestoreState.mMobileSite=(0 == mViewportWidth);
  if (mRestoredScale > 0) {
    mRestoreState.mViewScale=mRestoredScale / 100.0f;
    if (mRestoredScreenWidthScale > 0) {
      mRestoreState.mTextWrapScale=mRestoredScreenWidthScale / 100.0f;
    }
 else {
      mRestoreState.mTextWrapScale=mRestoreState.mViewScale;
    }
  }
 else {
    if (mViewportInitialScale > 0) {
      mRestoreState.mViewScale=mRestoreState.mTextWrapScale=mViewportInitialScale / 100.0f;
    }
 else     if (mViewportWidth > 0 && mViewportWidth < webViewWidth) {
      mRestoreState.mViewScale=mRestoreState.mTextWrapScale=(float)webViewWidth / mViewportWidth;
    }
 else {
      mRestoreState.mTextWrapScale=adjust;
      mRestoreState.mViewScale=0;
    }
  }
  if (mWebView.mHeightCanMeasure) {
    mWebView.mLastHeightSent=0;
    WebView.ViewSizeData data=new WebView.ViewSizeData();
    data.mWidth=mWebView.mLastWidthSent;
    data.mHeight=0;
    data.mTextWrapWidth=data.mWidth;
    data.mScale=-1.0f;
    data.mIgnoreHeight=false;
    data.mAnchorX=data.mAnchorY=0;
    mEventHub.removeMessages(EventHub.VIEW_SIZE_CHANGED);
    mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,EventHub.VIEW_SIZE_CHANGED,data));
  }
 else   if (mSettings.getUseWideViewPort()) {
    if (viewportWidth == 0) {
      mWebView.mLastWidthSent=0;
    }
 else {
      WebView.ViewSizeData data=new WebView.ViewSizeData();
      data.mScale=mRestoreState.mViewScale == 0 ? (mRestoredScale > 0 ? mRestoredScale : mRestoreState.mTextWrapScale) : mRestoreState.mViewScale;
      data.mWidth=Math.round(webViewWidth / data.mScale);
      data.mHeight=mCurrentViewHeight * data.mWidth / viewportWidth;
      data.mTextWrapWidth=Math.round(webViewWidth / mRestoreState.mTextWrapScale);
      data.mIgnoreHeight=false;
      data.mAnchorX=data.mAnchorY=0;
      mEventHub.removeMessages(EventHub.VIEW_SIZE_CHANGED);
      mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,EventHub.VIEW_SIZE_CHANGED,data));
    }
  }
}