Skip to content

Commit

Permalink
Fixed: Error mapping table #150
Browse files Browse the repository at this point in the history
- do not inherit min/max width/height properties!
- height calculation for block heights given in percent.
- render <blockquote> as block not as list.
  • Loading branch information
BerndGabriel committed Oct 1, 2016
1 parent f40b831 commit b45e126
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
55 changes: 26 additions & 29 deletions source/HTMLSubs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2932,21 +2932,18 @@ procedure TImageObj.DrawLogicInline(Canvas: TCanvas; FO: TFontObj; AvailableWidt
if FImage = nil then
begin
TmpImage := nil;
//UName := htUpperCase(htTrim(Source));
UName := htTrim(Source);
UName := htTrim(FSource);
if UName <> '' then
begin
if not Assigned(Document.GetBitmap) and not Assigned(Document.GetImage) then
FSource := Document.TheOwner.HtmlExpandFilename(Source)
FSource := htTrim(Document.TheOwner.HtmlExpandFilename(FSource))
else if Assigned(Document.ExpandName) then
begin
Document.ExpandName(Document.TheOwner, Source, Rslt);
FSource := Rslt;
Document.ExpandName(Document.TheOwner, FSource, Rslt);
FSource := htTrim(Rslt);
end;
//UName := htUpperCase(htTrim(Source));
UName := htTrim(Source);
if Document.MissingImages.IndexOf(UName) = -1 then
TmpImage := Document.GetTheImage(Source, Transparent, FromCache, Missing)
TmpImage := Document.GetTheImage(FSource, Transparent, FromCache, Missing)
else
Missing := True; {already in list, don't request it again}
end;
Expand Down Expand Up @@ -5283,13 +5280,14 @@ function TBlock.DrawLogic1(Canvas: TCanvas; X, Y, XRef, YRef, AWidth, AHeight, B
IB, Xin: Integer;

function GetClientContentBot(ClientContentBot: Integer): Integer;
var
H: Integer;
begin
Result := ContentTop + MargArray[piHeight];
if VarIsIntNull(MargArrayO[piHeight])
or (Self is TTableBlock) // and (Pos('%', VarToStr(MargArrayO[piHeight])) > 0))
or (VarToStr(MargArrayO[piHeight]) = 'auto')
then
Result := Max(Result, Max(ContentTop, ClientContentBot));
H := MargArray[piHeight];
if not VarIsIntNull(MargArrayO[piHeight]) then
if Pos('%', VarToStr(MargArrayO[piHeight])) > 0 then
H := LengthConv(MargArrayO[piHeight], False, ContainingBox.Bottom - ContainingBox.Top, EmSize, ExSize, 0);
Result := Max(H, Max(ContentTop, ClientContentBot));
end;

procedure DrawLogicAsBlock;
Expand Down Expand Up @@ -10315,9 +10313,9 @@ function THtmlTable.DrawLogic1(Canvas: TCanvas; X, Y, XRef, YRef, AWidth, AHeigh
CodeSite.SendFmtMsg('Stored TableWidth = %d, TableHeight = %d', [TableWidth, TableHeight]);
{$endif}
end;
finally
MaxWidth := TableWidth;
Result := TableHeight;
finally
Dec(Document.TableNestLevel);
{$ifdef JPM_DEBUGGING_LOGIC}
{$ifdef JPM_DEBUGGING_LOGIC1}
Expand Down Expand Up @@ -13017,20 +13015,20 @@ function TSection.Draw1(Canvas: TCanvas; const ARect: TRect;

end;
BottomP := TopP + FlObj.ClientHeight;
end;

if Start - Buff = BR.BStart then
begin {border starts at image}
BR.bRect.Top := TopP;
BR.bRect.Left := CPx + FlObj.HSpaceL;
if BR.BEnd = BR.BStart + 1 then {border ends with image also, rt side set by image width}
BR.bRect.Right := BR.bRect.Left + FlObj.ClientWidth;
BR.bRect.Bottom := BottomP;
end
else if Start - Buff <> BR.BEnd then
begin {image is included in border and may effect the border top and bottom}
BR.bRect.Top := Min(BR.bRect.Top, TopP);
BR.bRect.Bottom := Max(BR.bRect.Bottom, BottomP);
if Start - Buff = BR.BStart then
begin {border starts at image}
BR.bRect.Top := TopP;
BR.bRect.Left := CPx + FlObj.HSpaceL;
if BR.BEnd = BR.BStart + 1 then {border ends with image also, rt side set by image width}
BR.bRect.Right := BR.bRect.Left + FlObj.ClientWidth;
BR.bRect.Bottom := BottomP;
end
else if Start - Buff <> BR.BEnd then
begin {image is included in border and may effect the border top and bottom}
BR.bRect.Top := Min(BR.bRect.Top, TopP);
BR.bRect.Bottom := Max(BR.bRect.Bottom, BottomP);
end;
end;
end;
end;
Expand Down Expand Up @@ -15307,7 +15305,6 @@ procedure TSizeableObj.ProcessProperties(Prop: TProperties);
var
MargArrayO: ThtVMarginArray;
Align: ThtAlignmentStyle;
DummyAutoCount: Integer;
begin
if Prop.GetVertAlign(Align) then
VertAlign := Align;
Expand Down
8 changes: 4 additions & 4 deletions source/ReadHTML.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ procedure THtmlParser.DoDivEtc(Sym: TElemSymb; const TermSet: TElemSymbSet);
IsInline: Boolean;
begin
case Sym of
DivSy, MainSy, HeaderSy, NavSy, SectionSy, ArticleSy, AsideSy, FooterSy, HGroupSy:
DivSy, MainSy, HeaderSy, NavSy, SectionSy, ArticleSy, AsideSy, FooterSy, HGroupSy, BlockQuoteSy:
begin
SectionList.Add(Section, TagIndex);
PushNewProp(Sym, Attributes);
Expand Down Expand Up @@ -1596,12 +1596,12 @@ procedure THtmlParser.DoDivEtc(Sym: TElemSymb; const TermSet: TElemSymbSet);
end;
until Sy <> FormSy; {in case <form> terminated by andother <form>}

BlockQuoteSy, AddressSy:
AddressSy:
begin
SectionList.Add(Section, TagIndex);
Section := nil;
DoLists(Sy, TermSet + [BlockQuoteEndSy, AddressEndSy]);
if Sy in [BlockQuoteEndSy, AddressEndSy] then
DoLists(Sy, TermSet + [AddressEndSy]);
if Sy in [AddressEndSy] then
Next;
end;

Expand Down
2 changes: 2 additions & 0 deletions source/StyleUn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ procedure TProperties.Inherit(Tag: ThtString; Source: TProperties);
else
case I of
MarginTop..BorderLeftStyle,
piMinHeight, piMinWidth,
piMaxHeight, piMaxWidth,
piWidth, piHeight,
piTop..piLeft:
Props[I] := IntNull;
Expand Down

0 comments on commit b45e126

Please sign in to comment.