/* * Create a tag that will reblock us */ void LO_CreateReblockTag(MWContext * context, LO_Element * current_script) { lo_TopState *top_state; pa_DocData *doc_data; PA_Tag * tag/*, ** tag_ptr*/; top_state = lo_FetchTopState(XP_DOCID(context)); doc_data = (pa_DocData *)top_state->doc_data; tag = pa_CreateMDLTag(doc_data, script_reblock_tag, sizeof script_reblock_tag - 1); if (tag == NULL) return; tag->lo_data = current_script; /* * Kludge in the write level for sanity check in lo_LayoutTag. */ tag->newline_count = (uint16)top_state->input_write_level; /* * Add the reblock tag to the tags list but don't advance the write_point * in case we just wrote a nested script that also writes: the inner * script must insert before the outer reblock tag, but after all the * earlier tags. */ /* tag_ptr = top_state->input_write_point; */ lo_BlockTag(context, NULL, tag); /* top_state->input_write_point = tag_ptr; */ }
void LO_ClearJavaAppBlock(MWContext *context, LO_JavaAppStruct *java_app) { int32 doc_id; lo_TopState *top_state; lo_DocState *main_doc_state; lo_DocState *state; /* * Get the unique document ID, and retreive this * documents layout state. */ doc_id = XP_DOCID(context); top_state = lo_FetchTopState(doc_id); if ((top_state == NULL)||(top_state->doc_state == NULL)) { return; } if (top_state->layout_blocking_element == (LO_Element *)java_app) { if (java_app->width == 0) { java_app->width = JAVA_DEF_DIM; } if (java_app->height == 0) { java_app->height = JAVA_DEF_DIM; } main_doc_state = top_state->doc_state; state = lo_CurrentSubState(main_doc_state); lo_FinishJavaApp(context, state, java_app); lo_FlushBlockage(context, state, main_doc_state); } }
/* * A script has just completed. If we are blocked on that script * free the blockage */ static void lo_unblock_script_tag(MWContext * context, Bool messWithParser) { lo_TopState *top_state; lo_DocState *state; LO_Element * block_ele; LO_Element * current_script; PA_Tag * tag; NET_StreamClass stream; top_state = lo_FetchTopState(XP_DOCID(context)); if (!top_state || !top_state->doc_state) return; state = top_state->doc_state; /* * Remember the fake element we created but clear the current * script flag of the top_state since the FlushBlockage call * might just turn around and block us on another script */ current_script = top_state->current_script; top_state->current_script = NULL; /* * if we are finishing a nested script make sure the current_script * points to our parent script */ for (tag = top_state->tags; tag; tag = tag->next) { if (tag->type == P_NSCP_REBLOCK) { top_state->current_script = tag->lo_data; break; } } /* Flush tags blocked by this <SCRIPT SRC="URL"> tag. */ block_ele = top_state->layout_blocking_element; /* no longer in a script */ top_state->in_script = SCRIPT_TYPE_NOT; /* * we must be blocked on something either the script that just ended or * some other object */ if (!block_ele) goto done; if (messWithParser && top_state->doc_data && SCRIPT_EXEC_OK(top_state, state, block_ele->type, LO_SCRIPT)) { top_state->doc_data->overflow_depth --; XP_ASSERT(top_state->doc_data->overflow_depth >= 0); } lo_FlushLineBuffer(context, top_state->doc_state); /* * unblock on UNKNOWN's as well since that's the type for * style attribute scripts */ if (block_ele->type == LO_SCRIPT || block_ele->type == LO_UNKNOWN) { lo_UnblockLayout(context, top_state); } else { /* * we're still blocked on something else - make sure * there are no reblock tags that are going to hose * us. Find the reblock tags that point to our script * tag and render them hermless */ PA_Tag * tag; for (tag = top_state->tags; tag; tag = tag->next) { if (tag->type == P_NSCP_REBLOCK) { LO_Element * lo_ele = tag->lo_data; if (lo_ele == current_script) { tag->lo_data = NULL; } } } } /* free the fake element we created earlier */ lo_FreeElement(context, current_script, FALSE); done: /* the parser is now able to receive new data from netlib */ stream.data_object=(pa_DocData *)top_state->doc_data; pa_FlushOverflow(&stream); /* * The initial call to lo_UnblockLayout() might have not torn * everything down because we were waiting for the last * chunk of data to come out of the doc_data->overflow_buf * We need to get to lo_FlushedBlockedTags() and lo_FinishLayout() * at the bottom of lo_FlushBlockage(). */ if (!top_state->layout_blocking_element) lo_FlushBlockage(context, top_state->doc_state, top_state->doc_state); }
void EmbedUrlExit(URL_Struct *pUrl, int iStatus, MWContext *pContext) { // The embedded item is finished downloading, and possibly has an error and stuff. NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pUrl->fe_data; if (!pEmbeddedApp) { NET_FreeURLStruct(pUrl); return; } CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data; // if an EMBED tag's SRC attribute is a LOCAL file which does not exist, // pItem is NULL. Bandaid against GPF for 2.0, but later we must fix the // FE_GetEmbedSize() and NP_EmbedCreate() combo that cause this problem. if(pItem != NULL) { if(wfe_IsTypePlugin(pEmbeddedApp)) { pItem->m_bLoading = FALSE; NET_FreeURLStruct(pUrl); return; } #ifdef MOCHA { /* only wait on applets if onload flag */ lo_TopState *top_state = lo_FetchTopState(XP_DOCID(pContext)); if (top_state != NULL && top_state->mocha_loading_embeds_count) { top_state->mocha_loading_embeds_count--; ET_SendLoadEvent(pContext, EVENT_XFER_DONE, NULL, NULL, LO_DOCUMENT_LAYER_ID, FALSE); } } #endif /* MOCHA */ // else must be an OLE stream exit if(iStatus != MK_DATA_LOADED) { // Load error. pItem->m_bBroken = TRUE; } else if(pUrl->server_status != 0 && pUrl->server_status / 100 != 2 && pUrl->server_status / 100 != 3 && iStatus == MK_DATA_LOADED) { // Server error. pItem->m_bBroken = TRUE; } // If the item isn't broken, we can load it up. if(pItem->m_bBroken == FALSE) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); if(FALSE == pItem->CreateFromFile(pItem->m_csFileName)) { // Couldn't create for some reason! pItem->m_bBroken = TRUE; } SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } pItem->m_bLoading = FALSE; // Get the width and height out of our newly created item, if it isn't broken. // We need to do this two different ways, depending on what type of context we // are in. CSize csExtents; // New way. CDCCX *pCX = VOID2CX(pContext->fe.cx, CDCCX); if(pItem->m_bBroken == FALSE) { pItem->GetExtent(&csExtents); csExtents.cx = CASTINT(pCX->Metric2TwipsX(csExtents.cx)); csExtents.cy = CASTINT(pCX->Metric2TwipsY(csExtents.cy)); } else { LTRB Rect; int32 x, y; // pCX->DisplayIcon(Rect.left, Rect.right, IL_IMAGE_BAD_DATA, &x, &y); pCX->GetIconDimensions(&x, &y, IL_IMAGE_BAD_DATA); csExtents.cx = CASTINT(x); csExtents.cy = CASTINT(y); } // Need to flush all delayed display, and blocked layout. // Do all blocks. POSITION rIndex = pItem->m_cplUnblock.GetHeadPosition(); LO_EmbedStruct *pLayoutData = NULL; while(rIndex != NULL && iStatus != MK_INTERRUPTED) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplUnblock.GetNext(rIndex); if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) { if ( pLayoutData->width) csExtents.cx = pLayoutData->width; if ( pLayoutData->height) csExtents.cy = pLayoutData->height; pLayoutData->width = csExtents.cx; pLayoutData->height = csExtents.cy; } LO_ClearEmbedBlock(ABSTRACTCX(pContext)->GetDocumentContext(), pLayoutData); } pItem->m_cplUnblock.RemoveAll(); #ifdef LAYERS rIndex = pItem->m_cplElements.GetHeadPosition(); while (rIndex != NULL) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplElements.GetNext(rIndex); // An OLE container is windowless until it is activated. LO_SetEmbedType(pLayoutData, PR_FALSE); } #endif // LAYERS // Do all needed display. rIndex = pItem->m_cplDisplay.GetHeadPosition(); while(rIndex != NULL) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplDisplay.GetNext(rIndex); if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) { if ( pLayoutData->width ) csExtents.cx = pLayoutData->width; if ( pLayoutData->height) csExtents.cy = pLayoutData->height; pLayoutData->width = csExtents.cx; pLayoutData->height = csExtents.cy; } #ifdef LAYERS if (pContext->compositor) { XP_Rect rect; CL_GetLayerBbox(pLayoutData->layer, &rect); CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->layer), pLayoutData->layer, &rect, PR_FALSE); } else #endif /* LAYERS */ pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData); } pItem->m_cplDisplay.RemoveAll(); } // And well, hey, get rid of the url. NET_FreeURLStruct(pUrl); }